Module: Mesa
Branch: master
Commit: 2bee6ffec3ff5bc0009cc242c6e2793524ea0060
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2bee6ffec3ff5bc0009cc242c6e2793524ea0060

Author: Alejandro PiƱeiro <[email protected]>
Date:   Tue Mar 16 12:11:28 2021 +0100

v3dv/pipeline: compute sha1 for no-op fragment shaders correctly

We should use the nir shader, as with internal vkShaderModule, instead
of just the name.

Reviewed-by: Iago Toral Quiroga <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9403>

---

 src/broadcom/vulkan/v3dv_pipeline.c | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/src/broadcom/vulkan/v3dv_pipeline.c 
b/src/broadcom/vulkan/v3dv_pipeline.c
index 0f5852b29b8..5ec734a8cba 100644
--- a/src/broadcom/vulkan/v3dv_pipeline.c
+++ b/src/broadcom/vulkan/v3dv_pipeline.c
@@ -57,6 +57,21 @@ v3dv_print_v3d_key(struct v3d_key *key,
    fprintf(stderr, "key %p: %s\n", key, sha1buf);
 }
 
+static void
+pipeline_compute_sha1_from_nir(nir_shader *nir,
+                               unsigned char sha1[20])
+{
+   assert(nir);
+   struct blob blob;
+   blob_init(&blob);
+
+   nir_serialize(&blob, nir, false);
+   if (!blob.out_of_memory)
+      _mesa_sha1_compute(blob.data, blob.size, sha1);
+
+   blob_finish(&blob);
+}
+
 void
 v3dv_shader_module_internal_init(struct v3dv_device *device,
                                  struct vk_shader_module *module,
@@ -67,16 +82,7 @@ v3dv_shader_module_internal_init(struct v3dv_device *device,
    module->nir = nir;
    module->size = 0;
 
-   if (nir != NULL) {
-      struct blob blob;
-      blob_init(&blob);
-
-      nir_serialize(&blob, nir, false);
-      if (!blob.out_of_memory)
-         _mesa_sha1_compute(blob.data, blob.size, module->sha1);
-
-      blob_finish(&blob);
-   }
+   pipeline_compute_sha1_from_nir(nir, module->sha1);
 }
 
 void
@@ -1970,12 +1976,7 @@ pipeline_compile_graphics(struct v3dv_pipeline *pipeline,
       p_stage->entrypoint = "main";
       p_stage->module = 0;
       p_stage->nir = b.shader;
-      /* The no-op shader is always the same, so we can just create the sha1
-       * using the name
-       */
-      _mesa_sha1_compute(b.shader->info.name, strlen(b.shader->info.name),
-                         p_stage->shader_sha1);
-
+      pipeline_compute_sha1_from_nir(p_stage->nir, p_stage->shader_sha1);
       p_stage->program_id =
          p_atomic_inc_return(&physical_device->next_program_id);
 

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to