[Mesa-dev] [PATCH 61/71] st/nine: Remove NINED3DRS_ZBIASSCALE

Axel Davy axel.davy at ens.fr
Sun Aug 16 08:28:25 PDT 2015


It wasn't giving the expected result.

This fixes some object being transparents
in games like FEAR.

Signed-off-by: Axel Davy <axel.davy at ens.fr>
---
 src/gallium/state_trackers/nine/nine_pipe.c  | 12 +++++++++++-
 src/gallium/state_trackers/nine/nine_state.c | 20 --------------------
 src/gallium/state_trackers/nine/nine_state.h |  3 +--
 3 files changed, 12 insertions(+), 23 deletions(-)

diff --git a/src/gallium/state_trackers/nine/nine_pipe.c b/src/gallium/state_trackers/nine/nine_pipe.c
index 668ce38..9ac5700 100644
--- a/src/gallium/state_trackers/nine/nine_pipe.c
+++ b/src/gallium/state_trackers/nine/nine_pipe.c
@@ -118,7 +118,17 @@ nine_convert_rasterizer_state(struct pipe_rasterizer_state *rast_state, const DW
                 asfloat(rs[D3DRS_POINTSIZE_MIN]),
                 asfloat(rs[D3DRS_POINTSIZE_MAX]));
     }
-    rast.offset_units = asfloat(rs[D3DRS_DEPTHBIAS]) * asfloat(rs[NINED3DRS_ZBIASSCALE]);
+    /* offset_units has the ogl/d3d11 meaning.
+     * d3d9: offset = scale * dz + bias
+     * ogl/d3d11: offset = scale * dz + r * bias
+     * with r implementation dependant and is supposed to be
+     * the smallest value the depth buffer format can hold.
+     * In practice on current and past hw it seems to be 2^-23
+     * for all formats except float formats where it varies depending
+     * on the content.
+     * For now use 1 << 23, but in the future perhaps add a way in gallium
+     * to get r for the format or get the gallium behaviour */
+    rast.offset_units = asfloat(rs[D3DRS_DEPTHBIAS]) * (float)(1 << 23);
     rast.offset_scale = asfloat(rs[D3DRS_SLOPESCALEDEPTHBIAS]);
  /* rast.offset_clamp = 0.0f; */
 
diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c
index 04b5f18..a7d884c 100644
--- a/src/gallium/state_trackers/nine/nine_state.c
+++ b/src/gallium/state_trackers/nine/nine_state.c
@@ -496,26 +496,6 @@ update_framebuffer(struct NineDevice9 *device)
 
     pipe->set_framebuffer_state(pipe, fb); /* XXX: cso ? */
 
-    if (fb->zsbuf) {
-        DWORD scale;
-        switch (fb->zsbuf->format) {
-        case PIPE_FORMAT_Z32_FLOAT:
-        case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT:
-            scale = fui(1.0f);
-            break;
-        case PIPE_FORMAT_Z16_UNORM:
-            scale = fui((float)(1 << 16));
-            break;
-        default:
-            scale = fui((float)(1 << 24));
-            break;
-        }
-        if (state->rs[NINED3DRS_ZBIASSCALE] != scale) {
-            state->rs[NINED3DRS_ZBIASSCALE] = scale;
-            state->changed.group |= NINE_STATE_RASTERIZER;
-        }
-    }
-
     return state->changed.group;
 }
 
diff --git a/src/gallium/state_trackers/nine/nine_state.h b/src/gallium/state_trackers/nine/nine_state.h
index 109c0bb..0f3c2fa 100644
--- a/src/gallium/state_trackers/nine/nine_state.h
+++ b/src/gallium/state_trackers/nine/nine_state.h
@@ -33,8 +33,7 @@
 
 #define NINED3DRS_VSPOINTSIZE (D3DRS_BLENDOPALPHA + 1)
 #define NINED3DRS_RTMASK      (D3DRS_BLENDOPALPHA + 2)
-#define NINED3DRS_ZBIASSCALE  (D3DRS_BLENDOPALPHA + 3)
-#define NINED3DRS_ALPHACOVERAGE  (D3DRS_BLENDOPALPHA + 4)
+#define NINED3DRS_ALPHACOVERAGE  (D3DRS_BLENDOPALPHA + 3)
 
 #define D3DRS_LAST       D3DRS_BLENDOPALPHA
 #define NINED3DRS_LAST   NINED3DRS_ALPHACOVERAGE /* 213 */
-- 
2.1.0



More information about the mesa-dev mailing list