Commit a0adaf98 by Jamie Madill Committed by Commit Bot

Vulkan: Work around unused sampler validation.

Work around glslang's improved validation by using a valid but very high layout binding. This should be more robust. Tests already passing: dEQP-GLES2.functional.state_query.shader.uniform_value_sampler Bug: angleproject:2691 Bug: angleproject:2612 Bug: angleproject:2600 Change-Id: Ie78ae89f76cc0a42806724b622d7f201241bd041 Reviewed-on: https://chromium-review.googlesource.com/1117477Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent dc66ef9d
...@@ -95,6 +95,17 @@ void InsertQualifierSpecifierString(std::string *shaderString, ...@@ -95,6 +95,17 @@ void InsertQualifierSpecifierString(std::string *shaderString,
angle::ReplaceSubstring(shaderString, searchString, replacementString); angle::ReplaceSubstring(shaderString, searchString, replacementString);
} }
void EraseLayoutAndQualifierStrings(std::string *vertexSource,
std::string *fragmentSource,
const std::string &uniformName)
{
InsertLayoutSpecifierString(vertexSource, uniformName, "");
InsertLayoutSpecifierString(fragmentSource, uniformName, "");
InsertQualifierSpecifierString(vertexSource, uniformName, "");
InsertQualifierSpecifierString(fragmentSource, uniformName, "");
}
std::string GetMappedSamplerName(const std::string &originalName) std::string GetMappedSamplerName(const std::string &originalName)
{ {
std::string samplerName = gl::ParseResourceName(originalName, nullptr); std::string samplerName = gl::ParseResourceName(originalName, nullptr);
...@@ -216,10 +227,7 @@ gl::LinkResult GlslangWrapper::linkProgram(const gl::Context *glContext, ...@@ -216,10 +227,7 @@ gl::LinkResult GlslangWrapper::linkProgram(const gl::Context *glContext,
// Remove all the markers for unused varyings. // Remove all the markers for unused varyings.
for (const std::string &varyingName : resources.varyingPacking.getInactiveVaryingNames()) for (const std::string &varyingName : resources.varyingPacking.getInactiveVaryingNames())
{ {
InsertLayoutSpecifierString(&vertexSource, varyingName, ""); EraseLayoutAndQualifierStrings(&vertexSource, &fragmentSource, varyingName);
InsertLayoutSpecifierString(&fragmentSource, varyingName, "");
InsertQualifierSpecifierString(&vertexSource, varyingName, "");
InsertQualifierSpecifierString(&fragmentSource, varyingName, "");
} }
// Bind the default uniforms for vertex and fragment shaders. // Bind the default uniforms for vertex and fragment shaders.
...@@ -262,21 +270,33 @@ gl::LinkResult GlslangWrapper::linkProgram(const gl::Context *glContext, ...@@ -262,21 +270,33 @@ gl::LinkResult GlslangWrapper::linkProgram(const gl::Context *glContext,
textureCount++; textureCount++;
} }
// Start the unused sampler bindings at something ridiculously high.
constexpr int kBaseUnusedSamplerBinding = 100;
int unusedSamplerBinding = kBaseUnusedSamplerBinding;
for (const gl::UnusedUniform &unusedUniform : resources.unusedUniforms) for (const gl::UnusedUniform &unusedUniform : resources.unusedUniforms)
{ {
std::string uniformName = unusedUniform.name;
if (unusedUniform.isSampler) if (unusedUniform.isSampler)
{ {
// Samplers in structs are extracted and renamed. // Samplers in structs are extracted and renamed.
uniformName = GetMappedSamplerName(uniformName); std::string uniformName = GetMappedSamplerName(unusedUniform.name);
}
InsertLayoutSpecifierString(&vertexSource, uniformName, ""); std::stringstream layoutStringStream;
InsertLayoutSpecifierString(&fragmentSource, uniformName, "");
const std::string qualifierToUse = unusedUniform.isSampler ? kUniformQualifier : ""; layoutStringStream << "set = 0, binding = " << unusedSamplerBinding++;
InsertQualifierSpecifierString(&vertexSource, uniformName, qualifierToUse);
InsertQualifierSpecifierString(&fragmentSource, uniformName, qualifierToUse); std::string layoutString = layoutStringStream.str();
InsertLayoutSpecifierString(&vertexSource, uniformName, layoutString);
InsertLayoutSpecifierString(&fragmentSource, uniformName, layoutString);
InsertQualifierSpecifierString(&vertexSource, uniformName, kUniformQualifier);
InsertQualifierSpecifierString(&fragmentSource, uniformName, kUniformQualifier);
}
else
{
EraseLayoutAndQualifierStrings(&vertexSource, &fragmentSource, unusedUniform.name);
}
} }
std::array<const char *, 2> strings = {{vertexSource.c_str(), fragmentSource.c_str()}}; std::array<const char *, 2> strings = {{vertexSource.c_str(), fragmentSource.c_str()}};
......
...@@ -307,7 +307,6 @@ ...@@ -307,7 +307,6 @@
2405 VULKAN : dEQP-GLES2.functional.vertex_arrays.single_attribute.usages.buffer_0_8_fixed* = SKIP 2405 VULKAN : dEQP-GLES2.functional.vertex_arrays.single_attribute.usages.buffer_0_8_fixed* = SKIP
2598 VULKAN : dEQP-GLES2.functional.rasterization.primitives.line* = SKIP 2598 VULKAN : dEQP-GLES2.functional.rasterization.primitives.line* = SKIP
2599 VULKAN : dEQP-GLES2.functional.rasterization.limits.points = SKIP 2599 VULKAN : dEQP-GLES2.functional.rasterization.limits.points = SKIP
2600 VULKAN : dEQP-GLES2.functional.state_query.shader.uniform_value_sampler = SKIP
2601 VULKAN : dEQP-GLES2.functional.clipping.* = SKIP 2601 VULKAN : dEQP-GLES2.functional.clipping.* = SKIP
2353 VULKAN : dEQP-GLES2.functional.polygon_offset.* = SKIP 2353 VULKAN : dEQP-GLES2.functional.polygon_offset.* = SKIP
2444 VULKAN : dEQP-GLES2.functional.draw.draw_arrays.points.default_attribute = SKIP 2444 VULKAN : dEQP-GLES2.functional.draw.draw_arrays.points.default_attribute = SKIP
......
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