Commit 6423b7fc by Tim Van Patten Committed by Commit Bot

Return the correct location count for Matrices

GetLocationCount() is currently returning the number of rows in the matrix, rather than the columns, which leads to shader validation errors (and test failures). This fix returns the number of columns in a matrix. Bug: angleproject:4200 Test: dEQP-GLES31.functional.separate_shader.random.63 Change-Id: I8d25eb3733c2ddbe53ff54794f480c1d43e22a88 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1952173Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarCourtney Goeltzenleuchter <courtneygo@google.com> Commit-Queue: Tim Van Patten <timvp@google.com>
parent 20432bf3
......@@ -53,9 +53,13 @@ int GetLocationCount(const TIntermSymbol *varying, bool ignoreVaryingArraySize)
ASSERT(!varyingType.isArrayOfArrays());
return varyingType.getSecondarySize();
}
else if (varyingType.isMatrix())
{
return varyingType.getNominalSize() * static_cast<int>(varyingType.getArraySizeProduct());
}
else
{
return varyingType.getSecondarySize() * static_cast<int>(varyingType.getArraySizeProduct());
return static_cast<int>(varyingType.getArraySizeProduct());
}
}
......
......@@ -76,6 +76,7 @@ angle_end2end_tests_sources = [
"gl_tests/InstancingTest.cpp",
"gl_tests/LineLoopTest.cpp",
"gl_tests/LinkAndRelinkTest.cpp",
"gl_tests/MatrixTest.cpp",
"gl_tests/MaxTextureSizeTest.cpp",
"gl_tests/MemorySizeTest.cpp",
"gl_tests/MemoryObjectTest.cpp",
......
//
// Copyright 2019 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// MatrixTest:
// Test various shader matrix variable declarations.
#include <vector>
#include "test_utils/ANGLETest.h"
#include "test_utils/gl_raii.h"
using namespace angle;
namespace
{
class MatrixTest31 : public ANGLETest
{
protected:
MatrixTest31()
{
setWindowWidth(64);
setWindowHeight(64);
setConfigRedBits(8);
setConfigGreenBits(8);
setConfigBlueBits(8);
setConfigAlphaBits(8);
}
};
TEST_P(MatrixTest31, Mat3Varying)
{
constexpr char kVS[] = R"(#version 310 es
precision mediump float;
in vec4 a_position;
layout(location=0) out mat3 matrix;
layout(location=3) out vec3 vector;
void main()
{
matrix = mat3(1.0);
vector = vec3(1.0);
gl_Position = a_position;
})";
constexpr char kFS[] = R"(#version 310 es
precision mediump float;
layout(location=0) in mat3 matrix;
layout(location=3) in vec3 vector;
out vec4 oColor;
void main()
{
oColor = vec4(matrix[0], 1.0);
})";
ANGLE_GL_PROGRAM(program, kVS, kFS);
glUseProgram(program);
drawQuad(program, "a_position", 0.5f);
EXPECT_GL_NO_ERROR();
}
TEST_P(MatrixTest31, Mat3VaryingBadLocation)
{
constexpr char kVS[] = R"(#version 310 es
precision mediump float;
in vec4 a_position;
layout(location=0) out mat3 matrix;
layout(location=2) out vec3 vector;
void main()
{
matrix = mat3(1.0);
vector = vec3(1.0);
gl_Position = a_position;
})";
GLProgram program;
GLuint vs = glCreateShader(GL_VERTEX_SHADER);
const char *sourceVsArray[1] = {kVS};
glShaderSource(vs, 1, sourceVsArray, nullptr);
glCompileShader(vs);
GLint compileResult;
glGetShaderiv(vs, GL_COMPILE_STATUS, &compileResult);
EXPECT_GL_FALSE(compileResult);
}
TEST_P(MatrixTest31, Mat3x4Varying)
{
constexpr char kVS[] = R"(#version 310 es
precision mediump float;
in vec4 a_position;
layout(location=0) out mat3x4 matrix;
layout(location=3) out vec3 vector;
void main()
{
matrix = mat3x4(1.0);
vector = vec3(1.0);
gl_Position = a_position;
})";
constexpr char kFS[] = R"(#version 310 es
precision mediump float;
layout(location=0) in mat3x4 matrix;
layout(location=3) in vec3 vector;
out vec4 oColor;
void main()
{
oColor = vec4(matrix[0]);
})";
ANGLE_GL_PROGRAM(program, kVS, kFS);
glUseProgram(program);
drawQuad(program, "a_position", 0.5f);
EXPECT_GL_NO_ERROR();
}
TEST_P(MatrixTest31, Mat3x4VaryingBadLocation)
{
constexpr char kVS[] = R"(#version 310 es
precision mediump float;
in vec4 a_position;
layout(location=0) out mat3x4 matrix;
layout(location=2) out vec3 vector;
void main()
{
matrix = mat3x4(1.0);
vector = vec3(1.0);
gl_Position = a_position;
})";
GLProgram program;
GLuint vs = glCreateShader(GL_VERTEX_SHADER);
const char *sourceVsArray[1] = {kVS};
glShaderSource(vs, 1, sourceVsArray, nullptr);
glCompileShader(vs);
GLint compileResult;
glGetShaderiv(vs, GL_COMPILE_STATUS, &compileResult);
EXPECT_GL_FALSE(compileResult);
}
TEST_P(MatrixTest31, Mat3x4ArrayVarying)
{
constexpr char kVS[] = R"(#version 310 es
precision mediump float;
in vec4 a_position;
layout(location=0) out mat3x4[2] matrix;
layout(location=6) out vec3 vector;
void main()
{
matrix[0] = mat3x4(1.0);
matrix[1] = mat3x4(1.0);
vector = vec3(1.0);
gl_Position = a_position;
})";
constexpr char kFS[] = R"(#version 310 es
precision mediump float;
layout(location=0) in mat3x4[2] matrix;
layout(location=6) in vec3 vector;
out vec4 oColor;
bool isZero(vec4 value) {
return value == vec4(0,0,0,0);
}
void main()
{
oColor = vec4(matrix[0][0]);
})";
ANGLE_GL_PROGRAM(program, kVS, kFS);
glUseProgram(program);
drawQuad(program, "a_position", 0.5f);
EXPECT_GL_NO_ERROR();
}
TEST_P(MatrixTest31, Mat3x4ArrayVaryingBadLocation)
{
constexpr char kVS[] = R"(#version 310 es
precision mediump float;
in vec4 a_position;
layout(location=0) out mat3x4[2] matrix;
layout(location=5) out vec3 vector;
void main()
{
matrix[0] = mat3x4(1.0);
matrix[1] = mat3x4(1.0);
vector = vec3(1.0);
gl_Position = a_position;
})";
GLProgram program;
GLuint vs = glCreateShader(GL_VERTEX_SHADER);
const char *sourceVsArray[1] = {kVS};
glShaderSource(vs, 1, sourceVsArray, nullptr);
glCompileShader(vs);
GLint compileResult;
glGetShaderiv(vs, GL_COMPILE_STATUS, &compileResult);
EXPECT_GL_FALSE(compileResult);
}
ANGLE_INSTANTIATE_TEST_ES31(MatrixTest31);
} // namespace
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