Commit dcf12c70 by Olli Etuaho Committed by Commit Bot

Fix validating non-square matrix compound multiplication

The validation previously checked that two matrices in compound multiplication are the exact same size, which isn't correct for non-square matrices introduced in ESSL 3.00. Instead, check that the matrix multiplication is valid and that the resulting value has the same number of columns as the lvalue. The number of rows in the result is taken from the lvalue so it doesn't need to be checked. BUG=angleproject:1431 TEST=angle_unittests Change-Id: I6f32b7dc037d72c3c5cfdfffcda5d996e8450283 Reviewed-on: https://chromium-review.googlesource.com/356411Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent 62ba9623
......@@ -57,8 +57,10 @@ bool ValidateMultiplication(TOperator op, const TType &left, const TType &right)
case EOpMatrixTimesMatrix:
return left.getCols() == right.getRows();
case EOpMatrixTimesMatrixAssign:
return left.getCols() == right.getCols() &&
left.getRows() == right.getRows();
// We need to check two things:
// 1. The matrix multiplication step is valid.
// 2. The result will have the same number of columns as the lvalue.
return left.getCols() == right.getRows() && left.getCols() == right.getCols();
default:
UNREACHABLE();
......
......@@ -1572,3 +1572,41 @@ TEST_F(MalformedShaderTest, ESSL300BuiltInFunctionOverload)
FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog;
}
}
// Multiplying a 4x2 matrix with a 4x2 matrix should not work.
TEST_F(MalformedShaderTest, CompoundMultiplyMatrixIdenticalNonSquareDimensions)
{
const std::string &shaderString =
"#version 300 es\n"
"precision mediump float;\n"
"out vec4 my_FragColor;\n"
"void main()\n"
"{\n"
" mat4x2 foo;\n"
" foo *= mat4x2(4.0);\n"
" my_FragColor = vec4(0.0);\n"
"}\n";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog;
}
}
// Multiplying a matrix with 2 columns and 4 rows with a 2x2 matrix should work.
TEST_F(MalformedShaderTest, CompoundMultiplyMatrixValidNonSquareDimensions)
{
const std::string &shaderString =
"#version 300 es\n"
"precision mediump float;\n"
"out vec4 my_FragColor;\n"
"void main()\n"
"{\n"
" mat2x4 foo;\n"
" foo *= mat2x2(4.0);\n"
" my_FragColor = vec4(0.0);\n"
"}\n";
if (!compile(shaderString))
{
FAIL() << "Shader compilation failed, expecting success " << 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