radv/rt: Fix any_hit scratch variables.

We have to make sure not to change call_data locations as well.

Fixes: 481f78ab93 ('radv/rt: place any-hit scratch vars after intersection scratch vars')
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21876>
(cherry picked from commit f6a36190a1)
This commit is contained in:
Daniel Schürmann 2023-03-13 16:59:16 +01:00 committed by Dylan Baker
parent 3e383010d1
commit 6caeb11fe9
2 changed files with 12 additions and 2 deletions

View file

@ -6223,7 +6223,7 @@
"description": "radv/rt: Fix any_hit scratch variables.",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "481f78ab93e2f2169c53a7c8494b488d45b60def"
},

View file

@ -914,15 +914,25 @@ lower_any_hit_for_intersection(nir_shader *any_hit)
nir_instr_remove(&intrin->instr);
break;
/* We place all any_hit scratch variables after intersection scratch variables.
* For that reason, we increment the scratch offset by the intersection scratch
* size. For call_data, we have to subtract the offset again.
*/
case nir_intrinsic_load_scratch:
b->cursor = nir_before_instr(instr);
nir_instr_rewrite_src_ssa(instr, &intrin->src[0],
nir_iadd_nuw(b, scratch_offset, intrin->src[0].ssa));
break;
case nir_intrinsic_store_scratch:
b->cursor = nir_before_instr(instr);
nir_instr_rewrite_src_ssa(instr, &intrin->src[1],
nir_iadd_nuw(b, scratch_offset, intrin->src[1].ssa));
break;
case nir_intrinsic_load_rt_arg_scratch_offset_amd:
b->cursor = nir_after_instr(instr);
nir_ssa_def *arg_offset = nir_isub(b, &intrin->dest.ssa, scratch_offset);
nir_ssa_def_rewrite_uses_after(&intrin->dest.ssa, arg_offset, arg_offset->parent_instr);
break;
default:
break;