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, ...@@ -1049,27 +1049,6 @@ const TVariable *TParseContext::getNamedVariable(const TSourceLoc &location,
{ {
recover(); 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) if (!variable)
......
...@@ -56,9 +56,7 @@ class TParseContext : angle::NonCopyable ...@@ -56,9 +56,7 @@ class TParseContext : angle::NonCopyable
mDirectiveHandler(ext, mDiagnostics, mShaderVersion, debugShaderPrecisionSupported), mDirectiveHandler(ext, mDiagnostics, mShaderVersion, debugShaderPrecisionSupported),
mPreprocessor(&mDiagnostics, &mDirectiveHandler), mPreprocessor(&mDiagnostics, &mDirectiveHandler),
mScanner(nullptr), mScanner(nullptr),
mDeferredSingleDeclarationErrorCheck(false), mDeferredSingleDeclarationErrorCheck(false)
mUsesFragData(false),
mUsesFragColor(false)
{ {
} }
...@@ -75,7 +73,6 @@ class TParseContext : angle::NonCopyable ...@@ -75,7 +73,6 @@ class TParseContext : angle::NonCopyable
const char *extraInfo=""); const char *extraInfo="");
void warning(const TSourceLoc &loc, const char *reason, const char *token, void warning(const TSourceLoc &loc, const char *reason, const char *token,
const char *extraInfo=""); const char *extraInfo="");
void recover(); void recover();
TIntermNode *getTreeRoot() const { return mTreeRoot; } TIntermNode *getTreeRoot() const { return mTreeRoot; }
void setTreeRoot(TIntermNode *treeRoot) { mTreeRoot = treeRoot; } void setTreeRoot(TIntermNode *treeRoot) { mTreeRoot = treeRoot; }
...@@ -342,8 +339,6 @@ class TParseContext : angle::NonCopyable ...@@ -342,8 +339,6 @@ class TParseContext : angle::NonCopyable
TDirectiveHandler mDirectiveHandler; TDirectiveHandler mDirectiveHandler;
pp::Preprocessor mPreprocessor; pp::Preprocessor mPreprocessor;
void *mScanner; void *mScanner;
bool mUsesFragData; // track if we are using both gl_FragData and gl_FragColor
bool mUsesFragColor;
}; };
int PaParseStrings( int PaParseStrings(
......
...@@ -757,8 +757,11 @@ bool DynamicHLSL::generateShaderLinkHLSL(const gl::Data &data, InfoLog &infoLog, ...@@ -757,8 +757,11 @@ bool DynamicHLSL::generateShaderLinkHLSL(const gl::Data &data, InfoLog &infoLog,
bool usesPointSize = vertexShader->mUsesPointSize; bool usesPointSize = vertexShader->mUsesPointSize;
bool useInstancedPointSpriteEmulation = usesPointSize && mRenderer->getWorkarounds().useInstancedPointSpriteEmulation; bool useInstancedPointSpriteEmulation = usesPointSize && mRenderer->getWorkarounds().useInstancedPointSpriteEmulation;
// Validation done in the compiler if (usesFragColor && usesFragData)
ASSERT(!usesFragColor || !usesFragData); {
infoLog << "Cannot use both gl_FragColor and gl_FragData in the same fragment shader.";
return false;
}
// Write the HLSL input/output declarations // Write the HLSL input/output declarations
const int shaderModel = mRenderer->getMajorShaderModel(); const int shaderModel = mRenderer->getMajorShaderModel();
......
...@@ -545,20 +545,3 @@ TEST_F(MalformedShaderTest, AssignConstGlobalToGlobal) ...@@ -545,20 +545,3 @@ TEST_F(MalformedShaderTest, AssignConstGlobalToGlobal)
FAIL() << "Shader compilation failed, expecting success " << mInfoLog; 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