[PATCH 3/5] wined3d: Support NVIDIA alpha to coverage state.

Henri Verbeet hverbeet at codeweavers.com
Tue Feb 18 10:52:05 CST 2020


From: Paul Gofman <gofmanp at gmail.com>

Signed-off-by: Paul Gofman <gofmanp at gmail.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
 dlls/d3d9/tests/visual.c  |  2 +-
 dlls/wined3d/device.c     | 11 ++++++++---
 dlls/wined3d/stateblock.c | 17 +++++++++++------
 dlls/wined3d/utils.c      | 10 ++++++++++
 include/wine/wined3d.h    |  1 +
 5 files changed, 31 insertions(+), 10 deletions(-)

diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index 3151efaf330..8db30467ee5 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -26604,7 +26604,7 @@ static void test_alpha_to_coverage(void)
         ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
         if (!adapter_is_amd(&identifier))
         {
-            skip("Alpha to coverage is not supported.\n");
+            win_skip("Alpha to coverage is not supported.\n");
             refcount = IDirect3DDevice9_Release(device);
             ok(!refcount, "Device has %u references left.\n", refcount);
             IDirect3D9_Release(d3d);
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 1e6ec5d0981..17d71b3b1a3 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -3842,6 +3842,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
     struct wined3d_blend_state *blend_state;
     struct wined3d_color colour;
     unsigned int i, j, count;
+    BOOL set_blend_state;
 
     TRACE("device %p, stateblock %p.\n", device, stateblock);
 
@@ -3945,14 +3946,18 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
         }
     }
 
-    if (changed->blend_state)
+    if ((set_blend_state = changed->blend_state
+            || wined3d_bitmap_is_set(changed->renderState, WINED3D_RS_ADAPTIVETESS_Y)))
     {
+        blend_state = state->rs[WINED3D_RS_ADAPTIVETESS_Y] == WINED3DFMT_ATOC
+                ? device->blend_state_atoc_enabled : state->blend_state;
+
         if (wined3d_bitmap_is_set(changed->renderState, WINED3D_RS_BLENDFACTOR))
             wined3d_color_from_d3dcolor(&colour, stateblock->stateblock_state.rs[WINED3D_RS_BLENDFACTOR]);
         else
             wined3d_device_get_blend_state(device, &colour);
 
-        wined3d_device_set_blend_state(device, state->blend_state, &colour);
+        wined3d_device_set_blend_state(device, blend_state, &colour);
     }
 
     for (i = 0; i < ARRAY_SIZE(state->rs); ++i)
@@ -3966,7 +3971,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
             continue;
         }
 
-        if (!changed->blend_state)
+        if (!set_blend_state)
         {
             blend_state = wined3d_device_get_blend_state(device, &colour);
             wined3d_color_from_d3dcolor(&colour, state->rs[i]);
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index 71d88bf1949..a09c020f3f7 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -1052,6 +1052,7 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock,
     struct wined3d_device *device = stateblock->device;
     struct wined3d_blend_state *blend_state;
     struct wined3d_color colour;
+    BOOL set_blend_state;
     unsigned int i;
     DWORD map;
 
@@ -1140,21 +1141,25 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock,
         wined3d_device_set_ps_consts_b(device, idx, 1, &stateblock->stateblock_state.ps_consts_b[idx]);
     }
 
-    if (stateblock->changed.blend_state)
+    if ((set_blend_state = stateblock->changed.blend_state
+            || wined3d_bitmap_is_set(stateblock->changed.renderState, WINED3D_RS_ADAPTIVETESS_Y)))
     {
-        if (stateblock->stateblock_state.blend_state)
-            wined3d_blend_state_incref(stateblock->stateblock_state.blend_state);
+        blend_state = stateblock->stateblock_state.rs[WINED3D_RS_ADAPTIVETESS_Y] == WINED3DFMT_ATOC
+                ? device->blend_state_atoc_enabled : stateblock->stateblock_state.blend_state;
+
+        if (blend_state)
+            wined3d_blend_state_incref(blend_state);
         if (state->blend_state)
             wined3d_blend_state_decref(state->blend_state);
 
-        state->blend_state = stateblock->stateblock_state.blend_state;
+        state->blend_state = blend_state;
 
         if (wined3d_bitmap_is_set(stateblock->changed.renderState, WINED3D_RS_BLENDFACTOR))
             wined3d_color_from_d3dcolor(&colour, stateblock->stateblock_state.rs[WINED3D_RS_BLENDFACTOR]);
         else
             wined3d_device_get_blend_state(device, &colour);
 
-        wined3d_device_set_blend_state(device, stateblock->stateblock_state.blend_state, &colour);
+        wined3d_device_set_blend_state(device, blend_state, &colour);
     }
 
     /* Render states. */
