Constants::Constants()
{
- for(int i = 0; i < 256; i++)
- {
- sRGBtoLinear8[i] = (unsigned short)(sw::sRGBtoLinear((float)i / 0xFF) * 0x1000 + 0.5f);
- }
-
static const unsigned int transposeBit0[16] =
{
0x00000000,
invMaskD01X[i][3] = ~-(i >> 1 & 1);
}
+ for(int i = 0; i < 256; i++)
+ {
+ sRGBtoLinear8_12[i] = (unsigned short)(sw::sRGBtoLinear((float)i / 0xFF) * 0x1000 + 0.5f);
+ }
+
+ for(int i = 0; i < 64; i++)
+ {
+ sRGBtoLinear6_12[i] = (unsigned short)(sw::sRGBtoLinear((float)i / 0x3F) * 0x1000 + 0.5f);
+ }
+
+ for(int i = 0; i < 32; i++)
+ {
+ sRGBtoLinear5_12[i] = (unsigned short)(sw::sRGBtoLinear((float)i / 0x1F) * 0x1000 + 0.5f);
+ }
+
for(int i = 0; i < 0x1000; i++)
{
- linToSRGB12_16[i] = (unsigned short)(clamp(sw::linearToSRGB((float)i / 0x0FFF) * 0xFFFF + 0.5f, 0.0f, (float)0xFFFF));
- sRGBtoLin12_16[i] = (unsigned short)(clamp(sw::sRGBtoLinear((float)i / 0x0FFF) * 0xFFFF + 0.5f, 0.0f, (float)0xFFFF));
+ linearToSRGB12_16[i] = (unsigned short)(clamp(sw::linearToSRGB((float)i / 0x0FFF) * 0xFFFF + 0.5f, 0.0f, (float)0xFFFF));
+ sRGBtoLinear12_16[i] = (unsigned short)(clamp(sw::sRGBtoLinear((float)i / 0x0FFF) * 0xFFFF + 0.5f, 0.0f, (float)0xFFFF));
}
for(int q = 0; q < 4; q++)
struct Constants\r
{\r
Constants();\r
-\r
- unsigned short sRGBtoLinear8[256];\r
-\r
+ \r
unsigned int transposeBit0[16];\r
unsigned int transposeBit1[16];\r
unsigned int transposeBit2[16];\r
dword4 maskD01X[4];\r
dword4 invMaskD01X[4];\r
\r
- unsigned short linToSRGB12_16[4096];\r
- unsigned short sRGBtoLin12_16[4096];\r
+ unsigned short sRGBtoLinear8_12[256];\r
+ unsigned short sRGBtoLinear6_12[64];\r
+ unsigned short sRGBtoLinear5_12[32];\r
+\r
+ unsigned short linearToSRGB12_16[4096];\r
+ unsigned short sRGBtoLinear12_16[4096];\r
\r
// Centroid parameters\r
float4 sampleX[4][16];\r
if(postBlendSRGB && state.writeSRGB)
{
- sRGBtoLinear16_16(r, pixel);
+ sRGBtoLinear16_12_16(r, pixel);
}
// Final Color = ObjectColor * SourceBlendFactor + PixelColor * DestinationBlendFactor
if(postBlendSRGB && state.writeSRGB)
{
- linearToSRGB16_16(r, current);
+ linearToSRGB16_12_16(r, current);
}
if(exactColorRounding)
return Float4(cs) * Float4(1.0f / 0xFFFF);
}
- void PixelRoutine::sRGBtoLinear16_16(Registers &r, Vector4s &c)
+ void PixelRoutine::sRGBtoLinear16_12_16(Registers &r, Vector4s &c)
{
c.x = As<UShort4>(c.x) >> 4;
c.y = As<UShort4>(c.y) >> 4;
void PixelRoutine::sRGBtoLinear12_16(Registers &r, Vector4s &c)
{
- Pointer<Byte> LUT = r.constants + OFFSET(Constants,sRGBtoLin12_16);
+ Pointer<Byte> LUT = r.constants + OFFSET(Constants,sRGBtoLinear12_16);
c.x = Insert(c.x, *Pointer<Short>(LUT + 2 * Int(Extract(c.x, 0))), 0);
c.x = Insert(c.x, *Pointer<Short>(LUT + 2 * Int(Extract(c.x, 1))), 1);
c.z = Insert(c.z, *Pointer<Short>(LUT + 2 * Int(Extract(c.z, 3))), 3);
}
- void PixelRoutine::linearToSRGB16_16(Registers &r, Vector4s &c)
+ void PixelRoutine::linearToSRGB16_12_16(Registers &r, Vector4s &c)
{
c.x = As<UShort4>(c.x) >> 4;
c.y = As<UShort4>(c.y) >> 4;
void PixelRoutine::linearToSRGB12_16(Registers &r, Vector4s &c)
{
- Pointer<Byte> LUT = r.constants + OFFSET(Constants,linToSRGB12_16);
+ Pointer<Byte> LUT = r.constants + OFFSET(Constants,linearToSRGB12_16);
c.x = Insert(c.x, *Pointer<Short>(LUT + 2 * Int(Extract(c.x, 0))), 0);
c.x = Insert(c.x, *Pointer<Short>(LUT + 2 * Int(Extract(c.x, 1))), 1);
Float4 convertUnsigned16(UShort4 cs);
UShort4 convertFixed16(Float4 &cf, bool saturate = true);
void convertFixed16(Vector4s &cs, Vector4f &cf, bool saturate = true);
- void sRGBtoLinear16_16(Registers &r, Vector4s &c);
+ void sRGBtoLinear16_12_16(Registers &r, Vector4s &c);
void sRGBtoLinear12_16(Registers &r, Vector4s &c);
- void linearToSRGB16_16(Registers &r, Vector4s &c);
+ void linearToSRGB16_12_16(Registers &r, Vector4s &c);
void linearToSRGB12_16(Registers &r, Vector4s &c);
Float4 sRGBtoLinear(const Float4 &x);
Float4 linearToSRGB(const Float4 &x);
{
if(state.sRGB && isRGBComponent(component))
{
- sRGBtoLinear16_12(c[component]); // FIXME: Perform linearization at surface level for read-only textures
+ sRGBtoLinear16_8_12(c[component]); // FIXME: Perform linearization at surface level for read-only textures
}
else
{
{
if(state.sRGB && isRGBComponent(component))
{
- sRGBtoLinear16_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
convertSigned12(c[component], cs[component]);
}
else
cf = Float4(As<UShort4>(cs)) * Float4(1.0f / 0xFFFF);
}
- void SamplerCore::sRGBtoLinear16_12(Short4 &c)
+ void SamplerCore::sRGBtoLinear16_8_12(Short4 &c)
{
c = As<UShort4>(c) >> 8;
- Pointer<Byte> LUT = Pointer<Byte>(constants + OFFSET(Constants,sRGBtoLinear8));
+ Pointer<Byte> LUT = Pointer<Byte>(constants + OFFSET(Constants,sRGBtoLinear8_12));
+
+ c = Insert(c, *Pointer<Short>(LUT + 2 * Int(Extract(c, 0))), 0);
+ c = Insert(c, *Pointer<Short>(LUT + 2 * Int(Extract(c, 1))), 1);
+ c = Insert(c, *Pointer<Short>(LUT + 2 * Int(Extract(c, 2))), 2);
+ c = Insert(c, *Pointer<Short>(LUT + 2 * Int(Extract(c, 3))), 3);
+ }
+
+ void SamplerCore::sRGBtoLinear16_6_12(Short4 &c)
+ {
+ c = As<UShort4>(c) >> 10;
+
+ Pointer<Byte> LUT = Pointer<Byte>(constants + OFFSET(Constants,sRGBtoLinear6_12));
+
+ c = Insert(c, *Pointer<Short>(LUT + 2 * Int(Extract(c, 0))), 0);
+ c = Insert(c, *Pointer<Short>(LUT + 2 * Int(Extract(c, 1))), 1);
+ c = Insert(c, *Pointer<Short>(LUT + 2 * Int(Extract(c, 2))), 2);
+ c = Insert(c, *Pointer<Short>(LUT + 2 * Int(Extract(c, 3))), 3);
+ }
+
+ void SamplerCore::sRGBtoLinear16_5_12(Short4 &c)
+ {
+ c = As<UShort4>(c) >> 11;
+
+ Pointer<Byte> LUT = Pointer<Byte>(constants + OFFSET(Constants,sRGBtoLinear5_12));
c = Insert(c, *Pointer<Short>(LUT + 2 * Int(Extract(c, 0))), 0);
c = Insert(c, *Pointer<Short>(LUT + 2 * Int(Extract(c, 1))), 1);
void convertSigned12(Float4 &cf, Short4 &ci);\r
void convertSigned15(Float4 &cf, Short4 &ci);\r
void convertUnsigned16(Float4 &cf, Short4 &ci);\r
- void sRGBtoLinear16_12(Short4 &c);\r
+ void sRGBtoLinear16_8_12(Short4 &c);\r
+ void sRGBtoLinear16_6_12(Short4 &c);\r
+ void sRGBtoLinear16_5_12(Short4 &c);\r
\r
bool hasFloatTexture() const;\r
bool hasUnsignedTextureComponent(int component) const;\r