nir: Add sha1 hash for nir shaders converted from spir-v
authorIllia Polishchuk <illia.a.polishchuk@globallogic.com>
Tue, 31 Jan 2023 20:30:13 +0000 (22:30 +0200)
committerMarge Bot <emma+marge@anholt.net>
Wed, 1 Feb 2023 04:19:04 +0000 (04:19 +0000)
The sha1 hash inside nir structure
makes it easier to find bad shader in games.

For example INTEL_DEBUG=fs will show not zero
source_sha1 field for shaders with vulkan applications

Signed-off-by: Illia Polishchuk <illia.a.polishchuk@globallogic.com>
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21012>

src/compiler/spirv/spirv_to_nir.c

index 5a21f4d..d06c1a1 100644 (file)
@@ -6585,12 +6585,13 @@ spirv_to_nir(const uint32_t *words, size_t word_count,
       return NULL;
    }
 
-   /* Skip the SPIR-V header, handled at vtn_create_builder */
-   words+= 5;
-
    b->shader = nir_shader_create(b, stage, nir_options, NULL);
    b->shader->info.subgroup_size = options->subgroup_size;
    b->shader->info.float_controls_execution_mode = options->float_controls_execution_mode;
+   _mesa_sha1_compute(words, word_count * sizeof(uint32_t), b->shader->info.source_sha1);
+
+   /* Skip the SPIR-V header, handled at vtn_create_builder */
+   words+= 5;
 
    /* Handle all the preamble instructions */
    words = vtn_foreach_instruction(b, words, word_end,