Mesa (master): r300g: turn magic numbers into names in the hyperz code

Marek Olšák mareko at kemper.freedesktop.org
Wed Nov 10 14:41:29 UTC 2010


Module: Mesa
Branch: master
Commit: 93c04749be3e4a7e224b5dafe67f479264199908
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=93c04749be3e4a7e224b5dafe67f479264199908

Author: Marek Olšák <maraeo at gmail.com>
Date:   Tue Nov  9 15:04:34 2010 +0100

r300g: turn magic numbers into names in the hyperz code

---

 src/gallium/drivers/r300/r300_hyperz.c |   30 ++++++++++++++++++------------
 1 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/src/gallium/drivers/r300/r300_hyperz.c b/src/gallium/drivers/r300/r300_hyperz.c
index 6e0e1b5..79f7f8a 100644
--- a/src/gallium/drivers/r300/r300_hyperz.c
+++ b/src/gallium/drivers/r300/r300_hyperz.c
@@ -44,10 +44,10 @@
 static bool r300_get_sc_hz_max(struct r300_context *r300)
 {
     struct r300_dsa_state *dsa_state = r300->dsa_state.state;
-    int func = dsa_state->z_stencil_control & 0x7;
+    int func = dsa_state->z_stencil_control & R300_ZS_MASK;
     int ret = R300_SC_HYPERZ_MIN;
 
-    if (func >= 4 && func <= 7)
+    if (func >= R300_ZS_GEQUAL && func <= R300_ZS_ALWAYS)
        ret = R300_SC_HYPERZ_MAX;
     return ret;
 }
@@ -55,23 +55,26 @@ static bool r300_get_sc_hz_max(struct r300_context *r300)
 static bool r300_zfunc_same_direction(int func1, int func2)
 {
     /* func1 is less/lessthan */
-    if (func1 == 1 || func1 == 2)
-        if (func2 == 3 || func2 == 4 || func2 == 5)
+    if ((func1 == R300_ZS_LESS || func1 == R300_ZS_LEQUAL) &&
+        (func2 == R300_ZS_EQUAL || func2 == R300_ZS_GEQUAL ||
+         func2 == R300_ZS_GREATER))
             return FALSE;
 
-    if (func2 == 1 || func2 == 2)
-        if (func1 == 4 || func1 == 5)
+    /* func1 is greater/greaterthan */
+    if ((func1 == R300_ZS_GEQUAL || func1 == R300_ZS_GREATER) &&
+        (func2 == R300_ZS_LESS || func2 == R300_ZS_LEQUAL))
             return FALSE;
+
     return TRUE;
 }
 
 static int r300_get_hiz_min(struct r300_context *r300)
 {
     struct r300_dsa_state *dsa_state = r300->dsa_state.state;
-    int func = dsa_state->z_stencil_control & 0x7;
+    int func = dsa_state->z_stencil_control & R300_ZS_MASK;
     int ret = R300_HIZ_MIN;
 
-    if (func == 1 || func == 2)
+    if (func == R300_ZS_LESS || func == R300_ZS_LEQUAL)
        ret = R300_HIZ_MAX;
     return ret;
 }
@@ -112,13 +115,16 @@ static boolean r300_can_hiz(struct r300_context *r300)
     }
     /* depth comparison function - if just cleared save and return okay */
     if (z->current_func == -1) {
-        int func = dsa_state->z_stencil_control & 0x7;
+        int func = dsa_state->z_stencil_control & R300_ZS_MASK;
         if (func != 0 && func != 7)
-            z->current_func = dsa_state->z_stencil_control & 0x7;
+            z->current_func = dsa_state->z_stencil_control & R300_ZS_MASK;
     } else {
         /* simple don't change */
-        if (!r300_zfunc_same_direction(z->current_func, (dsa_state->z_stencil_control & 0x7))) {
-            DBG(r300, DBG_HYPERZ, "z func changed direction - disabling hyper-z %d -> %d\n", z->current_func, dsa_state->z_stencil_control);
+        if (!r300_zfunc_same_direction(z->current_func,
+                                       (dsa_state->z_stencil_control & R300_ZS_MASK))) {
+            DBG(r300, DBG_HYPERZ,
+                "z func changed direction - disabling hyper-z %d -> %d\n",
+                z->current_func, dsa_state->z_stencil_control);
             return FALSE;
         }
     }    




More information about the mesa-commit mailing list