Commit 086aded3 by Shahbaz Youssefi Committed by Commit Bot

Return the correct location count for matrices in structs

GetLocationCount() returned secondary size for fields of a struct. For matrices however, the correct value would be the primary size. This is a similar fix to 6423b7fc. Bug: angleproject:4200 Change-Id: I2c69b9454729993010766fcde0cabec986b7429d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2021738Reviewed-by: 's avatarCourtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: 's avatarTim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
parent d0b4eaf6
......@@ -37,7 +37,8 @@ int GetLocationCount(const TIntermSymbol *varying, bool ignoreVaryingArraySize)
const auto *fieldType = field->type();
ASSERT(fieldType->getStruct() == nullptr && !fieldType->isArray());
totalLocation += fieldType->getSecondarySize();
totalLocation +=
fieldType->isMatrix() ? fieldType->getNominalSize() : fieldType->getSecondarySize();
}
return totalLocation;
}
......
......@@ -183,10 +183,6 @@ 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]);
......@@ -227,6 +223,82 @@ void main()
EXPECT_GL_FALSE(compileResult);
}
TEST_P(MatrixTest31, Mat3x4StructVarying)
{
constexpr char kVS[] = R"(#version 310 es
precision mediump float;
in vec4 a_position;
struct S
{
mat3x4 m;
};
layout(location=0) out S matrix;
layout(location=3) out vec3 vector;
void main()
{
matrix.m = mat3x4(1.0);
vector = vec3(1.0);
gl_Position = a_position;
})";
constexpr char kFS[] = R"(#version 310 es
precision mediump float;
struct S
{
mat3x4 m;
};
layout(location=0) in S matrix;
layout(location=3) in vec3 vector;
out vec4 oColor;
void main()
{
oColor = vec4(matrix.m[0]);
})";
ANGLE_GL_PROGRAM(program, kVS, kFS);
glUseProgram(program);
drawQuad(program, "a_position", 0.5f);
EXPECT_GL_NO_ERROR();
}
TEST_P(MatrixTest31, Mat3x4StructVaryingBadLocation)
{
constexpr char kVS[] = R"(#version 310 es
precision mediump float;
in vec4 a_position;
struct S
{
mat3x4 m;
};
layout(location=0) out S matrix;
layout(location=2) out vec3 vector;
void main()
{
matrix.m = 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