Add flags for local size values ( compute shader )
Purpose : According to GLSL SPEC 4.6 ( 4.4.1.4 Compute Shader Inputs), for compute shader input qualifiers, we should declare such qualifiers with same values in the same shader (local_size_x, y and z). "If such a layout qualifier is declared more than once in the same shader, all those declarations must set the same set of local work-group sizes and set them to the same values; otherwise a compile-time error results." Why this fix: If we manually set "local_size_x = 1" and directly following a declaration like "local_size_x = 2", this would not be detected. That is because currently we treat all the '1' as default value and could not restrictly detect whether those are default values. Test case: ...... layout(local_size_x=1) in; layout(local_size_x=2) in; ...... So I add test cases for this fix: 1. set local_size_y = 1 => success 2. set local_size_y = 2 => error 3. set local_size_y = 1 => success
This commit is contained in:
parent
664ad418f8
commit
352e668a6d
5 changed files with 98 additions and 79 deletions
|
|
@ -1195,6 +1195,7 @@ struct TShaderQualifiers {
|
|||
TVertexOrder order;
|
||||
bool pointMode;
|
||||
int localSize[3]; // compute shader
|
||||
bool localSizeNotDefault[3]; // compute shader
|
||||
int localSizeSpecId[3]; // compute shader specialization id for gl_WorkGroupSize
|
||||
#ifndef GLSLANG_WEB
|
||||
bool earlyFragmentTests; // fragment input
|
||||
|
|
@ -1225,6 +1226,9 @@ struct TShaderQualifiers {
|
|||
localSize[0] = 1;
|
||||
localSize[1] = 1;
|
||||
localSize[2] = 1;
|
||||
localSizeNotDefault[0] = false;
|
||||
localSizeNotDefault[1] = false;
|
||||
localSizeNotDefault[2] = false;
|
||||
localSizeSpecId[0] = TQualifier::layoutNotSet;
|
||||
localSizeSpecId[1] = TQualifier::layoutNotSet;
|
||||
localSizeSpecId[2] = TQualifier::layoutNotSet;
|
||||
|
|
@ -1272,6 +1276,9 @@ struct TShaderQualifiers {
|
|||
if (src.localSize[i] > 1)
|
||||
localSize[i] = src.localSize[i];
|
||||
}
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
localSizeNotDefault[i] = src.localSizeNotDefault[i] || localSizeNotDefault[i];
|
||||
}
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
if (src.localSizeSpecId[i] != TQualifier::layoutNotSet)
|
||||
localSizeSpecId[i] = src.localSizeSpecId[i];
|
||||
|
|
|
|||
|
|
@ -5360,14 +5360,17 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi
|
|||
}
|
||||
if (id == "local_size_x") {
|
||||
publicType.shaderQualifiers.localSize[0] = value;
|
||||
publicType.shaderQualifiers.localSizeNotDefault[0] = true;
|
||||
return;
|
||||
}
|
||||
if (id == "local_size_y") {
|
||||
publicType.shaderQualifiers.localSize[1] = value;
|
||||
publicType.shaderQualifiers.localSizeNotDefault[1] = true;
|
||||
return;
|
||||
}
|
||||
if (id == "local_size_z") {
|
||||
publicType.shaderQualifiers.localSize[2] = value;
|
||||
publicType.shaderQualifiers.localSizeNotDefault[2] = true;
|
||||
return;
|
||||
}
|
||||
if (spvVersion.spv != 0) {
|
||||
|
|
@ -7945,7 +7948,7 @@ void TParseContext::updateStandaloneQualifierDefaults(const TSourceLoc& loc, con
|
|||
error(loc, "can only apply to 'in'", "point_mode", "");
|
||||
}
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
if (publicType.shaderQualifiers.localSize[i] > 1) {
|
||||
if (publicType.shaderQualifiers.localSizeNotDefault[i]) {
|
||||
if (publicType.qualifier.storage == EvqVaryingIn) {
|
||||
if (! intermediate.setLocalSize(i, publicType.shaderQualifiers.localSize[i]))
|
||||
error(loc, "cannot change previously set size", "local_size", "");
|
||||
|
|
|
|||
|
|
@ -271,6 +271,9 @@ public:
|
|||
localSize[0] = 1;
|
||||
localSize[1] = 1;
|
||||
localSize[2] = 1;
|
||||
localSizeNotDefault[0] = false;
|
||||
localSizeNotDefault[1] = false;
|
||||
localSizeNotDefault[2] = false;
|
||||
localSizeSpecId[0] = TQualifier::layoutNotSet;
|
||||
localSizeSpecId[1] = TQualifier::layoutNotSet;
|
||||
localSizeSpecId[2] = TQualifier::layoutNotSet;
|
||||
|
|
@ -648,8 +651,9 @@ public:
|
|||
|
||||
bool setLocalSize(int dim, int size)
|
||||
{
|
||||
if (localSize[dim] > 1)
|
||||
if (localSizeNotDefault[dim])
|
||||
return size == localSize[dim];
|
||||
localSizeNotDefault[dim] = true;
|
||||
localSize[dim] = size;
|
||||
return true;
|
||||
}
|
||||
|
|
@ -921,6 +925,7 @@ protected:
|
|||
TInterlockOrdering interlockOrdering;
|
||||
bool pointMode;
|
||||
int localSize[3];
|
||||
bool localSizeNotDefault[3];
|
||||
int localSizeSpecId[3];
|
||||
bool earlyFragmentTests;
|
||||
bool postDepthCoverage;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue