Signed-off-by: Paul Gofman gofmanp@gmail.com --- dlls/d3d9/tests/visual.c | 2 +- dlls/wined3d/glsl_shader.c | 2 ++ dlls/wined3d/state.c | 21 +++++++++++++++++++++ dlls/wined3d/wined3d_private.h | 5 +++++ 4 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index 859f3e5f1f..b4991d4e5e 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -27100,7 +27100,7 @@ static void test_alpha_to_coverage(void) colour = get_readback_color(&rb, 64, 64);
/* Nvidia is probably using some proprietary algorithm for averaging sample colour values. */ - todo_wine ok(color_match(colour, 0x9f404080, 1) || color_match(colour, 0x9f485cbc, 1) /* Nvidia */, + ok(color_match(colour, 0x9f404080, 1) || color_match(colour, 0x9f485cbc, 1) /* Nvidia */, "Got unexpected colour %08x.\n", colour); release_surface_readback(&rb);
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index cc7afe5165..d4bd0d25ca 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -12173,6 +12173,8 @@ static void glsl_vertex_pipe_pointsize(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { context->constant_update_mask |= WINED3D_SHADER_CONST_VS_POINTSIZE; + + state_alpha_to_coverage(context, state, state_id); }
static void glsl_vertex_pipe_pointscale(struct wined3d_context *context, diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index 87e1ca4bac..97fab9cd40 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -1507,6 +1507,25 @@ static void state_psizemin_arb(struct wined3d_context *context, const struct win checkGLcall("glPointParameterfARB(...)"); }
+void state_alpha_to_coverage(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; + + if (!gl_info->supported[ARB_MULTISAMPLE]) + return; + + if (state->render_states[WINED3D_RS_POINTSIZE] == WINED3D_ALPHA_TO_COVERAGE_ENABLE) + { + gl_info->gl_ops.gl.p_glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE); + checkGLcall("glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE)"); + } + else if (state->render_states[WINED3D_RS_POINTSIZE] == WINED3D_ALPHA_TO_COVERAGE_DISABLE) + { + gl_info->gl_ops.gl.p_glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE); + checkGLcall("glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE)"); + } +} + static void state_pscale(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; @@ -1532,6 +1551,8 @@ static void state_pscale(struct wined3d_context *context, const struct wined3d_s
gl_info->gl_ops.gl.p_glPointSize(max(pointsize, FLT_MIN)); checkGLcall("glPointSize(...);"); + + state_alpha_to_coverage(context, state, state_id); }
static void state_debug_monitor(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 3b9b342441..8e595db65d 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -76,6 +76,9 @@
#define WINED3D_MAX_DIRTY_REGION_COUNT 7
+#define WINED3D_ALPHA_TO_COVERAGE_ENABLE MAKEFOURCC('A','2','M','1') +#define WINED3D_ALPHA_TO_COVERAGE_DISABLE MAKEFOURCC('A','2','M','0') + struct wined3d_fragment_pipe_ops; struct wined3d_adapter; struct wined3d_context; @@ -4608,6 +4611,8 @@ void state_pointsprite(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN; void state_shademode(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN; +void state_alpha_to_coverage(struct wined3d_context *context, + const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
GLenum gl_primitive_type_from_d3d(enum wined3d_primitive_type primitive_type) DECLSPEC_HIDDEN; enum wined3d_primitive_type d3d_primitive_type_from_gl(GLenum primitive_type) DECLSPEC_HIDDEN;
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=37073 Signed-off-by: Paul Gofman gofmanp@gmail.com --- dlls/wined3d/state.c | 10 ++++++++-- dlls/wined3d/utils.c | 10 ++++++++++ dlls/wined3d/wined3d_private.h | 3 ++- include/wine/wined3d.h | 1 + 4 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index 97fab9cd40..f87421ebf9 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -1514,15 +1514,20 @@ void state_alpha_to_coverage(struct wined3d_context *context, const struct wined if (!gl_info->supported[ARB_MULTISAMPLE]) return;
- if (state->render_states[WINED3D_RS_POINTSIZE] == WINED3D_ALPHA_TO_COVERAGE_ENABLE) + if (state->render_states[WINED3D_RS_POINTSIZE] == WINED3D_ALPHA_TO_COVERAGE_ENABLE + || state->render_states[WINED3D_RS_ADAPTIVETESS_Y] == WINED3DFMT_ATOC) { gl_info->gl_ops.gl.p_glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE); checkGLcall("glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE)"); + if (state->render_states[WINED3D_RS_ADAPTIVETESS_Y] == WINED3DFMT_ATOC) + context->nv_atoc_enabled = 1; } - else if (state->render_states[WINED3D_RS_POINTSIZE] == WINED3D_ALPHA_TO_COVERAGE_DISABLE) + else if (state->render_states[WINED3D_RS_POINTSIZE] == WINED3D_ALPHA_TO_COVERAGE_DISABLE + || (context->nv_atoc_enabled && state->render_states[WINED3D_RS_ADAPTIVETESS_Y] == WINED3DFMT_UNKNOWN)) { gl_info->gl_ops.gl.p_glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE); checkGLcall("glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE)"); + context->nv_atoc_enabled = 0; } }
@@ -1947,6 +1952,7 @@ static void state_nvdb(struct wined3d_context *context, const struct wined3d_sta checkGLcall("glDisable(GL_DEPTH_BOUNDS_TEST_EXT)"); }
+ state_alpha_to_coverage(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 8e595db65d..e3f3fc6f2a 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1977,7 +1977,8 @@ struct wined3d_context DWORD destroyed : 1; DWORD destroy_delayed : 1; DWORD clip_distance_mask : 8; /* WINED3D_MAX_CLIP_DISTANCES, 8 */ - DWORD padding : 14; + DWORD nv_atoc_enabled : 1; + DWORD padding : 13;
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 };
On Mon, 10 Feb 2020 at 13:12, Paul Gofman gofmanp@gmail.com wrote:
Signed-off-by: Paul Gofman gofmanp@gmail.com
dlls/d3d9/tests/visual.c | 2 +- dlls/wined3d/glsl_shader.c | 2 ++ dlls/wined3d/state.c | 21 +++++++++++++++++++++ dlls/wined3d/wined3d_private.h | 5 +++++ 4 files changed, 29 insertions(+), 1 deletion(-)
This potentially conflicts with state_blend_object() also controlling GL_SAMPLE_ALPHA_TO_COVERAGE.
On 2/10/20 17:37, Henri Verbeet wrote:
On Mon, 10 Feb 2020 at 13:12, Paul Gofman gofmanp@gmail.com wrote:
Signed-off-by: Paul Gofman gofmanp@gmail.com
dlls/d3d9/tests/visual.c | 2 +- dlls/wined3d/glsl_shader.c | 2 ++ dlls/wined3d/state.c | 21 +++++++++++++++++++++ dlls/wined3d/wined3d_private.h | 5 +++++ 4 files changed, 29 insertions(+), 1 deletion(-)
This potentially conflicts with state_blend_object() also controlling GL_SAMPLE_ALPHA_TO_COVERAGE.
Yes, I suggest I merge state_alpha_to_coverage() into state_blend_object() so that the logic from state_alpha_to_coverage() has effect only if no blend_state is set (which can happen for d3d11 only).
On Mon, 10 Feb 2020 at 18:34, Paul Gofman gofmanp@gmail.com wrote:
On 2/10/20 17:37, Henri Verbeet wrote:
This potentially conflicts with state_blend_object() also controlling GL_SAMPLE_ALPHA_TO_COVERAGE.
Yes, I suggest I merge state_alpha_to_coverage() into state_blend_object() so that the logic from state_alpha_to_coverage() has effect only if no blend_state is set (which can happen for d3d11 only).
Yes, that makes sense.