st/nine: ATOC has effect only with ALPHATESTENABLE
authorAxel Davy <axel.davy@ens.fr>
Sun, 3 Apr 2016 08:52:22 +0000 (10:52 +0200)
committerAxel Davy <axel.davy@ens.fr>
Wed, 18 May 2016 21:37:14 +0000 (23:37 +0200)
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@ens.fr>
src/gallium/state_trackers/nine/device9.c
src/gallium/state_trackers/nine/nine_pipe.c
src/gallium/state_trackers/nine/nine_state.h

index 7edba6b1e9f4c6c404777efd7cf9449ee811d512..ed5d17a6e071f4616d4a095fe940ba32f1132a2f 100644 (file)
@@ -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);
index 461b416d2a26c1f59d8521d6ab4b8801a260f5fa..fc708c29d38561e5b1d69265f81d41830a1c3d60 100644 (file)
@@ -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) {
index 91bf0cdb6e9625d5901fa3fa57787687ebff136f..7e7a8996c917f5d339477d26442e3135d15f9a43 100644 (file)
 
 #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