diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c index 97cc277f988..b826c1df7f5 100644 --- a/src/amd/vulkan/radv_cmd_buffer.c +++ b/src/amd/vulkan/radv_cmd_buffer.c @@ -11983,8 +11983,22 @@ static void radv_emit_rt_stack_size(struct radv_cmd_buffer *cmd_buffer) { struct radv_device *device = radv_cmd_buffer_device(cmd_buffer); + const struct radv_physical_device *pdev = radv_device_physical(device); const struct radv_shader *rt_prolog = cmd_buffer->state.rt_prolog; unsigned rsrc2 = rt_prolog->config.rsrc2; + + /* Reserve scratch for stacks manually since it is not handled by the compute path. */ + uint32_t scratch_bytes_per_wave = rt_prolog->config.scratch_bytes_per_wave; + const uint32_t wave_size = rt_prolog->info.wave_size; + + /* The hardware register is specified as a multiple of 64 or 256 DWORDS. */ + const unsigned scratch_alloc_granule = pdev->info.gfx_level >= GFX11 ? 256 : 1024; + + scratch_bytes_per_wave += align(cmd_buffer->state.rt_stack_size * wave_size, scratch_alloc_granule); + + cmd_buffer->compute_scratch_size_per_wave_needed = + MAX2(cmd_buffer->compute_scratch_size_per_wave_needed, scratch_bytes_per_wave); + if (cmd_buffer->state.rt_stack_size) rsrc2 |= S_00B12C_SCRATCH_EN(1); @@ -12287,17 +12301,6 @@ radv_trace_rays(struct radv_cmd_buffer *cmd_buffer, VkTraceRaysIndirectCommand2K struct radv_compute_pipeline *pipeline = &cmd_buffer->state.rt_pipeline->base; struct radv_shader *rt_prolog = cmd_buffer->state.rt_prolog; - /* Reserve scratch for stacks manually since it is not handled by the compute path. */ - uint32_t scratch_bytes_per_wave = rt_prolog->config.scratch_bytes_per_wave; - uint32_t wave_size = rt_prolog->info.wave_size; - - /* The hardware register is specified as a multiple of 64 or 256 DWORDS. */ - unsigned scratch_alloc_granule = pdev->info.gfx_level >= GFX11 ? 256 : 1024; - scratch_bytes_per_wave += align(cmd_buffer->state.rt_stack_size * wave_size, scratch_alloc_granule); - - cmd_buffer->compute_scratch_size_per_wave_needed = - MAX2(cmd_buffer->compute_scratch_size_per_wave_needed, scratch_bytes_per_wave); - /* Since the workgroup size is 8x4 (or 8x8), 1D dispatches can only fill 8 threads per wave at most. To increase * occupancy, it's beneficial to convert to a 2D dispatch in these cases. */ if (tables && tables->height == 1 && tables->width >= cmd_buffer->state.rt_prolog->info.cs.block_size[0])