Commit 531e3d22 by Olli Etuaho

Revert "translator: Reject shaders that use both FragColor+FragData."

The change introduced a warning in Windows release build. This reverts commit b8e3a568. Change-Id: I77bbc35876043c9a164aa2665965f5189ee90052 Reviewed-on: https://chromium-review.googlesource.com/271430Reviewed-by: 's avatarOlli Etuaho <oetuaho@nvidia.com> Tested-by: 's avatarOlli Etuaho <oetuaho@nvidia.com>
parent e8675195
......@@ -1049,27 +1049,6 @@ const TVariable *TParseContext::getNamedVariable(const TSourceLoc &location,
{
recover();
}
// Reject shaders using both gl_FragData and gl_FragColor
TQualifier qualifier = variable->getType().getQualifier();
if (qualifier == EvqFragData)
{
mUsesFragData = true;
}
else if (qualifier == EvqFragColor)
{
mUsesFragColor = true;
}
// This validation is not quite correct - it's only an error to write to
// both FragData and FragColor. For simplicity, and because users shouldn't
// be rewarded for reading from undefined varaibles, return an error
// if they are both referenced, rather than assigned.
if (mUsesFragData && mUsesFragColor)
{
error(location, "cannot use both gl_FragData and gl_FragColor", name->c_str());
recover();
}
}
if (!variable)
......
......@@ -56,9 +56,7 @@ class TParseContext : angle::NonCopyable
mDirectiveHandler(ext, mDiagnostics, mShaderVersion, debugShaderPrecisionSupported),
mPreprocessor(&mDiagnostics, &mDirectiveHandler),
mScanner(nullptr),
mDeferredSingleDeclarationErrorCheck(false),
mUsesFragData(false),
mUsesFragColor(false)
mDeferredSingleDeclarationErrorCheck(false)
{
}
......@@ -75,7 +73,6 @@ class TParseContext : angle::NonCopyable
const char *extraInfo="");
void warning(const TSourceLoc &loc, const char *reason, const char *token,
const char *extraInfo="");
void recover();
TIntermNode *getTreeRoot() const { return mTreeRoot; }
void setTreeRoot(TIntermNode *treeRoot) { mTreeRoot = treeRoot; }
......@@ -342,8 +339,6 @@ class TParseContext : angle::NonCopyable
TDirectiveHandler mDirectiveHandler;
pp::Preprocessor mPreprocessor;
void *mScanner;
bool mUsesFragData; // track if we are using both gl_FragData and gl_FragColor
bool mUsesFragColor;
};
int PaParseStrings(
......
......@@ -757,8 +757,11 @@ bool DynamicHLSL::generateShaderLinkHLSL(const gl::Data &data, InfoLog &infoLog,
bool usesPointSize = vertexShader->mUsesPointSize;
bool useInstancedPointSpriteEmulation = usesPointSize && mRenderer->getWorkarounds().useInstancedPointSpriteEmulation;
// Validation done in the compiler
ASSERT(!usesFragColor || !usesFragData);
if (usesFragColor && usesFragData)
{
infoLog << "Cannot use both gl_FragColor and gl_FragData in the same fragment shader.";
return false;
}
// Write the HLSL input/output declarations
const int shaderModel = mRenderer->getMajorShaderModel();
......
......@@ -545,20 +545,3 @@ TEST_F(MalformedShaderTest, AssignConstGlobalToGlobal)
FAIL() << "Shader compilation failed, expecting success " << mInfoLog;
}
}
// Statically assigning to both gl_FragData and gl_FragColor is forbidden (ESSL 1.00 section 7.2)
TEST_F(MalformedShaderTest, WriteBothFragDataAndFragColor)
{
const std::string &shaderString =
"precision mediump float;\n"
"void foo() {\n"
" gl_FragData[0].a++;\n"
"}\n"
"void main() {\n"
" gl_FragColor.x += 0.0;\n"
"}\n";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure " << 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