[PATCH v3 2/4] wined3d: Support Nvidia alpha to coverage state.

Paul Gofman gofmanp at gmail.com
Wed Feb 12 08:38:02 CST 2020


Signed-off-by: Paul Gofman <gofmanp at gmail.com>
---
    v3:
        - make ATOC state depend on the currently present _ADAPTIVETESS_Y and
          not on its history as thats what Nvidia does.

 dlls/d3d9/tests/visual.c |  2 +-
 dlls/wined3d/state.c     | 16 ++++++++++++++--
 dlls/wined3d/utils.c     | 10 ++++++++++
 include/wine/wined3d.h   |  1 +
 4 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index b4991d4e5e..d5767ee129 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -27024,7 +27024,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/state.c b/dlls/wined3d/state.c
index 87e1ca4bac..60d02d3458 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -616,7 +616,7 @@ static void state_blend_factor(struct wined3d_context *context, const struct win
 static void state_blend_object(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 {
     const struct wined3d_gl_info *gl_info = wined3d_context_gl(context)->gl_info;
-    BOOL alpha_to_coverage = FALSE;
+    BOOL alpha_to_coverage;
 
     if (!gl_info->supported[ARB_MULTISAMPLE])
         return;
@@ -626,6 +626,10 @@ static void state_blend_object(struct wined3d_context *context, const struct win
         struct wined3d_blend_state_desc *desc = &state->blend_state->desc;
         alpha_to_coverage = desc->alpha_to_coverage;
     }
+    else
+    {
+        alpha_to_coverage = state->render_states[WINED3D_RS_ADAPTIVETESS_Y] == WINED3DFMT_ATOC;
+    }
 
     if (alpha_to_coverage)
         gl_info->gl_ops.gl.p_glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
@@ -1929,6 +1933,14 @@ static void state_nvdb(struct wined3d_context *context, const struct wined3d_sta
     state_tessellation(context, state, STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION));
 }
 
+static void state_nv_atoc(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
+{
+    if (!isStateDirty(context, STATE_BLEND))
+        state_blend_object(context, state, state_id);
+
+    state_tessellation(context, state, STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION));
+}
+
 static void state_wrapu(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 {
     if (state->render_states[WINED3D_RS_WRAPU])
@@ -4652,7 +4664,7 @@ const struct wined3d_state_entry_template misc_state_template[] =
     { STATE_RENDER(WINED3D_RS_MINTESSELLATIONLEVEL),      { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION),NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3D_RS_MAXTESSELLATIONLEVEL),      { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION),NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3D_RS_ADAPTIVETESS_X),            { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION),NULL                }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3D_RS_ADAPTIVETESS_Y),            { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION),NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3D_RS_ADAPTIVETESS_Y),            { STATE_RENDER(WINED3D_RS_ADAPTIVETESS_Y),            state_nv_atoc       }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3D_RS_ADAPTIVETESS_Z),            { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION),NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3D_RS_ADAPTIVETESS_W),            { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION),NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION),{ STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION),state_nvdb          }, EXT_DEPTH_BOUNDS_TEST           },
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index a968aa4eea..a476c977c8 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},
 };
 
@@ -3709,6 +3712,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. */
@@ -4627,6 +4636,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 28162275db..d944478aa2 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.24.1




More information about the wine-devel mailing list