Commit 19ecebe7 by Olli Etuaho Committed by Commit Bot

Fix compound assignment precision emulation

Precision emulation for compound assignment used to set the wrong type for the compound assignment nodes, which could cause an assert to trigger. The wrong rounding function was also being called in the lowp rounded compound assignment function. BUG=chromium:699479 TEST=angle_unittests Change-Id: I60b4cb3bf1830e8249511c13037348bb2423e5b9 Reviewed-on: https://chromium-review.googlesource.com/514045Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent e0e009fe
...@@ -157,7 +157,7 @@ void RoundingHelperWriter::writeCompoundAssignmentHelper(TInfoSinkBase &sink, ...@@ -157,7 +157,7 @@ void RoundingHelperWriter::writeCompoundAssignmentHelper(TInfoSinkBase &sink,
"}\n"; "}\n";
sink << sink <<
lTypeStr << " angle_compound_" << opNameStr << "_frl(inout " << lTypeStr << " x, in " << rTypeStr << " y) {\n" lTypeStr << " angle_compound_" << opNameStr << "_frl(inout " << lTypeStr << " x, in " << rTypeStr << " y) {\n"
" x = angle_frl(angle_frm(x) " << opStr << " y);\n" " x = angle_frl(angle_frl(x) " << opStr << " y);\n"
" return x;\n" " return x;\n"
"}\n"; "}\n";
// clang-format on // clang-format on
...@@ -464,7 +464,7 @@ TIntermAggregate *createCompoundAssignmentFunctionCallNode(TIntermTyped *left, ...@@ -464,7 +464,7 @@ TIntermAggregate *createCompoundAssignmentFunctionCallNode(TIntermTyped *left,
TIntermSequence *arguments = new TIntermSequence(); TIntermSequence *arguments = new TIntermSequence();
arguments->push_back(left); arguments->push_back(left);
arguments->push_back(right); arguments->push_back(right);
return createInternalFunctionCallNode(TType(EbtVoid), functionName, arguments); return createInternalFunctionCallNode(left->getType(), functionName, arguments);
} }
bool ParentUsesResult(TIntermNode *parent, TIntermTyped *node) bool ParentUsesResult(TIntermNode *parent, TIntermTyped *node)
......
...@@ -1042,3 +1042,20 @@ TEST(DebugShaderPrecisionNegativeTest, HLSL3Unsupported) ...@@ -1042,3 +1042,20 @@ TEST(DebugShaderPrecisionNegativeTest, HLSL3Unsupported)
shaderString, &resources, 0, &translatedCode, &infoLog)); shaderString, &resources, 0, &translatedCode, &infoLog));
} }
#endif // defined(ANGLE_ENABLE_HLSL) #endif // defined(ANGLE_ENABLE_HLSL)
// Test that compound assignment inside an expression compiles correctly. This is a test for a bug
// where incorrect type information on the compound assignment call node caused an assert to trigger
// in the debug build.
TEST_F(DebugShaderPrecisionTest, CompoundAssignmentInsideExpression)
{
const std::string &shaderString =
"#version 300 es\n"
"precision mediump float;\n"
"out vec4 my_FragColor;\n"
"void main() {\n"
" float f = 0.0;\n"
" my_FragColor = vec4(abs(f += 1.0), 0, 0, 1);\n"
"}\n";
compile(shaderString);
ASSERT_TRUE(foundInAllGLSLCode("abs(angle_compound_add_frm(f, 1.0))"));
}
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