Commit 57642356 by Nicolas Capens Committed by Nicolas Capens

Don't perform component swizzling on a null texture.

When sampling from an incomplete texture, the OpenGL spec states that (0, 0, 0, 1) will be returned to the shader from the texture lookup function. Swizzling is only described for filtered texture values. Change-Id: Ie8a02b3b0b9e571fd2f86302e777a4ff985da022 Reviewed-on: https://swiftshader-review.googlesource.com/17488Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 3e5f6fd5
...@@ -131,7 +131,9 @@ namespace sw ...@@ -131,7 +131,9 @@ namespace sw
convertFixed12(c, cf); convertFixed12(c, cf);
} }
if(fixed12 && !hasFloatTexture()) if(fixed12)
{
if(!hasFloatTexture())
{ {
if(state.textureFormat == FORMAT_R5G6B5) if(state.textureFormat == FORMAT_R5G6B5)
{ {
...@@ -155,7 +157,7 @@ namespace sw ...@@ -155,7 +157,7 @@ namespace sw
} }
} }
if(fixed12 && state.textureFilter != FILTER_GATHER) if(state.textureFilter != FILTER_GATHER)
{ {
int componentCount = textureComponentCount(); int componentCount = textureComponentCount();
short defaultColorValue = colorsDefaultToZero ? 0x0000 : 0x1000; short defaultColorValue = colorsDefaultToZero ? 0x0000 : 0x1000;
...@@ -254,13 +256,11 @@ namespace sw ...@@ -254,13 +256,11 @@ namespace sw
ASSERT(false); ASSERT(false);
} }
} }
}
if(fixed12 && if((state.swizzleR != SWIZZLE_RED) ||
((state.swizzleR != SWIZZLE_RED) ||
(state.swizzleG != SWIZZLE_GREEN) || (state.swizzleG != SWIZZLE_GREEN) ||
(state.swizzleB != SWIZZLE_BLUE) || (state.swizzleB != SWIZZLE_BLUE) ||
(state.swizzleA != SWIZZLE_ALPHA))) (state.swizzleA != SWIZZLE_ALPHA))
{ {
const Vector4s col(c); const Vector4s col(c);
applySwizzle(state.swizzleR, c.x, col); applySwizzle(state.swizzleR, c.x, col);
...@@ -268,6 +268,8 @@ namespace sw ...@@ -268,6 +268,8 @@ namespace sw
applySwizzle(state.swizzleB, c.z, col); applySwizzle(state.swizzleB, c.z, col);
applySwizzle(state.swizzleA, c.w, col); applySwizzle(state.swizzleA, c.w, col);
} }
}
}
return c; return c;
} }
...@@ -484,7 +486,6 @@ namespace sw ...@@ -484,7 +486,6 @@ namespace sw
ASSERT(false); ASSERT(false);
} }
} }
}
if((state.swizzleR != SWIZZLE_RED) || if((state.swizzleR != SWIZZLE_RED) ||
(state.swizzleG != SWIZZLE_GREEN) || (state.swizzleG != SWIZZLE_GREEN) ||
...@@ -497,6 +498,7 @@ namespace sw ...@@ -497,6 +498,7 @@ namespace sw
applySwizzle(state.swizzleB, c.z, col); applySwizzle(state.swizzleB, c.z, col);
applySwizzle(state.swizzleA, c.w, col); applySwizzle(state.swizzleA, c.w, col);
} }
}
return c; return c;
} }
......
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