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: Nicolas Capens <nicolascapens@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
diff --git a/src/Device/Sampler.cpp b/src/Device/Sampler.cpp
index 520f011..19e2365 100644
--- a/src/Device/Sampler.cpp
+++ b/src/Device/Sampler.cpp
@@ -88,7 +88,6 @@
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 @@
addressingModeW = addressingMode;
}
- void Sampler::setReadSRGB(bool sRGB)
- {
- this->sRGB = sRGB;
- }
-
void Sampler::setMaxAnisotropy(float maxAnisotropy)
{
texture.maxAnisotropy = maxAnisotropy;
diff --git a/src/Device/Sampler.hpp b/src/Device/Sampler.hpp
index 9f0e72f..af6c428 100644
--- a/src/Device/Sampler.hpp
+++ b/src/Device/Sampler.hpp
@@ -157,7 +157,6 @@
AddressingMode addressingModeV;
AddressingMode addressingModeW;
MipmapType mipmapFilter;
- bool sRGB;
VkComponentMapping swizzle;
bool highPrecisionFiltering;
CompareFunc compare;
@@ -182,7 +181,6 @@
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);
diff --git a/src/Pipeline/Constants.cpp b/src/Pipeline/Constants.cpp
index a7f5a6b..45e8b50 100644
--- a/src/Pipeline/Constants.cpp
+++ b/src/Pipeline/Constants.cpp
@@ -267,16 +267,6 @@
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));
diff --git a/src/Pipeline/Constants.hpp b/src/Pipeline/Constants.hpp
index eac6e6a..e3e2ee8 100644
--- a/src/Pipeline/Constants.hpp
+++ b/src/Pipeline/Constants.hpp
@@ -68,8 +68,6 @@
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];
diff --git a/src/Pipeline/SamplerCore.cpp b/src/Pipeline/SamplerCore.cpp
index d60baa8..4c56de6 100644
--- a/src/Pipeline/SamplerCore.cpp
+++ b/src/Pipeline/SamplerCore.cpp
@@ -1684,22 +1684,13 @@
}
else ASSERT(false);
- if(state.sRGB)
+ if (state.textureFormat.isSRGBformat())
{
- if(state.textureFormat == VK_FORMAT_R5G6B5_UNORM_PACK16)
+ for(int i = 0; i < textureComponentCount(); i++)
{
- sRGBtoLinear16_5_16(c.x);
- sRGBtoLinear16_6_16(c.y);
- sRGBtoLinear16_5_16(c.z);
- }
- else
- {
- 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 @@
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();
diff --git a/src/Pipeline/SamplerCore.hpp b/src/Pipeline/SamplerCore.hpp
index 9255e60..2aad2c9 100644
--- a/src/Pipeline/SamplerCore.hpp
+++ b/src/Pipeline/SamplerCore.hpp
@@ -96,8 +96,6 @@
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;
diff --git a/src/Pipeline/SpirvShaderSampling.cpp b/src/Pipeline/SpirvShaderSampling.cpp
index 6c546e5..905551f 100644
--- a/src/Pipeline/SpirvShaderSampling.cpp
+++ b/src/Pipeline/SpirvShaderSampling.cpp
@@ -80,7 +80,6 @@
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)