From b2bce19cd4ecf9cfcc74852dd8466c0996b6bfca Mon Sep 17 00:00:00 2001 From: Patrick Lerda Date: Thu, 9 May 2024 14:16:35 +0200 Subject: [PATCH] r600: fix vertex state update clover regression This change handles the case when "vertex_fetch_shader.cso" is null, it implements the previous behavior in this specific case. This situation is happening with clover. For instance, this issue is triggered with "piglit/bin/cl-custom-buffer-flags": ==6467==ERROR: AddressSanitizer: SEGV on unknown address 0x00000000000c (pc 0x7ff92908fe6e bp 0x7ffe86ae5ad0 sp 0x7ffe86ae5a30 T0) ==6467==The signal is caused by a READ memory access. ==6467==Hint: address points to the zero page. #0 0x7ff92908fe6e in evergreen_emit_vertex_buffers ../src/gallium/drivers/r600/evergreen_state.c:2123 #1 0x7ff92908444b in r600_emit_atom ../src/gallium/drivers/r600/r600_pipe.h:627 #2 0x7ff92908444b in compute_emit_cs ../src/gallium/drivers/r600/evergreen_compute.c:798 #3 0x7ff92908444b in evergreen_launch_grid ../src/gallium/drivers/r600/evergreen_compute.c:927 #4 0x7ff9349f9350 in clover::kernel::launch(clover::command_queue&, std::vector > const&, std::vector > const&, std::vector > const&) ../src/gallium/frontends/clover/core/kernel.cpp:105 #5 0x7ff9349c331d in std::function::operator()(clover::event&) const /usr/include/c++/11.4.0/bits/std_function.h:590 #6 0x7ff9349c331d in clover::event::trigger() ../src/gallium/frontends/clover/core/event.cpp:54 #7 0x7ff9349c82f1 in clover::hard_event::hard_event(clover::command_queue&, unsigned int, clover::ref_vector const&, std::function) ../src/gallium/frontends/clover/core/event.cpp:138 #8 0x7ff9348daa47 in create&, clEnqueueNDRangeKernel(cl_command_queue, cl_kernel, cl_uint, const size_t*, const size_t*, const size_t*, cl_uint, _cl_event* const*, _cl_event**):: > ../src/gallium/frontends/clover/util/pointer.hpp:241 #9 0x7ff9348daa47 in clEnqueueNDRangeKernel ../src/gallium/frontends/clover/api/kernel.cpp:334 Fixes: 659b7eb2 ("r600: better tracking for vertex buffer emission") Related: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10079 Signed-off-by: Patrick Lerda Part-of: (cherry picked from commit f8a1d9f787908612d234c5e7ffeaab825c5b7d7a) --- .pick_status.json | 2 +- src/gallium/drivers/r600/evergreen_state.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 223c7cf6dc5..7e3a86a7b76 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -584,7 +584,7 @@ "description": "r600: fix vertex state update clover regression", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "659b7eb2799bccfff817961518d0ff2ab9e65bca", "notes": null diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c index a8885ff4fa3..a9c200c6657 100644 --- a/src/gallium/drivers/r600/evergreen_state.c +++ b/src/gallium/drivers/r600/evergreen_state.c @@ -2120,7 +2120,8 @@ static void evergreen_emit_vertex_buffers(struct r600_context *rctx, { struct radeon_cmdbuf *cs = &rctx->b.gfx.cs; struct r600_fetch_shader *shader = (struct r600_fetch_shader*)rctx->vertex_fetch_shader.cso; - uint32_t dirty_mask = state->dirty_mask & shader->buffer_mask; + uint32_t buffer_mask = shader ? shader->buffer_mask : ~0; + uint32_t dirty_mask = state->dirty_mask & buffer_mask; while (dirty_mask) { struct pipe_vertex_buffer *vb; @@ -2159,7 +2160,7 @@ static void evergreen_emit_vertex_buffers(struct r600_context *rctx, radeon_emit(cs, radeon_add_to_buffer_list(&rctx->b, &rctx->b.gfx, rbuffer, RADEON_USAGE_READ | RADEON_PRIO_VERTEX_BUFFER)); } - state->dirty_mask &= ~shader->buffer_mask; + state->dirty_mask &= ~buffer_mask; } static void evergreen_fs_emit_vertex_buffers(struct r600_context *rctx, struct r600_atom * atom)