From 8265347fe80555517587dfaeb89b4c1e11ac7d0f Mon Sep 17 00:00:00 2001 From: David Neto Date: Wed, 4 Sep 2019 09:54:37 -0400 Subject: [PATCH] Avoid unused var warning when SPIRV-Tools not used --- src/shader_compiler.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/shader_compiler.cc b/src/shader_compiler.cc index a5e98aa36..0fd4cf302 100644 --- a/src/shader_compiler.cc +++ b/src/shader_compiler.cc @@ -144,13 +144,18 @@ std::pair> 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);