spirv2dxil: Split read-only image as SRV logic into declared and inferred
authorPedro J. Estébanez <pedrojrulez@gmail.com>
Tue, 4 Apr 2023 16:51:42 +0000 (18:51 +0200)
committerMarge Bot <emma+marge@anholt.net>
Tue, 4 Apr 2023 22:50:05 +0000 (22:50 +0000)
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
src/microsoft/spirv_to_dxil/spirv2dxil.c
src/microsoft/spirv_to_dxil/spirv_to_dxil.h
src/microsoft/vulkan/dzn_pipeline.c

index 7347932..5537307 100644 (file)
@@ -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,
index b797663..fd0613c 100644 (file)
@@ -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;
index cb82e46..40adf76 100644 (file)
@@ -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;
index 09df6a0..f1166c9 100644 (file)
@@ -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,