Module: Mesa Branch: main Commit: e59fdcb93cec9b6035e2f9eec824d0707a1619fe URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e59fdcb93cec9b6035e2f9eec824d0707a1619fe
Author: Pedro J. Estébanez <[email protected]> Date: Tue Apr 4 18:51:42 2023 +0200 spirv2dxil: Split read-only image as SRV logic into declared and inferred Fixes: e0a090ad ("spirv2dxil: Only lower readonly images to SRVs when the option is set") Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22289> --- src/microsoft/spirv_to_dxil/dxil_spirv_nir.c | 4 ++-- src/microsoft/spirv_to_dxil/spirv2dxil.c | 1 + src/microsoft/spirv_to_dxil/spirv_to_dxil.h | 6 +++++- src/microsoft/vulkan/dzn_pipeline.c | 3 ++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/microsoft/spirv_to_dxil/dxil_spirv_nir.c b/src/microsoft/spirv_to_dxil/dxil_spirv_nir.c index 7347932633f..55373076623 100644 --- a/src/microsoft/spirv_to_dxil/dxil_spirv_nir.c +++ b/src/microsoft/spirv_to_dxil/dxil_spirv_nir.c @@ -1000,7 +1000,7 @@ dxil_spirv_nir_passes(nir_shader *nir, nir_var_mem_ubo | nir_var_mem_push_const | nir_var_mem_ssbo); - if (conf->read_only_images_as_srvs) { + if (conf->inferred_read_only_images_as_srvs) { const nir_opt_access_options opt_access_options = { .is_vulkan = true, }; @@ -1088,7 +1088,7 @@ dxil_spirv_nir_passes(nir_shader *nir, } while (progress); } - if (conf->read_only_images_as_srvs) + if (conf->declared_read_only_images_as_srvs) NIR_PASS_V(nir, nir_lower_readonly_images_to_tex, true); nir_lower_tex_options lower_tex_options = { .lower_txp = UINT32_MAX, diff --git a/src/microsoft/spirv_to_dxil/spirv2dxil.c b/src/microsoft/spirv_to_dxil/spirv2dxil.c index b7976639ae0..fd0613c7927 100644 --- a/src/microsoft/spirv_to_dxil/spirv2dxil.c +++ b/src/microsoft/spirv_to_dxil/spirv2dxil.c @@ -186,6 +186,7 @@ main(int argc, char **argv) conf.runtime_data_cbv.base_shader_register = 0; conf.runtime_data_cbv.register_space = 31; conf.zero_based_vertex_instance_id = true; + conf.declared_read_only_images_as_srvs = true; conf.shader_model_max = SHADER_MODEL_6_2; bool any_shaders = false; diff --git a/src/microsoft/spirv_to_dxil/spirv_to_dxil.h b/src/microsoft/spirv_to_dxil/spirv_to_dxil.h index cb82e463942..40adf761ef5 100644 --- a/src/microsoft/spirv_to_dxil/spirv_to_dxil.h +++ b/src/microsoft/spirv_to_dxil/spirv_to_dxil.h @@ -165,7 +165,11 @@ struct dxil_spirv_runtime_conf { // 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; + bool declared_read_only_images_as_srvs; + + // The caller supports read-write images to be turned into SRV accesses, + // if they are found not to be written + bool inferred_read_only_images_as_srvs; // Force sample rate shading on a fragment shader bool force_sample_rate_shading; diff --git a/src/microsoft/vulkan/dzn_pipeline.c b/src/microsoft/vulkan/dzn_pipeline.c index 09df6a08433..f1166c98e8e 100644 --- a/src/microsoft/vulkan/dzn_pipeline.c +++ b/src/microsoft/vulkan/dzn_pipeline.c @@ -243,7 +243,8 @@ dzn_pipeline_get_nir_shader(struct dzn_device *device, .y_mask = options->y_flip_mask, .z_mask = options->z_flip_mask, }, - .read_only_images_as_srvs = !device->bindless, + .declared_read_only_images_as_srvs = !device->bindless, + .inferred_read_only_images_as_srvs = !device->bindless, .force_sample_rate_shading = options->force_sample_rate_shading, .lower_view_index = options->lower_view_index, .lower_view_index_to_rt_layer = options->lower_view_index_to_rt_layer,
