mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-03 02:50:16 +01:00
radv: Add bool return value to ray tracing NIR lowerings.
And don't use them with the deprecated NIR_PASS_V macro anymore. Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33609>
This commit is contained in:
parent
bf1a968a11
commit
65902ded29
2 changed files with 23 additions and 9 deletions
|
|
@ -723,7 +723,7 @@ radv_lower_rt_instruction(nir_builder *b, nir_instr *instr, void *_data)
|
|||
|
||||
/* This lowers all the RT instructions that we do not want to pass on to the combined shader and
|
||||
* that we can implement using the variables from the shader we are going to inline into. */
|
||||
static void
|
||||
static bool
|
||||
lower_rt_instructions(nir_shader *shader, struct rt_variables *vars, bool late_lowering,
|
||||
struct radv_rt_shader_info *out_info)
|
||||
{
|
||||
|
|
@ -732,18 +732,21 @@ lower_rt_instructions(nir_shader *shader, struct rt_variables *vars, bool late_l
|
|||
.late_lowering = late_lowering,
|
||||
.out_info = out_info,
|
||||
};
|
||||
nir_shader_instructions_pass(shader, radv_lower_rt_instruction, nir_metadata_none, &data);
|
||||
return nir_shader_instructions_pass(shader, radv_lower_rt_instruction, nir_metadata_none, &data);
|
||||
}
|
||||
|
||||
/* Lowers hit attributes to registers or shared memory. If hit_attribs is NULL, attributes are
|
||||
* lowered to shared memory. */
|
||||
static void
|
||||
static bool
|
||||
lower_hit_attribs(nir_shader *shader, nir_variable **hit_attribs, uint32_t workgroup_size)
|
||||
{
|
||||
bool progress = false;
|
||||
nir_function_impl *impl = nir_shader_get_entrypoint(shader);
|
||||
|
||||
nir_foreach_variable_with_modes (attrib, shader, nir_var_ray_hit_attrib)
|
||||
nir_foreach_variable_with_modes (attrib, shader, nir_var_ray_hit_attrib) {
|
||||
attrib->data.mode = nir_var_shader_temp;
|
||||
progress = true;
|
||||
}
|
||||
|
||||
nir_builder b = nir_builder_create(impl);
|
||||
|
||||
|
|
@ -757,6 +760,7 @@ lower_hit_attribs(nir_shader *shader, nir_variable **hit_attribs, uint32_t workg
|
|||
intrin->intrinsic != nir_intrinsic_store_hit_attrib_amd)
|
||||
continue;
|
||||
|
||||
progress = true;
|
||||
b.cursor = nir_after_instr(instr);
|
||||
|
||||
nir_def *offset;
|
||||
|
|
@ -784,6 +788,11 @@ lower_hit_attribs(nir_shader *shader, nir_variable **hit_attribs, uint32_t workg
|
|||
|
||||
if (!hit_attribs)
|
||||
shader->info.shared_size = MAX2(shader->info.shared_size, workgroup_size * RADV_MAX_HIT_ATTRIB_SIZE);
|
||||
|
||||
if (progress)
|
||||
nir_metadata_preserve(impl, nir_metadata_control_flow);
|
||||
|
||||
return progress;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -830,7 +839,7 @@ insert_rt_case(nir_builder *b, nir_shader *shader, struct rt_variables *vars, ni
|
|||
struct rt_variables src_vars = create_rt_variables(shader, vars->device, vars->flags, vars->monolithic);
|
||||
map_rt_variables(var_remap, &src_vars, vars);
|
||||
|
||||
NIR_PASS_V(shader, lower_rt_instructions, &src_vars, false, NULL);
|
||||
NIR_PASS(_, shader, lower_rt_instructions, &src_vars, false, NULL);
|
||||
|
||||
NIR_PASS(_, shader, nir_lower_returns);
|
||||
NIR_PASS(_, shader, nir_opt_dce);
|
||||
|
|
@ -2073,7 +2082,7 @@ radv_nir_lower_rt_abi(nir_shader *shader, const VkRayTracingPipelineCreateInfoKH
|
|||
NIR_PASS(_, shader, nir_lower_global_vars_to_local);
|
||||
NIR_PASS(_, shader, nir_lower_vars_to_ssa);
|
||||
if (shader->info.stage == MESA_SHADER_CLOSEST_HIT || shader->info.stage == MESA_SHADER_INTERSECTION)
|
||||
NIR_PASS_V(shader, lower_hit_attribs, NULL, info->wave_size);
|
||||
NIR_PASS(_, shader, lower_hit_attribs, NULL, info->wave_size);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
|
|
|||
|
|
@ -332,9 +332,10 @@ should_move_rt_instruction(nir_intrinsic_instr *instr)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
static bool
|
||||
move_rt_instructions(nir_shader *shader)
|
||||
{
|
||||
bool progress = false;
|
||||
nir_cursor target = nir_before_impl(nir_shader_get_entrypoint(shader));
|
||||
|
||||
nir_foreach_block (block, nir_shader_get_entrypoint(shader)) {
|
||||
|
|
@ -347,11 +348,15 @@ move_rt_instructions(nir_shader *shader)
|
|||
if (!should_move_rt_instruction(intrinsic))
|
||||
continue;
|
||||
|
||||
progress = true;
|
||||
nir_instr_move(target, instr);
|
||||
}
|
||||
}
|
||||
|
||||
nir_metadata_preserve(nir_shader_get_entrypoint(shader), nir_metadata_control_flow);
|
||||
if (progress)
|
||||
nir_metadata_preserve(nir_shader_get_entrypoint(shader), nir_metadata_control_flow);
|
||||
|
||||
return progress;
|
||||
}
|
||||
|
||||
static VkResult
|
||||
|
|
@ -387,7 +392,7 @@ radv_rt_nir_to_asm(struct radv_device *device, struct vk_pipeline_cache *cache,
|
|||
/* Move ray tracing system values to the top that are set by rt_trace_ray
|
||||
* to prevent them from being overwritten by other rt_trace_ray calls.
|
||||
*/
|
||||
NIR_PASS_V(stage->nir, move_rt_instructions);
|
||||
NIR_PASS(_, stage->nir, move_rt_instructions);
|
||||
|
||||
uint32_t num_resume_shaders = 0;
|
||||
nir_shader **resume_shaders = NULL;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue