SpirvShader: Fully initialize variables in emitSamplerFunction()
Let's just initialize these to zero, and let the optimizer remove redundant assignments.
Bug: b/136149446
Change-Id: Ia776bae4433f78f5a66b16f275e728a70dd4e18d
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/33468
Tested-by: Ben Clayton <bclayton@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
diff --git a/src/Pipeline/SpirvShaderSampling.cpp b/src/Pipeline/SpirvShaderSampling.cpp
index 6255726..87bba39 100644
--- a/src/Pipeline/SpirvShaderSampling.cpp
+++ b/src/Pipeline/SpirvShaderSampling.cpp
@@ -125,12 +125,12 @@
Pointer<SIMD::Float> out = function.Arg<3>();
Pointer<Byte> constants = function.Arg<4>();
- SIMD::Float uvw[4];
- SIMD::Float q;
- SIMD::Float lodOrBias; // Explicit level-of-detail, or bias added to the implicit level-of-detail (depending on samplerMethod).
- Vector4f dsx;
- Vector4f dsy;
- Vector4f offset;
+ SIMD::Float uvw[4] = {0, 0, 0, 0};
+ SIMD::Float q = 0;
+ SIMD::Float lodOrBias = 0; // Explicit level-of-detail, or bias added to the implicit level-of-detail (depending on samplerMethod).
+ Vector4f dsx = {0, 0, 0, 0};
+ Vector4f dsy = {0, 0, 0, 0};
+ Vector4f offset = {0, 0, 0, 0};
SamplerFunction samplerFunction = instruction.getSamplerFunction();
uint32_t i = 0;