Commit f3b4e6c3 by Shahbaz Youssefi Committed by Commit Bot

Vulkan: No inactive samplers left to cleanup in glslang wrapper

Loose inactive samplers are already removed in RemoveInactiveInterfaceVariables. In-struct samplers are always marked active by CollectVariables if the uniform is active. If the uniform is inactive, it is removed entirely by the translator. Thus no inactive samplers are left for glslang wrapper to clean up. Bug: angleproject:3394 Change-Id: Ic0fef052afa992bd612fd22ffa1e5b9aa72a17bc Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1999488 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 8dfe472c
......@@ -730,7 +730,9 @@ bool TranslatorVulkan::translateImpl(TIntermBlock *root,
// Remove declarations of inactive shader interface variables so glslang wrapper doesn't need to
// replace them. Note: this is done before extracting samplers from structs, as removing such
// inactive samplers is not yet supported.
// inactive samplers is not yet supported. Note also that currently, CollectVariables marks
// every field of an active uniform that's of struct type as active, i.e. no extracted sampler
// is inactive.
if (!RemoveInactiveInterfaceVariables(this, root, getUniforms(), getInterfaceBlocks()))
{
return false;
......
......@@ -845,22 +845,14 @@ void AssignUniformBindings(const GlslangSourceOptions &options,
void AssignResourceBinding(gl::ShaderBitSet activeShaders,
const std::string &name,
const std::string &bindingString,
bool eraseLayoutIfInactive,
gl::ShaderMap<IntermediateShaderSource> *shaderSources)
{
for (const gl::ShaderType shaderType : gl::AllShaderTypes())
{
IntermediateShaderSource &shaderSource = (*shaderSources)[shaderType];
if (!shaderSource.empty())
if (activeShaders[shaderType] && !shaderSource.empty())
{
if (activeShaders[shaderType])
{
shaderSource.insertLayoutSpecifier(name, bindingString);
}
else if (eraseLayoutIfInactive)
{
shaderSource.eraseLayoutAndQualifierSpecifiers(name, kInactiveVariableSubstitution);
}
shaderSource.insertLayoutSpecifier(name, bindingString);
}
}
}
......@@ -881,8 +873,7 @@ uint32_t AssignInterfaceBlockBindings(const GlslangSourceOptions &options,
const std::string bindingString =
resourcesDescriptorSet + ", binding = " + Str(bindingIndex++);
AssignResourceBinding(block.activeShaders(), block.name, bindingString, false,
shaderSources);
AssignResourceBinding(block.activeShaders(), block.name, bindingString, shaderSources);
}
}
......@@ -938,8 +929,7 @@ uint32_t AssignImageBindings(const GlslangSourceOptions &options,
name = name.substr(0, name.find('['));
}
AssignResourceBinding(imageUniform.activeShaders(), name, bindingString, false,
shaderSources);
AssignResourceBinding(imageUniform.activeShaders(), name, bindingString, shaderSources);
}
return bindingIndex;
......@@ -998,7 +988,7 @@ void AssignTextureBindings(const GlslangSourceOptions &options,
? GetMappedSamplerNameOld(samplerUniform.name)
: GlslangGetMappedSamplerName(samplerUniform.name);
AssignResourceBinding(samplerUniform.activeShaders(), samplerName, bindingString, true,
AssignResourceBinding(samplerUniform.activeShaders(), samplerName, bindingString,
shaderSources);
}
}
......@@ -1037,26 +1027,6 @@ void CleanupUnusedEntities(bool useOldRewriteStructSamplers,
shaderSource.eraseLayoutAndQualifierSpecifiers(varyingName, "");
}
}
// Comment out inactive samplers. This relies on the fact that the shader compiler outputs
// uniforms to a single line.
for (const gl::UnusedUniform &unusedUniform : resources.unusedUniforms)
{
if (!unusedUniform.isSampler)
{
continue;
}
std::string uniformName = useOldRewriteStructSamplers
? GetMappedSamplerNameOld(unusedUniform.name)
: GlslangGetMappedSamplerName(unusedUniform.name);
for (IntermediateShaderSource &shaderSource : *shaderSources)
{
shaderSource.eraseLayoutAndQualifierSpecifiers(uniformName,
kInactiveVariableSubstitution);
}
}
}
constexpr gl::ShaderMap<EShLanguage> kShLanguageMap = {
......
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