From 0c5d727a5e10581736be6956f70936d3d64a4656 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Fri, 29 Mar 2024 21:36:44 -0400 Subject: [PATCH] radeonsi: document better how X/Y flipping in the compute blit works Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/gallium/drivers/radeonsi/si_shaderlib_nir.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_shaderlib_nir.c b/src/gallium/drivers/radeonsi/si_shaderlib_nir.c index 198df1298ed..10dc604323c 100644 --- a/src/gallium/drivers/radeonsi/si_shaderlib_nir.c +++ b/src/gallium/drivers/radeonsi/si_shaderlib_nir.c @@ -456,9 +456,12 @@ void *si_create_blit_cs(struct si_context *sctx, const union si_compute_blit_sha /* Flip src coordinates. */ for (unsigned i = 0; i < 2; i++) { if (i ? options->flip_y : options->flip_x) { - /* x goes from 0 to (dim - 1). - * The flipped blit should load from -dim to -1. - * Therefore do: x = -x - 1; + /* A normal blit loads from (box.x + tid.x) where tid.x = 0..(width - 1). + * + * A flipped blit sets box.x = width, so we should make tid.x negative to load from + * (width - 1)..0. + * + * Therefore do: x = -x - 1, which becomes (width - 1) to 0 after we add box.x = width. */ nir_def *comp = nir_channel(&b, src_xyz, i); comp = nir_iadd_imm(&b, nir_ineg(&b, comp), -1);