GL_ARB_enhanced_layouts, part 5: uniform offset and align semantics. Numerical computations not yet done.

git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@25092 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
John Kessenich 2014-01-28 21:13:59 +00:00
parent 255df5760a
commit 04b1c6ed4c
12 changed files with 243 additions and 46 deletions

View file

@ -186,17 +186,22 @@ typedef TMap<TString, TString>::tAllocator TPragmaTableAllocator;
const int GlslangMaxTokenLength = 1024;
template <class T> bool IsPow2(T powerOf2)
{
return (powerOf2 & (powerOf2 - 1)) == 0;
}
// Round number up to a multiple of the given powerOf2, which is not
// a power, just a number that must be a power of 2.
template <class T> void RoundToPow2(T& number, int powerOf2)
{
assert((powerOf2 & (powerOf2 - 1)) == 0);
assert(IsPow2(powerOf2));
number = (number + powerOf2 - 1) & ~(powerOf2 - 1);
}
template <class T> bool IsMultipleOfPow2(T number, int powerOf2)
{
assert((powerOf2 & (powerOf2 - 1)) == 0);
assert(IsPow2(powerOf2));
return ! (number & (powerOf2 - 1));
}