diff --git a/Test/310.vert b/Test/310.vert index a0bf9e15..647d6709 100644 --- a/Test/310.vert +++ b/Test/310.vert @@ -123,3 +123,19 @@ out gl_PerVertex { // ERROR, already used and already redeclared highp vec4 gl_Position; highp vec4 t; }; + +smooth out smo { // ERROR, no smooth on a block + int i; +} smon; + +flat out fmo { // ERROR, no flat on a block + int i; +} fmon; + +centroid out cmo { // ERROR, no centroid on a block + int i; +} cmon; + +invariant out imo { // ERROR, no invariant on a block + int i; +} imon; diff --git a/Test/baseResults/310.vert.out b/Test/baseResults/310.vert.out index fb9f0f30..1f12a19d 100644 --- a/Test/baseResults/310.vert.out +++ b/Test/baseResults/310.vert.out @@ -23,7 +23,11 @@ ERROR: 0:109: 'gl_PerVertex' : block redeclaration has extra members ERROR: 0:119: 'gl_PointSize' : member of nameless block was not redeclared ERROR: 0:119: 'assign' : cannot convert from 'const float' to 'gl_PointSize highp void PointSize' ERROR: 0:122: 'gl_PerVertex' : can only redeclare a built-in block once, and before any use -ERROR: 22 compilation errors. No code generated. +ERROR: 0:127: 'flat/smooth/noperspective' : cannot use interpolation qualifiers on an interface block +ERROR: 0:131: 'flat/smooth/noperspective' : cannot use interpolation qualifiers on an interface block +ERROR: 0:135: 'centroid' : cannot use centroid qualifier on an interface block +ERROR: 0:139: 'invariant' : cannot use invariant qualifier on an interface block +ERROR: 26 compilation errors. No code generated. Shader version: 310 @@ -225,6 +229,10 @@ ERROR: node is still EOpNull! 0:? 'aliased' (layout(location=12 ) smooth out highp int) 0:? 'inbinst' (in block{in highp int a}) 0:? 'anon@1' (out block{gl_Position highp 4-component vector of float Position gl_Position, }) +0:? 'smon' (smooth out block{out highp int i}) +0:? 'fmon' (flat out block{out highp int i}) +0:? 'cmon' (centroid out block{out highp int i}) +0:? 'imon' (invariant out block{out highp int i}) 0:? 'gl_VertexID' (gl_VertexId highp int VertexId) 0:? 'gl_InstanceID' (gl_InstanceId highp int InstanceId) @@ -431,6 +439,10 @@ ERROR: node is still EOpNull! 0:? 'aliased' (layout(location=12 ) smooth out highp int) 0:? 'inbinst' (in block{in highp int a}) 0:? 'anon@1' (out block{gl_Position highp 4-component vector of float Position gl_Position, }) +0:? 'smon' (smooth out block{out highp int i}) +0:? 'fmon' (flat out block{out highp int i}) +0:? 'cmon' (centroid out block{out highp int i}) +0:? 'imon' (invariant out block{out highp int i}) 0:? 'gl_VertexID' (gl_VertexId highp int VertexId) 0:? 'gl_InstanceID' (gl_InstanceId highp int InstanceId) diff --git a/Test/baseResults/preprocessor.errors.vert.err b/Test/baseResults/preprocessor.errors.vert.err index 7da61a0a..a92e34fc 100644 --- a/Test/baseResults/preprocessor.errors.vert.err +++ b/Test/baseResults/preprocessor.errors.vert.err @@ -1,8 +1,8 @@ -Warning, version 310 is not yet complete; most version-specific features are present, but some are missing. -ERROR: 0:9: '#error' : This should show up in pp output . -ERROR: 0:14: '#' : invalid directive: def -ERROR: 0:15: 'preprocessor evaluation' : undefined macro in expression not allowed in es profile Y -ERROR: 0:21: '' : missing #endif -ERROR: 4 compilation errors. No code generated. - - +Warning, version 310 is not yet complete; most version-specific features are present, but some are missing. +ERROR: 0:9: '#error' : This should show up in pp output . +ERROR: 0:14: '#' : invalid directive: def +ERROR: 0:15: 'preprocessor evaluation' : undefined macro in expression not allowed in es profile Y +ERROR: 0:21: '' : missing #endif +ERROR: 4 compilation errors. No code generated. + + diff --git a/Test/baseResults/preprocessor.success_if_parse_would_fail.vert.out b/Test/baseResults/preprocessor.success_if_parse_would_fail.vert.out index 624813a0..ab57fb0e 100644 --- a/Test/baseResults/preprocessor.success_if_parse_would_fail.vert.out +++ b/Test/baseResults/preprocessor.success_if_parse_would_fail.vert.out @@ -1,4 +1,4 @@ -int x(){ - something that shouldnt compile; -} - +int x(){ + something that shouldnt compile; +} + diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index 3b0ace55..a1ad7479 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -4586,6 +4586,7 @@ TIntermTyped* TParseContext::constructStruct(TIntermNode* node, const TType& typ void TParseContext::declareBlock(TSourceLoc loc, TTypeList& typeList, const TString* instanceName, TArraySizes* arraySizes) { blockStageIoCheck(loc, currentBlockQualifier); + blockQualifierCheck(loc, currentBlockQualifier); if (arraySizes) arrayUnsizedCheck(loc, currentBlockQualifier, arraySizes->getOuterSize(), false); arrayDimCheck(loc, arraySizes, 0); @@ -4810,10 +4811,40 @@ void TParseContext::blockStageIoCheck(TSourceLoc loc, const TQualifier& qualifie break; default: error(loc, "only uniform, buffer, in, or out blocks are supported", blockName->c_str(), ""); - return; + break; } } +// Do all block-declaration checking regarding its qualifers. +void TParseContext::blockQualifierCheck(TSourceLoc loc, const TQualifier& qualifier) +{ + // The 4.5 specification says: + // + // interface-block : + // layout-qualifieropt interface-qualifier block-name { member-list } instance-nameopt ; + // + // interface-qualifier : + // in + // out + // patch in + // patch out + // uniform + // buffer + // + // Note however memory qualifiers aren't included, yet the specification also says + // + // "...memory qualifiers may also be used in the declaration of shader storage blocks..." + + if (qualifier.isInterpolation()) + error(loc, "cannot use interpolation qualifiers on an interface block", "flat/smooth/noperspective", ""); + if (qualifier.centroid) + error(loc, "cannot use centroid qualifier on an interface block", "centroid", ""); + if (qualifier.sample) + error(loc, "cannot use sample qualifier on an interface block", "sample", ""); + if (qualifier.invariant) + error(loc, "cannot use invariant qualifier on an interface block", "invariant", ""); +} + // // "For a block, this process applies to the entire block, or until the first member // is reached that has a location layout qualifier. When a block member is declared with a location diff --git a/glslang/MachineIndependent/ParseHelper.h b/glslang/MachineIndependent/ParseHelper.h index 6f3f7ce1..d48ae9d6 100644 --- a/glslang/MachineIndependent/ParseHelper.h +++ b/glslang/MachineIndependent/ParseHelper.h @@ -193,6 +193,7 @@ public: TIntermTyped* constructBuiltIn(const TType&, TOperator, TIntermTyped*, TSourceLoc, bool subset); void declareBlock(TSourceLoc, TTypeList& typeList, const TString* instanceName = 0, TArraySizes* arraySizes = 0); void blockStageIoCheck(TSourceLoc, const TQualifier&); + void blockQualifierCheck(TSourceLoc, const TQualifier&); void fixBlockLocations(TSourceLoc, TQualifier&, TTypeList&, bool memberWithLocation, bool memberWithoutLocation); void fixBlockXfbOffsets(TQualifier&, TTypeList&); void fixBlockUniformOffsets(TQualifier&, TTypeList&);