[Mesa-dev] [PATCH] i965: Add comment to explain the weird-looking shadow compares.

Chris Forbes chrisf at ijw.co.nz
Sat Apr 12 03:34:19 PDT 2014


This always looks crazy when I stumble across it, until I remember
what the hardware is doing. Describing it ought to short-circuit
that process next time :)

Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
---
 src/mesa/drivers/dri/i965/intel_state.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/intel_state.c b/src/mesa/drivers/dri/i965/intel_state.c
index bfc35d8..1597db6 100644
--- a/src/mesa/drivers/dri/i965/intel_state.c
+++ b/src/mesa/drivers/dri/i965/intel_state.c
@@ -40,6 +40,17 @@
 int
 intel_translate_shadow_compare_func(GLenum func)
 {
+   /* GL specifies the result of shadow comparisons as:
+    *     1     if   ref <op> texel,
+    *     0     otherwise.
+    *
+    * The hardware does:
+    *     0     if texel <op> ref,
+    *     1     otherwise.
+    *
+    * So, these look a bit strange because there's both a negation
+    * and swapping of the arguments involved.
+    */
    switch (func) {
    case GL_NEVER:
        return BRW_COMPAREFUNCTION_ALWAYS;
@@ -50,11 +61,11 @@ intel_translate_shadow_compare_func(GLenum func)
    case GL_GREATER:
        return BRW_COMPAREFUNCTION_GEQUAL;
    case GL_GEQUAL:
-      return BRW_COMPAREFUNCTION_GREATER;
+       return BRW_COMPAREFUNCTION_GREATER;
    case GL_NOTEQUAL:
-      return BRW_COMPAREFUNCTION_EQUAL;
+       return BRW_COMPAREFUNCTION_EQUAL;
    case GL_EQUAL:
-      return BRW_COMPAREFUNCTION_NOTEQUAL;
+       return BRW_COMPAREFUNCTION_NOTEQUAL;
    case GL_ALWAYS:
        return BRW_COMPAREFUNCTION_NEVER;
    }
-- 
1.9.2



More information about the mesa-dev mailing list