Require fixed workgroup size declaration

Fix 2479.
This commit is contained in:
Jeremy Hayes 2021-02-22 18:21:25 -07:00
parent 9801a9e42a
commit 1c62806468
5 changed files with 99 additions and 0 deletions

View file

@ -2756,6 +2756,11 @@ void TParseContext::rValueErrorCheck(const TSourceLoc& loc, const char* op, TInt
if (!(symNode && symNode->getQualifier().isWriteOnly())) // base class checks
if (symNode && symNode->getQualifier().isExplicitInterpolation())
error(loc, "can't read from explicitly-interpolated object: ", op, symNode->getName().c_str());
// local_size_{xyz} must be assigned or specialized before gl_WorkGroupSize can be assigned.
if(node->getQualifier().builtIn == EbvWorkGroupSize &&
!(intermediate.isLocalSizeSet() || intermediate.isLocalSizeSpecialized()))
error(loc, "can't read from gl_WorkGroupSize before a fixed workgroup size has been declared", op, "");
}
//

View file

@ -550,6 +550,11 @@ public:
return true;
}
unsigned int getLocalSize(int dim) const { return localSize[dim]; }
bool isLocalSizeSet() const
{
// Return true if any component has been set (i.e. any component is not default).
return localSizeNotDefault[0] || localSizeNotDefault[1] || localSizeNotDefault[2];
}
bool setLocalSizeSpecId(int dim, int id)
{
if (localSizeSpecId[dim] != TQualifier::layoutNotSet)
@ -558,6 +563,13 @@ public:
return true;
}
int getLocalSizeSpecId(int dim) const { return localSizeSpecId[dim]; }
bool isLocalSizeSpecialized() const
{
// Return true if any component has been specialized.
return localSizeSpecId[0] != TQualifier::layoutNotSet ||
localSizeSpecId[1] != TQualifier::layoutNotSet ||
localSizeSpecId[2] != TQualifier::layoutNotSet;
}
#ifdef GLSLANG_WEB
void output(TInfoSink&, bool tree) { }