From 1272640d55243105bb192a5dd460dc70fc7a77a6 Mon Sep 17 00:00:00 2001 From: Axel Davy Date: Thu, 11 Mar 2021 20:43:04 +0100 Subject: [PATCH] st/nine: Fix alpha to coverage states MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The sequence of states to disable NVidia alpha to coverage was disabling AMD alpha to coverage. This patch fixes it. Found with wine tests. Signed-off-by: Axel Davy Acked-by: Timur Kristóf Part-of: --- src/gallium/frontends/nine/nine_pipe.c | 2 +- src/gallium/frontends/nine/nine_state.c | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/gallium/frontends/nine/nine_pipe.c b/src/gallium/frontends/nine/nine_pipe.c index 671ea635827..8f4f11827f5 100644 --- a/src/gallium/frontends/nine/nine_pipe.c +++ b/src/gallium/frontends/nine/nine_pipe.c @@ -166,7 +166,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] & 1; + blend.alpha_to_coverage = !!(rs[NINED3DRS_ALPHACOVERAGE] & 5); blend.rt[0].blend_enable = !!rs[D3DRS_ALPHABLENDENABLE]; if (blend.rt[0].blend_enable) { diff --git a/src/gallium/frontends/nine/nine_state.c b/src/gallium/frontends/nine/nine_state.c index c6bae93035d..1c61ed85c2e 100644 --- a/src/gallium/frontends/nine/nine_state.c +++ b/src/gallium/frontends/nine/nine_state.c @@ -1415,9 +1415,16 @@ CSMT_ITEM_NO_WAIT(nine_context_set_render_state, return; } + /* NINED3DRS_ALPHACOVERAGE: + * bit 0: NVIDIA alpha to coverage + * bit 1: NVIDIA ATOC state active + * bit 2: AMD alpha to coverage + * These need to be separate else the set of states to + * disable NVIDIA alpha to coverage can disable the AMD one */ if (Value == ALPHA_TO_COVERAGE_ENABLE || Value == ALPHA_TO_COVERAGE_DISABLE) { - context->rs[NINED3DRS_ALPHACOVERAGE] = (Value == ALPHA_TO_COVERAGE_ENABLE); + context->rs[NINED3DRS_ALPHACOVERAGE] &= 3; + context->rs[NINED3DRS_ALPHACOVERAGE] |= (Value == ALPHA_TO_COVERAGE_ENABLE) ? 4 : 0; context->changed.group |= NINE_STATE_BLEND; return; } @@ -1425,16 +1432,18 @@ CSMT_ITEM_NO_WAIT(nine_context_set_render_state, /* NV hack */ if (unlikely(State == D3DRS_ADAPTIVETESS_Y)) { - if (Value == D3DFMT_ATOC || (Value == D3DFMT_UNKNOWN && context->rs[NINED3DRS_ALPHACOVERAGE])) { - context->rs[NINED3DRS_ALPHACOVERAGE] = (Value == D3DFMT_ATOC) ? 3 : 0; - context->rs[NINED3DRS_ALPHACOVERAGE] &= context->rs[D3DRS_ALPHATESTENABLE] ? 3 : 2; + if (Value == D3DFMT_ATOC || (Value == D3DFMT_UNKNOWN && context->rs[NINED3DRS_ALPHACOVERAGE] & 3)) { + context->rs[NINED3DRS_ALPHACOVERAGE] &= 4; + context->rs[NINED3DRS_ALPHACOVERAGE] |= + ((Value == D3DFMT_ATOC) ? 3 : 0) & (context->rs[D3DRS_ALPHATESTENABLE] ? 3 : 2); context->changed.group |= NINE_STATE_BLEND; return; } } if (unlikely(State == D3DRS_ALPHATESTENABLE && (context->rs[NINED3DRS_ALPHACOVERAGE] & 2))) { DWORD alphacoverage_prev = context->rs[NINED3DRS_ALPHACOVERAGE]; - context->rs[NINED3DRS_ALPHACOVERAGE] = (Value ? 3 : 2); + context->rs[NINED3DRS_ALPHACOVERAGE] &= 6; + context->rs[NINED3DRS_ALPHACOVERAGE] |= (context->rs[D3DRS_ALPHATESTENABLE] ? 1 : 0); if (context->rs[NINED3DRS_ALPHACOVERAGE] != alphacoverage_prev) context->changed.group |= NINE_STATE_BLEND; }