Commit f6fd48fd by Luc Ferron Committed by Commit Bot

Vulkan: Get uniform for array of matrices fix

Bug: angleproject:2666 Change-Id: Ib50b0dd89abbd1d8d6c829a5ecf6438acc970da3 Reviewed-on: https://chromium-review.googlesource.com/1104305Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Luc Ferron <lucferron@chromium.org>
parent 50cf2be0
......@@ -531,7 +531,7 @@ void ProgramVk::getUniformImpl(GLint location, T *v, GLenum entryPointType) cons
if (gl::IsMatrixType(linkedUniform.type))
{
const uint8_t *ptrToElement = uniformBlock.uniformData.data() + layoutInfo.offset +
(locationInfo.arrayIndex * linkedUniform.getElementSize());
(locationInfo.arrayIndex * layoutInfo.arrayStride);
GetMatrixUniform(linkedUniform.type, v, reinterpret_cast<const T *>(ptrToElement), false);
}
else
......
......@@ -249,6 +249,37 @@ void main() {
}
}
// Test that we can get and set an array of matrices uniform.
TEST_P(SimpleUniformTest, ArrayOfMat3UniformStateQuery)
{
constexpr char kFragShader[] = R"(
precision mediump float;
uniform mat3 umatarray[2];
void main() {
gl_FragColor = vec4(umatarray[1]);
})";
ANGLE_GL_PROGRAM(program, essl1_shaders::vs::Zero(), kFragShader);
glUseProgram(program);
std::vector<std::vector<GLfloat>> expected = {
{1.0f, 0.5f, 0.2f, -0.8f, -0.2f, 0.1f, 0.1f, 0.2f, 0.7f},
{0.9f, 0.4f, 0.1f, -0.9f, -0.3f, 0.0f, 0.0f, 0.1f, 0.6f}};
for (size_t i = 0; i < expected.size(); i++)
{
std::string locationName = "umatarray[" + std::to_string(i) + "]";
GLint uniformLocation = glGetUniformLocation(program, locationName.c_str());
glUniformMatrix3fv(uniformLocation, 1, false, expected[i].data());
ASSERT_GL_NO_ERROR();
ASSERT_NE(uniformLocation, -1);
std::vector<GLfloat> results(9, 0);
glGetUniformfv(program, uniformLocation, results.data());
ASSERT_GL_NO_ERROR();
ASSERT_EQ(results, expected[i]);
}
}
// Test that we can get and set an int array of uniforms.
TEST_P(SimpleUniformTest, FloatIntUniformStateQuery)
{
......
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