Commit 3a014ff6 by Nicolas Capens

Implement R5G6B5 to 4.12 normalization.

Bug 20891368 Change-Id: I492a3420facefed5a0ff7e469da54fd67bd68092 Reviewed-on: https://swiftshader-review.googlesource.com/3115Reviewed-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 27496315
...@@ -106,6 +106,30 @@ namespace sw ...@@ -106,6 +106,30 @@ namespace sw
if(fixed12 && !hasFloatTexture()) if(fixed12 && !hasFloatTexture())
{ {
if(has16bitTextureFormat())
{
switch(state.textureFormat)
{
case FORMAT_R5G6B5:
if(state.sRGB)
{
sRGBtoLinear16_5_12(c.x);
sRGBtoLinear16_6_12(c.y);
sRGBtoLinear16_5_12(c.z);
}
else
{
c.x = MulHigh(As<UShort4>(c.x), UShort4(0x10000000 / 0xF800));
c.y = MulHigh(As<UShort4>(c.y), UShort4(0x10000000 / 0xFC00));
c.z = MulHigh(As<UShort4>(c.z), UShort4(0x10000000 / 0xF800));
}
break;
default:
ASSERT(false);
}
}
else
{
for(int component = 0; component < textureComponentCount(); component++) for(int component = 0; component < textureComponentCount(); component++)
{ {
if(state.sRGB && isRGBComponent(component)) if(state.sRGB && isRGBComponent(component))
...@@ -125,6 +149,7 @@ namespace sw ...@@ -125,6 +149,7 @@ namespace sw
} }
} }
} }
}
if(fixed12 && state.textureFilter != FILTER_GATHER) if(fixed12 && state.textureFilter != FILTER_GATHER)
{ {
...@@ -264,6 +289,34 @@ namespace sw ...@@ -264,6 +289,34 @@ namespace sw
for(int component = 0; component < textureComponentCount(); component++) for(int component = 0; component < textureComponentCount(); component++)
{ {
if(has16bitTextureFormat())
{
switch(state.textureFormat)
{
case FORMAT_R5G6B5:
if(state.sRGB)
{
sRGBtoLinear16_5_12(cs.x);
sRGBtoLinear16_6_12(cs.y);
sRGBtoLinear16_5_12(cs.z);
convertSigned12(c.x, cs.x);
convertSigned12(c.y, cs.y);
convertSigned12(c.z, cs.z);
}
else
{
c.x = Float4(As<UShort4>(cs.x)) * Float4(1.0f / 0xF800);
c.y = Float4(As<UShort4>(cs.y)) * Float4(1.0f / 0xFC00);
c.z = Float4(As<UShort4>(cs.z)) * Float4(1.0f / 0xF800);
}
break;
default:
ASSERT(false);
}
}
else
{
if(state.sRGB && isRGBComponent(component)) if(state.sRGB && isRGBComponent(component))
{ {
sRGBtoLinear16_8_12(cs[component]); // FIXME: Perform linearization at surface level for read-only textures sRGBtoLinear16_8_12(cs[component]); // FIXME: Perform linearization at surface level for read-only textures
...@@ -282,6 +335,7 @@ namespace sw ...@@ -282,6 +335,7 @@ namespace sw
} }
} }
} }
}
int componentCount = textureComponentCount(); int componentCount = textureComponentCount();
......
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