From d19e2597cedf39439f7aa5dc3676509f96ab6c3b Mon Sep 17 00:00:00 2001 From: Patrick Lerda Date: Sat, 19 Oct 2024 03:39:34 +0200 Subject: [PATCH] r600: fix spec ext_packed_depth_stencil getteximage This very test was working until the commit 4da147a02b54 ("mesa: remove fallback for GL_DEPTH_STENCIL"). Indeed this commit lets the driver handles this path and this was failing on evergreen r600. The test was processed through r600_blit() which loads the fragment shader util_make_fs_blit_zs(). This fragment shader loads two textures the stencil and depth. The texture depth was processed properly but the other texture was generating incorrect values. This issue, which seems to be related to the hardware configuration, disappears when the underlying surface is allocated using a width multiple of 32. This change was tested on cayman and palm with the normal test: "piglit/bin/ext_packed_depth_stencil-getteximage -auto -fb" and the test was modified to test all the relevant width and height values. The gpu rv770 was not affected by this issue. Here is the result: spec/ext_packed_depth_stencil/getteximage: fail pass Cc: mesa-stable Signed-off-by: Patrick Lerda Acked-by: Gert Wollny Part-of: --- src/gallium/drivers/r600/r600_texture.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gallium/drivers/r600/r600_texture.c b/src/gallium/drivers/r600/r600_texture.c index bc9e208337f..2045e0aa7c7 100644 --- a/src/gallium/drivers/r600/r600_texture.c +++ b/src/gallium/drivers/r600/r600_texture.c @@ -191,10 +191,17 @@ static int r600_init_surface(struct r600_common_screen *rscreen, bool is_depth, is_stencil; int r; unsigned i, bpe, flags = 0; + struct pipe_resource ptmp; is_depth = util_format_has_depth(desc); is_stencil = util_format_has_stencil(desc); + if (unlikely(rscreen->gfx_level >= EVERGREEN && ptex->format == PIPE_FORMAT_S8_UINT_Z24_UNORM && (ptex->width0 & 31))) { + memcpy(&ptmp, ptex, sizeof(ptmp)); + ptmp.width0 = (ptex->width0 + 31) & ~31; + ptex = &ptmp; + } + if (rscreen->gfx_level >= EVERGREEN && !is_flushed_depth && ptex->format == PIPE_FORMAT_Z32_FLOAT_S8X24_UINT) { bpe = 4; /* stencil is allocated separately on evergreen */