r300g: turn magic numbers into names in the hyperz code
authorMarek Olšák <maraeo@gmail.com>
Tue, 9 Nov 2010 14:04:34 +0000 (15:04 +0100)
committerMarek Olšák <maraeo@gmail.com>
Wed, 10 Nov 2010 14:14:25 +0000 (15:14 +0100)
src/gallium/drivers/r300/r300_hyperz.c

index 6e0e1b5bf4c9262ebfa3d50ee082c44137b3455e..79f7f8abe9bd7fb48192308c5703786f82cf8c92 100644 (file)
 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;
         }
     }