Commit cc2a10e9 by jchen10 Committed by Commit Bot

Unify opaque type validation in GLSL parsing

Refactor separate sampler and image validations into unified opaque type handling. This paves way for adding atomic counter, another new opaque type. BUG=angleproject:1729 Change-Id: I201d28e31c84534db43e656d518650e378bab76c Reviewed-on: https://chromium-review.googlesource.com/493618Reviewed-by: 's avatarOlli Etuaho <oetuaho@nvidia.com> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
parent 7142f6ce
......@@ -123,12 +123,9 @@ class TParseContext : angle::NonCopyable
bool checkIsNonVoid(const TSourceLoc &line, const TString &identifier, const TBasicType &type);
void checkIsScalarBool(const TSourceLoc &line, const TIntermTyped *type);
void checkIsScalarBool(const TSourceLoc &line, const TPublicType &pType);
bool checkIsNotSampler(const TSourceLoc &line,
const TTypeSpecifierNonArray &pType,
const char *reason);
bool checkIsNotImage(const TSourceLoc &line,
const TTypeSpecifierNonArray &pType,
const char *reason);
bool checkIsNotOpaqueType(const TSourceLoc &line,
const TTypeSpecifierNonArray &pType,
const char *reason);
void checkDeclaratorLocationIsNotSpecified(const TSourceLoc &line, const TPublicType &pType);
void checkLocationIsNotSpecified(const TSourceLoc &location,
const TLayoutQualifier &layoutQualifier);
......@@ -384,15 +381,9 @@ class TParseContext : angle::NonCopyable
// Assumes that multiplication op has already been set based on the types.
bool isMultiplicationTypeCombinationValid(TOperator op, const TType &left, const TType &right);
void checkOutParameterIsNotImage(const TSourceLoc &line,
TQualifier qualifier,
const TType &type);
void checkOutParameterIsNotOpaqueType(const TSourceLoc &line,
TQualifier qualifier,
const TType &type);
void checkOutParameterIsNotSampler(const TSourceLoc &line,
TQualifier qualifier,
const TType &type);
void checkInternalFormatIsNotSpecified(const TSourceLoc &location,
TLayoutImageInternalFormat internalFormat);
......
......@@ -526,17 +526,6 @@ bool TStructure::containsSamplers() const
return false;
}
bool TStructure::containsImages() const
{
for (size_t i = 0; i < mFields->size(); ++i)
{
const TType *fieldType = (*mFields)[i]->type();
if (IsImage(fieldType->getBasicType()) || fieldType->isStructureContainingImages())
return true;
}
return false;
}
void TStructure::createSamplerSymbols(const TString &structName,
const TString &structAPIName,
const unsigned int arrayOfStructsSize,
......
......@@ -98,7 +98,6 @@ class TStructure : public TFieldListCollection
bool containsArrays() const;
bool containsType(TBasicType t) const;
bool containsSamplers() const;
bool containsImages() const;
void createSamplerSymbols(const TString &structName,
const TString &structAPIName,
......@@ -468,11 +467,6 @@ class TType
return structure ? structure->containsSamplers() : false;
}
bool isStructureContainingImages() const
{
return structure ? structure->containsImages() : false;
}
void createSamplerSymbols(const TString &structName,
const TString &structAPIName,
const unsigned int arrayOfStructsSize,
......
......@@ -3762,3 +3762,20 @@ TEST_F(FragmentShaderValidationTest, UniformLocationEmptyDeclaration)
FAIL() << "Shader compilation succeeded, expecting failure:\n" << mInfoLog;
}
}
// Test function parameters of opaque type can't be l-value too.
TEST_F(FragmentShaderValidationTest, OpaqueParameterCanNotBeLValue)
{
const std::string &shaderString =
"#version 310 es\n"
"uniform sampler2D s;\n"
"void foo(sampler2D as) {\n"
" as = s;\n"
"}\n"
"void main() {}\n";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure:\n" << mInfoLog;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment