Disable SPIR-V validation during pipeline compilation

Validation is costly and it's the applications' responsibility to send
valid SPIR-V to the ICD, so we shouldn't do it in Release builds.

Note that while in Debug builds we already perform validation during
creation of the shader module (to catch issues even sooner), we should
validate again during pipeline compilation to ensure we (or the tooling
we use) didn't alter the SPIR-V to become invalid.

Bug: b/158228522
Change-Id: I5b8153f0397c609d139e37909868b5836d57d40e
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/51168
Reviewed-by: Sean Risser <srisser@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Vulkan/VkPipeline.cpp b/src/Vulkan/VkPipeline.cpp
index a7a6611..962af58 100644
--- a/src/Vulkan/VkPipeline.cpp
+++ b/src/Vulkan/VkPipeline.cpp
@@ -75,7 +75,12 @@
 	}
 
 	std::vector<uint32_t> optimized;
-	opt.Run(code.data(), code.size(), &optimized);
+	spvtools::OptimizerOptions options;
+#if defined(NDEBUG)
+	options.set_run_validator(false);
+#endif
+
+	opt.Run(code.data(), code.size(), &optimized, options);
 
 	if(false)
 	{