Atomic memory function can only be used for shader storage block member or shared variable.

The glsl spec says:A shader will fail to compile if the value passed to the mem argument of an atomic memory function does not
correspond to a buffer or shared variable.
This commit is contained in:
ZhiqianXia 2021-05-12 20:07:52 +08:00
parent 202c8abae0
commit 587261a817
4 changed files with 113 additions and 0 deletions

View file

@ -2330,6 +2330,12 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan
(arg0->getType().isFloatingDomain())) {
requireExtensions(loc, 1, &E_GL_EXT_shader_atomic_float, fnCandidate.getName().c_str());
}
const TIntermTyped* base = TIntermediate::findLValueBase(arg0, true);
const TQualifier& qualifier = base->getType().getQualifier();
if (qualifier.storage != EvqShared && qualifier.storage != EvqBuffer)
error(loc,"Atomic memory function can only be used for shader storage block member or shared variable.", fnCandidate.getName().c_str(), "");
break;
}