Commit c719481d by John Kessenich

Flesh out 4.x block redeclaration semantics:

- hide non-redeclared anonymous members - array size limit checking - illegal member qualifiers - additional members git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@24406 e7fa87d3-cd2b-0410-9028-fcbf551c1848
parent e1b2e39a
...@@ -23,3 +23,19 @@ void foo() ...@@ -23,3 +23,19 @@ void foo()
vec4 c = gl_Color; vec4 c = gl_Color;
outVar = inVar; outVar = inVar;
} }
in gl_block { // ERROR
int gl_i;
} gl_name;
in myBlock {
int gl_i; // ERROR
} gl_name; // ERROR
in gl_PerVertex { // ERROR
vec4 gl_FragCoord;
} gl_in[];
in gl_PerVertex { // ERROR
vec4 gl_FragCoord;
}; // ERROR
...@@ -17,6 +17,7 @@ layout(max_vertices = 127, invocations = 4) out; ...@@ -17,6 +17,7 @@ layout(max_vertices = 127, invocations = 4) out;
in gl_PerVertex { // testing input arrays with a block redeclaration, see 420.geom for without in gl_PerVertex { // testing input arrays with a block redeclaration, see 420.geom for without
vec4 gl_Position; vec4 gl_Position;
layout(std140, location = 3) patch float gl_PointSize; // ERRORs...
} gl_in[]; } gl_in[];
void foo() void foo()
......
...@@ -27,6 +27,8 @@ out gl_PerVertex { ...@@ -27,6 +27,8 @@ out gl_PerVertex {
void foo() void foo()
{ {
float p = gl_in[1].gl_PointSize; // use of redeclared float p = gl_in[1].gl_PointSize; // use of redeclared
gl_PointSize = p; // use of redeclared gl_PointSize = p; // use of redeclared
vec4 v = gl_in[1].gl_Position; // ERROR, not included in the redeclaration
gl_Position = vec4(1.0); // ERROR, not included in the redeclaration
} }
...@@ -43,3 +43,8 @@ void foo4() ...@@ -43,3 +43,8 @@ void foo4()
v4.x = 3.2; // ERROR v4.x = 3.2; // ERROR
v4.xy; // should have non-uniform type v4.xy; // should have non-uniform type
} }
out gl_PerVertex {
float gl_PointSize[1]; // ERROR, adding array
float gl_ClipDistance; // ERROR, removing array
};
...@@ -77,3 +77,7 @@ layout(binding = 31) uniform sampler2D sampb5[2]; // ERROR, binding too big ...@@ -77,3 +77,7 @@ layout(binding = 31) uniform sampler2D sampb5[2]; // ERROR, binding too big
int fgfg(float f, mediump int i); int fgfg(float f, mediump int i);
int fgfg(float f, highp int i); int fgfg(float f, highp int i);
out gl_PerVertex {
float gl_ClipDistance[4];
};
330.frag 330.frag
Warning, version 330 is not yet complete; some version-specific features are present, but many are missing. Warning, version 330 is not yet complete; some version-specific features are present, but many are missing.
ERROR: 0:27: 'block declaration' : cannot redeclare block: gl_block
ERROR: 0:31: 'gl_' : reserved built-in name: gl_name
ERROR: 0:32: 'gl_' : reserved built-in name: gl_i
ERROR: 0:35: 'gl_in' : no declaration found for redeclaration
ERROR: 0:39: 'gl_FragCoord' : cannot redeclare a non block as a block
ERROR: 5 compilation errors. No code generated.
0:? Sequence
ERROR: node is still EOpNull!
0:8 Function Definition: main( (void) 0:8 Function Definition: main( (void)
0:8 Function Parameters: 0:8 Function Parameters:
0:10 Sequence 0:10 Sequence
...@@ -26,9 +33,9 @@ Warning, version 330 is not yet complete; some version-specific features are pre ...@@ -26,9 +33,9 @@ Warning, version 330 is not yet complete; some version-specific features are pre
0:23 move second child to first child (4-component vector of float) 0:23 move second child to first child (4-component vector of float)
0:23 'c' (4-component vector of float) 0:23 'c' (4-component vector of float)
0:23 gl_Color: direct index for structure (in 4-component vector of float) 0:23 gl_Color: direct index for structure (in 4-component vector of float)
0:23 '__anon__0' (in block{gl_Color}) 0:23 '__anon__0' (in block{gl_Color,})
0:23 Constant: 0:23 Constant:
0:23 0 (const uint) 0:23 2 (const uint)
0:24 move second child to first child (4-component vector of float) 0:24 move second child to first child (4-component vector of float)
0:24 'outVar' (out 4-component vector of float) 0:24 'outVar' (out 4-component vector of float)
0:24 'inVar' (smooth in 4-component vector of float) 0:24 'inVar' (smooth in 4-component vector of float)
...@@ -36,7 +43,8 @@ Warning, version 330 is not yet complete; some version-specific features are pre ...@@ -36,7 +43,8 @@ Warning, version 330 is not yet complete; some version-specific features are pre
0:? 'inVar' (smooth in 4-component vector of float) 0:? 'inVar' (smooth in 4-component vector of float)
0:? 'outVar' (out 4-component vector of float) 0:? 'outVar' (out 4-component vector of float)
0:? 'varyingVar' (smooth in 4-component vector of float) 0:? 'varyingVar' (smooth in 4-component vector of float)
0:? '__anon__0' (in block{gl_Color}) 0:? '__anon__0' (in block{gl_Color,})
0:? 'gl_name' (in block{gl_i})
Linked fragment stage: Linked fragment stage:
......
400.geom 400.geom
Warning, version 400 is not yet complete; some version-specific features are present, but many are missing. Warning, version 400 is not yet complete; some version-specific features are present, but many are missing.
ERROR: 0:13: 'invocations' : can only apply to a standalone qualifier ERROR: 0:13: 'invocations' : can only apply to a standalone qualifier
ERROR: 0:24: 'length' : array must be declared with a size before using this method ERROR: 0:20: 'gl_PointSize' : cannot add layout to redeclared block member
ERROR: 0:35: 'length' : array must be declared with a size before using this method ERROR: 0:20: 'gl_PointSize' : cannot add patch to redeclared block member
ERROR: 0:39: 'triangles' : inconsistent input primitive for array size colorBad ERROR: 0:25: 'length' : array must be declared with a size before using this method
ERROR: 0:43: 'triangles' : inconsistent input primitive for array size colorbad2 ERROR: 0:36: 'length' : array must be declared with a size before using this method
ERROR: 0:55: 'location' : repeated use of location 4 ERROR: 0:40: 'triangles' : inconsistent input primitive for array size colorBad
ERROR: 6 compilation errors. No code generated. ERROR: 0:44: 'triangles' : inconsistent input primitive for array size colorbad2
ERROR: 0:56: 'location' : repeated use of location 4
ERROR: 8 compilation errors. No code generated.
invocations = 4 invocations = 4
...@@ -29,39 +31,39 @@ ERROR: node is still EOpNull! ...@@ -29,39 +31,39 @@ ERROR: node is still EOpNull!
0:10 move second child to first child (int) 0:10 move second child to first child (int)
0:10 'id' (int) 0:10 'id' (int)
0:10 'gl_InvocationID' (in int) 0:10 'gl_InvocationID' (in int)
0:22 Function Definition: foo( (void) 0:23 Function Definition: foo( (void)
0:22 Function Parameters: 0:23 Function Parameters:
0:24 Sequence 0:25 Sequence
0:24 Constant: 0:25 Constant:
0:24 1 (const int) 0:25 1 (const int)
0:25 gl_Position: direct index for structure (4-component vector of float) 0:26 gl_Position: direct index for structure (4-component vector of float)
0:25 direct index (block{gl_Position}) 0:26 direct index (block{gl_Position,gl_PointSize})
0:25 'gl_in' (in 3-element array of block{gl_Position}) 0:26 'gl_in' (in 3-element array of block{gl_Position,gl_PointSize})
0:25 Constant: 0:26 Constant:
0:25 1 (const int) 0:26 1 (const int)
0:25 Constant: 0:26 Constant:
0:25 0 (const int) 0:26 0 (const int)
0:33 Function Definition: foo2( (void) 0:34 Function Definition: foo2( (void)
0:33 Function Parameters: 0:34 Function Parameters:
0:35 Sequence 0:36 Sequence
0:35 Constant:
0:35 1 (const int)
0:36 Constant: 0:36 Constant:
0:36 3 (const int) 0:36 1 (const int)
0:45 Function Definition: foo3( (void) 0:37 Constant:
0:45 Function Parameters: 0:37 3 (const int)
0:47 Sequence 0:46 Function Definition: foo3( (void)
0:47 Constant: 0:46 Function Parameters:
0:47 3 (const int) 0:48 Sequence
0:48 Constant: 0:48 Constant:
0:48 3 (const int) 0:48 3 (const int)
0:49 Constant: 0:49 Constant:
0:49 3 (const int) 0:49 3 (const int)
0:50 Constant: 0:50 Constant:
0:50 3 (const int) 0:50 3 (const int)
0:51 Constant:
0:51 3 (const int)
0:? Linker Objects 0:? Linker Objects
0:? '__anon__0' (layout(stream=0 ) out block{a}) 0:? '__anon__0' (layout(stream=0 ) out block{a})
0:? 'gl_in' (in 3-element array of block{gl_Position}) 0:? 'gl_in' (in 3-element array of block{gl_Position,gl_PointSize})
0:? 'color' (in 3-element array of 4-component vector of float) 0:? 'color' (in 3-element array of 4-component vector of float)
0:? 'color2' (in 3-element array of 4-component vector of float) 0:? 'color2' (in 3-element array of 4-component vector of float)
0:? 'colorS' (in 3-element array of 4-component vector of float) 0:? 'colorS' (in 3-element array of 4-component vector of float)
......
410.geom 410.geom
Warning, version 410 is not yet complete; some version-specific features are present, but many are missing. Warning, version 410 is not yet complete; some version-specific features are present, but many are missing.
ERROR: 0:8: 'myIn' : cannot redeclare a built-in block with a user name ERROR: 0:8: 'myIn' : cannot redeclare a built-in block with a user name
ERROR: 0:8: 'gl_' : reserved built-in name ERROR: 0:12: 'gl_myIn' : no declaration found for redeclaration
ERROR: 0:12: 'gl_' : reserved built-in name
ERROR: 0:20: 'gl_PerVertex' : can only redeclare a built-in block once, and before any use ERROR: 0:20: 'gl_PerVertex' : can only redeclare a built-in block once, and before any use
ERROR: 0:20: 'gl_' : reserved built-in name ERROR: 0:32: 'gl_Position' : no such field in structure
ERROR: 5 compilation errors. No code generated. ERROR: 0:32: '=' : cannot convert from 'block{gl_PointSize}' to '4-component vector of float'
ERROR: 0:33: 'gl_Position' : member of nameless block was not redeclared
ERROR: 0:33: 'assign' : cannot convert from 'const 4-component vector of float' to 'layout(stream=0 ) gl_Position void'
ERROR: 7 compilation errors. No code generated.
invocations = 0 invocations = 0
...@@ -35,13 +37,17 @@ ERROR: node is still EOpNull! ...@@ -35,13 +37,17 @@ ERROR: node is still EOpNull!
0:30 0 (const int) 0:30 0 (const int)
0:31 move second child to first child (float) 0:31 move second child to first child (float)
0:31 gl_PointSize: direct index for structure (layout(stream=0 ) gl_PointSize float) 0:31 gl_PointSize: direct index for structure (layout(stream=0 ) gl_PointSize float)
0:31 '__anon__0' (layout(stream=0 ) out block{gl_PointSize}) 0:31 '__anon__0' (layout(stream=0 ) out block{gl_PointSize,})
0:31 Constant: 0:31 Constant:
0:31 0 (const uint) 0:31 1 (const uint)
0:31 'p' (float) 0:31 'p' (float)
0:33 gl_Position: direct index for structure (layout(stream=0 ) gl_Position void)
0:33 '__anon__0' (layout(stream=0 ) out block{gl_PointSize,})
0:33 Constant:
0:33 0 (const uint)
0:? Linker Objects 0:? Linker Objects
0:? 'gl_in' (in unsized array of block{gl_PointSize}) 0:? 'gl_in' (in unsized array of block{gl_PointSize})
0:? '__anon__0' (layout(stream=0 ) out block{gl_PointSize}) 0:? '__anon__0' (layout(stream=0 ) out block{gl_PointSize,})
Linked geometry stage: Linked geometry stage:
......
...@@ -4,7 +4,9 @@ ERROR: 0:9: 'length' : array must be declared with a size before using this met ...@@ -4,7 +4,9 @@ ERROR: 0:9: 'length' : array must be declared with a size before using this met
ERROR: 0:11: '[' : array must be redeclared with a size before being indexed with a variable ERROR: 0:11: '[' : array must be redeclared with a size before being indexed with a variable
ERROR: 0:42: 'assign' : l-value required (can't modify a const) ERROR: 0:42: 'assign' : l-value required (can't modify a const)
ERROR: 0:43: 'assign' : l-value required "v4" (can't modify a uniform) ERROR: 0:43: 'assign' : l-value required "v4" (can't modify a uniform)
ERROR: 4 compilation errors. No code generated. ERROR: 0:48: 'gl_PointSize' : cannot change arrayness of redeclared block member
ERROR: 0:49: 'gl_ClipDistance' : cannot change arrayness of redeclared block member
ERROR: 6 compilation errors. No code generated.
invocations = 0 invocations = 0
...@@ -115,6 +117,7 @@ ERROR: node is still EOpNull! ...@@ -115,6 +117,7 @@ ERROR: node is still EOpNull!
0:? 's2D' (uniform sampler2D) 0:? 's2D' (uniform sampler2D)
0:? 'coord' (in 2-component vector of float) 0:? 'coord' (in 2-component vector of float)
0:? 'v4' (uniform 4-component vector of float) 0:? 'v4' (uniform 4-component vector of float)
0:? '__anon__0' (layout(stream=0 ) out block{gl_PointSize,gl_ClipDistance})
Linked geometry stage: Linked geometry stage:
......
...@@ -130,6 +130,7 @@ ERROR: node is still EOpNull! ...@@ -130,6 +130,7 @@ ERROR: node is still EOpNull!
0:? 'sampb3' (layout(binding=32 ) uniform sampler2D) 0:? 'sampb3' (layout(binding=32 ) uniform sampler2D)
0:? 'sampb4' (layout(binding=31 ) uniform sampler2D) 0:? 'sampb4' (layout(binding=31 ) uniform sampler2D)
0:? 'sampb5' (layout(binding=31 ) uniform 2-element array of sampler2D) 0:? 'sampb5' (layout(binding=31 ) uniform 2-element array of sampler2D)
0:? '__anon__3' (out block{gl_ClipDistance,})
0:? 'gl_VertexID' (gl_VertexId int) 0:? 'gl_VertexID' (gl_VertexId int)
0:? 'gl_InstanceID' (gl_InstanceId int) 0:? 'gl_InstanceID' (gl_InstanceId int)
......
...@@ -23,9 +23,9 @@ ERROR: node is still EOpNull! ...@@ -23,9 +23,9 @@ ERROR: node is still EOpNull!
0:16 move second child to first child (float) 0:16 move second child to first child (float)
0:16 direct index (float) 0:16 direct index (float)
0:16 gl_ClipDistance: direct index for structure (17-element array of float) 0:16 gl_ClipDistance: direct index for structure (17-element array of float)
0:16 '__anon__0' (out block{gl_ClipDistance}) 0:16 '__anon__0' (out block{gl_ClipDistance,})
0:16 Constant: 0:16 Constant:
0:16 0 (const uint) 0:16 2 (const uint)
0:16 Constant: 0:16 Constant:
0:16 2 (const int) 0:16 2 (const int)
0:16 Constant: 0:16 Constant:
...@@ -41,7 +41,7 @@ ERROR: node is still EOpNull! ...@@ -41,7 +41,7 @@ ERROR: node is still EOpNull!
0:? 'uv4' (layout(location=4 ) uniform 4-component vector of float) 0:? 'uv4' (layout(location=4 ) uniform 4-component vector of float)
0:? 'b1' (layout(location=2 ) in block{v}) 0:? 'b1' (layout(location=2 ) in block{v})
0:? 'b2' (layout(location=2 ) out block{v}) 0:? 'b2' (layout(location=2 ) out block{v})
0:? '__anon__0' (out block{gl_ClipDistance}) 0:? '__anon__0' (out block{gl_ClipDistance,})
0:? 'cs' (layout(location=10 ) smooth out 2-element array of structure{m,f}) 0:? 'cs' (layout(location=10 ) smooth out 2-element array of structure{m,f})
0:? 'cf' (layout(location=54 ) smooth out float) 0:? 'cf' (layout(location=54 ) smooth out float)
0:? 'cg' (layout(location=53 ) smooth out float) 0:? 'cg' (layout(location=53 ) smooth out float)
......
...@@ -8,15 +8,15 @@ ERROR: 0:22: 'vn8' : illegal use of type 'void' ...@@ -8,15 +8,15 @@ ERROR: 0:22: 'vn8' : illegal use of type 'void'
ERROR: 0:22: 'vp' : illegal use of type 'void' ERROR: 0:22: 'vp' : illegal use of type 'void'
ERROR: 0:25: 'cij' : variables with qualifier 'const' must be initialized ERROR: 0:25: 'cij' : variables with qualifier 'const' must be initialized
ERROR: 0:27: 'cip' : variables with qualifier 'const' must be initialized ERROR: 0:27: 'cip' : variables with qualifier 'const' must be initialized
ERROR: 0:34: 'gl_' : reserved built-in name ERROR: 0:34: 'gl_' : reserved built-in name: gl_vi4
ERROR: 0:35: 'gl_' : reserved built-in name ERROR: 0:35: 'gl_' : reserved built-in name: gl_vj
ERROR: 0:35: 'gl_' : reserved built-in name ERROR: 0:35: 'gl_' : reserved built-in name: gl_vk5
ERROR: 0:36: 'gl_' : reserved built-in name ERROR: 0:36: 'gl_' : reserved built-in name: gl_vm2
ERROR: 0:36: 'gl_' : reserved built-in name ERROR: 0:36: 'gl_' : reserved built-in name: gl_vm3
ERROR: 0:37: 'gl_' : reserved built-in name ERROR: 0:37: 'gl_' : reserved built-in name: gl_vn8
ERROR: 0:37: 'gl_' : reserved built-in name ERROR: 0:37: 'gl_' : reserved built-in name: gl_vp
ERROR: 0:42: '' : boolean expression expected ERROR: 0:42: '' : boolean expression expected
ERROR: 0:43: 'gl_' : reserved built-in name ERROR: 0:43: 'gl_' : reserved built-in name: gl_cond
ERROR: 18 compilation errors. No code generated. ERROR: 18 compilation errors. No code generated.
......
...@@ -828,9 +828,11 @@ public: ...@@ -828,9 +828,11 @@ public:
if (structure) { if (structure) {
s.append("{"); s.append("{");
for (size_t i = 0; i < structure->size(); ++i) { for (size_t i = 0; i < structure->size(); ++i) {
s.append((*structure)[i].type->getFieldName()); if ((*structure)[i].type->getBasicType() != EbtVoid) {
if (i < structure->size()-1) s.append((*structure)[i].type->getFieldName());
s.append(","); if (i < structure->size() - 1)
s.append(",");
}
} }
s.append("}"); s.append("}");
} }
......
...@@ -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 "24397" #define GLSLANG_REVISION "24400"
#define GLSLANG_DATE "2013/12/06 16:57:42" #define GLSLANG_DATE "2013/12/06 17:28:07"
...@@ -74,7 +74,7 @@ public: ...@@ -74,7 +74,7 @@ public:
const char *szExtraInfoFormat, ...); const char *szExtraInfoFormat, ...);
void C_DECL warn(TSourceLoc, const char *szReason, const char *szToken, void C_DECL warn(TSourceLoc, const char *szReason, const char *szToken,
const char *szExtraInfoFormat, ...); const char *szExtraInfoFormat, ...);
bool reservedErrorCheck(TSourceLoc, const TString&); void reservedErrorCheck(TSourceLoc, const TString&);
void reservedPpErrorCheck(TSourceLoc, const char* name, const char* op); void reservedPpErrorCheck(TSourceLoc, const char* name, const char* op);
bool lineContinuationCheck(TSourceLoc, bool endOfComment); bool lineContinuationCheck(TSourceLoc, bool endOfComment);
bool builtInName(const TString&); bool builtInName(const TString&);
...@@ -125,7 +125,7 @@ public: ...@@ -125,7 +125,7 @@ public:
void parameterSamplerCheck(TSourceLoc, TStorageQualifier qualifier, const TType& type); void parameterSamplerCheck(TSourceLoc, TStorageQualifier qualifier, const TType& type);
bool containsSampler(const TType& type); bool containsSampler(const TType& type);
TSymbol* redeclareBuiltinVariable(TSourceLoc, const TString&, const TQualifier&, const TShaderQualifiers&, bool& newDeclaration); TSymbol* redeclareBuiltinVariable(TSourceLoc, const TString&, const TQualifier&, const TShaderQualifiers&, bool& newDeclaration);
bool redeclareBuiltinBlock(TSourceLoc, TTypeList& typeList, const TString& blockName, const TString* instanceName, TArraySizes* arraySizes); void redeclareBuiltinBlock(TSourceLoc, TTypeList& typeList, const TString& blockName, const TString* instanceName, TArraySizes* arraySizes);
void paramCheckFix(TSourceLoc, const TStorageQualifier&, TType& type); void paramCheckFix(TSourceLoc, const TStorageQualifier&, TType& type);
void paramCheckFix(TSourceLoc, const TQualifier&, TType& type); void paramCheckFix(TSourceLoc, const TQualifier&, TType& type);
void nestedBlockCheck(TSourceLoc); void nestedBlockCheck(TSourceLoc);
...@@ -134,6 +134,7 @@ public: ...@@ -134,6 +134,7 @@ public:
void opaqueCheck(TSourceLoc, const TType&, const char* op); void opaqueCheck(TSourceLoc, const TType&, const char* op);
void structTypeCheck(TSourceLoc, TPublicType&); void structTypeCheck(TSourceLoc, TPublicType&);
void inductiveLoopCheck(TSourceLoc, TIntermNode* init, TIntermLoop* loop); void inductiveLoopCheck(TSourceLoc, TIntermNode* init, TIntermLoop* loop);
void arrayLimitCheck(TSourceLoc, const TString&, int size);
void limitCheck(TSourceLoc, int value, const char* limit, const char* feature); void limitCheck(TSourceLoc, int value, const char* limit, const char* feature);
void inductiveLoopBodyCheck(TIntermNode*, int loopIndexId, TSymbolTable&); void inductiveLoopBodyCheck(TIntermNode*, int loopIndexId, TSymbolTable&);
......
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