Front-end: Fix issue #409, check for implicitly-sized binding arrays.

This commit is contained in:
John Kessenich
2016-07-27 14:43:01 -06:00
parent e15509e450
commit 414f735443
5 changed files with 15 additions and 5 deletions

View File

@@ -157,3 +157,5 @@ void qlod()
levels = textureQueryLevels(samp1D); // ERROR, not until 430 levels = textureQueryLevels(samp1D); // ERROR, not until 430
levels = textureQueryLevels(samp1Ds); // ERROR, not until 430 levels = textureQueryLevels(samp1Ds); // ERROR, not until 430
} }
layout(binding=0) writeonly uniform image1D badArray[];

View File

@@ -51,6 +51,7 @@ ERROR: 0:157: 'textureQueryLevels' : no matching overloaded function found
ERROR: 0:157: 'assign' : cannot convert from 'const float' to 'temp int' ERROR: 0:157: 'assign' : cannot convert from 'const float' to 'temp int'
ERROR: 0:158: 'textureQueryLevels' : no matching overloaded function found ERROR: 0:158: 'textureQueryLevels' : no matching overloaded function found
ERROR: 0:158: 'assign' : cannot convert from 'const float' to 'temp int' ERROR: 0:158: 'assign' : cannot convert from 'const float' to 'temp int'
WARNING: 0:161: '[]' : assuming array size of one for compile-time checking of binding numbers for implicitly-sized array
ERROR: 50 compilation errors. No code generated. ERROR: 50 compilation errors. No code generated.
@@ -299,6 +300,7 @@ ERROR: node is still EOpNull!
0:? 'offcheckI' (layout(column_major shared ) uniform block{layout(column_major shared offset=16 ) uniform int foo}) 0:? 'offcheckI' (layout(column_major shared ) uniform block{layout(column_major shared offset=16 ) uniform int foo})
0:? 'samp1D' (uniform sampler1D) 0:? 'samp1D' (uniform sampler1D)
0:? 'samp1Ds' (uniform sampler1DShadow) 0:? 'samp1Ds' (uniform sampler1DShadow)
0:? 'badArray' (layout(binding=0 ) writeonly uniform implicitly-sized array of image1D)
0:? 'gl_VertexID' (gl_VertexId int VertexId) 0:? 'gl_VertexID' (gl_VertexId int VertexId)
0:? 'gl_InstanceID' (gl_InstanceId int InstanceId) 0:? 'gl_InstanceID' (gl_InstanceId int InstanceId)
@@ -551,6 +553,7 @@ ERROR: node is still EOpNull!
0:? 'offcheckI' (layout(column_major shared ) uniform block{layout(column_major shared offset=16 ) uniform int foo}) 0:? 'offcheckI' (layout(column_major shared ) uniform block{layout(column_major shared offset=16 ) uniform int foo})
0:? 'samp1D' (uniform sampler1D) 0:? 'samp1D' (uniform sampler1D)
0:? 'samp1Ds' (uniform sampler1DShadow) 0:? 'samp1Ds' (uniform sampler1DShadow)
0:? 'badArray' (layout(binding=0 ) writeonly uniform 1-element array of image1D)
0:? 'gl_VertexID' (gl_VertexId int VertexId) 0:? 'gl_VertexID' (gl_VertexId int VertexId)
0:? 'gl_InstanceID' (gl_InstanceId int InstanceId) 0:? 'gl_InstanceID' (gl_InstanceId int InstanceId)

View File

@@ -2,5 +2,5 @@
// For the version, it uses the latest git tag followed by the number of commits. // For the version, it uses the latest git tag followed by the number of commits.
// For the date, it uses the current date (when then script is run). // For the date, it uses the current date (when then script is run).
#define GLSLANG_REVISION "SPIRV99.1351" #define GLSLANG_REVISION "SPIRV99.1353"
#define GLSLANG_DATE "27-Jul-2016" #define GLSLANG_DATE "27-Jul-2016"

View File

@@ -4544,8 +4544,13 @@ void TParseContext::layoutTypeCheck(const TSourceLoc& loc, const TType& type)
error(loc, "requires block, or sampler/image, or atomic-counter type", "binding", ""); error(loc, "requires block, or sampler/image, or atomic-counter type", "binding", "");
if (type.getBasicType() == EbtSampler) { if (type.getBasicType() == EbtSampler) {
int lastBinding = qualifier.layoutBinding; int lastBinding = qualifier.layoutBinding;
if (type.isArray()) if (type.isArray()) {
lastBinding += type.getCumulativeArraySize(); if (type.isImplicitlySizedArray()) {
lastBinding += 1;
warn(loc, "assuming array size of one for compile-time checking of binding numbers for implicitly-sized array", "[]", "");
} else
lastBinding += type.getCumulativeArraySize();
}
if (lastBinding >= resources.maxCombinedTextureImageUnits) if (lastBinding >= resources.maxCombinedTextureImageUnits)
error(loc, "sampler binding not less than gl_MaxCombinedTextureImageUnits", "binding", type.isArray() ? "(using array)" : ""); error(loc, "sampler binding not less than gl_MaxCombinedTextureImageUnits", "binding", type.isArray() ? "(using array)" : "");
} }

View File

@@ -651,7 +651,7 @@ int TIntermediate::addUsedLocation(const TQualifier& qualifier, const TType& typ
int size; int size;
if (qualifier.isUniformOrBuffer()) { if (qualifier.isUniformOrBuffer()) {
if (type.isArray()) if (type.isExplicitlySizedArray())
size = type.getCumulativeArraySize(); size = type.getCumulativeArraySize();
else else
size = 1; size = 1;