Added 'upperPowerOfTwo' function.
This commit is contained in:
		| @@ -60,4 +60,17 @@ namespace PolyVox | ||||
| 		else | ||||
| 			return ((uInput & (uInput-1)) == 0); | ||||
| 	} | ||||
|  | ||||
| 	// http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2 | ||||
| 	uint32_t upperPowerOfTwo(uint32_t v) | ||||
| 	{ | ||||
| 		v--; | ||||
| 		v |= v >> 1; | ||||
| 		v |= v >> 2; | ||||
| 		v |= v >> 4; | ||||
| 		v |= v >> 8; | ||||
| 		v |= v >> 16; | ||||
| 		v++; | ||||
| 		return v; | ||||
| 	} | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user