Commit 66be2450 by Nicolas Capens

Work around a GCC miscompilation issue.

Bug 18470793 Change-Id: Idac85c738810db112e7af56f5e1635c2ac6d325c Reviewed-on: https://swiftshader-review.googlesource.com/1841Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com>
parent 66d40e8e
......@@ -97,11 +97,12 @@ namespace sw
{
Interpolant color[2];
Interpolant texture[8];
Interpolant fog;
};
Interpolant interpolant[10];
};
Interpolant fog;
};
struct State : States
......
......@@ -48,12 +48,13 @@ namespace sw
{
PlaneEquation C[2][4];
PlaneEquation T[8][4];
PlaneEquation f;
};
PlaneEquation V[10][4];
};
PlaneEquation f;
float area;
// Masks for two-sided stencil
......
......@@ -250,11 +250,9 @@ namespace sw
r.Dw = *Pointer<Float4>(r.primitive + OFFSET(Primitive,w.C), 16) + yyyy * *Pointer<Float4>(r.primitive + OFFSET(Primitive,w.B), 16);
}
for(int interpolant = 0; interpolant < 11; interpolant++)
for(int interpolant = 0; interpolant < 10; interpolant++)
{
int componentCount = interpolant < 10 ? 4 : 1; // Fog only has one component
for(int component = 0; component < componentCount; component++)
for(int component = 0; component < 4; component++)
{
if(state.interpolant[interpolant].component & (1 << component))
{
......@@ -268,6 +266,16 @@ namespace sw
}
}
if(state.fog.component)
{
r.Df = *Pointer<Float4>(r.primitive + OFFSET(Primitive,f.C), 16);
if(!state.fog.flat)
{
r.Df += yyyy * *Pointer<Float4>(r.primitive + OFFSET(Primitive,f.B), 16);
}
}
Short4 xLeft[4];
Short4 xRight[4];
......
......@@ -100,18 +100,20 @@ namespace sw
state.pointSizeRegister = Pts;
}
for(int interpolant = 0; interpolant < 11; interpolant++)
for(int interpolant = 0; interpolant < 10; interpolant++)
{
int componentCount = interpolant < 10 ? 4 : 1; // Fog only has one component
for(int component = 0; component < componentCount; component++)
for(int component = 0; component < 4; component++)
{
state.gradient[interpolant][component].attribute = 0x3F;
state.gradient[interpolant][component].attribute = Unused;
state.gradient[interpolant][component].flat = false;
state.gradient[interpolant][component].wrap = false;
}
}
state.fog.attribute = Unused;
state.fog.flat = false;
state.fog.wrap = false;
const bool point = context->isDrawPoint(true);
const bool sprite = context->pointSpriteActive();
const bool flatShading = (context->shadingMode == SHADING_FLAT) || point;
......
......@@ -52,7 +52,7 @@ namespace sw
struct Gradient
{
unsigned char attribute : 6;
unsigned char attribute : BITS(Unused);
bool flat : 1;
bool wrap : 1;
};
......@@ -63,11 +63,12 @@ namespace sw
{
Gradient color[2][4];
Gradient texture[8][4];
Gradient fog;
};
Gradient gradient[10][4];
};
Gradient fog;
};
struct State : States
......
......@@ -18,11 +18,11 @@
namespace sw
{
enum Out // Default vertex attribute semantic
enum Out // Default vertex output semantic
{
Pos = 0,
D0 = 1,
D1 = 2,
D0 = 1, // Diffuse
D1 = 2, // Specular
T0 = 3,
T1 = 4,
T2 = 5,
......@@ -31,8 +31,9 @@ namespace sw
T5 = 8,
T6 = 9,
T7 = 10,
Fog = 11, // x component
Pts = Fog // y component
Fog = 11, // x component
Pts = Fog, // y component
Unused
};
struct UVWQ
......
......@@ -127,7 +127,7 @@ namespace sw
Long interpTime = Ticks();
#endif
Float4 yyyy = Float4(Float(y)) + *Pointer<Float4>(r.primitive + OFFSET(Primitive, yQuad), 16);
Float4 yyyy = Float4(Float(y)) + *Pointer<Float4>(r.primitive + OFFSET(Primitive,yQuad), 16);
// Centroid locations
Float4 XXXX = Float4(0.0f);
......
......@@ -451,23 +451,26 @@ namespace sw
*Pointer<Float4>(primitive + OFFSET(Primitive,z.C), 16) = C;
}
for(int interpolant = 0; interpolant < 11; interpolant++)
for(int interpolant = 0; interpolant < 10; interpolant++)
{
int componentCount = interpolant < 10 ? 4 : 1; // Fog only has one component
for(int component = 0; component < componentCount; component++)
for(int component = 0; component < 4; component++)
{
int attribute = state.gradient[interpolant][component].attribute;
bool flat = state.gradient[interpolant][component].flat;
bool wrap = state.gradient[interpolant][component].wrap;
if(attribute < 12)
if(attribute != Unused)
{
setupGradient(primitive, tri, w012, M, v0, v1, v2, OFFSET(Vertex,v[attribute][component]), OFFSET(Primitive,V[interpolant][component]), flat, sprite, state.perspective, wrap, component);
}
}
}
if(state.fog.attribute == Fog)
{
setupGradient(primitive, tri, w012, M, v0, v1, v2, OFFSET(Vertex,f), OFFSET(Primitive,f), state.fog.flat, false, state.perspective, false, 0);
}
Return(true);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment