Commit 0ae59f2a by Shahbaz Youssefi Committed by Commit Bot

Add test to verify uniform matrix upload

Bug: angleproject:3198 Change-Id: Icb63d036a756b849c44d36342c7ba2fc2db0f910 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1604069 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarTobin Ehlis <tobine@google.com>
parent e1de1ab3
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <array> #include <array>
#include <cmath> #include <cmath>
#include <sstream>
using namespace angle; using namespace angle;
...@@ -1242,6 +1243,95 @@ TEST_P(UniformTestES3, StructWithNonSquareMatrixAndBool) ...@@ -1242,6 +1243,95 @@ TEST_P(UniformTestES3, StructWithNonSquareMatrixAndBool)
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::white); EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::white);
} }
// Test that matrix uniform upload is correct.
TEST_P(UniformTestES3, MatrixUniformUpload)
{
// TODO(syoussefi): Bug in matrix uniform handling. http://anglebug.com/3198
ANGLE_SKIP_TEST_IF(IsVulkan());
constexpr size_t kMinDims = 2;
constexpr size_t kMaxDims = 4;
GLfloat matrixValues[kMaxDims * kMaxDims];
for (size_t i = 0; i < kMaxDims * kMaxDims; ++i)
{
matrixValues[i] = static_cast<GLfloat>(i);
}
using UniformMatrixCxRfv = decltype(glUniformMatrix2fv);
UniformMatrixCxRfv uniformMatrixCxRfv[kMaxDims + 1][kMaxDims + 1] = {
{nullptr, nullptr, nullptr, nullptr, nullptr},
{nullptr, nullptr, nullptr, nullptr, nullptr},
{nullptr, nullptr, glUniformMatrix2fv, glUniformMatrix2x3fv, glUniformMatrix2x4fv},
{nullptr, nullptr, glUniformMatrix3x2fv, glUniformMatrix3fv, glUniformMatrix3x4fv},
{nullptr, nullptr, glUniformMatrix4x2fv, glUniformMatrix4x3fv, glUniformMatrix4fv},
};
for (int transpose = 0; transpose < 2; ++transpose)
{
for (size_t cols = kMinDims; cols <= kMaxDims; ++cols)
{
for (size_t rows = kMinDims; rows <= kMaxDims; ++rows)
{
std::ostringstream shader;
shader << "#version 300 es\n"
"precision highp float;\n"
"out highp vec4 colorOut;\n"
"uniform mat"
<< cols << 'x' << rows
<< " m;\n"
"void main()\n"
"{\n"
" bool isCorrect =";
for (size_t col = 0; col < cols; ++col)
{
for (size_t row = 0; row < rows; ++row)
{
size_t value;
if (!transpose)
{
// Matrix data is uploaded column-major.
value = col * rows + row;
}
else
{
// Matrix data is uploaded row-major.
value = row * cols + col;
}
if (value != 0)
{
shader << "&&\n ";
}
shader << "(m[" << col << "][" << row << "] == " << value << ".0)";
}
}
shader << ";\n colorOut = vec4(isCorrect);\n"
"}\n";
ANGLE_GL_PROGRAM(program, essl3_shaders::vs::Simple(), shader.str().c_str());
glUseProgram(program.get());
GLint location = glGetUniformLocation(program.get(), "m");
ASSERT_NE(-1, location);
uniformMatrixCxRfv[cols][rows](location, 1, transpose != 0, matrixValues);
ASSERT_GL_NO_ERROR();
drawQuad(program.get(), essl3_shaders::PositionAttrib(), 0.0f);
ASSERT_GL_NO_ERROR();
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::white);
}
}
}
}
// Test that uniforms with reserved OpenGL names that aren't reserved in GL ES 2 work correctly. // Test that uniforms with reserved OpenGL names that aren't reserved in GL ES 2 work correctly.
TEST_P(UniformTest, UniformWithReservedOpenGLName) TEST_P(UniformTest, UniformWithReservedOpenGLName)
{ {
......
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