Pass down the texture compare state.
Depth format textures can have a comparison operation performed after
their texels have been sampled.
Change-Id: I49f6bb7fab9765265761144ee8b6b62439beb5a3
Reviewed-on: https://swiftshader-review.googlesource.com/5870
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
diff --git a/src/Renderer/Sampler.cpp b/src/Renderer/Sampler.cpp
index 123a1c9..5bf11c8 100644
--- a/src/Renderer/Sampler.cpp
+++ b/src/Renderer/Sampler.cpp
@@ -67,6 +67,8 @@
swizzleB = SWIZZLE_BLUE;
swizzleA = SWIZZLE_ALPHA;
+ compare = COMPARE_BYPASS;
+
texture.LOD = 0.0f;
exp2LOD = 1.0f;
@@ -99,6 +101,7 @@
state.swizzleB = swizzleB;
state.swizzleA = swizzleA;
state.highPrecisionFiltering = highPrecisionFiltering;
+ state.compare = getCompareFunc();
#if PERF_PROFILE
state.compressedFormat = Surface::isCompressed(externalTextureFormat);
@@ -332,6 +335,11 @@
this->swizzleA = swizzleA;
}
+ void Sampler::setCompareFunc(CompareFunc compare)
+ {
+ this->compare = compare;
+ }
+
void Sampler::setBaseLevel(int baseLevel)
{
texture.baseLevel = baseLevel;
@@ -478,4 +486,19 @@
return addressingModeW;
}
+
+ CompareFunc Sampler::getCompareFunc() const
+ {
+ if(getTextureFilter() == FILTER_GATHER)
+ {
+ return COMPARE_BYPASS;
+ }
+
+ if(internalTextureFormat == FORMAT_D32FS8_SHADOW)
+ {
+ return COMPARE_LESSEQUAL;
+ }
+
+ return compare;
+ }
}