[Mesa-dev] [PATCH 35/39] st/nine: ATOC has effect only with ALPHATESTENABLE

Axel Davy axel.davy at ens.fr
Sun May 15 10:45:49 UTC 2016


ATOC extension does something only when alpha test is enabled.
Use a second bit to encode the difference with ATIATOC.

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

diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c
index c1e22cb..bfe9966 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -2429,11 +2429,18 @@ NineDevice9_SetRenderState( struct NineDevice9 *This,
     /* NV hack */
     if (unlikely(State == D3DRS_ADAPTIVETESS_Y)) {
         if (Value == D3DFMT_ATOC || (Value == D3DFMT_UNKNOWN && state->rs[NINED3DRS_ALPHACOVERAGE])) {
-            state->rs[NINED3DRS_ALPHACOVERAGE] = (Value == D3DFMT_ATOC);
+            state->rs[NINED3DRS_ALPHACOVERAGE] = (Value == D3DFMT_ATOC) ? 3 : 0;
+            state->rs[NINED3DRS_ALPHACOVERAGE] &= state->rs[D3DRS_ALPHATESTENABLE] ? 3 : 2;
             state->changed.group |= NINE_STATE_BLEND;
             return D3D_OK;
         }
     }
+    if (unlikely(State == D3DRS_ALPHATESTENABLE && (state->rs[NINED3DRS_ALPHACOVERAGE] & 2))) {
+        DWORD alphacoverage_prev = state->rs[NINED3DRS_ALPHACOVERAGE];
+        state->rs[NINED3DRS_ALPHACOVERAGE] = (Value ? 3 : 2);
+        if (state->rs[NINED3DRS_ALPHACOVERAGE] != alphacoverage_prev)
+            state->changed.group |= NINE_STATE_BLEND;
+    }
 
     state->rs[State] = nine_fix_render_state_value(State, Value);
     state->changed.rs[State / 32] |= 1 << (State % 32);
diff --git a/src/gallium/state_trackers/nine/nine_pipe.c b/src/gallium/state_trackers/nine/nine_pipe.c
index 461b416..fc708c2 100644
--- a/src/gallium/state_trackers/nine/nine_pipe.c
+++ b/src/gallium/state_trackers/nine/nine_pipe.c
@@ -162,7 +162,7 @@ nine_convert_blend_state(struct pipe_blend_state *blend_state, const DWORD *rs)
     blend.dither = !!rs[D3DRS_DITHERENABLE];
 
  /* blend.alpha_to_one = 0; */
-    blend.alpha_to_coverage = !!rs[NINED3DRS_ALPHACOVERAGE];
+    blend.alpha_to_coverage = rs[NINED3DRS_ALPHACOVERAGE] & 1;
 
     blend.rt[0].blend_enable = !!rs[D3DRS_ALPHABLENDENABLE];
     if (blend.rt[0].blend_enable) {
diff --git a/src/gallium/state_trackers/nine/nine_state.h b/src/gallium/state_trackers/nine/nine_state.h
index 91bf0cd..7e7a899 100644
--- a/src/gallium/state_trackers/nine/nine_state.h
+++ b/src/gallium/state_trackers/nine/nine_state.h
@@ -33,6 +33,10 @@
 
 #define NINED3DRS_VSPOINTSIZE (D3DRS_BLENDOPALPHA + 1)
 #define NINED3DRS_RTMASK      (D3DRS_BLENDOPALPHA + 2)
+/* ALPHACOVERAGE:
+ * bit 0: enable alpha coverage
+ * bit 1: ATOC is on
+ */
 #define NINED3DRS_ALPHACOVERAGE  (D3DRS_BLENDOPALPHA + 3)
 
 #define D3DRS_LAST       D3DRS_BLENDOPALPHA
-- 
2.8.2



More information about the mesa-dev mailing list