SpirvShaderDebugger: Fix store() of arrays

```
template<typename T, std::size_t N>
void store(const rr::RValue<rr::Pointer<rr::Byte>> &ptr, const std::array<T, N> &val)
```

was completely broken as it was using `sizeof(T)` for element offsets.
All uses of this overload use Reactor values for T, and so `sizeof(T)` evaluates to the size of the compiler type, not the runtime data type.

Also remove the useless `for(int i = 0; i < N; i++)` in `buildGlobal()`.
This iterator isn't used, so we're just doing the same calls to `put()` `N` times.

Bug: b/170383642
Change-Id: I9ba9efce07e886087124118122de56a4d31c5503
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/49129
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Ben Clayton <bclayton@google.com>
diff --git a/src/Pipeline/SpirvShaderDebugger.cpp b/src/Pipeline/SpirvShaderDebugger.cpp
index 25331f6..45c01ba 100644
--- a/src/Pipeline/SpirvShaderDebugger.cpp
+++ b/src/Pipeline/SpirvShaderDebugger.cpp
@@ -146,28 +146,35 @@
 	});
 }
 
-// store() emits a store instruction to write sizeof(T) bytes from val into ptr.
+// store() emits a store instruction to copy val into ptr.
 template<typename T>
 void store(const rr::RValue<rr::Pointer<rr::Byte>> &ptr, const rr::RValue<T> &val)
 {
 	*rr::Pointer<T>(ptr) = val;
 }
 
-// store() emits a store instruction to write sizeof(T) bytes from val into ptr.
+// store() emits a store instruction to copy val into ptr.
 template<typename T>
 void store(const rr::RValue<rr::Pointer<rr::Byte>> &ptr, const T &val)
 {
 	*rr::Pointer<T>(ptr) = val;
 }
 
-// store() emits a store instruction to write sizeof(T) * N bytes from val into
-// ptr.
+// clang-format off
+template<typename T> struct ReactorTypeSize {};
+template<> struct ReactorTypeSize<rr::Int>    { static constexpr const int value = 4; };
+template<> struct ReactorTypeSize<rr::Float>  { static constexpr const int value = 4; };
+template<> struct ReactorTypeSize<rr::Int4>   { static constexpr const int value = 16; };
+template<> struct ReactorTypeSize<rr::Float4> { static constexpr const int value = 16; };
+// clang-format on
+
+// store() emits a store instruction to copy val into ptr.
 template<typename T, std::size_t N>
 void store(const rr::RValue<rr::Pointer<rr::Byte>> &ptr, const std::array<T, N> &val)
 {
 	for(std::size_t i = 0; i < N; i++)
 	{
-		store<T>(ptr + i * sizeof(T), val[i]);
+		store<T>(ptr + i * ReactorTypeSize<T>::value, val[i]);
 	}
 }
 
@@ -2346,10 +2353,7 @@
 {
 	for(int lane = 0; lane < sw::SIMD::Width; lane++)
 	{
-		for(int i = 0; i < N; i++)
-		{
-			globals.lanes[lane]->put(name, makeDbgValue(simd[lane]));
-		}
+		globals.lanes[lane]->put(name, makeDbgValue(simd[lane]));
 	}
 }