@@ -1169,7 +1174,7 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock,
             continue;
         }
 
-        if (!stateblock->changed.blend_state)
+        if (!set_blend_state)
         {
             blend_state = wined3d_device_get_blend_state(device, &colour);
             wined3d_color_from_d3dcolor(&colour, stateblock->stateblock_state.rs[rs]);
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index bd239d7659f..f696b922140 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -65,6 +65,7 @@ format_index_remap[] =
     {WINED3DFMT_R16,          WINED3D_FORMAT_FOURCC_BASE + 20},
     {WINED3DFMT_AL16,         WINED3D_FORMAT_FOURCC_BASE + 21},
     {WINED3DFMT_NV12,         WINED3D_FORMAT_FOURCC_BASE + 22},
+    {WINED3DFMT_ATOC,         WINED3D_FORMAT_FOURCC_BASE + 23},
 };
 
 #define WINED3D_FORMAT_COUNT (WINED3D_FORMAT_FOURCC_BASE + ARRAY_SIZE(format_index_remap))
@@ -135,6 +136,7 @@ static const struct wined3d_format_channels formats[] =
     {WINED3DFMT_ATI1N,                      0,  0,  0,  0,   0,  0,  0,  0,    1,   0,     0},
     {WINED3DFMT_ATI2N,                      0,  0,  0,  0,   0,  0,  0,  0,    1,   0,     0},
     {WINED3DFMT_NVDB,                       0,  0,  0,  0,   0,  0,  0,  0,    0,   0,     0},
+    {WINED3DFMT_ATOC,                       0,  0,  0,  0,   0,  0,  0,  0,    0,   0,     0},
     {WINED3DFMT_INST,                       0,  0,  0,  0,   0,  0,  0,  0,    0,   0,     0},
     {WINED3DFMT_INTZ,                       0,  0,  0,  0,   0,  0,  0,  0,    4,  24,     8},
     {WINED3DFMT_RESZ,                       0,  0,  0,  0,   0,  0,  0,  0,    0,   0,     0},
@@ -339,6 +341,7 @@ static const struct wined3d_format_base_flags format_base_flags[] =
     {WINED3DFMT_INST,                 WINED3DFMT_FLAG_EXTENSION},
     {WINED3DFMT_NULL,                 WINED3DFMT_FLAG_EXTENSION},
     {WINED3DFMT_NVDB,                 WINED3DFMT_FLAG_EXTENSION},
+    {WINED3DFMT_ATOC,                 WINED3DFMT_FLAG_EXTENSION},
     {WINED3DFMT_RESZ,                 WINED3DFMT_FLAG_EXTENSION},
 };
 
@@ -3673,6 +3676,12 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_
         format_set_flag(&format->f, WINED3DFMT_FLAG_TEXTURE);
     }
 
+    if (gl_info->supported[ARB_MULTISAMPLE])
+    {
+        format = get_format_gl_internal(adapter, WINED3DFMT_ATOC);
+        format_set_flag(&format->f, WINED3DFMT_FLAG_TEXTURE);
+    }
+
     /* RESZ aka AMD DX9-level hack for multisampled depth buffer resolve. You query for RESZ
      * support by checking for availability of MAKEFOURCC('R','E','S','Z') surfaces with
      * RENDERTARGET usage. */
@@ -4591,6 +4600,7 @@ const char *debug_d3dformat(enum wined3d_format_id format_id)
         FMT_TO_STR(WINED3DFMT_R16);
         FMT_TO_STR(WINED3DFMT_AL16);
         FMT_TO_STR(WINED3DFMT_NV12);
+        FMT_TO_STR(WINED3DFMT_ATOC);
 #undef FMT_TO_STR
         default:
         {
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index d783e64a26d..734380b0adc 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -269,6 +269,7 @@ enum wined3d_format_id
     WINED3DFMT_NV12                         = WINEMAKEFOURCC('N','V','1','2'),
     WINED3DFMT_DF16                         = WINEMAKEFOURCC('D','F','1','6'),
     WINED3DFMT_DF24                         = WINEMAKEFOURCC('D','F','2','4'),
+    WINED3DFMT_ATOC                         = WINEMAKEFOURCC('A','T','O','C'),
 
     WINED3DFMT_FORCE_DWORD = 0xffffffff
 };
-- 
2.20.1




More information about the wine-devel mailing list