aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Neto <dneto@google.com>2019-09-04 11:17:14 -0400
committerdan sinclair <dsinclair@chromium.org>2019-09-04 11:17:14 -0400
commit16b8e09b3d934c04bce227874fcc14b6f4051d72 (patch)
tree32ea40ffa929ada142420b642c99d0f5b5b029a3
parent6e16cab40484dd0cf488ae63fc41f882068712e9 (diff)
downloadamber-16b8e09b3d934c04bce227874fcc14b6f4051d72.tar.gz
Avoid unused var warning when SPIRV-Tools not used (#626)
-rw-r--r--src/shader_compiler.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/shader_compiler.cc b/src/shader_compiler.cc
index a5e98aa..0fd4cf3 100644
--- a/src/shader_compiler.cc
+++ b/src/shader_compiler.cc
@@ -144,13 +144,18 @@ std::pair<Result, std::vector<uint32_t>> ShaderCompiler::Compile(
return {Result("Invalid shader format"), results};
}
-#if AMBER_ENABLE_SPIRV_TOOLS
+ // Validate the shader, but have an option to disable that.
+ // Always use the data member, to avoid an unused-variable warning
+ // when not using SPIRV-Tools support.
if (!disable_spirv_validation_) {
+#if AMBER_ENABLE_SPIRV_TOOLS
spvtools::ValidatorOptions options;
if (!tools.Validate(results.data(), results.size(), options))
return {Result("Invalid shader: " + spv_errors), {}};
+#endif // AMBER_ENABLE_SPIRV_TOOLS
}
+#if AMBER_ENABLE_SPIRV_TOOLS
// Optimize the shader if any optimizations were specified.
if (!shader_info->GetShaderOptimizations().empty()) {
spvtools::Optimizer optimizer(target_env);