From e65303c6e681bc01b4ae4f93492fee7452952ac3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Louis-Francis=20Ratt=C3=A9-Boulianne?= Date: Tue, 9 Nov 2021 22:54:29 -0500 Subject: [PATCH] microsoft/spirv_to_dxil: check for variables r/w access Reviewed-by: Jesse Natalie Part-of: --- src/microsoft/spirv_to_dxil/spirv_to_dxil.c | 10 ++++++++++ src/microsoft/spirv_to_dxil/spirv_to_dxil.h | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/src/microsoft/spirv_to_dxil/spirv_to_dxil.c b/src/microsoft/spirv_to_dxil/spirv_to_dxil.c index 2e895b9..50dda8d 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 6284355..23bcaeb 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 { -- 2.7.4