From 67f01e02d9daa3334f14f17899bc7aa068d89459 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Thu, 18 Nov 2021 09:15:27 -0500 Subject: [PATCH] mesa: add gl_linked_shader::linked_source_sha1 Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/compiler/glsl/linker.cpp | 18 ++++++++++++++++++ src/mesa/main/mtypes.h | 3 +++ 2 files changed, 21 insertions(+) diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp index fa44fa887bc..7ec74df0829 100644 --- a/src/compiler/glsl/linker.cpp +++ b/src/compiler/glsl/linker.cpp @@ -2654,6 +2654,24 @@ link_intrastage_shaders(void *mem_ctx, if (ctx->Const.LowerCsDerivedVariables) lower_cs_derived(linked); + /* Set the linked source SHA1. */ + if (num_shaders == 1) { + memcpy(linked->linked_source_sha1, shader_list[0]->compiled_source_sha1, + SHA1_DIGEST_LENGTH); + } else { + struct mesa_sha1 sha1_ctx; + _mesa_sha1_init(&sha1_ctx); + + for (unsigned i = 0; i < num_shaders; i++) { + if (shader_list[i] == NULL) + continue; + + _mesa_sha1_update(&sha1_ctx, shader_list[i]->compiled_source_sha1, + SHA1_DIGEST_LENGTH); + } + _mesa_sha1_final(&sha1_ctx, linked->linked_source_sha1); + } + return linked; } diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 20719c757b2..6de28f39112 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2610,6 +2610,9 @@ struct gl_linked_shader { gl_shader_stage Stage; + /** All gl_shader::compiled_source_sha1 combined. */ + uint8_t linked_source_sha1[SHA1_DIGEST_LENGTH]; + struct gl_program *Program; /**< Post-compile assembly code */ /**