Commit 3933dc51 by John Kessenich

nonuniform: prevent use of struct/block members.

parent bd4603e0
...@@ -7,7 +7,9 @@ ERROR: 0:24: 'constructor' : too many arguments ...@@ -7,7 +7,9 @@ ERROR: 0:24: 'constructor' : too many arguments
ERROR: 0:24: 'assign' : cannot convert from ' const float' to ' nonuniform temp int' ERROR: 0:24: 'assign' : cannot convert from ' const float' to ' nonuniform temp int'
ERROR: 0:25: 'constructor' : not enough data provided for construction ERROR: 0:25: 'constructor' : not enough data provided for construction
ERROR: 0:25: 'assign' : cannot convert from ' const float' to ' nonuniform temp int' ERROR: 0:25: 'assign' : cannot convert from ' const float' to ' nonuniform temp int'
ERROR: 8 compilation errors. No code generated. ERROR: 0:28: 'nonuniformEXT' : not allowed on block or structure members
ERROR: 0:29: 'nonuniformEXT' : not allowed on block or structure members
ERROR: 10 compilation errors. No code generated.
Shader version: 450 Shader version: 450
...@@ -42,8 +44,8 @@ ERROR: node is still EOpNull! ...@@ -42,8 +44,8 @@ ERROR: node is still EOpNull!
0:? 'nu_uv4' ( nonuniform uniform 4-component vector of float) 0:? 'nu_uv4' ( nonuniform uniform 4-component vector of float)
0:? 'nu_constf' ( nonuniform const float) 0:? 'nu_constf' ( nonuniform const float)
0:? 1.000000 0:? 1.000000
0:? 'ins' (layout( location=1) smooth in structure{ global float a, nonuniform temp float b}) 0:? 'ins' (layout( location=1) smooth in structure{ global float a, temp float b})
0:? 'inb' (layout( location=3) in block{ in float a, nonuniform in float b}) 0:? 'inb' (layout( location=3) in block{ in float a, in float b})
Linked fragment stage: Linked fragment stage:
...@@ -81,6 +83,6 @@ ERROR: node is still EOpNull! ...@@ -81,6 +83,6 @@ ERROR: node is still EOpNull!
0:? 'nu_uv4' ( nonuniform uniform 4-component vector of float) 0:? 'nu_uv4' ( nonuniform uniform 4-component vector of float)
0:? 'nu_constf' ( nonuniform const float) 0:? 'nu_constf' ( nonuniform const float)
0:? 1.000000 0:? 1.000000
0:? 'ins' (layout( location=1) smooth in structure{ global float a, nonuniform temp float b}) 0:? 'ins' (layout( location=1) smooth in structure{ global float a, temp float b})
0:? 'inb' (layout( location=3) in block{ in float a, nonuniform in float b}) 0:? 'inb' (layout( location=3) in block{ in float a, in float b})
spv.nonuniform.frag spv.nonuniform.frag
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 80005 // Generated by (magic number): 80005
// Id's are bound by 54 // Id's are bound by 42
Capability Shader Capability Shader
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 33 44 50 EntryPoint Fragment 4 "main" 33
ExecutionMode 4 OriginUpperLeft ExecutionMode 4 OriginUpperLeft
Source GLSL 450 Source GLSL 450
Name 4 "main" Name 4 "main"
...@@ -20,14 +20,6 @@ spv.nonuniform.frag ...@@ -20,14 +20,6 @@ spv.nonuniform.frag
Name 30 "b" Name 30 "b"
Name 33 "nu_inv4" Name 33 "nu_inv4"
Name 39 "nu_gf" Name 39 "nu_gf"
Name 42 "S"
MemberName 42(S) 0 "a"
MemberName 42(S) 1 "b"
Name 44 "ins"
Name 48 "inbName"
MemberName 48(inbName) 0 "a"
MemberName 48(inbName) 1 "b"
Name 50 "inb"
Decorate 13 DecorationNonUniformEXT Decorate 13 DecorationNonUniformEXT
Decorate 17(nu_li) DecorationNonUniformEXT Decorate 17(nu_li) DecorationNonUniformEXT
Decorate 19 DecorationNonUniformEXT Decorate 19 DecorationNonUniformEXT
...@@ -37,12 +29,6 @@ spv.nonuniform.frag ...@@ -37,12 +29,6 @@ spv.nonuniform.frag
Decorate 33(nu_inv4) DecorationNonUniformEXT Decorate 33(nu_inv4) DecorationNonUniformEXT
Decorate 39(nu_gf) DecorationNonUniformEXT Decorate 39(nu_gf) DecorationNonUniformEXT
Decorate 40 DecorationNonUniformEXT Decorate 40 DecorationNonUniformEXT
MemberDecorate 42(S) 1 DecorationNonUniformEXT
Decorate 44(ins) Location 1
MemberDecorate 48(inbName) 0 DecorationNonUniformEXT
Decorate 48(inbName) Block
Decorate 50(inb) Location 3
Decorate 52 DecorationNonUniformEXT
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeInt 32 1 6: TypeInt 32 1
...@@ -57,13 +43,6 @@ spv.nonuniform.frag ...@@ -57,13 +43,6 @@ spv.nonuniform.frag
34: TypeInt 32 0 34: TypeInt 32 0
35: 34(int) Constant 0 35: 34(int) Constant 0
36: TypePointer Input 28(float) 36: TypePointer Input 28(float)
42(S): TypeStruct 28(float) 28(float)
43: TypePointer Input 42(S)
44(ins): 43(ptr) Variable Input
45: 6(int) Constant 0
48(inbName): TypeStruct 28(float) 28(float)
49: TypePointer Input 48(inbName)
50(inb): 49(ptr) Variable Input
4(main): 2 Function None 3 4(main): 2 Function None 3
5: Label 5: Label
16(a): 7(ptr) Variable Function 16(a): 7(ptr) Variable Function
...@@ -88,12 +67,6 @@ spv.nonuniform.frag ...@@ -88,12 +67,6 @@ spv.nonuniform.frag
40: 28(float) Load 39(nu_gf) 40: 28(float) Load 39(nu_gf)
41: 28(float) FMul 38 40 41: 28(float) FMul 38 40
Store 30(b) 41 Store 30(b) 41
46: 36(ptr) AccessChain 44(ins) 45
47: 28(float) Load 46
51: 36(ptr) AccessChain 50(inb) 45
52: 28(float) Load 51
53: 28(float) FAdd 47 52
Store 30(b) 53
Return Return
FunctionEnd FunctionEnd
11(foo(i1;i1;): 6(int) Function None 8 11(foo(i1;i1;): 6(int) Function None 8
......
...@@ -25,5 +25,5 @@ void main() ...@@ -25,5 +25,5 @@ void main()
nu_li = nonuniformEXT(); // ERROR, no arguments nu_li = nonuniformEXT(); // ERROR, no arguments
} }
layout(location=1) in struct S { float a; nonuniformEXT float b; } ins; layout(location=1) in struct S { float a; nonuniformEXT float b; } ins; // ERROR, not on member
layout(location=3) in inbName { float a; nonuniformEXT float b; } inb; layout(location=3) in inbName { float a; nonuniformEXT float b; } inb; // ERROR, not on member
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
layout(location=0) nonuniformEXT in vec4 nu_inv4; layout(location=0) nonuniformEXT in vec4 nu_inv4;
nonuniformEXT float nu_gf; nonuniformEXT float nu_gf;
layout(location=1) in struct S { float a; nonuniformEXT float b; } ins;
layout(location=3) in inbName { nonuniformEXT float a; float b; } inb;
nonuniformEXT int foo(nonuniformEXT int nupi, nonuniformEXT out int f) nonuniformEXT int foo(nonuniformEXT int nupi, nonuniformEXT out int f)
{ {
...@@ -19,5 +17,4 @@ void main() ...@@ -19,5 +17,4 @@ void main()
float b; float b;
b = nu_inv4.x * nu_gf; b = nu_inv4.x * nu_gf;
b = ins.a + inb.a;
} }
\ No newline at end of file
...@@ -2575,6 +2575,19 @@ void TParseContext::transparentOpaqueCheck(const TSourceLoc& loc, const TType& t ...@@ -2575,6 +2575,19 @@ void TParseContext::transparentOpaqueCheck(const TSourceLoc& loc, const TType& t
} }
// //
// Qualifier checks knowing the qualifier and that it is a member of a struct/block.
//
void TParseContext::memberQualifierCheck(glslang::TPublicType& publicType)
{
globalQualifierFixCheck(publicType.loc, publicType.qualifier);
checkNoShaderLayouts(publicType.loc, publicType.shaderQualifiers);
if (publicType.qualifier.isNonUniform()) {
error(publicType.loc, "not allowed on block or structure members", "nonuniformEXT", "");
publicType.qualifier.nonUniform = false;
}
}
//
// Check/fix just a full qualifier (no variables or types yet, but qualifier is complete) at global level. // Check/fix just a full qualifier (no variables or types yet, but qualifier is complete) at global level.
// //
void TParseContext::globalQualifierFixCheck(const TSourceLoc& loc, TQualifier& qualifier) void TParseContext::globalQualifierFixCheck(const TSourceLoc& loc, TQualifier& qualifier)
......
...@@ -351,6 +351,7 @@ public: ...@@ -351,6 +351,7 @@ public:
void samplerCheck(const TSourceLoc&, const TType&, const TString& identifier, TIntermTyped* initializer); void samplerCheck(const TSourceLoc&, const TType&, const TString& identifier, TIntermTyped* initializer);
void atomicUintCheck(const TSourceLoc&, const TType&, const TString& identifier); void atomicUintCheck(const TSourceLoc&, const TType&, const TString& identifier);
void transparentOpaqueCheck(const TSourceLoc&, const TType&, const TString& identifier); void transparentOpaqueCheck(const TSourceLoc&, const TType&, const TString& identifier);
void memberQualifierCheck(glslang::TPublicType&);
void globalQualifierFixCheck(const TSourceLoc&, TQualifier&); void globalQualifierFixCheck(const TSourceLoc&, TQualifier&);
void globalQualifierTypeCheck(const TSourceLoc&, const TQualifier&, const TPublicType&); void globalQualifierTypeCheck(const TSourceLoc&, const TQualifier&, const TPublicType&);
bool structQualifierErrorCheck(const TSourceLoc&, const TPublicType& pType); bool structQualifierErrorCheck(const TSourceLoc&, const TPublicType& pType);
......
...@@ -3127,7 +3127,6 @@ struct_declaration ...@@ -3127,7 +3127,6 @@ struct_declaration
} }
} }
| type_qualifier type_specifier struct_declarator_list SEMICOLON { | type_qualifier type_specifier struct_declarator_list SEMICOLON {
parseContext.globalQualifierFixCheck($1.loc, $1.qualifier);
if ($2.arraySizes) { if ($2.arraySizes) {
parseContext.profileRequires($2.loc, ENoProfile, 120, E_GL_3DL_array_objects, "arrayed type"); parseContext.profileRequires($2.loc, ENoProfile, 120, E_GL_3DL_array_objects, "arrayed type");
parseContext.profileRequires($2.loc, EEsProfile, 300, 0, "arrayed type"); parseContext.profileRequires($2.loc, EEsProfile, 300, 0, "arrayed type");
...@@ -3137,7 +3136,7 @@ struct_declaration ...@@ -3137,7 +3136,7 @@ struct_declaration
$$ = $3; $$ = $3;
parseContext.checkNoShaderLayouts($1.loc, $1.shaderQualifiers); parseContext.memberQualifierCheck($1);
parseContext.voidErrorCheck($2.loc, (*$3)[0].type->getFieldName(), $2.basicType); parseContext.voidErrorCheck($2.loc, (*$3)[0].type->getFieldName(), $2.basicType);
parseContext.mergeQualifiers($2.loc, $2.qualifier, $1.qualifier, true); parseContext.mergeQualifiers($2.loc, $2.qualifier, $1.qualifier, true);
parseContext.precisionQualifierCheck($2.loc, $2.basicType, $2.qualifier); parseContext.precisionQualifierCheck($2.loc, $2.basicType, $2.qualifier);
......
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