radv/rt: use dynamic_callable_stack_base also for static stack_sizes
This patch also removes rt_pipeline->dynamic_stack_size and replaces it by checking for rt_pipeline->stack_size == -1u. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21159>
This commit is contained in:
committed by
Marge Bot
parent
2649a1f272
commit
8e718c5b63
@@ -9771,17 +9771,18 @@ radv_trace_rays(struct radv_cmd_buffer *cmd_buffer, const VkTraceRaysIndirectCom
|
||||
struct radv_compute_pipeline *pipeline = &cmd_buffer->state.rt_pipeline->base;
|
||||
uint32_t base_reg = pipeline->base.user_data_0[MESA_SHADER_COMPUTE];
|
||||
|
||||
/* Reserve scratch for dynamic stacks manually since it is not handled by the compute path. */
|
||||
if (cmd_buffer->state.rt_pipeline->dynamic_stack_size) {
|
||||
uint32_t scratch_bytes_per_wave = pipeline->base.scratch_bytes_per_wave;
|
||||
uint32_t wave_size = pipeline->base.shaders[MESA_SHADER_COMPUTE]->info.wave_size;
|
||||
/* Reserve scratch for stacks manually since it is not handled by the compute path. */
|
||||
uint32_t scratch_bytes_per_wave = pipeline->base.scratch_bytes_per_wave;
|
||||
uint32_t wave_size = pipeline->base.shaders[MESA_SHADER_COMPUTE]->info.wave_size;
|
||||
uint32_t stack_size = cmd_buffer->state.rt_pipeline->stack_size;
|
||||
if (stack_size == -1u)
|
||||
stack_size = cmd_buffer->state.rt_stack_size; /* dynamic stack size */
|
||||
|
||||
/* The hardware register is specified as a multiple of 256 DWORDS. */
|
||||
scratch_bytes_per_wave += align(cmd_buffer->state.rt_stack_size * wave_size, 1024);
|
||||
/* The hardware register is specified as a multiple of 256 DWORDS. */
|
||||
scratch_bytes_per_wave += align(stack_size * wave_size, 1024);
|
||||
|
||||
cmd_buffer->compute_scratch_size_per_wave_needed =
|
||||
MAX2(cmd_buffer->compute_scratch_size_per_wave_needed, scratch_bytes_per_wave);
|
||||
}
|
||||
cmd_buffer->compute_scratch_size_per_wave_needed =
|
||||
MAX2(cmd_buffer->compute_scratch_size_per_wave_needed, scratch_bytes_per_wave);
|
||||
|
||||
struct radv_dispatch_info info = {0};
|
||||
info.unaligned = true;
|
||||
|
||||
@@ -236,10 +236,13 @@ radv_rt_pipeline_has_dynamic_stack_size(const VkRayTracingPipelineCreateInfoKHR
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned
|
||||
static unsigned
|
||||
compute_rt_stack_size(const VkRayTracingPipelineCreateInfoKHR *pCreateInfo,
|
||||
const struct radv_pipeline_shader_stack_size *stack_sizes)
|
||||
{
|
||||
if (radv_rt_pipeline_has_dynamic_stack_size(pCreateInfo))
|
||||
return -1u;
|
||||
|
||||
unsigned raygen_size = 0;
|
||||
unsigned callable_size = 0;
|
||||
unsigned chit_size = 0;
|
||||
@@ -395,7 +398,6 @@ radv_rt_pipeline_create(VkDevice _device, VkPipelineCache _cache,
|
||||
goto shader_fail;
|
||||
}
|
||||
|
||||
rt_pipeline->dynamic_stack_size = radv_rt_pipeline_has_dynamic_stack_size(pCreateInfo);
|
||||
rt_pipeline->stack_size = compute_rt_stack_size(pCreateInfo, rt_pipeline->stack_sizes);
|
||||
|
||||
/* For General and ClosestHit shaders, we can use the shader ID directly as handle.
|
||||
|
||||
@@ -1999,9 +1999,6 @@ uint32_t radv_get_hash_flags(const struct radv_device *device, bool stats);
|
||||
|
||||
bool radv_rt_pipeline_has_dynamic_stack_size(const VkRayTracingPipelineCreateInfoKHR *pCreateInfo);
|
||||
|
||||
unsigned compute_rt_stack_size(const VkRayTracingPipelineCreateInfoKHR *pCreateInfo,
|
||||
const struct radv_pipeline_shader_stack_size *stack_sizes);
|
||||
|
||||
bool radv_enable_rt(const struct radv_physical_device *pdevice, bool rt_pipelines);
|
||||
|
||||
bool radv_emulate_rt(const struct radv_physical_device *pdevice);
|
||||
@@ -2231,7 +2228,6 @@ struct radv_ray_tracing_pipeline {
|
||||
struct radv_pipeline_shader_stack_size *stack_sizes;
|
||||
uint32_t group_count;
|
||||
uint32_t stack_size;
|
||||
bool dynamic_stack_size;
|
||||
};
|
||||
|
||||
#define RADV_DECL_PIPELINE_DOWNCAST(pipe_type, pipe_enum) \
|
||||
|
||||
@@ -1527,10 +1527,7 @@ create_rt_shader(struct radv_device *device, const VkRayTracingPipelineCreateInf
|
||||
|
||||
struct rt_variables vars = create_rt_variables(b.shader, pCreateInfo, stack_sizes, key);
|
||||
load_sbt_entry(&b, &vars, nir_imm_int(&b, 0), SBT_RAYGEN, SBT_GENERAL_IDX);
|
||||
if (radv_rt_pipeline_has_dynamic_stack_size(pCreateInfo))
|
||||
nir_store_var(&b, vars.stack_ptr, nir_load_rt_dynamic_callable_stack_base_amd(&b), 0x1);
|
||||
else
|
||||
nir_store_var(&b, vars.stack_ptr, nir_imm_int(&b, 0), 0x1);
|
||||
nir_store_var(&b, vars.stack_ptr, nir_load_rt_dynamic_callable_stack_base_amd(&b), 0x1);
|
||||
|
||||
nir_store_var(&b, vars.launch_id, nir_load_global_invocation_id(&b, 32), 0x7);
|
||||
nir_ssa_def *launch_size_addr = nir_load_ray_launch_size_addr_amd(&b);
|
||||
@@ -1601,11 +1598,6 @@ create_rt_shader(struct radv_device *device, const VkRayTracingPipelineCreateInf
|
||||
|
||||
nir_pop_loop(&b, loop);
|
||||
|
||||
if (radv_rt_pipeline_has_dynamic_stack_size(pCreateInfo))
|
||||
b.shader->scratch_size = 0; /* Stack size is set by the application. */
|
||||
else
|
||||
b.shader->scratch_size += compute_rt_stack_size(pCreateInfo, stack_sizes);
|
||||
|
||||
/* Deal with all the inline functions. */
|
||||
nir_index_ssa_defs(nir_shader_get_entrypoint(b.shader));
|
||||
nir_metadata_preserve(nir_shader_get_entrypoint(b.shader), nir_metadata_none);
|
||||
|
||||
Reference in New Issue
Block a user