From e7a851e6cf6b828c51af6664c2df4b83c0f1e403 Mon Sep 17 00:00:00 2001 From: Aleksi Sapon Date: Tue, 8 Oct 2024 10:58:54 -0400 Subject: [PATCH] softpipe: Fix anisotropic sampling aliasing bug "Backport" of the llvmpip fix. Nearest sampling was being done using coordinates on texel boundaries, which caused aliasing bugs. Shift coordinates by half a texel to correct this. Reviewed-by: Adam Jackson Part-of: --- src/gallium/drivers/softpipe/sp_tex_sample.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c index 149dd9597aa..57e3720123f 100644 --- a/src/gallium/drivers/softpipe/sp_tex_sample.c +++ b/src/gallium/drivers/softpipe/sp_tex_sample.c @@ -2444,8 +2444,8 @@ img_filter_2d_ewa(const struct sp_sampler_view *sp_sview, const float weight = weightLut[qClamped]; weight_buffer[buffer_next] = weight; - s_buffer[buffer_next] = u / ((float) width); - t_buffer[buffer_next] = v / ((float) height); + s_buffer[buffer_next] = (u + 0.5f) / width; + t_buffer[buffer_next] = (v + 0.5f) / height; buffer_next++; if (buffer_next == TGSI_QUAD_SIZE) {