Mesa (main): radv: clone shader in radv_shader_compile_to_nir

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Dec 8 11:31:07 UTC 2021


Module: Mesa
Branch: main
Commit: 85161fb8ac1b926b2222b4a860168d73c33a5801
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=85161fb8ac1b926b2222b4a860168d73c33a5801

Author: Rhys Perry <pendingchaos02 at gmail.com>
Date:   Mon Dec  6 19:11:06 2021 +0000

radv: clone shader in radv_shader_compile_to_nir

This way, radv_shader_compile_to_nir doesn't alter the NIR.

Signed-off-by: Rhys Perry <pendingchaos02 at gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14087>

---

 src/amd/vulkan/radv_pipeline.c | 7 -------
 src/amd/vulkan/radv_shader.c   | 5 +++--
 2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c
index 32821e76a15..9c6e5a1adcb 100644
--- a/src/amd/vulkan/radv_pipeline.c
+++ b/src/amd/vulkan/radv_pipeline.c
@@ -3563,13 +3563,6 @@ radv_create_shaders(struct radv_pipeline *pipeline, struct radv_pipeline_layout
                                           stage ? stage->pSpecializationInfo : NULL,
                                           pipeline_layout, pipeline_key);
 
-      /* We don't want to alter meta shaders IR directly so clone it
-       * first.
-       */
-      if (nir[i]->info.name) {
-         nir[i] = nir_shader_clone(NULL, nir[i]);
-      }
-
       radv_stop_feedback(stage_feedbacks[i], false);
    }
 
diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c
index 00731ea074f..65972d3b9ab 100644
--- a/src/amd/vulkan/radv_shader.c
+++ b/src/amd/vulkan/radv_shader.c
@@ -443,8 +443,9 @@ radv_shader_compile_to_nir(struct radv_device *device, struct vk_shader_module *
    if (module->nir) {
       /* Some things such as our meta clear/blit code will give us a NIR
        * shader directly.  In that case, we just ignore the SPIR-V entirely
-       * and just use the NIR shader */
-      nir = module->nir;
+       * and just use the NIR shader.  We don't want to alter meta and RT
+       * shaders IR directly, so clone it first. */
+      nir = nir_shader_clone(NULL, module->nir);
       nir->options = &device->physical_device->nir_options;
       nir_validate_shader(nir, "in internal shader");
 



More information about the mesa-commit mailing list