Skip to content
Snippets Groups Projects
Commit 9497485e authored by John Kessenich's avatar John Kessenich
Browse files

Add geometry shader input array sizing/checking WRT declared input primitive layout.

git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@23698 e7fa87d3-cd2b-0410-9028-fcbf551c1848
parent ab41fe5d
No related branches found
No related tags found
No related merge requests found
Showing
with 368 additions and 62 deletions
......@@ -12,3 +12,40 @@ void main()
layout(invocations = 3) out outbn { int a; }; // ERROR, not on a block
layout(max_vertices = 127, invocations = 4) out;
#extension GL_ARB_separate_shader_objects : enable
in gl_PerVertex { // testing input arrays with a block redeclaration, see 420.geom for without
vec4 gl_Position;
} gl_in[];
void foo()
{
gl_in.length(); // ERROR
gl_in[1].gl_Position;
}
in vec4 color[];
in vec4 color2[];
in vec4 colorS[3];
in vec4 colorBad[4];
void foo2()
{
color.length(); // ERROR
colorS.length();
}
layout(triangles) in; // give ERROR just for colorBad
in vec4 color[3];
in vec4 color2[3];
in vec4 colorbad2[2]; // ERROR
void foo3()
{
gl_in.length();
color.length();
color2.length();
colorS.length();
}
#version 150 core
// testing input arrays without a gl_in[] block redeclaration, see 400.geom for with
int i;
void foo()
{
gl_in.length(); // ERROR
gl_in[1].gl_Position;
gl_in[i].gl_Position; // ERROR
}
layout(triangles) in;
in vec4 color3[3];
void foo3()
{
gl_in.length();
gl_in[i].gl_Position;
color3.length();
}
......@@ -300,7 +300,7 @@ ERROR: node is still EOpNull!
0:121 add second child into first child (4-component vector of float)
0:121 'v' (4-component vector of float)
0:121 direct index (smooth in 4-component vector of float)
0:121 'gl_TexCoord' (smooth in unsized array of 4-component vector of float)
0:121 'gl_TexCoord' (smooth in 6-element array of 4-component vector of float)
0:121 Constant:
0:121 3 (const int)
0:? Linker Objects
......
......@@ -46,5 +46,6 @@ ERROR: node is still EOpNull!
0:? 'fflat' (flat in float)
0:? 'fsmooth' (smooth in float)
0:? 'fnop' (noperspective in float)
0:? 'gl_ClipDistance' (smooth in unsized array of float)
0:? 'sampC' (uniform samplerCube)
......@@ -19,4 +19,5 @@ ERROR: node is still EOpNull!
0:? 'i' (smooth in 4-component vector of float)
0:? 'o' (out 4-component vector of float)
0:? 'gl_ClipDistance' (smooth in 5-element array of float)
0:? 'gl_ClipDistance' (smooth in 5-element array of float)
......@@ -63,7 +63,7 @@ ERROR: node is still EOpNull!
0:33 direct index (float)
0:33 gl_ClipDistance: direct index for structure (unsized array of float)
0:33 direct index (in block{gl_Position,gl_PointSize,gl_ClipDistance})
0:33 'gl_in' (in unsized array of block{gl_Position,gl_PointSize,gl_ClipDistance})
0:33 'gl_in' (in 4-element array of block{gl_Position,gl_PointSize,gl_ClipDistance})
0:33 Constant:
0:33 1 (const int)
0:33 Constant:
......@@ -77,7 +77,7 @@ ERROR: node is still EOpNull!
0:34 0 (const uint)
0:34 gl_Position: direct index for structure (4-component vector of float)
0:34 direct index (in block{gl_Position,gl_PointSize,gl_ClipDistance})
0:34 'gl_in' (in unsized array of block{gl_Position,gl_PointSize,gl_ClipDistance})
0:34 'gl_in' (in 4-element array of block{gl_Position,gl_PointSize,gl_ClipDistance})
0:34 Constant:
0:34 0 (const int)
0:34 Constant:
......@@ -89,7 +89,7 @@ ERROR: node is still EOpNull!
0:35 1 (const uint)
0:35 gl_PointSize: direct index for structure (float)
0:35 direct index (in block{gl_Position,gl_PointSize,gl_ClipDistance})
0:35 'gl_in' (in unsized array of block{gl_Position,gl_PointSize,gl_ClipDistance})
0:35 'gl_in' (in 4-element array of block{gl_Position,gl_PointSize,gl_ClipDistance})
0:35 Constant:
0:35 3 (const int)
0:35 Constant:
......@@ -119,6 +119,7 @@ ERROR: node is still EOpNull!
0:? 'fromV' (in block{color})
0:? 'toF' (layout(stream=0 ) out block{color})
0:? '__anon__0' (layout(stream=0 ) out block{color})
0:? 'gl_in' (in 4-element array of block{gl_Position,gl_PointSize,gl_ClipDistance})
0:? 'ov0' (layout(stream=0 ) out 4-component vector of float)
0:? 'ov4' (layout(stream=4 ) out 4-component vector of float)
0:? 'o1v0' (layout(stream=0 ) out 4-component vector of float)
......
......@@ -112,6 +112,7 @@ ERROR: node is still EOpNull!
0:? 'arrayedSampler' (uniform 5-element array of sampler2D)
0:? 'samp2dr' (uniform usampler2DRect)
0:? 'isamp2DA' (uniform isampler2DArray)
0:? 'gl_ClipDistance' (smooth in unsized array of float)
0:? 'vl' (layout(location=4 ) smooth in 4-component vector of float)
0:? 'vl2' (layout(location=4 ) smooth in 4-component vector of float)
0:? 'uv3' (layout(location=3 ) uniform 3-component vector of float)
......
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: 1 compilation errors. No code generated.
ERROR: 0:24: 'length' : array must be declared with a size before using this method
ERROR: 0:35: 'length' : array must be declared with a size before using this method
ERROR: 0:39: 'triangles' : inconsistent input primitive for array size colorBad
ERROR: 0:43: 'triangles' : inconsistent input primitive for array size colorbad2
ERROR: 5 compilation errors. No code generated.
invocations = 4
max_vertices = 127
input primitive = none
input primitive = triangles
output primitive = none
ERROR: node is still EOpNull!
0:3 Function Definition: main( (void)
......@@ -22,6 +26,42 @@ ERROR: node is still EOpNull!
0:10 move second child to first child (int)
0:10 'id' (int)
0:10 'gl_InvocationID' (in int)
0:22 Function Definition: foo( (void)
0:22 Function Parameters:
0:24 Sequence
0:24 Constant:
0:24 1 (const int)
0:25 gl_Position: direct index for structure (4-component vector of float)
0:25 direct index (in block{gl_Position})
0:25 'gl_in' (in 3-element array of block{gl_Position})
0:25 Constant:
0:25 1 (const int)
0:25 Constant:
0:25 0 (const int)
0:33 Function Definition: foo2( (void)
0:33 Function Parameters:
0:35 Sequence
0:35 Constant:
0:35 1 (const int)
0:36 Constant:
0:36 3 (const int)
0:45 Function Definition: foo3( (void)
0:45 Function Parameters:
0:47 Sequence
0:47 Constant:
0:47 3 (const int)
0:48 Constant:
0:48 3 (const int)
0:49 Constant:
0:49 3 (const int)
0:50 Constant:
0:50 3 (const int)
0:? Linker Objects
0:? '__anon__0' (layout(stream=0 ) out block{a})
0:? 'gl_in' (in 3-element array of block{gl_Position})
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:? 'colorS' (in 3-element array of 4-component vector of float)
0:? 'colorBad' (in 4-element array of 4-component vector of float)
0:? 'colorbad2' (in 2-element array of 4-component vector of float)
......@@ -2,7 +2,7 @@ Warning, version 410 is not yet complete; some version-specific features are pre
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_' : reserved built-in name
ERROR: 0:20: 'gl_PerVertex' : can only redeclare a built-in block once
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: 5 compilation errors. No code generated.
......
Warning, version 150 is not yet complete; some version-specific features are present, but many are missing.
ERROR: 0:9: 'length' : array must be declared with a size before using this method
ERROR: 0:11: '[' : array must be redeclared with a size before being indexed with a variable
ERROR: 2 compilation errors. No code generated.
invocations = 0
max_vertices = 0
input primitive = triangles
output primitive = none
ERROR: node is still EOpNull!
0:7 Function Definition: foo( (void)
0:7 Function Parameters:
0:9 Sequence
0:9 Constant:
0:9 1 (const int)
0:10 gl_Position: direct index for structure (4-component vector of float)
0:10 direct index (in block{gl_Position,gl_PointSize,gl_ClipDistance})
0:10 'gl_in' (in 3-element array of block{gl_Position,gl_PointSize,gl_ClipDistance})
0:10 Constant:
0:10 1 (const int)
0:10 Constant:
0:10 0 (const int)
0:11 gl_Position: direct index for structure (4-component vector of float)
0:11 indirect index (in block{gl_Position,gl_PointSize,gl_ClipDistance})
0:11 'gl_in' (in 3-element array of block{gl_Position,gl_PointSize,gl_ClipDistance})
0:11 'i' (int)
0:11 Constant:
0:11 0 (const int)
0:18 Function Definition: foo3( (void)
0:18 Function Parameters:
0:20 Sequence
0:20 Constant:
0:20 3 (const int)
0:21 gl_Position: direct index for structure (4-component vector of float)
0:21 indirect index (in block{gl_Position,gl_PointSize,gl_ClipDistance})
0:21 'gl_in' (in 3-element array of block{gl_Position,gl_PointSize,gl_ClipDistance})
0:21 'i' (int)
0:21 Constant:
0:21 0 (const int)
0:22 Constant:
0:22 3 (const int)
0:? Linker Objects
0:? 'i' (int)
0:? 'gl_in' (in 3-element array of block{gl_Position,gl_PointSize,gl_ClipDistance})
0:? 'color3' (in 3-element array of 4-component vector of float)
......@@ -286,8 +286,11 @@ ERROR: node is still EOpNull!
0:? '__anon__1' (in block{LightPos,LightColor})
0:? 'Materiala' (in block{Color,TexCoord})
0:? 'gl_FragCoord' (gl_FragCoord 4-component vector of float)
0:? 'gl_FragCoord' (gl_FragCoord 4-component vector of float)
0:? 'factor' (layout(location=3 ) out 4-component vector of float)
0:? 'colors' (layout(location=2 ) out 3-element array of 4-component vector of float)
0:? 'gl_FragDepth' (gl_FragDepth float)
0:? 'gl_FragDepth' (gl_FragDepth float)
0:? '__anon__2' (in block{gl_FogFragCoord,gl_TexCoord,gl_Color,gl_SecondaryColor})
0:? '__anon__2' (in block{gl_FogFragCoord,gl_TexCoord,gl_Color,gl_SecondaryColor})
......@@ -294,6 +294,7 @@ ERROR: node is still EOpNull!
0:? 'c2' (layout(binding=3 ) uniform int)
0:? 'd2' (layout(binding=2 ) uniform int)
0:? '__anon__5' (out block{gl_Position,gl_PointSize,gl_ClipDistance,gl_ClipVertex,gl_FrontColor,gl_BackColor,gl_FrontSecondaryColor,gl_BackSecondaryColor,gl_TexCoord,gl_FogFragCoord})
0:? '__anon__5' (out block{gl_Position,gl_PointSize,gl_ClipDistance,gl_ClipVertex,gl_FrontColor,gl_BackColor,gl_FrontSecondaryColor,gl_BackSecondaryColor,gl_TexCoord,gl_FogFragCoord})
0:? 'ColorInv' (smooth out 3-component vector of float)
0:? 'Color4' (invariant centroid smooth out 3-component vector of float)
0:? 'position' (smooth out 4-component vector of float)
......
......@@ -54,5 +54,6 @@ WARNING: 0:8: varying deprecated in version 130; may be removed in future releas
0:? 'color' (smooth in 4-component vector of float)
0:? 'alpha' (smooth in float)
0:? 'gl_TexCoord' (smooth in 6-element array of 4-component vector of float)
0:? 'gl_TexCoord' (smooth in 6-element array of 4-component vector of float)
0:? 'foo' (smooth in 3-element array of 4-component vector of float)
......@@ -55,6 +55,7 @@ WARNING: 0:8: varying deprecated in version 130; may be removed in future releas
0:? 'color' (smooth in 4-component vector of float)
0:? 'alpha' (smooth in float)
0:? 'gl_TexCoord' (smooth in 6-element array of 4-component vector of float)
0:? 'gl_TexCoord' (smooth in 6-element array of 4-component vector of float)
0:? 'userIn' (smooth in 2-element array of 4-component vector of float)
0:? 'a' (uniform int)
0:? 'b' (uniform int)
......
......@@ -47,6 +47,7 @@ tokenLength.vert
300scope.vert
400.frag
420.vert
420.geom
430scope.vert
lineContinuation.vert
numeral.frag
......
This diff is collapsed.
......@@ -72,12 +72,17 @@ public:
const char *szExtraInfoFormat, ...);
void C_DECL warn(TSourceLoc, const char *szReason, const char *szToken,
const char *szExtraInfoFormat, ...);
bool reservedErrorCheck(TSourceLoc, const TString& identifier);
bool reservedErrorCheck(TSourceLoc, const TString&);
bool builtInName(const TString&);
void updateExtensionBehavior(const char* extName, const char* behavior);
void handlePragma(const char **tokens, int numTokens);
TIntermTyped* handleVariable(TSourceLoc, TSymbol* symbol, TString* string);
TIntermTyped* handleBracketDereference(TSourceLoc, TIntermTyped* base, TIntermTyped* index);
void handleIndexLimits(TSourceLoc, TIntermTyped* base, TIntermTyped* index);
void handleInputArrayAccess(TSourceLoc, TIntermTyped* base);
void checkInputArrayConsistency(TSourceLoc, bool tailOnly = false);
void checkInputArrayConsistency(TSourceLoc, TLayoutGeometry, TType&, const TString&);
TIntermTyped* handleDotDereference(TSourceLoc, TIntermTyped* base, TString& field);
TFunction* handleFunctionDeclarator(TSourceLoc loc, TFunction& function);
TIntermAggregate* handleFunctionPrototype(TSourceLoc, TFunction&);
......@@ -230,6 +235,40 @@ protected:
bool anyIndexLimits;
TVector<TIntermTyped*> needsIndexLimitationChecking;
// TODO: desktop functionality: track use of gl_FragDepth before redeclaration
//
// Geometry shader input arrays:
// - array sizing is based on input primitive and/or explicit size
// - array sizing is retroactive
// - built-in block redeclarations interact with this
//
// Design:
// - use a per-context "resize-list", a list of entities whose array sizes
// can be fixed; this is logically one list, but physically two:
// * a list for nodes in the AST
// * a list for symbols in the symbol table
// this could be done a bit more simply, but this allows better error messages.
//
// - the resize-list starts empty at beginning of user-shader compilation, it does
// not have built-ins in it
//
// - on built-in input array use: copy-up symbol and add both the symbol and
// its use to resize-list
//
// - on user-input array declaration: add it to the resize-list
//
// - on block redeclaration: copy-up symbol and add it to the resize-list
// * note, that appropriately gives an error if redeclaring a block that
// was already used and hence already copied-up
//
// - on seeing an input primitive-layout declaration, fix everything in the resize-list,
// giving errors for mismatch
//
// - on seeing an array size declaration, give errors on mismatch between it and previous
// input primitive declarations
//
TVector<TIntermSymbol*> inputArrayNodeResizeList;
TVector<TSymbol*> inputArraySymbolResizeList;
};
} // end namespace glslang
......
......@@ -99,7 +99,7 @@ public:
virtual int getUniqueId() const { return uniqueId; }
virtual void dump(TInfoSink &infoSink) const = 0;
virtual bool isReadOnly() { return ! writable; }
virtual bool isReadOnly() const { return ! writable; }
virtual void makeReadOnly() { writable = false; }
protected:
......@@ -417,9 +417,10 @@ public:
// 3: user-shader globals
//
protected:
static const int globalLevel = 3;
bool isSharedLevel(int level) { return level <= 1; } // exclude all per-compile levels
bool isBuiltInLevel(int level) { return level <= 2; } // exclude user globals
bool isGlobalLevel(int level) { return level <= 3; } // include user globals
bool isGlobalLevel(int level) { return level <= globalLevel; } // include user globals
public:
bool isEmpty() { return table.size() == 0; }
bool atBuiltInLevel() { return isBuiltInLevel(currentLevel()); }
......@@ -482,7 +483,7 @@ public:
TSymbol* copyUp(TSymbol* shared)
{
TSymbol* copy = copyUpDeferredInsert(shared);
table[currentLevel()]->insert(*copy);
table[globalLevel]->insert(*copy);
if (shared->getAsVariable())
return copy;
else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment