| // SwiftShader Software Renderer |
| // Copyright(c) 2005-2012 TransGaming Inc. |
| // All rights reserved. No part of this software may be copied, distributed, transmitted, |
| // transcribed, stored in a retrieval system, translated into any human or computer |
| // language by any means, or disclosed to third parties without the explicit written |
| // agreement of TransGaming Inc. Without such an agreement, no rights or licenses, express |
| // or implied, including but not limited to any patent rights, are granted to you. |
| // mathutil.h: Math and bit manipulation functions. |
| #ifndef LIBGL_MATHUTIL_H_ |
| #define LIBGL_MATHUTIL_H_ |
| #include "common/debug.h" |
| #include "Common/Math.hpp" |
| inline bool isPow2(int x) |
| return (x & (x - 1)) == 0 && (x != 0); |
| inline unsigned int ceilPow2(unsigned int x) |
| inline unsigned int unorm(float x) |
| const unsigned int max = 0xFFFFFFFF >> (32 - n); |
| return (unsigned int)(max * x + 0.5f); |
| #endif // LIBGL_MATHUTIL_H_ |