From 61911b6a4b627bafe8ea936d48c7b1ea62aeaafe Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 17 Feb 2025 19:18:39 +0100 Subject: [PATCH] llvmpipe: Fix alpha-to-coverage without dithering Implementing alpha-to-coverage dithering broke the non-dithering case. (Discovered by accident, not really a big deal since it's almost always enabled and can only be disabled by using a Nvidia GL extension, and can't be disabled with Vulkan.) Fixes: ad4635d6ef05 Part-of: --- src/gallium/drivers/llvmpipe/lp_bld_blend.c | 3 ++- src/gallium/drivers/llvmpipe/lp_bld_blend.h | 1 + src/gallium/drivers/llvmpipe/lp_state_fs.c | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/llvmpipe/lp_bld_blend.c b/src/gallium/drivers/llvmpipe/lp_bld_blend.c index e59c18c4725..edb46cb4e9d 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_blend.c +++ b/src/gallium/drivers/llvmpipe/lp_bld_blend.c @@ -321,6 +321,7 @@ lp_build_alpha_to_coverage(struct gallivm_state *gallivm, struct lp_type type, struct lp_build_mask_context *mask, LLVMValueRef alpha, + bool dither, bool do_branch) { struct lp_build_context bld; @@ -329,7 +330,7 @@ lp_build_alpha_to_coverage(struct gallivm_state *gallivm, lp_build_context_init(&bld, gallivm, type); - alpha_ref_value = lp_build_const_vec(gallivm, type, 0); + alpha_ref_value = lp_build_const_vec(gallivm, type, dither ? 0 : 0.5); test = lp_build_cmp(&bld, PIPE_FUNC_GREATER, alpha, alpha_ref_value); diff --git a/src/gallium/drivers/llvmpipe/lp_bld_blend.h b/src/gallium/drivers/llvmpipe/lp_bld_blend.h index b5db966a666..8f0c0c99a3d 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_blend.h +++ b/src/gallium/drivers/llvmpipe/lp_bld_blend.h @@ -104,6 +104,7 @@ lp_build_alpha_to_coverage(struct gallivm_state *gallivm, struct lp_type type, struct lp_build_mask_context *mask, LLVMValueRef alpha, + bool dither, bool do_branch); #endif /* !LP_BLD_BLEND_H */ diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 40c812766bf..27cbac712ff 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -1150,6 +1150,7 @@ generate_fs_loop(struct gallivm_state *gallivm, if (!key->multisample) { lp_build_alpha_to_coverage(gallivm, type, &mask, alpha, + key->blend.alpha_to_coverage_dither, (depth_mode & LATE_DEPTH_TEST) != 0); } else { lp_build_sample_alpha_to_coverage(gallivm, type, key->coverage_samples, num_loop,