Commit 44722daa by Shahbaz Youssefi Committed by Commit Bot

Vulkan: Enable inactive SSBO with unsized array tests

The change introduced in https://chromium-review.googlesource.com/c/angle/angle/+/1951523 removes inactive shader interface declarations. That automatically resolves an issue where glslang wrapper doesn't handle inactive SSBO declarations with unsized arrays, by removing those declarations at translation time altogether. Bug: angleproject:3714 Change-Id: I710d59546d716bfb5bc0112b5152fed20a810a52 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1954615 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarCourtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 7e19e25e
...@@ -483,7 +483,9 @@ class FlattenUniformVisitor : public sh::VariableNameVisitor ...@@ -483,7 +483,9 @@ class FlattenUniformVisitor : public sh::VariableNameVisitor
} }
else else
{ {
mUnusedUniforms->emplace_back(linkedUniform.name, linkedUniform.isSampler()); mUnusedUniforms->emplace_back(linkedUniform.name, linkedUniform.isSampler(),
linkedUniform.isImage(),
linkedUniform.isAtomicCounter());
} }
uniformList->push_back(linkedUniform); uniformList->push_back(linkedUniform);
...@@ -912,7 +914,8 @@ void UniformLinker::pruneUnusedUniforms() ...@@ -912,7 +914,8 @@ void UniformLinker::pruneUnusedUniforms()
} }
else else
{ {
mUnusedUniforms.emplace_back(uniformIter->name, uniformIter->isSampler()); mUnusedUniforms.emplace_back(uniformIter->name, uniformIter->isSampler(),
uniformIter->isImage(), uniformIter->isAtomicCounter());
uniformIter = mUniforms.erase(uniformIter); uniformIter = mUniforms.erase(uniformIter);
} }
} }
...@@ -940,7 +943,9 @@ bool UniformLinker::flattenUniformsAndCheckCapsForShader( ...@@ -940,7 +943,9 @@ bool UniformLinker::flattenUniformsAndCheckCapsForShader(
} }
else else
{ {
unusedUniforms.emplace_back(uniform.name, IsSamplerType(uniform.type)); unusedUniforms.emplace_back(uniform.name, IsSamplerType(uniform.type),
IsImageType(uniform.type),
IsAtomicCounterType(uniform.type));
} }
} }
......
...@@ -190,14 +190,18 @@ class AtomicCounterBufferLinker final : angle::NonCopyable ...@@ -190,14 +190,18 @@ class AtomicCounterBufferLinker final : angle::NonCopyable
// TODO(jmadill): Integrate uniform linking/filtering as well as interface blocks. // TODO(jmadill): Integrate uniform linking/filtering as well as interface blocks.
struct UnusedUniform struct UnusedUniform
{ {
UnusedUniform(std::string name, bool isSampler) UnusedUniform(std::string name, bool isSampler, bool isImage, bool isAtomicCounter)
{ {
this->name = name; this->name = name;
this->isSampler = isSampler; this->isSampler = isSampler;
this->isImage = isImage;
this->isAtomicCounter = isAtomicCounter;
} }
std::string name; std::string name;
bool isSampler; bool isSampler;
bool isImage;
bool isAtomicCounter;
}; };
struct ProgramLinkedResources struct ProgramLinkedResources
......
...@@ -55,7 +55,6 @@ constexpr char kParamsBegin = '('; ...@@ -55,7 +55,6 @@ constexpr char kParamsBegin = '(';
constexpr char kParamsEnd = ')'; constexpr char kParamsEnd = ')';
constexpr char kUniformQualifier[] = "uniform"; constexpr char kUniformQualifier[] = "uniform";
constexpr char kSSBOQualifier[] = "buffer"; constexpr char kSSBOQualifier[] = "buffer";
constexpr char kUnusedBlockSubstitution[] = "struct";
constexpr char kUnusedUniformSubstitution[] = "// "; constexpr char kUnusedUniformSubstitution[] = "// ";
constexpr char kVersionDefine[] = "#version 450 core\n"; constexpr char kVersionDefine[] = "#version 450 core\n";
constexpr char kLineRasterDefine[] = R"(#version 450 core constexpr char kLineRasterDefine[] = R"(#version 450 core
...@@ -865,7 +864,7 @@ void AssignResourceBinding(gl::ShaderBitSet activeShaders, ...@@ -865,7 +864,7 @@ void AssignResourceBinding(gl::ShaderBitSet activeShaders,
shaderSource.insertLayoutSpecifier(name, bindingString); shaderSource.insertLayoutSpecifier(name, bindingString);
shaderSource.insertQualifierSpecifier(name, qualifier); shaderSource.insertQualifierSpecifier(name, qualifier);
} }
else else if (unusedSubstitution)
{ {
shaderSource.eraseLayoutAndQualifierSpecifiers(name, unusedSubstitution); shaderSource.eraseLayoutAndQualifierSpecifiers(name, unusedSubstitution);
} }
...@@ -891,7 +890,7 @@ uint32_t AssignInterfaceBlockBindings(const GlslangSourceOptions &options, ...@@ -891,7 +890,7 @@ uint32_t AssignInterfaceBlockBindings(const GlslangSourceOptions &options,
resourcesDescriptorSet + ", binding = " + Str(bindingIndex++); resourcesDescriptorSet + ", binding = " + Str(bindingIndex++);
AssignResourceBinding(block.activeShaders(), block.name, bindingString, qualifier, AssignResourceBinding(block.activeShaders(), block.name, bindingString, qualifier,
kUnusedBlockSubstitution, shaderSources); nullptr, shaderSources);
} }
} }
...@@ -950,7 +949,7 @@ uint32_t AssignImageBindings(const GlslangSourceOptions &options, ...@@ -950,7 +949,7 @@ uint32_t AssignImageBindings(const GlslangSourceOptions &options,
} }
AssignResourceBinding(imageUniform.activeShaders(), name, bindingString, kUniformQualifier, AssignResourceBinding(imageUniform.activeShaders(), name, bindingString, kUniformQualifier,
kUnusedUniformSubstitution, shaderSources); nullptr, shaderSources);
} }
return bindingIndex; return bindingIndex;
...@@ -1049,20 +1048,15 @@ void CleanupUnusedEntities(bool useOldRewriteStructSamplers, ...@@ -1049,20 +1048,15 @@ void CleanupUnusedEntities(bool useOldRewriteStructSamplers,
} }
} }
// Remove all the markers for unused interface blocks, and replace them with |struct|. // Comment out unused default uniforms. This relies on the fact that the shader compiler
for (const std::string &unusedInterfaceBlock : resources.unusedInterfaceBlocks) // outputs uniforms to a single line.
for (const gl::UnusedUniform &unusedUniform : resources.unusedUniforms)
{ {
for (IntermediateShaderSource &shaderSource : *shaderSources) if (unusedUniform.isImage || unusedUniform.isAtomicCounter)
{ {
shaderSource.eraseLayoutAndQualifierSpecifiers(unusedInterfaceBlock, continue;
kUnusedBlockSubstitution);
} }
}
// Comment out unused uniforms. This relies on the fact that the shader compiler outputs
// uniforms to a single line.
for (const gl::UnusedUniform &unusedUniform : resources.unusedUniforms)
{
std::string uniformName = unusedUniform.isSampler std::string uniformName = unusedUniform.isSampler
? useOldRewriteStructSamplers ? useOldRewriteStructSamplers
? GetMappedSamplerNameOld(unusedUniform.name) ? GetMappedSamplerNameOld(unusedUniform.name)
......
...@@ -681,9 +681,6 @@ ...@@ -681,9 +681,6 @@
// Cannot create 2D (array) view of 3D texture. // Cannot create 2D (array) view of 3D texture.
3886 VULKAN : dEQP-GLES31.functional.image_load_store.3d.*layer = FAIL 3886 VULKAN : dEQP-GLES31.functional.image_load_store.3d.*layer = FAIL
// Inactive SSBOs with flexible array member (about 20% of these tests are affected):
3714 VULKAN : dEQP-GLES31.functional.ssbo.layout.random.* = FAIL
// OpenGL ES 3.1 conformance failures // OpenGL ES 3.1 conformance failures
4098 SWIFTSHADER : dEQP-GLES31.functional.compute.basic.write_multiple_unsized_arr_multiple_groups = FAIL 4098 SWIFTSHADER : dEQP-GLES31.functional.compute.basic.write_multiple_unsized_arr_multiple_groups = FAIL
4098 SWIFTSHADER : dEQP-GLES31.functional.compute.basic.write_multiple_unsized_arr_single_invocation = FAIL 4098 SWIFTSHADER : dEQP-GLES31.functional.compute.basic.write_multiple_unsized_arr_single_invocation = FAIL
......
...@@ -2224,6 +2224,38 @@ void main() ...@@ -2224,6 +2224,38 @@ void main()
EXPECT_GL_NO_ERROR(); EXPECT_GL_NO_ERROR();
} }
// Test that inactive but statically used SSBOs with unsized array are handled correctly.
//
// Glslang wrapper used to replace the layout/qualifier of an inactive SSBO with |struct|,
// effectively turning the interface block declaration into a struct definition. This generally
// worked except for SSBOs with an unsized array. This test makes sure this special case is
// now properly handled.
TEST_P(ShaderStorageBufferTest31, InactiveButStaticallyUsedWithUnsizedArray)
{
constexpr char kComputeShaderSource[] =
R"(#version 310 es
layout (local_size_x=1) in;
layout(binding=0, std140) buffer Storage
{
uint data[];
} sb;
void main()
{
if (false)
{
sb.data[0] = 1u;
}
}
)";
ANGLE_GL_COMPUTE_PROGRAM(program, kComputeShaderSource);
EXPECT_GL_NO_ERROR();
glUseProgram(program);
glDispatchCompute(1, 1, 1);
EXPECT_GL_NO_ERROR();
}
ANGLE_INSTANTIATE_TEST_ES31(ShaderStorageBufferTest31); ANGLE_INSTANTIATE_TEST_ES31(ShaderStorageBufferTest31);
} // namespace } // 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