nir: Fix shader calls with nir_opt_dead_write_vars.

Fixes: 5a28893279 ("spirv,nir: Add ray-tracing intrinsics")
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10096>
(cherry picked from commit 84e0f6dbd8)
This commit is contained in:
Bas Nieuwenhuizen 2021-03-31 02:41:15 +02:00 committed by Dylan Baker
parent 6870d9097b
commit ce5cd85211
2 changed files with 15 additions and 1 deletions

View file

@ -202,7 +202,7 @@
"description": "nir: Fix shader calls with nir_opt_dead_write_vars.",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"master_sha": null,
"because_sha": "5a2889327970ce2e7f342c357efb50fa25c2a5e4"
},

View file

@ -169,6 +169,20 @@ remove_dead_write_vars_local(void *mem_ctx, nir_shader *shader, nir_block *block
break;
}
case nir_intrinsic_execute_callable: {
/* Mark payload as it can be used by the callee */
nir_deref_instr *src = nir_src_as_deref(intrin->src[1]);
clear_unused_for_read(&unused_writes, src);
break;
}
case nir_intrinsic_trace_ray: {
/* Mark payload as it can be used by the callees */
nir_deref_instr *src = nir_src_as_deref(intrin->src[10]);
clear_unused_for_read(&unused_writes, src);
break;
}
case nir_intrinsic_load_deref: {
nir_deref_instr *src = nir_src_as_deref(intrin->src[0]);
if (nir_deref_mode_must_be(src, nir_var_read_only_modes))