diff --git a/src/microsoft/spirv_to_dxil/spirv_to_dxil.c b/src/microsoft/spirv_to_dxil/spirv_to_dxil.c index 2e895b96741..50dda8d5f31 100644 --- a/src/microsoft/spirv_to_dxil/spirv_to_dxil.c +++ b/src/microsoft/spirv_to_dxil/spirv_to_dxil.c @@ -336,6 +336,16 @@ spirv_to_dxil(const uint32_t *words, size_t word_count, conf->runtime_data_cbv.register_space, conf->runtime_data_cbv.base_shader_register); + NIR_PASS_V(nir, nir_opt_deref); + + if (conf->read_only_images_as_srvs) { + const nir_opt_access_options opt_access_options = { + .is_vulkan = true, + .infer_non_readable = true, + }; + NIR_PASS_V(nir, nir_opt_access, &opt_access_options); + } + NIR_PASS_V(nir, nir_split_per_member_structs); NIR_PASS_V(nir, nir_remove_dead_variables, diff --git a/src/microsoft/spirv_to_dxil/spirv_to_dxil.h b/src/microsoft/spirv_to_dxil/spirv_to_dxil.h index 6284355d159..23bcaeb8787 100644 --- a/src/microsoft/spirv_to_dxil/spirv_to_dxil.h +++ b/src/microsoft/spirv_to_dxil/spirv_to_dxil.h @@ -144,6 +144,10 @@ struct dxil_spirv_runtime_conf { uint16_t y_mask; uint16_t z_mask; } yz_flip; + + // The caller supports read-only images to be turned into SRV accesses, + // which allows us to run the nir_opt_access() pass + bool read_only_images_as_srvs; }; struct dxil_spirv_debug_options {