Commit ac3a4a49 by Chris Forbes

Remove Sampler::State::srgb

sRGB decode is controlled by format, not extra state. There is also no 565 sRGB format in Vulkan. Also remove the 5 and 6bit sRGB LUTs since they are no longer used. Change-Id: Iea8770a50e4ef77004dc66d4a9867df62e7c2aaf Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/30368 Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarChris Forbes <chrisforbes@google.com>
parent 2acaccd3
......@@ -88,7 +88,6 @@ namespace sw
state.addressingModeV = getAddressingModeV();
state.addressingModeW = getAddressingModeW();
state.mipmapFilter = mipmapFilter();
state.sRGB = (sRGB && textureFormat.isSRGBreadable()) || textureFormat.isSRGBformat();
state.swizzle = swizzle;
state.highPrecisionFiltering = highPrecisionFiltering;
state.compare = getCompareFunc();
......@@ -278,11 +277,6 @@ namespace sw
addressingModeW = addressingMode;
}
void Sampler::setReadSRGB(bool sRGB)
{
this->sRGB = sRGB;
}
void Sampler::setMaxAnisotropy(float maxAnisotropy)
{
texture.maxAnisotropy = maxAnisotropy;
......
......@@ -157,7 +157,6 @@ namespace sw
AddressingMode addressingModeV;
AddressingMode addressingModeW;
MipmapType mipmapFilter;
bool sRGB;
VkComponentMapping swizzle;
bool highPrecisionFiltering;
CompareFunc compare;
......@@ -182,7 +181,6 @@ namespace sw
void setAddressingModeU(AddressingMode addressingMode);
void setAddressingModeV(AddressingMode addressingMode);
void setAddressingModeW(AddressingMode addressingMode);
void setReadSRGB(bool sRGB);
void setMaxAnisotropy(float maxAnisotropy);
void setHighPrecisionFiltering(bool highPrecisionFiltering);
void setCompareFunc(CompareFunc compare);
......
......@@ -267,16 +267,6 @@ namespace sw
sRGBtoLinear8_16[i] = (unsigned short)(sw::sRGBtoLinear((float)i / 0xFF) * 0xFFFF + 0.5f);
}
for(int i = 0; i < 64; i++)
{
sRGBtoLinear6_16[i] = (unsigned short)(sw::sRGBtoLinear((float)i / 0x3F) * 0xFFFF + 0.5f);
}
for(int i = 0; i < 32; i++)
{
sRGBtoLinear5_16[i] = (unsigned short)(sw::sRGBtoLinear((float)i / 0x1F) * 0xFFFF + 0.5f);
}
for(int i = 0; i < 0x1000; i++)
{
linearToSRGB12_16[i] = (unsigned short)(clamp(sw::linearToSRGB((float)i / 0x0FFF) * 0xFFFF + 0.5f, 0.0f, (float)0xFFFF));
......
......@@ -68,8 +68,6 @@ namespace sw
word4 mask565Q[8];
unsigned short sRGBtoLinear8_16[256];
unsigned short sRGBtoLinear6_16[64];
unsigned short sRGBtoLinear5_16[32];
unsigned short linearToSRGB12_16[4096];
unsigned short sRGBtoLinear12_16[4096];
......
......@@ -1684,22 +1684,13 @@ namespace sw
}
else ASSERT(false);
if(state.sRGB)
if (state.textureFormat.isSRGBformat())
{
if(state.textureFormat == VK_FORMAT_R5G6B5_UNORM_PACK16)
{
sRGBtoLinear16_5_16(c.x);
sRGBtoLinear16_6_16(c.y);
sRGBtoLinear16_5_16(c.z);
}
else
for(int i = 0; i < textureComponentCount(); i++)
{
for(int i = 0; i < textureComponentCount(); i++)
if(isRGBComponent(i))
{
if(isRGBComponent(i))
{
sRGBtoLinear16_8_16(c[i]);
}
sRGBtoLinear16_8_16(c[i]);
}
}
}
......@@ -2278,30 +2269,6 @@ namespace sw
c = Insert(c, *Pointer<Short>(LUT + 2 * Int(Extract(c, 3))), 3);
}
void SamplerCore::sRGBtoLinear16_6_16(Short4 &c)
{
c = As<UShort4>(c) >> 10;
Pointer<Byte> LUT = Pointer<Byte>(constants + OFFSET(Constants,sRGBtoLinear6_16));
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_16(Short4 &c)
{
c = As<UShort4>(c) >> 11;
Pointer<Byte> LUT = Pointer<Byte>(constants + OFFSET(Constants,sRGBtoLinear5_16));
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);
}
bool SamplerCore::hasFloatTexture() const
{
return state.textureFormat.isFloatFormat();
......
......@@ -96,8 +96,6 @@ namespace sw
void convertSigned15(Float4 &cf, Short4 &ci);
void convertUnsigned16(Float4 &cf, Short4 &ci);
void sRGBtoLinear16_8_16(Short4 &c);
void sRGBtoLinear16_6_16(Short4 &c);
void sRGBtoLinear16_5_16(Short4 &c);
bool hasFloatTexture() const;
bool hasUnnormalizedIntegerTexture() const;
......
......@@ -80,7 +80,6 @@ void SpirvShader::emitSamplerFunction(
samplerState.addressingModeW = convertAddressingMode(2, sampler->addressModeW, imageView->getType());
samplerState.mipmapFilter = convertMipmapMode(sampler);
samplerState.sRGB = imageView->getFormat().isSRGBformat();
samplerState.swizzle = imageView->getComponentMapping();
samplerState.highPrecisionFiltering = false;
samplerState.compare = COMPARE_BYPASS; ASSERT(sampler->compareEnable == VK_FALSE); // TODO(b/129523279)
......
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