Fix potentially uninitialized variables.
Bug 15387371
Change-Id: Ie0486feeebc6e4bceba148bea69f2d1ee1d1ffd8
Reviewed-on: https://swiftshader-review.googlesource.com/4499
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
diff --git a/src/Shader/PixelPipeline.cpp b/src/Shader/PixelPipeline.cpp
index 24ffd9b..0879ce9 100644
--- a/src/Shader/PixelPipeline.cpp
+++ b/src/Shader/PixelPipeline.cpp
@@ -1,26 +1,26 @@
-// SwiftShader Software Renderer
-//
-// Copyright(c) 2015 Google Inc.
-//
-// All rights reserved. No part of this software may be copied, distributed, transmitted,
-// transcribed, stored in a retrieval system, translated into any human or computer
-// language by any means, or disclosed to third parties without the explicit written
-// agreement of Google Inc. Without such an agreement, no rights or licenses, express
-// or implied, including but not limited to any patent rights, are granted to you.
-//
-
-#include "PixelPipeline.hpp"
-#include "Renderer.hpp"
-#include "SamplerCore.hpp"
-
-namespace sw
-{
- extern bool postBlendSRGB;
-
- void PixelPipeline::setBuiltins(PixelRoutine::Registers &rBase, Int &x, Int &y, Float4(&z)[4], Float4 &w)
- {
- Registers& r = *static_cast<Registers*>(&rBase);
-
+// SwiftShader Software Renderer
+//
+// Copyright(c) 2015 Google Inc.
+//
+// All rights reserved. No part of this software may be copied, distributed, transmitted,
+// transcribed, stored in a retrieval system, translated into any human or computer
+// language by any means, or disclosed to third parties without the explicit written
+// agreement of Google Inc. Without such an agreement, no rights or licenses, express
+// or implied, including but not limited to any patent rights, are granted to you.
+//
+
+#include "PixelPipeline.hpp"
+#include "Renderer.hpp"
+#include "SamplerCore.hpp"
+
+namespace sw
+{
+ extern bool postBlendSRGB;
+
+ void PixelPipeline::setBuiltins(PixelRoutine::Registers &rBase, Int &x, Int &y, Float4(&z)[4], Float4 &w)
+ {
+ Registers& r = *static_cast<Registers*>(&rBase);
+
if(state.color[0].component & 0x1) r.diffuse.x = convertFixed12(r.v[0].x); else r.diffuse.x = Short4(0x1000);
if(state.color[0].component & 0x2) r.diffuse.y = convertFixed12(r.v[0].y); else r.diffuse.y = Short4(0x1000);
if(state.color[0].component & 0x4) r.diffuse.z = convertFixed12(r.v[0].z); else r.diffuse.z = Short4(0x1000);
@@ -29,11 +29,11 @@
if(state.color[1].component & 0x1) r.specular.x = convertFixed12(r.v[1].x); else r.specular.x = Short4(0x0000, 0x0000, 0x0000, 0x0000);
if(state.color[1].component & 0x2) r.specular.y = convertFixed12(r.v[1].y); else r.specular.y = Short4(0x0000, 0x0000, 0x0000, 0x0000);
if(state.color[1].component & 0x4) r.specular.z = convertFixed12(r.v[1].z); else r.specular.z = Short4(0x0000, 0x0000, 0x0000, 0x0000);
- if(state.color[1].component & 0x8) r.specular.w = convertFixed12(r.v[1].w); else r.specular.w = Short4(0x0000, 0x0000, 0x0000, 0x0000);
- }
-
+ if(state.color[1].component & 0x8) r.specular.w = convertFixed12(r.v[1].w); else r.specular.w = Short4(0x0000, 0x0000, 0x0000, 0x0000);
+ }
+
void PixelPipeline::fixedFunction(Registers& r)
- {
+ {
r.current = r.diffuse;
Vector4s temp(0x0000, 0x0000, 0x0000, 0x0000);
@@ -54,9 +54,9 @@
blendTexture(r, temp, texture, stage);
}
- specularPixel(r.current, r.specular);
- }
-
+ specularPixel(r.current, r.specular);
+ }
+
void PixelPipeline::applyShader(PixelRoutine::Registers &rBase, Int cMask[4])
{
Registers& r = *static_cast<Registers*>(&rBase);
@@ -257,12 +257,12 @@
}
}
}
- }
-
- Bool PixelPipeline::alphaTest(PixelRoutine::Registers &rBase, Int cMask[4])
- {
- Registers& r = *static_cast<Registers*>(&rBase);
-
+ }
+
+ Bool PixelPipeline::alphaTest(PixelRoutine::Registers &rBase, Int cMask[4])
+ {
+ Registers& r = *static_cast<Registers*>(&rBase);
+
r.current.x = Min(r.current.x, Short4(0x0FFF, 0x0FFF, 0x0FFF, 0x0FFF)); r.current.x = Max(r.current.x, Short4(0x0000, 0x0000, 0x0000, 0x0000));
r.current.y = Min(r.current.y, Short4(0x0FFF, 0x0FFF, 0x0FFF, 0x0FFF)); r.current.y = Max(r.current.y, Short4(0x0000, 0x0000, 0x0000, 0x0000));
r.current.z = Min(r.current.z, Short4(0x0FFF, 0x0FFF, 0x0FFF, 0x0FFF)); r.current.z = Max(r.current.z, Short4(0x0000, 0x0000, 0x0000, 0x0000));
@@ -299,13 +299,13 @@
pass = pass | cMask[q];
}
- return pass != 0x0;
- }
-
- void PixelPipeline::rasterOperation(PixelRoutine::Registers &rBase, Float4 &fog, Pointer<Byte> cBuffer[4], Int &x, Int sMask[4], Int zMask[4], Int cMask[4])
- {
- Registers& r = *static_cast<Registers*>(&rBase);
-
+ return pass != 0x0;
+ }
+
+ void PixelPipeline::rasterOperation(PixelRoutine::Registers &rBase, Float4 &fog, Pointer<Byte> cBuffer[4], Int &x, Int sMask[4], Int zMask[4], Int cMask[4])
+ {
+ Registers& r = *static_cast<Registers*>(&rBase);
+
if(!state.colorWriteActive(0))
{
return;
@@ -377,9 +377,9 @@
break;
default:
ASSERT(false);
- }
- }
-
+ }
+ }
+
void PixelPipeline::blendTexture(Registers &r, Vector4s &temp, Vector4s &texture, int stage)
{
Vector4s *arg1;
@@ -1172,8 +1172,8 @@
default:
ASSERT(false);
}
- }
-
+ }
+
void PixelPipeline::fogBlend(Registers &r, Vector4s ¤t, Float4 &f)
{
if(!state.fogActive)
@@ -1197,8 +1197,8 @@
current.x += As<Short4>(MulHigh(invFog, *Pointer<UShort4>(r.data + OFFSET(DrawData, fog.color4[0]))));
current.y += As<Short4>(MulHigh(invFog, *Pointer<UShort4>(r.data + OFFSET(DrawData, fog.color4[1]))));
current.z += As<Short4>(MulHigh(invFog, *Pointer<UShort4>(r.data + OFFSET(DrawData, fog.color4[2]))));
- }
-
+ }
+
void PixelPipeline::specularPixel(Vector4s ¤t, Vector4s &specular)
{
if(!state.specularAdd)
@@ -1209,8 +1209,8 @@
current.x = AddSat(current.x, specular.x);
current.y = AddSat(current.y, specular.y);
current.z = AddSat(current.z, specular.z);
- }
-
+ }
+
void PixelPipeline::sampleTexture(Registers &r, Vector4s &c, int coordinates, int stage, bool project)
{
Float4 u = r.v[2 + coordinates].x;
@@ -1264,7 +1264,7 @@
r.cycles[PERF_TEX] += Ticks() - texTime;
#endif
}
-
+
Short4 PixelPipeline::convertFixed12(RValue<Float4> cf)
{
return RoundShort4(cf * Float4(0x1000));
@@ -1290,7 +1290,7 @@
cf.z = convertSigned12(cs.z);
cf.w = convertSigned12(cs.w);
}
-
+
void PixelPipeline::writeDestination(Registers &r, Vector4s &d, const Dst &dst)
{
switch(dst.type)
@@ -1324,7 +1324,7 @@
ASSERT(false);
}
}
-
+
Vector4s PixelPipeline::fetchRegisterS(Registers &r, const Src &src)
{
Vector4s *reg;
@@ -1348,8 +1348,7 @@
case Shader::PARAMETER_TEXTURE: reg = &r.ts[i]; break;
case Shader::PARAMETER_VOID: return r.rs[0]; // Dummy
case Shader::PARAMETER_FLOAT4LITERAL: return r.rs[0]; // Dummy
- default:
- ASSERT(false);
+ default: ASSERT(false); return r.rs[0];
}
const Short4 &x = (*reg)[(src.swizzle >> 0) & 0x3];
@@ -1451,7 +1450,7 @@
return mod;
}
-
+
void PixelPipeline::MOV(Vector4s &dst, Vector4s &src0)
{
dst.x = src0.x;
@@ -1964,5 +1963,5 @@
t0 = AddSat(t0, src0.y);
dst.y = t0;
}
-}
-
+}
+