From b3007519fc7bb46292b91e2f22144fe9a6ef6152 Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Thu, 14 Aug 2014 07:07:21 +0000 Subject: [PATCH] Miscellaneous ES 3.1 semantics, and identification of all missing features. git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@27732 e7fa87d3-cd2b-0410-9028-fcbf551c1848 --- Test/300.frag | 3 + Test/300layout.frag | 6 +- Test/310.comp | 11 +++ Test/310.frag | 35 +++++++++ Test/baseResults/300.frag.out | 9 ++- Test/baseResults/300layout.frag.out | 5 +- Test/baseResults/310.comp.out | 28 ++++++- Test/baseResults/310.frag.out | 89 +++++++++++++++++++++- Todo.txt | 9 ++- glslang/MachineIndependent/ParseHelper.cpp | 20 ++++- glslang/MachineIndependent/Scan.cpp | 9 ++- 11 files changed, 210 insertions(+), 14 deletions(-) diff --git a/Test/300.frag b/Test/300.frag index 8b67b981d..9be2818b2 100644 --- a/Test/300.frag +++ b/Test/300.frag @@ -147,5 +147,8 @@ void foo324(void) uniform mediump; // ERROR +layout(early_fragment_tests) in; // ERROR + float imageBuffer; // ERROR, reserved float uimage2DRect; // ERROR, reserved + diff --git a/Test/300layout.frag b/Test/300layout.frag index 70cbc9a52..32a6b0267 100644 --- a/Test/300layout.frag +++ b/Test/300layout.frag @@ -14,6 +14,6 @@ void main() q[1] = pos; } -layout(location = 40) out float ca[4]; -layout(location = 41) out float cb[2]; // ERROR, overlap -layout(location = 39) out float cc[6]; // ERROR, overlap +layout(location = 40) out float ca[4]; // ERROR, overlap, ERROR too big +layout(location = 41) out float cb[2]; // ERROR, overlap, ERROR too big +layout(location = 39) out float cc[6]; // ERROR, overlap, ERROR too big diff --git a/Test/310.comp b/Test/310.comp index 7c010ead6..f2cd8c57a 100644 --- a/Test/310.comp +++ b/Test/310.comp @@ -161,3 +161,14 @@ void atoms() origi = atomicExchange(atomi, 4); origu = atomicCompSwap(atomu, 10u, 8u); } + +precision highp atomic_uint; +precision lowp atomic_uint; // ERROR + +precise int pfoo; // ERROR, reserved + +dmat2x4 dm; // ERROR +uniform samplerCubeArray sca; // ERROR +uniform iimage2DRect i2dr; // ERROR +uniform image2DMS i2dms; // ERROR +uniform uimage2DMSArray u2dmsa; // ERROR diff --git a/Test/310.frag b/Test/310.frag index 1309fa703..1db4ca69b 100644 --- a/Test/310.frag +++ b/Test/310.frag @@ -68,3 +68,38 @@ layout(binding = 1) uniform bb { int foo; layout(binding = 2) float f; // ERROR } bbi; + +in centroid vec4 centroidIn; +layout(location = 200000) uniform vec4 bigl; // ERROR, location too big + +layout(early_fragment_tests) in; + +layout(location = 40) out vec4 bigout1; // ERROR, too big +layout(location = 40) out vec4 bigout2; // ERROR, overlap +layout(location = -2) out vec4 neg; // ERROR, negative + +layout(std430) uniform b430 { + int i; +} b430i; + +layout(shared) uniform bshar { + int i; +} bshari; + +in smooth vec4 smoothIn; +in flat int flatIn; + +uniform sampler2DMS s2dms; + +void foots() +{ + highp ivec2 v2 = textureSize(s1, 2); + highp ivec3 v3 = textureSize(isamp2DA, 3); + v2 = textureSize(s2dms); + v2 = imageSize(i2D); +} + +out bool bout; // ERROR +out image2D imageOut; // ERROR +out mat2x3 mout; // ERROR + diff --git a/Test/baseResults/300.frag.out b/Test/baseResults/300.frag.out index 43fbe0971..be58e28da 100644 --- a/Test/baseResults/300.frag.out +++ b/Test/baseResults/300.frag.out @@ -34,12 +34,14 @@ 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:148: 'qualifier' : cannot use auxiliary, memory, interpolation, or precision qualifier in a default qualifier declaration (declaration with no type) -ERROR: 0:150: 'imageBuffer' : Reserved word. -ERROR: 0:150: '' : syntax error -ERROR: 37 compilation errors. No code generated. +ERROR: 0:150: 'early_fragment_tests' : not supported for this version or the enabled extensions +ERROR: 0:152: 'imageBuffer' : Reserved word. +ERROR: 0:152: '' : syntax error +ERROR: 38 compilation errors. No code generated. Shader version: 300 +using early_fragment_tests ERROR: node is still EOpNull! 0:53 Function Definition: main( (void) 0:53 Function Parameters: @@ -394,6 +396,7 @@ Linked fragment stage: ERROR: Linking fragment stage: when more than one fragment shader output, all must have location qualifiers Shader version: 300 +using early_fragment_tests ERROR: node is still EOpNull! 0:53 Function Definition: main( (void) 0:53 Function Parameters: diff --git a/Test/baseResults/300layout.frag.out b/Test/baseResults/300layout.frag.out index 21f12dd84..e16fb4551 100644 --- a/Test/baseResults/300layout.frag.out +++ b/Test/baseResults/300layout.frag.out @@ -1,9 +1,12 @@ 300layout.frag ERROR: 0:4: 'location qualifier on input' : not supported in this stage: fragment ERROR: 0:4: 'location qualifier on input' : not supported for this version or the enabled extensions +ERROR: 0:17: 'location' : too large for fragment output +ERROR: 0:18: 'location' : too large for fragment output ERROR: 0:18: 'location' : overlapping use of location 41 +ERROR: 0:19: 'location' : too large for fragment output ERROR: 0:19: 'location' : overlapping use of location 40 -ERROR: 4 compilation errors. No code generated. +ERROR: 7 compilation errors. No code generated. Shader version: 300 diff --git a/Test/baseResults/310.comp.out b/Test/baseResults/310.comp.out index 97cca31c9..e2816ed82 100644 --- a/Test/baseResults/310.comp.out +++ b/Test/baseResults/310.comp.out @@ -42,7 +42,21 @@ ERROR: 0:141: 'atomic_uint' : atomic counters can only be highp ERROR: 0:141: 'binding' : cannot be greater-than-or-equal to gl_MaxAtomicCounterBindings ERROR: 0:143: 'binding' : cannot be greater-than-or-equal to gl_MaxAtomicCounterBindings ERROR: 0:149: '[]' : scalar integer expression required -ERROR: 42 compilation errors. No code generated. +ERROR: 0:166: 'precision' : can only apply highp to atomic_uint +ERROR: 0:168: 'precise' : Reserved word. +ERROR: 0:170: 'dmat2x4' : Reserved word. +ERROR: 0:170: 'double matrix' : not supported with this profile: es +ERROR: 0:171: 'samplerCubeArray' : Reserved word. +ERROR: 0:171: 'sampler/image' : type requires declaration of default precision qualifier +ERROR: 0:172: 'iimage2DRect' : Reserved word. +ERROR: 0:172: 'sampler/image' : type requires declaration of default precision qualifier +ERROR: 0:172: '' : image variables not declared 'writeonly' must have a format layout qualifier +ERROR: 0:173: 'image2DMS' : Reserved word. +ERROR: 0:173: '' : image variables not declared 'writeonly' must have a format layout qualifier +ERROR: 0:174: 'uimage2DMSArray' : Reserved word. +ERROR: 0:174: 'sampler/image' : type requires declaration of default precision qualifier +ERROR: 0:174: '' : image variables not declared 'writeonly' must have a format layout qualifier +ERROR: 56 compilation errors. No code generated. Shader version: 310 @@ -262,6 +276,12 @@ ERROR: node is still EOpNull! 0:? 'i' (uniform highp int) 0:? 'atomi' (shared highp int) 0:? 'atomu' (shared highp uint) +0:? 'pfoo' (highp int) +0:? 'dm' (2X4 matrix of double) +0:? 'sca' (uniform mediump samplerCubeArray) +0:? 'i2dr' (uniform mediump iimage2DRect) +0:? 'i2dms' (uniform lowp image2DMS) +0:? 'u2dmsa' (uniform mediump uimage2DMSArray) Linked compute stage: @@ -484,4 +504,10 @@ ERROR: node is still EOpNull! 0:? 'i' (uniform highp int) 0:? 'atomi' (shared highp int) 0:? 'atomu' (shared highp uint) +0:? 'pfoo' (highp int) +0:? 'dm' (2X4 matrix of double) +0:? 'sca' (uniform mediump samplerCubeArray) +0:? 'i2dr' (uniform mediump iimage2DRect) +0:? 'i2dms' (uniform lowp image2DMS) +0:? 'u2dmsa' (uniform mediump uimage2DMSArray) diff --git a/Test/baseResults/310.frag.out b/Test/baseResults/310.frag.out index e1e30fcd4..92682da34 100644 --- a/Test/baseResults/310.frag.out +++ b/Test/baseResults/310.frag.out @@ -17,10 +17,25 @@ ERROR: 0:44: 'texel offset' : value is out of range: [gl_MinProgramTexelOffset, ERROR: 0:45: 'texel offset' : value is out of range: [gl_MinProgramTexelOffset, gl_MaxProgramTexelOffset] ERROR: 0:45: 'texel offset' : value is out of range: [gl_MinProgramTexelOffset, gl_MaxProgramTexelOffset] ERROR: 0:69: 'binding' : requires block, or sampler/image, or atomic-counter type -ERROR: 17 compilation errors. No code generated. +ERROR: 0:73: 'location' : location is too large +ERROR: 0:77: 'location' : too large for fragment output +ERROR: 0:78: 'location' : too large for fragment output +ERROR: 0:78: 'location' : overlapping use of location 40 +ERROR: 0:79: 'non-literal layout-id value' : not supported with this profile: es +ERROR: 0:79: 'layout-id value' : cannot be negative +ERROR: 0:92: 'sampler2DMS' : Reserved word. +ERROR: 0:98: 'textureSize' : no matching overloaded function found +ERROR: 0:98: 'assign' : cannot convert from 'const float' to 'highp 2-component vector of int' +ERROR: 0:99: 'writeonly' : argument cannot drop memory qualifier when passed to formal parameter +ERROR: 0:102: 'out' : cannot be bool +ERROR: 0:103: 'image2D' : sampler/image types can only be used in uniform variables or function parameters: imageOut +ERROR: 0:103: '' : image variables not declared 'writeonly' must have a format layout qualifier +ERROR: 0:104: 'out' : cannot be a matrix +ERROR: 31 compilation errors. No code generated. Shader version: 310 +using early_fragment_tests ERROR: node is still EOpNull! 0:21 Function Definition: main( (void) 0:21 Function Parameters: @@ -193,6 +208,28 @@ ERROR: node is still EOpNull! 0:60 'i' (uniform mediump int) 0:60 Construct bvec4 (4-component vector of bool) 0:60 'b' (bool) +0:94 Function Definition: foots( (void) +0:94 Function Parameters: +0:96 Sequence +0:96 Sequence +0:96 move second child to first child (highp 2-component vector of int) +0:96 'v2' (highp 2-component vector of int) +0:96 Function Call: textureSize(s21;i1; (highp 2-component vector of int) +0:96 's1' (layout(binding=3 ) uniform highp sampler2D) +0:96 Constant: +0:96 2 (const int) +0:97 Sequence +0:97 move second child to first child (highp 3-component vector of int) +0:97 'v3' (highp 3-component vector of int) +0:97 Function Call: textureSize(isA21;i1; (highp 3-component vector of int) +0:97 'isamp2DA' (uniform highp isampler2DArray) +0:97 Constant: +0:97 3 (const int) +0:98 'v2' (highp 2-component vector of int) +0:99 move second child to first child (highp 2-component vector of int) +0:99 'v2' (highp 2-component vector of int) +0:99 Function Call: imageSize(I21; (highp 2-component vector of int) +0:99 'i2D' (layout(binding=2 ) writeonly uniform highp image2D) 0:? Linker Objects 0:? 'gl_FragCoord' (smooth in mediump 4-component vector of float) 0:? 'v3' (layout(location=2 ) smooth in mediump 3-component vector of float) @@ -208,12 +245,27 @@ ERROR: node is still EOpNull! 0:? 's2' (layout(binding=3 ) uniform highp sampler2D) 0:? 'i2D' (layout(binding=2 ) writeonly uniform highp image2D) 0:? 'bbi' (layout(binding=1 column_major shared ) uniform block{layout(column_major shared ) uniform mediump int foo, layout(binding=2 column_major shared ) uniform mediump float f}) +0:? 'centroidIn' (centroid smooth in mediump 4-component vector of float) +0:? 'bigl' (uniform mediump 4-component vector of float) +0:? 'bigout1' (layout(location=40 ) out mediump 4-component vector of float) +0:? 'bigout2' (layout(location=40 ) out mediump 4-component vector of float) +0:? 'neg' (out mediump 4-component vector of float) +0:? 'b430i' (layout(column_major std430 ) uniform block{layout(column_major std430 offset=0 ) uniform mediump int i}) +0:? 'bshari' (layout(column_major shared ) uniform block{layout(column_major shared ) uniform mediump int i}) +0:? 'smoothIn' (smooth in mediump 4-component vector of float) +0:? 'flatIn' (flat in mediump int) +0:? 's2dms' (uniform highp sampler2DMS) +0:? 'bout' (out bool) +0:? 'imageOut' (out highp image2D) +0:? 'mout' (out mediump 2X3 matrix of float) Linked fragment stage: +ERROR: Linking fragment stage: when more than one fragment shader output, all must have location qualifiers Shader version: 310 +using early_fragment_tests ERROR: node is still EOpNull! 0:21 Function Definition: main( (void) 0:21 Function Parameters: @@ -386,6 +438,28 @@ ERROR: node is still EOpNull! 0:60 'i' (uniform mediump int) 0:60 Construct bvec4 (4-component vector of bool) 0:60 'b' (bool) +0:94 Function Definition: foots( (void) +0:94 Function Parameters: +0:96 Sequence +0:96 Sequence +0:96 move second child to first child (highp 2-component vector of int) +0:96 'v2' (highp 2-component vector of int) +0:96 Function Call: textureSize(s21;i1; (highp 2-component vector of int) +0:96 's1' (layout(binding=3 ) uniform highp sampler2D) +0:96 Constant: +0:96 2 (const int) +0:97 Sequence +0:97 move second child to first child (highp 3-component vector of int) +0:97 'v3' (highp 3-component vector of int) +0:97 Function Call: textureSize(isA21;i1; (highp 3-component vector of int) +0:97 'isamp2DA' (uniform highp isampler2DArray) +0:97 Constant: +0:97 3 (const int) +0:98 'v2' (highp 2-component vector of int) +0:99 move second child to first child (highp 2-component vector of int) +0:99 'v2' (highp 2-component vector of int) +0:99 Function Call: imageSize(I21; (highp 2-component vector of int) +0:99 'i2D' (layout(binding=2 ) writeonly uniform highp image2D) 0:? Linker Objects 0:? 'gl_FragCoord' (smooth in mediump 4-component vector of float) 0:? 'v3' (layout(location=2 ) smooth in mediump 3-component vector of float) @@ -401,4 +475,17 @@ ERROR: node is still EOpNull! 0:? 's2' (layout(binding=3 ) uniform highp sampler2D) 0:? 'i2D' (layout(binding=2 ) writeonly uniform highp image2D) 0:? 'bbi' (layout(binding=1 column_major shared ) uniform block{layout(column_major shared ) uniform mediump int foo, layout(binding=2 column_major shared ) uniform mediump float f}) +0:? 'centroidIn' (centroid smooth in mediump 4-component vector of float) +0:? 'bigl' (uniform mediump 4-component vector of float) +0:? 'bigout1' (layout(location=40 ) out mediump 4-component vector of float) +0:? 'bigout2' (layout(location=40 ) out mediump 4-component vector of float) +0:? 'neg' (out mediump 4-component vector of float) +0:? 'b430i' (layout(column_major std430 ) uniform block{layout(column_major std430 offset=0 ) uniform mediump int i}) +0:? 'bshari' (layout(column_major shared ) uniform block{layout(column_major shared ) uniform mediump int i}) +0:? 'smoothIn' (smooth in mediump 4-component vector of float) +0:? 'flatIn' (flat in mediump int) +0:? 's2dms' (uniform highp sampler2DMS) +0:? 'bout' (out bool) +0:? 'imageOut' (out highp image2D) +0:? 'mout' (out mediump 2X3 matrix of float) diff --git a/Todo.txt b/Todo.txt index 5fcdc3768..be174afaa 100644 --- a/Todo.txt +++ b/Todo.txt @@ -80,6 +80,13 @@ Shader Functionality to Implement/Finish + Texture gather + Bitfield operations + Integer mix function + - overlapping bindings + - offset post incrementing + - overlapping offsets + - frexp/ldexp + - packUnorm4x8(),packSnorm4x8(), unpackUnorm4x8(), unpackSnorm4x8() + - 2DMS samplers and images + - inheritance of memory qualifiers in block members GLSL 1.2 + Handle multiple compilation units per stage + Allow initializers on uniform declarations @@ -227,7 +234,7 @@ Shader Functionality to Implement/Finish elements of the array. - Arrays of arrays are now supported, as per the GL_ARB_arrays_of_arrays extension. + Compute shaders are now supported, as per the GL_ARB_compute_shader extension. - - Added imageSize() built-ins to query the dimensions of an image. + + Added imageSize() built-ins to query the dimensions of an image. - All choice of depth or stencil texturing, for a packed depth-stencil texture, as per the GL_ARB_stencil_texturing extension. - Allow explicit locations/indexes to be assigned to uniform variables and subroutines, as per the diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index ad99dba21..a1a90b777 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -1960,7 +1960,6 @@ void TParseContext::globalQualifierCheck(TSourceLoc loc, const TQualifier& quali if (publicType.basicType == EbtBool) { error(loc, "cannot be bool", GetStorageQualifierString(qualifier.storage), ""); - return; } @@ -2043,7 +2042,10 @@ void TParseContext::globalQualifierCheck(TSourceLoc loc, const TQualifier& quali profileRequires(loc, EEsProfile, 300, 0, "fragment shader output"); if (publicType.basicType == EbtStruct) { error(loc, "cannot be a structure", GetStorageQualifierString(qualifier.storage), ""); - + return; + } + if (publicType.matrixRows > 0) { + error(loc, "cannot be a matrix", GetStorageQualifierString(qualifier.storage), ""); return; } break; @@ -2157,6 +2159,13 @@ void TParseContext::setDefaultPrecision(TSourceLoc loc, TPublicType& publicType, } } + if (basicType == EbtAtomicUint) { + if (qualifier != EpqHigh) + error(loc, "can only apply highp to atomic_uint", "precision", ""); + + return; + } + error(loc, "cannot apply precision statement to this type; use 'float', 'int' or a sampler type", TType::getBasicString(basicType), ""); } @@ -3091,8 +3100,8 @@ void TParseContext::setLayoutQualifier(TSourceLoc loc, TPublicType& publicType, return; } if (id == "early_fragment_tests") { - requireProfile(loc, ENoProfile | ECoreProfile | ECompatibilityProfile, "early_fragment_tests"); profileRequires(loc, ENoProfile | ECoreProfile | ECompatibilityProfile, 420, GL_ARB_shader_image_load_store, "early_fragment_tests"); + profileRequires(loc, EEsProfile, 310, 0, "early_fragment_tests"); publicType.shaderQualifiers.earlyFragmentTests = true; return; } @@ -3393,6 +3402,11 @@ void TParseContext::layoutTypeCheck(TSourceLoc loc, const TType& type) error(loc, "cannot apply to a matrix, structure, or block", "component", ""); } + if (qualifier.storage == EvqVaryingOut && language == EShLangFragment) { + if (qualifier.layoutLocation >= (unsigned int)resources.maxDrawBuffers) + error(loc, "too large for fragment output", "location", ""); + } + switch (qualifier.storage) { case EvqVaryingIn: case EvqVaryingOut: diff --git a/glslang/MachineIndependent/Scan.cpp b/glslang/MachineIndependent/Scan.cpp index 1a92e3ebc..e9d3cfb0e 100644 --- a/glslang/MachineIndependent/Scan.cpp +++ b/glslang/MachineIndependent/Scan.cpp @@ -919,7 +919,9 @@ int TScanContext::tokenizeIdentifier() return keyword; case PRECISE: - if (parseContext.profile == EEsProfile || + if (parseContext.profile == EEsProfile && parseContext.version >= 310) + reservedWord(); + else if (parseContext.profile == EEsProfile || (parseContext.profile != EEsProfile && parseContext.version < 400)) return identifierOrType(); return keyword; @@ -1104,6 +1106,11 @@ int TScanContext::secondGenerationImage() { afterType = true; + if (parseContext.profile == EEsProfile && parseContext.version >= 310) { + reservedWord(); + return keyword; + } + if (parseContext.symbolTable.atBuiltInLevel() || parseContext.profile != EEsProfile && (parseContext.version >= 420 || parseContext.extensionsTurnedOn(1, &GL_ARB_shader_image_load_store))) return keyword;