Commit 593b1a6c by James Dong Committed by Commit Bot

Vulkan: Fix array handling in default uniforms

Changes default uniform block layout generation to only remove the first array subscript, which causes arrays of arrays to be recognized correctly. Bug: angleproject:3604 Test: ./angle_deqp_gles31_no_gtest --deqp-egl-display-type=angle-vulkan -n 'dEQP-GLES31.functional.shaders.arrays*' Test: ./angle_deqp_gles31_no_gtest --deqp-egl-display-type=angle-vulkan -n 'dEQP-GLES31.functional.program_interface_query.*array*array*' Change-Id: Ifacc665cae87c651253e5cb8d929178d7fc92817 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1724906Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: James Dong <dongja@google.com>
parent d43d24bb
...@@ -770,6 +770,13 @@ std::string ParseResourceName(const std::string &name, std::vector<unsigned int> ...@@ -770,6 +770,13 @@ std::string ParseResourceName(const std::string &name, std::vector<unsigned int>
return name.substr(0, baseNameLength); return name.substr(0, baseNameLength);
} }
std::string StripLastArrayIndex(const std::string &name)
{
size_t strippedNameLength = name.find_last_of('[');
ASSERT(strippedNameLength != std::string::npos && name.back() == ']');
return name.substr(0, strippedNameLength);
}
const sh::ShaderVariable *FindShaderVarField(const sh::ShaderVariable &var, const sh::ShaderVariable *FindShaderVarField(const sh::ShaderVariable &var,
const std::string &fullName, const std::string &fullName,
GLuint *fieldIndexOut) GLuint *fieldIndexOut)
......
...@@ -59,6 +59,9 @@ int AllocateFirstFreeBits(unsigned int *bits, unsigned int allocationSize, unsig ...@@ -59,6 +59,9 @@ int AllocateFirstFreeBits(unsigned int *bits, unsigned int allocationSize, unsig
// outSubscripts. // outSubscripts.
std::string ParseResourceName(const std::string &name, std::vector<unsigned int> *outSubscripts); std::string ParseResourceName(const std::string &name, std::vector<unsigned int> *outSubscripts);
// Strips only the last array index from a resource name.
std::string StripLastArrayIndex(const std::string &name);
// Find the child field which matches 'fullName' == var.name + "." + field.name. // Find the child field which matches 'fullName' == var.name + "." + field.name.
// Return nullptr if not found. // Return nullptr if not found.
const sh::ShaderVariable *FindShaderVarField(const sh::ShaderVariable &var, const sh::ShaderVariable *FindShaderVarField(const sh::ShaderVariable &var,
......
...@@ -671,7 +671,7 @@ void ProgramVk::initDefaultUniformLayoutMapping(gl::ShaderMap<sh::BlockLayoutMap ...@@ -671,7 +671,7 @@ void ProgramVk::initDefaultUniformLayoutMapping(gl::ShaderMap<sh::BlockLayoutMap
if (uniform.isArray()) if (uniform.isArray())
{ {
// Gets the uniform name without the [0] at the end. // Gets the uniform name without the [0] at the end.
uniformName = gl::ParseResourceName(uniformName, nullptr); uniformName = gl::StripLastArrayIndex(uniformName);
} }
bool found = false; bool found = false;
......
...@@ -642,7 +642,6 @@ ...@@ -642,7 +642,6 @@
3569 VULKAN : dEQP-GLES31.functional.shaders.builtin_functions.precision.frexp* = FAIL 3569 VULKAN : dEQP-GLES31.functional.shaders.builtin_functions.precision.frexp* = FAIL
3569 VULKAN : dEQP-GLES31.functional.shaders.builtin_functions.precision.ldexp* = FAIL 3569 VULKAN : dEQP-GLES31.functional.shaders.builtin_functions.precision.ldexp* = FAIL
3569 VULKAN : dEQP-GLES31.functional.shaders.functions* = FAIL 3569 VULKAN : dEQP-GLES31.functional.shaders.functions* = FAIL
3569 VULKAN : dEQP-GLES31.functional.shaders.arrays* = FAIL
3569 VULKAN : dEQP-GLES31.functional.shaders.linkage*uniform* = FAIL 3569 VULKAN : dEQP-GLES31.functional.shaders.linkage*uniform* = FAIL
3569 VULKAN : dEQP-GLES31.functional.shaders.builtin_constants.core.max_* = FAIL 3569 VULKAN : dEQP-GLES31.functional.shaders.builtin_constants.core.max_* = FAIL
3569 VULKAN : dEQP-GLES31.functional.shaders.builtin_constants.core.min_program_texel_offset = FAIL 3569 VULKAN : dEQP-GLES31.functional.shaders.builtin_constants.core.min_program_texel_offset = FAIL
...@@ -651,11 +650,9 @@ ...@@ -651,11 +650,9 @@
// SSBO and Image qualifiers: // SSBO and Image qualifiers:
3602 VULKAN : dEQP-GLES31.functional.synchronization.in_invocation.ssbo_alias_overwrite = FAIL 3602 VULKAN : dEQP-GLES31.functional.synchronization.in_invocation.ssbo_alias_overwrite = FAIL
// Array of array and struct default uniforms: // Struct referenced by:
3604 VULKAN : dEQP-GLES31.functional.program_interface_query.*float_struct = FAIL 3596 VULKAN : dEQP-GLES31.functional.program_interface_query.*.referenced_by*struct* = FAIL
3604 VULKAN : dEQP-GLES31.functional.program_interface_query.*float_struct_struct = FAIL 3596 VULKAN : dEQP-GLES31.functional.program_interface_query.*random* = FAIL
3604 VULKAN : dEQP-GLES31.functional.program_interface_query.*random* = FAIL
3604 VULKAN : dEQP-GLES31.functional.program_interface_query.*array*array* = SKIP
// Block name matching failure: // Block name matching failure:
3459 VULKAN : dEQP-GLES31.functional.shaders.linkage.es31.shader_storage_block.mismatch_with_and_without_instance_name = FAIL 3459 VULKAN : dEQP-GLES31.functional.shaders.linkage.es31.shader_storage_block.mismatch_with_and_without_instance_name = FAIL
......
...@@ -2891,6 +2891,44 @@ TEST_P(GLSLTest_ES3, WriteIntoDynamicIndexingOfSwizzledVector) ...@@ -2891,6 +2891,44 @@ TEST_P(GLSLTest_ES3, WriteIntoDynamicIndexingOfSwizzledVector)
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green); EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
} }
// Test that array indices for arrays of arrays work as expected.
TEST_P(GLSLTest_ES31, ArraysOfArrays)
{
constexpr char kFS[] =
"#version 310 es\n"
"precision mediump float;\n"
"out vec4 my_FragColor;\n"
"uniform ivec2 test[2][2];\n"
"void main() {\n"
" bool passed = true;\n"
" for (int i = 0; i < 2; i++) {\n"
" for (int j = 0; j < 2; j++) {\n"
" if (test[i][j] != ivec2(i + 1, j + 1)) {\n"
" passed = false;\n"
" }\n"
" }\n"
" }\n"
" my_FragColor = passed ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);\n"
"}\n";
ANGLE_GL_PROGRAM(program, essl31_shaders::vs::Simple(), kFS);
glUseProgram(program.get());
for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 2; j++)
{
std::stringstream uniformName;
uniformName << "test[" << i << "][" << j << "]";
GLint uniformLocation = glGetUniformLocation(program.get(), uniformName.str().c_str());
// All array indices should be used.
EXPECT_NE(uniformLocation, -1);
glUniform2i(uniformLocation, i + 1, j + 1);
}
}
drawQuad(program.get(), essl31_shaders::PositionAttrib(), 0.5f);
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
}
// This test covers a bug (and associated workaround) with nested sampling operations in the HLSL // This test covers a bug (and associated workaround) with nested sampling operations in the HLSL
// compiler DLL. // compiler DLL.
TEST_P(GLSLTest_ES3, NestedSamplingOperation) TEST_P(GLSLTest_ES3, NestedSamplingOperation)
...@@ -5651,4 +5689,4 @@ ANGLE_INSTANTIATE_TEST(GLSLTest_ES3, ES3_D3D11(), ES3_OPENGL(), ES3_OPENGLES(), ...@@ -5651,4 +5689,4 @@ ANGLE_INSTANTIATE_TEST(GLSLTest_ES3, ES3_D3D11(), ES3_OPENGL(), ES3_OPENGLES(),
ANGLE_INSTANTIATE_TEST(WebGLGLSLTest, ES2_D3D11(), ES2_OPENGL(), ES2_OPENGLES(), ES2_VULKAN()); ANGLE_INSTANTIATE_TEST(WebGLGLSLTest, ES2_D3D11(), ES2_OPENGL(), ES2_OPENGLES(), ES2_VULKAN());
ANGLE_INSTANTIATE_TEST(GLSLTest_ES31, ES31_D3D11(), ES31_OPENGL(), ES31_OPENGLES()); ANGLE_INSTANTIATE_TEST(GLSLTest_ES31, ES31_D3D11(), ES31_OPENGL(), ES31_OPENGLES(), ES31_VULKAN());
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