intel/fs: fix metadata preserve on trace_ray intrinsic

c78be5da30 ("intel/fs: lower ray query intrinsics") introduced a
helper function using nir_(push|pop)_if which invalidated dominance &
block_index for the replacement of nir_intrinsic_rt_trace_ray.

We can still keep dominance/block_index metadata for the lowering of
nir_intrinsic_rt_execute_callable though.

This change uses 2 different lowering function with correct metadata
preservation.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Fixes: c78be5da30 ("intel/fs: lower ray query intrinsics")
Reviewed-by: Marcin Ślusarz <marcin.slusarz@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15910>
This commit is contained in:
Lionel Landwerlin
2022-04-12 21:59:58 +03:00
committed by Marge Bot
parent fcd6b2a47a
commit 9c0805ef91

View File

@@ -125,7 +125,7 @@ store_resume_addr(nir_builder *b, nir_intrinsic_instr *call)
}
static bool
lower_shader_calls_instr(struct nir_builder *b, nir_instr *instr, void *data)
lower_shader_trace_ray_instr(struct nir_builder *b, nir_instr *instr, void *data)
{
if (instr->type != nir_instr_type_intrinsic)
return false;
@@ -134,9 +134,9 @@ lower_shader_calls_instr(struct nir_builder *b, nir_instr *instr, void *data)
* brw_nir_lower_rt_intrinsics()
*/
nir_intrinsic_instr *call = nir_instr_as_intrinsic(instr);
if (call->intrinsic != nir_intrinsic_rt_trace_ray)
return false;
switch (call->intrinsic) {
case nir_intrinsic_rt_trace_ray: {
b->cursor = nir_instr_remove(instr);
store_resume_addr(b, call);
@@ -209,15 +209,28 @@ lower_shader_calls_instr(struct nir_builder *b, nir_instr *instr, void *data)
.shader_index_multiplier = sbt_stride,
};
brw_nir_rt_store_mem_ray(b, &ray_defs, BRW_RT_BVH_LEVEL_WORLD);
nir_trace_ray_intel(b,
nir_load_btd_global_arg_addr_intel(b),
nir_imm_int(b, BRW_RT_BVH_LEVEL_WORLD),
nir_imm_int(b, GEN_RT_TRACE_RAY_INITAL),
.synchronous = false);
return true;
}
}
static bool
lower_shader_call_instr(struct nir_builder *b, nir_instr *instr, void *data)
{
if (instr->type != nir_instr_type_intrinsic)
return false;
/* Leave nir_intrinsic_rt_resume to be lowered by
* brw_nir_lower_rt_intrinsics()
*/
nir_intrinsic_instr *call = nir_instr_as_intrinsic(instr);
if (call->intrinsic != nir_intrinsic_rt_execute_callable)
return false;
case nir_intrinsic_rt_execute_callable: {
b->cursor = nir_instr_remove(instr);
store_resume_addr(b, call);
@@ -230,18 +243,18 @@ lower_shader_calls_instr(struct nir_builder *b, nir_instr *instr, void *data)
nir_u2u64(b, sbt_offset32));
brw_nir_btd_spawn(b, sbt_addr);
return true;
}
default:
return false;
}
}
bool
brw_nir_lower_shader_calls(nir_shader *shader)
{
return nir_shader_instructions_pass(shader,
lower_shader_calls_instr,
return
nir_shader_instructions_pass(shader,
lower_shader_trace_ray_instr,
nir_metadata_none,
NULL) |
nir_shader_instructions_pass(shader,
lower_shader_call_instr,
nir_metadata_block_index |
nir_metadata_dominance,
NULL);