Commit 04b1c6ed by John Kessenich

GL_ARB_enhanced_layouts, part 5: uniform offset and align semantics. Numerical…

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
parent 255df576
...@@ -145,5 +145,7 @@ void foo324(void) ...@@ -145,5 +145,7 @@ void foo324(void)
mat3x2 m32 = outerProduct(vec2(2,3), vec3(5,7,11));// rows: (10, 14, 22), (15, 21, 33) mat3x2 m32 = outerProduct(vec2(2,3), vec3(5,7,11));// rows: (10, 14, 22), (15, 21, 33)
} }
uniform mediump; // ERROR
float imageBuffer; // ERROR, reserved float imageBuffer; // ERROR, reserved
float uimage2DRect; // ERROR, reserved float uimage2DRect; // ERROR, reserved
...@@ -51,7 +51,7 @@ shared vec4 compute_only; // ERROR ...@@ -51,7 +51,7 @@ shared vec4 compute_only; // ERROR
layout(packed) uniform; layout(packed) uniform;
layout(packed) float aoeuntaoeu; // ERROR, packed on variable layout(packed) uniform float aoeuntaoeu; // ERROR, packed on variable
layout(location = 40) in float cd; layout(location = 40) in float cd;
layout(location = 37) in mat4x3 ce; // ERROR, overlap layout(location = 37) in mat4x3 ce; // ERROR, overlap
...@@ -20,3 +20,72 @@ layout(location = 20, component = 3) in float f[6]; ...@@ -20,3 +20,72 @@ layout(location = 20, component = 3) in float f[6];
layout(location = 30, component = 3) out int be; layout(location = 30, component = 3) out int be;
layout(location = 30, component = 0) out vec3 bf; // ERROR, not the same basic type layout(location = 30, component = 0) out vec3 bf; // ERROR, not the same basic type
writeonly uniform; // ERROR
readonly in; // ERROR
flat out; // ERROR
mediump uniform;
layout(offset=12) uniform; // ERROR
layout(offset=12) in; // ERROR
layout(offset=12) out; // ERROR
layout(align=16) uniform; // ERROR
layout(align=16) in; // ERROR
layout(align=16) out; // ERROR
layout(offset=12) uniform ubl1 { int a; } inst1; // ERROR
layout(offset=12) in inbl2 { int a; } inst2; // ERROR
layout(offset=12) out inbl3 { int a; } inst3; // ERROR
layout(align=16, std140) uniform ubl4 { int a; } inst4;
layout(align=16) uniform ubl8 { int a; } inst8; // ERROR, no packing
layout(align=16) in inbl5 { int a; } inst5; // ERROR
layout(align=16) out inbl6 { int a; } inst6; // ERROR
layout(offset=12) uniform vec4 v1; // ERROR
layout(offset=12) in vec4 v2; // ERROR
layout(offset=12) out vec4 v3; // ERROR
layout(align=16) uniform vec4 v4; // ERROR
layout(align=16) in vec4 v5; // ERROR
layout(align=16) out vec4 v6; // ERROR
layout(std140) in; // ERROR
layout(std140) uniform vec4 v7; // ERROR
layout(align=48) uniform ubl7 { // ERROR, not power of 2
layout(offset=12, align=4) float f; // ERROR, no packing
} inst7;
in ibl10 {
layout(offset=12) float f; // ERROR
layout(align=4) float g; // ERROR
} inst10;
layout(std430) uniform;
layout(align=32) uniform ubl9 {
float e;
layout(offset=12, align=4) float f;
layout(offset=20) float g;
float h;
} inst9;
uniform ubl11 {
layout(offset=12, align=4) float f;
float g;
} inst11;
layout(std140) uniform block {
vec4 a; // a takes offsets 0-15
layout(offset = 20) vec3 b; // b takes offsets 32-43
layout(offset = 40) vec2 c; // ERROR, lies within previous member
layout(offset = 48) vec2 d; // d takes offsets 48-55
layout(align = 16) float e; // e takes offsets 64-67
layout(align = 2) double f; // f takes offsets 72-79
layout(align = 6) double g; // ERROR, 6 is not a power of 2
layout(offset = 80) float h; // h takes offsets 80-83
layout(align = 64) dvec3 i; // i takes offsets 128-151
layout(offset = 153, align = 8) float j; // j takes offsets 160-163
} specExample;
...@@ -33,9 +33,10 @@ ERROR: 0:122: '=' : can't use with samplers or structs containing samplers ...@@ -33,9 +33,10 @@ ERROR: 0:122: '=' : can't use with samplers or structs containing samplers
ERROR: 0:123: '==' : can't use with samplers or structs containing samplers ERROR: 0:123: '==' : can't use with samplers or structs containing samplers
ERROR: 0:129: 'texel offset' : value is out of range: [gl_MinProgramTexelOffset, gl_MaxProgramTexelOffset] ERROR: 0:129: 'texel offset' : value is out of range: [gl_MinProgramTexelOffset, gl_MaxProgramTexelOffset]
ERROR: 0:129: 'texel offset' : value is out of range: [gl_MinProgramTexelOffset, gl_MaxProgramTexelOffset] ERROR: 0:129: 'texel offset' : value is out of range: [gl_MinProgramTexelOffset, gl_MaxProgramTexelOffset]
ERROR: 0:148: 'imageBuffer' : Reserved word. ERROR: 0:148: 'qualifier' : cannot use auxiliary, memory, interpolation, or precision qualifier in a default qualifier declaration (declaration with no type)
ERROR: 0:148: '' : syntax error ERROR: 0:150: 'imageBuffer' : Reserved word.
ERROR: 36 compilation errors. No code generated. ERROR: 0:150: '' : syntax error
ERROR: 37 compilation errors. No code generated.
ERROR: node is still EOpNull! ERROR: node is still EOpNull!
......
...@@ -15,7 +15,7 @@ ERROR: 0:38: 'output block' : not supported with this profile: es ...@@ -15,7 +15,7 @@ ERROR: 0:38: 'output block' : not supported with this profile: es
ERROR: 0:42: 'location qualifier on output' : not supported in this stage: vertex ERROR: 0:42: 'location qualifier on output' : not supported in this stage: vertex
ERROR: 0:50: 'shared' : not supported with this profile: es ERROR: 0:50: 'shared' : not supported with this profile: es
ERROR: 0:50: 'shared' : not supported in this stage: vertex ERROR: 0:50: 'shared' : not supported in this stage: vertex
ERROR: 0:54: 'layout' : qualifiers for matrix layout and block packing only apply to uniform or buffer blocks ERROR: 0:54: 'layout' : cannot specify packing on a variable declaration
ERROR: 0:57: 'location' : overlapping use of location 40 ERROR: 0:57: 'location' : overlapping use of location 40
ERROR: 18 compilation errors. No code generated. ERROR: 18 compilation errors. No code generated.
...@@ -73,7 +73,7 @@ ERROR: node is still EOpNull! ...@@ -73,7 +73,7 @@ ERROR: node is still EOpNull!
0:? '__anon__2' (out block{out highp float f}) 0:? '__anon__2' (out block{out highp float f})
0:? 'badoutA' (layout(location=10 ) smooth out highp 4-component vector of float) 0:? 'badoutA' (layout(location=10 ) smooth out highp 4-component vector of float)
0:? 'compute_only' (shared highp 4-component vector of float) 0:? 'compute_only' (shared highp 4-component vector of float)
0:? 'aoeuntaoeu' (layout(packed ) highp float) 0:? 'aoeuntaoeu' (layout(packed ) uniform highp float)
0:? 'cd' (layout(location=40 ) in highp float) 0:? 'cd' (layout(location=40 ) in highp float)
0:? 'ce' (layout(location=37 ) in highp 4X3 matrix of float) 0:? 'ce' (layout(location=37 ) in highp 4X3 matrix of float)
0:? 'gl_VertexID' (gl_VertexId highp int) 0:? 'gl_VertexID' (gl_VertexId highp int)
......
...@@ -3,7 +3,44 @@ Warning, version 440 is not yet complete; some version-specific features are pre ...@@ -3,7 +3,44 @@ Warning, version 440 is not yet complete; some version-specific features are pre
ERROR: 0:11: 'location' : overlapping use of location 4 ERROR: 0:11: 'location' : overlapping use of location 4
ERROR: 0:13: 'component' : type overflows the available 4 components ERROR: 0:13: 'component' : type overflows the available 4 components
ERROR: 0:22: 'location' : fragment outputs sharing the same location must be the same basic type 30 ERROR: 0:22: 'location' : fragment outputs sharing the same location must be the same basic type 30
ERROR: 3 compilation errors. No code generated. ERROR: 0:24: 'qualifier' : cannot use auxiliary, memory, interpolation, or precision qualifier in a default qualifier declaration (declaration with no type)
ERROR: 0:25: 'qualifier' : cannot use auxiliary, memory, interpolation, or precision qualifier in a default qualifier declaration (declaration with no type)
ERROR: 0:26: 'qualifier' : cannot use auxiliary, memory, interpolation, or precision qualifier in a default qualifier declaration (declaration with no type)
ERROR: 0:29: 'layout qualifier' : cannot use offset or align qualifiers in a default qualifier declaration (declaration with no type)
ERROR: 0:30: 'layout qualifier' : cannot use offset or align qualifiers in a default qualifier declaration (declaration with no type)
ERROR: 0:30: 'layout' : offset/align can only be used on a uniform or buffer
ERROR: 0:31: 'layout qualifier' : cannot use offset or align qualifiers in a default qualifier declaration (declaration with no type)
ERROR: 0:31: 'layout' : offset/align can only be used on a uniform or buffer
ERROR: 0:33: 'layout qualifier' : cannot use offset or align qualifiers in a default qualifier declaration (declaration with no type)
ERROR: 0:34: 'layout qualifier' : cannot use offset or align qualifiers in a default qualifier declaration (declaration with no type)
ERROR: 0:34: 'layout' : offset/align can only be used on a uniform or buffer
ERROR: 0:35: 'layout qualifier' : cannot use offset or align qualifiers in a default qualifier declaration (declaration with no type)
ERROR: 0:35: 'layout' : offset/align can only be used on a uniform or buffer
ERROR: 0:37: 'offset' : only applies to block members, not blocks
ERROR: 0:38: 'layout' : offset/align can only be used on a uniform or buffer
ERROR: 0:38: 'offset' : only applies to block members, not blocks
ERROR: 0:39: 'layout' : offset/align can only be used on a uniform or buffer
ERROR: 0:39: 'offset' : only applies to block members, not blocks
ERROR: 0:42: 'offset/align' : can only be used with std140 or std430 layout packing
ERROR: 0:43: 'offset/align' : can only be used with std140 or std430 layout packing
ERROR: 0:43: 'layout' : offset/align can only be used on a uniform or buffer
ERROR: 0:44: 'offset/align' : can only be used with std140 or std430 layout packing
ERROR: 0:44: 'layout' : offset/align can only be used on a uniform or buffer
ERROR: 0:46: 'offset' : cannot specify on a variable declaration
ERROR: 0:47: 'layout' : offset/align can only be used on a uniform or buffer
ERROR: 0:48: 'layout' : offset/align can only be used on a uniform or buffer
ERROR: 0:50: 'align' : cannot specify on a variable declaration
ERROR: 0:51: 'layout' : offset/align can only be used on a uniform or buffer
ERROR: 0:52: 'layout' : offset/align can only be used on a uniform or buffer
ERROR: 0:54: 'layout' : matrix or packing qualifiers can only be used on a uniform or buffer
ERROR: 0:55: 'layout' : cannot specify packing on a variable declaration
ERROR: 0:57: 'align' : must be a power of 2
ERROR: 0:58: 'align' : can only be used with std140 or std430 layout packing
ERROR: 0:63: 'align' : can only be used with std140 or std430 layout packing
ERROR: 0:62: 'layout' : offset/align can only be used on a uniform or buffer
ERROR: 0:63: 'layout' : offset/align can only be used on a uniform or buffer
ERROR: 0:87: 'align' : must be a power of 2
ERROR: 40 compilation errors. No code generated.
ERROR: node is still EOpNull! ERROR: node is still EOpNull!
...@@ -16,6 +53,25 @@ ERROR: node is still EOpNull! ...@@ -16,6 +53,25 @@ ERROR: node is still EOpNull!
0:? 'f' (layout(location=20 component=3 ) smooth in 6-element array of float) 0:? 'f' (layout(location=20 component=3 ) smooth in 6-element array of float)
0:? 'be' (layout(location=30 component=3 ) out int) 0:? 'be' (layout(location=30 component=3 ) out int)
0:? 'bf' (layout(location=30 component=0 ) out 3-component vector of float) 0:? 'bf' (layout(location=30 component=0 ) out 3-component vector of float)
0:? 'inst1' (layout(column_major shared offset=12 ) uniform block{layout(column_major shared ) uniform int a})
0:? 'inst2' (layout(offset=12 ) in block{in int a})
0:? 'inst3' (layout(offset=12 ) out block{out int a})
0:? 'inst4' (layout(column_major std140 align=16 ) uniform block{layout(column_major std140 align=16 ) uniform int a})
0:? 'inst8' (layout(column_major shared align=16 ) uniform block{layout(column_major shared ) uniform int a})
0:? 'inst5' (layout(align=16 ) in block{in int a})
0:? 'inst6' (layout(align=16 ) out block{out int a})
0:? 'v1' (layout(offset=12 ) uniform 4-component vector of float)
0:? 'v2' (layout(offset=12 ) smooth in 4-component vector of float)
0:? 'v3' (layout(offset=12 ) out 4-component vector of float)
0:? 'v4' (layout(align=16 ) uniform 4-component vector of float)
0:? 'v5' (layout(align=16 ) smooth in 4-component vector of float)
0:? 'v6' (layout(align=16 ) out 4-component vector of float)
0:? 'v7' (layout(std140 ) uniform 4-component vector of float)
0:? 'inst7' (layout(column_major shared ) uniform block{layout(column_major shared offset=12 align=4 ) uniform float f})
0:? 'inst10' (in block{layout(offset=12 ) in float f, layout(align=4 ) in float g})
0:? 'inst9' (layout(column_major std430 align=32 ) uniform block{layout(column_major std430 align=32 ) uniform float e, layout(column_major std430 offset=12 align=4 ) uniform float f, layout(column_major std430 offset=20 align=32 ) uniform float g, layout(column_major std430 align=32 ) uniform float h})
0:? 'inst11' (layout(column_major std430 ) uniform block{layout(column_major std430 offset=12 align=4 ) uniform float f, layout(column_major std430 ) uniform float g})
0:? 'specExample' (layout(column_major std140 ) uniform block{layout(column_major std140 ) uniform 4-component vector of float a, layout(column_major std140 offset=20 ) uniform 3-component vector of float b, layout(column_major std140 offset=40 ) uniform 2-component vector of float c, layout(column_major std140 offset=48 ) uniform 2-component vector of float d, layout(column_major std140 align=16 ) uniform float e, layout(column_major std140 align=2 ) uniform double f, layout(column_major std140 ) uniform double g, layout(column_major std140 offset=80 ) uniform float h, layout(column_major std140 align=64 ) uniform 3-component vector of double i, layout(column_major std140 offset=153 align=8 ) uniform float j})
Linked fragment stage: Linked fragment stage:
......
...@@ -19,6 +19,7 @@ ERROR: 0:55: 'stream' : there is no such layout identifier for this stage taking ...@@ -19,6 +19,7 @@ ERROR: 0:55: 'stream' : there is no such layout identifier for this stage taking
ERROR: 0:80: 's17' : redefinition ERROR: 0:80: 's17' : redefinition
ERROR: 0:85: 'uniform buffer-member offset' : not supported for this version or the enabled extensions ERROR: 0:85: 'uniform buffer-member offset' : not supported for this version or the enabled extensions
ERROR: 0:85: 'binding' : requires block, or sampler/image, or atomic-counter type ERROR: 0:85: 'binding' : requires block, or sampler/image, or atomic-counter type
ERROR: 0:85: 'offset' : cannot specify on a variable declaration
ERROR: 0:87: 'binding' : requires block, or sampler/image, or atomic-counter type ERROR: 0:87: 'binding' : requires block, or sampler/image, or atomic-counter type
ERROR: 0:89: 'uniform buffer-member offset' : not supported for this version or the enabled extensions ERROR: 0:89: 'uniform buffer-member offset' : not supported for this version or the enabled extensions
WARNING: 0:89: 'layout' : useless application of layout qualifier WARNING: 0:89: 'layout' : useless application of layout qualifier
...@@ -42,7 +43,7 @@ ERROR: 0:153: '' : function does not return a value: func3 ...@@ -42,7 +43,7 @@ ERROR: 0:153: '' : function does not return a value: func3
ERROR: 0:192: 'constructor' : constructing from a non-dereferenced array ERROR: 0:192: 'constructor' : constructing from a non-dereferenced array
ERROR: 0:193: 'constructor' : constructing from a non-dereferenced array ERROR: 0:193: 'constructor' : constructing from a non-dereferenced array
ERROR: 0:194: 'constructor' : constructing from a non-dereferenced array ERROR: 0:194: 'constructor' : constructing from a non-dereferenced array
ERROR: 41 compilation errors. No code generated. ERROR: 42 compilation errors. No code generated.
ERROR: node is still EOpNull! ERROR: node is still EOpNull!
......
...@@ -186,17 +186,22 @@ typedef TMap<TString, TString>::tAllocator TPragmaTableAllocator; ...@@ -186,17 +186,22 @@ typedef TMap<TString, TString>::tAllocator TPragmaTableAllocator;
const int GlslangMaxTokenLength = 1024; 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 // 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. // a power, just a number that must be a power of 2.
template <class T> void RoundToPow2(T& number, int powerOf2) template <class T> void RoundToPow2(T& number, int powerOf2)
{ {
assert((powerOf2 & (powerOf2 - 1)) == 0); assert(IsPow2(powerOf2));
number = (number + powerOf2 - 1) & ~(powerOf2 - 1); number = (number + powerOf2 - 1) & ~(powerOf2 - 1);
} }
template <class T> bool IsMultipleOfPow2(T number, int powerOf2) template <class T> bool IsMultipleOfPow2(T number, int powerOf2)
{ {
assert((powerOf2 & (powerOf2 - 1)) == 0); assert(IsPow2(powerOf2));
return ! (number & (powerOf2 - 1)); return ! (number & (powerOf2 - 1));
} }
......
...@@ -401,10 +401,26 @@ public: ...@@ -401,10 +401,26 @@ public:
bool hasUniformLayout() const bool hasUniformLayout() const
{ {
return layoutMatrix != ElmNone || return hasMatrix() ||
layoutPacking != ElpNone || hasPacking() ||
layoutOffset != -1 || hasOffset() ||
layoutAlign != -1; hasAlign();
}
bool hasMatrix() const
{
return layoutMatrix != ElmNone;
}
bool hasPacking() const
{
return layoutPacking != ElpNone;
}
bool hasOffset() const
{
return layoutOffset != -1;
}
bool hasAlign() const
{
return layoutAlign != -1;
} }
bool hasLocation() const bool hasLocation() const
{ {
...@@ -904,13 +920,13 @@ public: ...@@ -904,13 +920,13 @@ public:
p += snprintf(p, end - p, "binding=%d ", qualifier.layoutBinding); p += snprintf(p, end - p, "binding=%d ", qualifier.layoutBinding);
if (qualifier.hasStream()) if (qualifier.hasStream())
p += snprintf(p, end - p, "stream=%d ", qualifier.layoutStream); p += snprintf(p, end - p, "stream=%d ", qualifier.layoutStream);
if (qualifier.layoutMatrix != ElmNone) if (qualifier.hasMatrix())
p += snprintf(p, end - p, "%s ", TQualifier::getLayoutMatrixString(qualifier.layoutMatrix)); p += snprintf(p, end - p, "%s ", TQualifier::getLayoutMatrixString(qualifier.layoutMatrix));
if (qualifier.layoutPacking != ElpNone) if (qualifier.hasPacking())
p += snprintf(p, end - p, "%s ", TQualifier::getLayoutPackingString(qualifier.layoutPacking)); p += snprintf(p, end - p, "%s ", TQualifier::getLayoutPackingString(qualifier.layoutPacking));
if (qualifier.layoutOffset != -1) if (qualifier.hasOffset())
p += snprintf(p, end - p, "offset=%d ", qualifier.layoutOffset); p += snprintf(p, end - p, "offset=%d ", qualifier.layoutOffset);
if (qualifier.layoutAlign != -1) if (qualifier.hasAlign())
p += snprintf(p, end - p, "align=%d ", qualifier.layoutAlign); p += snprintf(p, end - p, "align=%d ", qualifier.layoutAlign);
if (qualifier.hasXfbBuffer() && qualifier.hasXfbOffset()) if (qualifier.hasXfbBuffer() && qualifier.hasXfbOffset())
......
...@@ -9,5 +9,5 @@ ...@@ -9,5 +9,5 @@
// source have to figure out how to create revision.h just to get a build // source have to figure out how to create revision.h just to get a build
// going. However, if it is not updated, it can be a version behind. // going. However, if it is not updated, it can be a version behind.
#define GLSLANG_REVISION "25018" #define GLSLANG_REVISION "25043"
#define GLSLANG_DATE "2014/01/26 00:56:43" #define GLSLANG_DATE "2014/01/27 13:02:12"
...@@ -166,6 +166,7 @@ public: ...@@ -166,6 +166,7 @@ public:
void declareBlock(TSourceLoc, TTypeList& typeList, const TString* instanceName = 0, TArraySizes* arraySizes = 0); void declareBlock(TSourceLoc, TTypeList& typeList, const TString* instanceName = 0, TArraySizes* arraySizes = 0);
void fixBlockLocations(TSourceLoc, TQualifier&, TTypeList&, bool memberWithLocation, bool memberWithoutLocation); void fixBlockLocations(TSourceLoc, TQualifier&, TTypeList&, bool memberWithLocation, bool memberWithoutLocation);
void fixBlockXfbOffsets(TSourceLoc, TQualifier&, TTypeList&); void fixBlockXfbOffsets(TSourceLoc, TQualifier&, TTypeList&);
void fixBlockUniformOffsets(TSourceLoc, TQualifier&, TTypeList&);
void addQualifierToExisting(TSourceLoc, TQualifier, const TString& identifier); void addQualifierToExisting(TSourceLoc, TQualifier, const TString& identifier);
void addQualifierToExisting(TSourceLoc, TQualifier, TIdentifierList&); void addQualifierToExisting(TSourceLoc, TQualifier, TIdentifierList&);
void invariantCheck(TSourceLoc, const TType&, const TString& identifier); void invariantCheck(TSourceLoc, const TType&, const TString& identifier);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment