From 89400ea73e5ac2c5ee0c5e6b6268cdb80fd2b83b Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Thu, 29 Jun 2017 10:46:47 -0600 Subject: [PATCH] GLSL: validation of early_fragment_tests, others, on an object. Some layout qualifiers must not be on an object and had a TBD for testing them: early_fragment_tests, cw/ccw, points, point_mode, and fractional_even_spacing/fractional_odd_spacing/equal_spacing. --- Test/450.frag | 2 ++ Test/450.geom | 2 ++ Test/450.tese | 7 ++++++ Test/baseResults/450.frag.out | 5 ++++- Test/baseResults/450.geom.out | 5 ++++- Test/baseResults/450.tese.out | 25 ++++++++++++++++++++-- glslang/MachineIndependent/ParseHelper.cpp | 21 ++++++++++++------ 7 files changed, 56 insertions(+), 11 deletions(-) diff --git a/Test/450.frag b/Test/450.frag index 9df13912d..076d0b3a9 100644 --- a/Test/450.frag +++ b/Test/450.frag @@ -64,3 +64,5 @@ layout(location = 12) in bName2 { float f; layout(location = 13) float g; // ERROR, location on array } bInst2[3]; + +layout(early_fragment_tests) in float f; // ERROR, must be standalone diff --git a/Test/450.geom b/Test/450.geom index 83d99aa62..45cbecba5 100644 --- a/Test/450.geom +++ b/Test/450.geom @@ -15,3 +15,5 @@ void main() gl_in[3].gl_Position; // ERROR, out of range gl_CullDistance[2] = gl_in[1].gl_CullDistance[2]; } + +layout(points) in float f[3]; // ERROR, must be standalone diff --git a/Test/450.tese b/Test/450.tese index 61447931c..8cdeb2072 100644 --- a/Test/450.tese +++ b/Test/450.tese @@ -12,3 +12,10 @@ void main() { gl_CullDistance[2] = gl_in[1].gl_CullDistance[2]; } + +layout(equal_spacing) in float f1[]; // ERROR, must be standalone +layout(fractional_even_spacing) in float f2[]; // ERROR, must be standalone +layout(fractional_odd_spacing) in float f3[]; // ERROR, must be standalone +layout(cw) in float f4[]; // ERROR, must be standalone +layout(ccw) in float f5[]; // ERROR, must be standalone +layout(point_mode) in float f6[]; // ERROR, must be standalone diff --git a/Test/baseResults/450.frag.out b/Test/baseResults/450.frag.out index c0db5a7b9..9cbb4cbd0 100644 --- a/Test/baseResults/450.frag.out +++ b/Test/baseResults/450.frag.out @@ -1,6 +1,7 @@ 450.frag ERROR: 0:63: 'location' : cannot use in a block array where new locations are needed for each block element -ERROR: 1 compilation errors. No code generated. +ERROR: 0:68: 'early_fragment_tests' : can only apply to a standalone qualifier +ERROR: 2 compilation errors. No code generated. Shader version: 450 @@ -164,6 +165,7 @@ ERROR: node is still EOpNull! 0:? 'i2dmsa' (layout( rgba32f) uniform image2DMSArray) 0:? 'bInst1' ( in block{layout( location=6) in float f, layout( location=7) in float g, layout( location=8) in 4X4 matrix of float m}) 0:? 'bInst2' ( in 3-element array of block{layout( location=12) in float f, layout( location=13) in float g}) +0:? 'f' ( smooth in float) Linked fragment stage: @@ -279,4 +281,5 @@ ERROR: node is still EOpNull! 0:? 'i2dmsa' (layout( rgba32f) uniform image2DMSArray) 0:? 'bInst1' ( in block{layout( location=6) in float f, layout( location=7) in float g, layout( location=8) in 4X4 matrix of float m}) 0:? 'bInst2' ( in 3-element array of block{layout( location=12) in float f, layout( location=13) in float g}) +0:? 'f' ( smooth in float) diff --git a/Test/baseResults/450.geom.out b/Test/baseResults/450.geom.out index ee08188c7..e75bf939a 100644 --- a/Test/baseResults/450.geom.out +++ b/Test/baseResults/450.geom.out @@ -1,7 +1,8 @@ 450.geom ERROR: 0:15: '[' : array index out of range '3' ERROR: 0:15: 'gl_Position' : no such field in structure -ERROR: 2 compilation errors. No code generated. +ERROR: 0:19: 'points' : can only apply to a standalone qualifier +ERROR: 3 compilation errors. No code generated. Shader version: 450 @@ -38,6 +39,7 @@ ERROR: node is still EOpNull! 0:? Linker Objects 0:? 'gl_in' ( in 3-element array of block{ in 3-element array of float CullDistance gl_CullDistance}) 0:? 'anon@0' (layout( stream=0) out block{layout( stream=0) out 3-element array of float CullDistance gl_CullDistance}) +0:? 'f' ( in 3-element array of float) Linked geometry stage: @@ -79,4 +81,5 @@ ERROR: node is still EOpNull! 0:? Linker Objects 0:? 'gl_in' ( in 3-element array of block{ in 3-element array of float CullDistance gl_CullDistance}) 0:? 'anon@0' (layout( stream=0) out block{layout( stream=0) out 3-element array of float CullDistance gl_CullDistance}) +0:? 'f' ( in 3-element array of float) diff --git a/Test/baseResults/450.tese.out b/Test/baseResults/450.tese.out index 7b803045e..796d6f160 100644 --- a/Test/baseResults/450.tese.out +++ b/Test/baseResults/450.tese.out @@ -1,9 +1,18 @@ 450.tese +ERROR: 0:16: 'equal_spacing' : can only apply to a standalone qualifier +ERROR: 0:17: 'fractional_even_spacing' : can only apply to a standalone qualifier +ERROR: 0:18: 'fractional_odd_spacing' : can only apply to a standalone qualifier +ERROR: 0:19: 'cw' : can only apply to a standalone qualifier +ERROR: 0:20: 'ccw' : can only apply to a standalone qualifier +ERROR: 0:21: 'point_mode' : can only apply to a standalone qualifier +ERROR: 6 compilation errors. No code generated. + + Shader version: 450 input primitive = none vertex spacing = none triangle order = none -0:? Sequence +ERROR: node is still EOpNull! 0:11 Function Definition: main( ( global void) 0:11 Function Parameters: 0:13 Sequence @@ -28,6 +37,12 @@ triangle order = none 0:? Linker Objects 0:? 'gl_in' ( in 32-element array of block{ in 3-element array of float CullDistance gl_CullDistance}) 0:? 'anon@0' ( out block{ out 3-element array of float CullDistance gl_CullDistance}) +0:? 'f1' ( in 32-element array of float) +0:? 'f2' ( in 32-element array of float) +0:? 'f3' ( in 32-element array of float) +0:? 'f4' ( in 32-element array of float) +0:? 'f5' ( in 32-element array of float) +0:? 'f6' ( in 32-element array of float) Linked tessellation evaluation stage: @@ -38,7 +53,7 @@ Shader version: 450 input primitive = none vertex spacing = equal_spacing triangle order = ccw -0:? Sequence +ERROR: node is still EOpNull! 0:11 Function Definition: main( ( global void) 0:11 Function Parameters: 0:13 Sequence @@ -63,4 +78,10 @@ triangle order = ccw 0:? Linker Objects 0:? 'gl_in' ( in 32-element array of block{ in 3-element array of float CullDistance gl_CullDistance}) 0:? 'anon@0' ( out block{ out 3-element array of float CullDistance gl_CullDistance}) +0:? 'f1' ( in 32-element array of float) +0:? 'f2' ( in 32-element array of float) +0:? 'f3' ( in 32-element array of float) +0:? 'f4' ( in 32-element array of float) +0:? 'f5' ( in 32-element array of float) +0:? 'f6' ( in 32-element array of float) diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index 517ac1ddb..95bf1ab25 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -4778,8 +4778,22 @@ void TParseContext::checkNoShaderLayouts(const TSourceLoc& loc, const TShaderQua if (shaderQualifiers.geometry != ElgNone) error(loc, message, TQualifier::getGeometryString(shaderQualifiers.geometry), ""); + if (shaderQualifiers.spacing != EvsNone) + error(loc, message, TQualifier::getVertexSpacingString(shaderQualifiers.spacing), ""); + if (shaderQualifiers.order != EvoNone) + error(loc, message, TQualifier::getVertexOrderString(shaderQualifiers.order), ""); + if (shaderQualifiers.pointMode) + error(loc, message, "point_mode", ""); if (shaderQualifiers.invocations != TQualifier::layoutNotSet) error(loc, message, "invocations", ""); + if (shaderQualifiers.earlyFragmentTests) + error(loc, message, "early_fragment_tests", ""); + for (int i = 0; i < 3; ++i) { + if (shaderQualifiers.localSize[i] > 1) + error(loc, message, "local_size", ""); + if (shaderQualifiers.localSizeSpecId[i] != TQualifier::layoutNotSet) + error(loc, message, "local_size id", ""); + } if (shaderQualifiers.vertices != TQualifier::layoutNotSet) { if (language == EShLangGeometry) error(loc, message, "max_vertices", ""); @@ -4788,15 +4802,8 @@ void TParseContext::checkNoShaderLayouts(const TSourceLoc& loc, const TShaderQua else assert(0); } - for (int i = 0; i < 3; ++i) { - if (shaderQualifiers.localSize[i] > 1) - error(loc, message, "local_size", ""); - if (shaderQualifiers.localSizeSpecId[i] != TQualifier::layoutNotSet) - error(loc, message, "local_size id", ""); - } if (shaderQualifiers.blendEquation) error(loc, message, "blend equation", ""); - // TBD: correctness: are any of these missing? pixelCenterInteger, originUpperLeft, spacing, order, pointmode, earlyfragment, depth } // Correct and/or advance an object's offset layout qualifier.