Translator: Fix SPIR-V translation without "variables" flag This flag is now assumed to always be true for the SPIR-V (and MSL) translators. They use the collected variables during translation. Bug: chromium:1447314 Change-Id: I69d31ce8144aec0bd2a7263bad6e5a366e922740 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4567830 Auto-Submit: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
diff --git a/src/compiler/translator/TranslatorVulkan.h b/src/compiler/translator/TranslatorVulkan.h index 6939eb8..59a030b 100644 --- a/src/compiler/translator/TranslatorVulkan.h +++ b/src/compiler/translator/TranslatorVulkan.h
@@ -32,6 +32,9 @@ PerformanceDiagnostics *perfDiagnostics) override; bool shouldFlattenPragmaStdglInvariantAll() override; + // Need to collect variables so that RemoveInactiveInterfaceVariables works. + bool shouldCollectVariables(const ShCompileOptions &compileOptions) override { return true; } + [[nodiscard]] bool translateImpl(TIntermBlock *root, const ShCompileOptions &compileOptions, PerformanceDiagnostics *perfDiagnostics,
diff --git a/src/tests/gl_tests/GLSLTest.cpp b/src/tests/gl_tests/GLSLTest.cpp index 1d88a2a..c003cc0 100644 --- a/src/tests/gl_tests/GLSLTest.cpp +++ b/src/tests/gl_tests/GLSLTest.cpp
@@ -1038,6 +1038,21 @@ ANGLE_GL_PROGRAM(program, essl1_shaders::vs::Simple(), kFS); } +// Test that inactive uniforms of struct type don't cause any errors. +TEST_P(GLSLTest, InactiveStructUniform) +{ + constexpr char kVS[] = R"( +uniform struct +{ + vec4 c; +} s; +void main() +{ +})"; + + ANGLE_GL_PROGRAM(program, kVS, essl1_shaders::fs::Red()); +} + // Test that struct with same name can be declared in inner scope. TEST_P(GLSLTest, SameNameStructInInnerScope) {