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

Paul Gofman gofmanp at gmail.com
Mon Feb 10 11:10:30 CST 2020


Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=37073
Signed-off-by: Paul Gofman <gofmanp at gmail.com>
---
 dlls/wined3d/state.c           | 11 ++++++++++-
 dlls/wined3d/utils.c           | 10 ++++++++++
 dlls/wined3d/wined3d_private.h |  3 ++-
 include/wine/wined3d.h         |  1 +
 4 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 856a4c9867..9db1311cdd 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -628,8 +628,10 @@ void state_atoc(struct wined3d_context *context, const struct wined3d_state *sta
     }
     else
     {
-        if (context->amd_atoc_enabled
+        if ((context->amd_atoc_enabled
                 && state->render_states[WINED3D_RS_POINTSIZE] != WINED3D_ALPHA_TO_COVERAGE_DISABLE)
+                || (context->nv_atoc_enabled
+                && state->render_states[WINED3D_RS_ADAPTIVETESS_Y] != WINED3DFMT_UNKNOWN))
             return;
 
         if (state->render_states[WINED3D_RS_POINTSIZE] == WINED3D_ALPHA_TO_COVERAGE_ENABLE)
@@ -637,10 +639,16 @@ void state_atoc(struct wined3d_context *context, const struct wined3d_state *sta
             alpha_to_coverage = TRUE;
             context->amd_atoc_enabled = 1;
         }
+        else if (state->render_states[WINED3D_RS_ADAPTIVETESS_Y] == WINED3DFMT_ATOC)
+        {
+            alpha_to_coverage = TRUE;
+            context->nv_atoc_enabled = 1;
+        }
         else
         {
             alpha_to_coverage = FALSE;
             context->amd_atoc_enabled = 0;
+            context->nv_atoc_enabled = 0;
         }
     }
 
@@ -1945,6 +1953,7 @@ static void state_nvdb(struct wined3d_context *context, const struct wined3d_sta
         checkGLcall("glDisable(GL_DEPTH_BOUNDS_TEST_EXT)");
     }
 
+    state_atoc(context, state, state_id);
     state_tessellation(context, state, STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION));
 }
 
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/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index dddf3e120a..f43b13a2a9 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1978,7 +1978,8 @@ struct wined3d_context
     DWORD destroy_delayed : 1;
     DWORD clip_distance_mask : 8; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
     DWORD amd_atoc_enabled : 1;
-    DWORD padding : 13;
+    DWORD nv_atoc_enabled : 1;
+    DWORD padding : 12;
 
     DWORD constant_update_mask;
     DWORD numbered_array_mask;
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 2b08e7f37a..bbb038d0d3 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