From 3ae8f910ad4a409e3c2f78057ffae21cf73cceef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Thu, 12 Mar 2026 21:18:29 -0400 Subject: [PATCH] Inline SHA1* functions, remove sha1.h Acked-by: Alyssa Rosenzweig Acked-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/amd/vulkan/radv_shader.h | 1 - src/freedreno/vulkan/tu_tracepoints.py | 2 +- src/gallium/auxiliary/draw/draw_context.h | 2 +- src/gallium/auxiliary/draw/draw_private.h | 2 +- .../auxiliary/util/u_live_shader_cache.h | 2 +- src/gallium/drivers/lima/lima_context.h | 2 +- src/gallium/drivers/llvmpipe/lp_screen.h | 2 +- .../frontends/rusticl/mesa/util/disk_cache.rs | 4 +- src/gallium/frontends/rusticl/meson.build | 3 +- .../frontends/rusticl/rusticl_mesa_bindings.h | 1 - src/gallium/include/frontend/api.h | 2 +- src/mesa/main/tests/disable_windows_include.c | 2 +- src/util/build_id.h | 2 +- src/util/fossilize_db.h | 2 +- src/util/mesa-sha1.c | 2 +- src/util/mesa-sha1.h | 8 ++-- src/util/meson.build | 1 - src/util/sha1/sha1.h | 43 ------------------- 18 files changed, 18 insertions(+), 65 deletions(-) delete mode 100644 src/util/sha1/sha1.h diff --git a/src/amd/vulkan/radv_shader.h b/src/amd/vulkan/radv_shader.h index f548f8c78f5..9421251e080 100644 --- a/src/amd/vulkan/radv_shader.h +++ b/src/amd/vulkan/radv_shader.h @@ -12,7 +12,6 @@ #define RADV_SHADER_H #include "util/mesa-blake3.h" -#include "util/sha1/sha1.h" #include "util/shader_stats.h" #include "util/u_math.h" #include "vulkan/vulkan.h" diff --git a/src/freedreno/vulkan/tu_tracepoints.py b/src/freedreno/vulkan/tu_tracepoints.py index cb47ec4c2e4..15d0ddce9e9 100644 --- a/src/freedreno/vulkan/tu_tracepoints.py +++ b/src/freedreno/vulkan/tu_tracepoints.py @@ -26,7 +26,7 @@ from u_trace import utrace_generate_perfetto_utils Header('vk_enum_to_str.h', scope=HeaderScope.SOURCE|HeaderScope.PERFETTO) Header('vk_format.h') -Header('util/sha1/sha1.h') +Header('util/mesa-blake3.h') Header('tu_cmd_buffer.h', scope=HeaderScope.SOURCE) Header('tu_device.h', scope=HeaderScope.SOURCE) Header('common/freedreno_lrz.h') diff --git a/src/gallium/auxiliary/draw/draw_context.h b/src/gallium/auxiliary/draw/draw_context.h index cea62d7e8ea..a78f713658d 100644 --- a/src/gallium/auxiliary/draw/draw_context.h +++ b/src/gallium/auxiliary/draw/draw_context.h @@ -40,7 +40,7 @@ #include "pipe/p_state.h" #include "pipe/p_shader_tokens.h" -#include "util/sha1/sha1.h" +#include "util/mesa-blake3.h" #include "nir.h" struct pipe_context; diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h index b24fcb78726..ef170801de3 100644 --- a/src/gallium/auxiliary/draw/draw_private.h +++ b/src/gallium/auxiliary/draw/draw_private.h @@ -44,7 +44,7 @@ #include "pipe/p_state.h" #include "pipe/p_defines.h" #include "pipe/p_shader_tokens.h" -#include "util/sha1/sha1.h" +#include "util/mesa-blake3.h" #include "draw_vertex_header.h" diff --git a/src/gallium/auxiliary/util/u_live_shader_cache.h b/src/gallium/auxiliary/util/u_live_shader_cache.h index b5e77ab2c2c..b7bc29700a3 100644 --- a/src/gallium/auxiliary/util/u_live_shader_cache.h +++ b/src/gallium/auxiliary/util/u_live_shader_cache.h @@ -49,7 +49,7 @@ #ifndef U_LIVE_SHADER_CACHE_H #define U_LIVE_SHADER_CACHE_H -#include "util/sha1/sha1.h" +#include "util/mesa-blake3.h" #include "util/simple_mtx.h" #include "pipe/p_state.h" diff --git a/src/gallium/drivers/lima/lima_context.h b/src/gallium/drivers/lima/lima_context.h index 345288d7f7d..c9bdb2b0016 100644 --- a/src/gallium/drivers/lima/lima_context.h +++ b/src/gallium/drivers/lima/lima_context.h @@ -26,7 +26,7 @@ #define H_LIMA_CONTEXT #include "util/list.h" -#include "util/sha1/sha1.h" +#include "util/mesa-blake3.h" #include "util/slab.h" #include "util/u_debug.h" diff --git a/src/gallium/drivers/llvmpipe/lp_screen.h b/src/gallium/drivers/llvmpipe/lp_screen.h index c2b6a7612ce..60dbee7cec3 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.h +++ b/src/gallium/drivers/llvmpipe/lp_screen.h @@ -38,7 +38,7 @@ #include "pipe/p_defines.h" #include "util/u_thread.h" #include "util/list.h" -#include "util/sha1/sha1.h" +#include "util/mesa-blake3.h" #include "util/vma.h" #include "gallivm/lp_bld.h" #include "gallivm/lp_bld_misc.h" diff --git a/src/gallium/frontends/rusticl/mesa/util/disk_cache.rs b/src/gallium/frontends/rusticl/mesa/util/disk_cache.rs index 2b8f19e024f..8427c321818 100644 --- a/src/gallium/frontends/rusticl/mesa/util/disk_cache.rs +++ b/src/gallium/frontends/rusticl/mesa/util/disk_cache.rs @@ -84,14 +84,14 @@ impl DiskCache { let mut cache_id = [0; BLAKE3_HEX_LEN as usize]; let cache = unsafe { - SHA1Init(&mut sha_ctx); + _mesa_blake3_init(&mut sha_ctx); for &func_ptr in func_ptrs { if !disk_cache_get_function_identifier(func_ptr, &mut sha_ctx) { return None; } } - SHA1Final(&mut sha, &mut sha_ctx); + _mesa_blake3_final(&mut sha_ctx, &mut sha); mesa_bytes_to_hex(cache_id.as_mut_ptr(), sha.as_ptr(), sha.len() as u32); disk_cache_create(name.as_ptr(), cache_id.as_ptr(), flags) }; diff --git a/src/gallium/frontends/rusticl/meson.build b/src/gallium/frontends/rusticl/meson.build index a32687ad8b8..d582dc50936 100644 --- a/src/gallium/frontends/rusticl/meson.build +++ b/src/gallium/frontends/rusticl/meson.build @@ -275,8 +275,7 @@ rusticl_mesa_bindings = rust.bindgen( '--allowlist-var', 'OS_.*', '--allowlist-function', 'rz?alloc_.*', '--allowlist-var', 'BLAKE3_.*', - '--allowlist-function', 'SHA1.*', - '--allowlist-var', 'SHA1_.*', + '--allowlist-function', '_mesa_blake3_.*', '--allowlist-function', 'u_.*', '--allowlist-function', 'util_format_.*', '--allowlist-function', 'util_queue_.*', diff --git a/src/gallium/frontends/rusticl/rusticl_mesa_bindings.h b/src/gallium/frontends/rusticl/rusticl_mesa_bindings.h index fa5163cfdef..857a64b51bb 100644 --- a/src/gallium/frontends/rusticl/rusticl_mesa_bindings.h +++ b/src/gallium/frontends/rusticl/rusticl_mesa_bindings.h @@ -26,7 +26,6 @@ #include "util/disk_cache.h" #include "util/hex.h" #include "util/os_time.h" -#include "util/sha1/sha1.h" #include "util/u_cpu_detect.h" #include "util/u_inlines.h" #include "util/u_upload_mgr.h" diff --git a/src/gallium/include/frontend/api.h b/src/gallium/include/frontend/api.h index 8375198cbf3..f00c6ab07a2 100644 --- a/src/gallium/include/frontend/api.h +++ b/src/gallium/include/frontend/api.h @@ -28,7 +28,7 @@ #define _API_H_ #include "util/format/u_formats.h" -#include "util/sha1/sha1.h" +#include "util/mesa-blake3.h" struct st_context; diff --git a/src/mesa/main/tests/disable_windows_include.c b/src/mesa/main/tests/disable_windows_include.c index 5ea32dcee62..ae7bf6ae479 100644 --- a/src/mesa/main/tests/disable_windows_include.c +++ b/src/mesa/main/tests/disable_windows_include.c @@ -247,7 +247,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/util/build_id.h b/src/util/build_id.h index 179181f1d48..821dcb231e7 100644 --- a/src/util/build_id.h +++ b/src/util/build_id.h @@ -41,7 +41,7 @@ extern "C" { #define BUILD_ID_EXPECTED_HASH_LENGTH 20 /* sha1 */ #include -#include "sha1/sha1.h" +#include "mesa-blake3.h" struct build_id_note; diff --git a/src/util/fossilize_db.h b/src/util/fossilize_db.h index 879cc79b303..d0674201c8c 100644 --- a/src/util/fossilize_db.h +++ b/src/util/fossilize_db.h @@ -45,7 +45,7 @@ #include #include -#include "sha1/sha1.h" +#include "mesa-blake3.h" #include "simple_mtx.h" /* Max number of DBs our implementation can read from at once */ diff --git a/src/util/mesa-sha1.c b/src/util/mesa-sha1.c index 2c755ed18fa..f7f3a9c949f 100644 --- a/src/util/mesa-sha1.c +++ b/src/util/mesa-sha1.c @@ -24,7 +24,7 @@ * DEALINGS IN THE SOFTWARE. */ -#include "sha1/sha1.h" +#include "mesa-blake3.h" #include "mesa-sha1.h" #include "hex.h" #include diff --git a/src/util/mesa-sha1.h b/src/util/mesa-sha1.h index ae37ba31a94..f4f4953bbf5 100644 --- a/src/util/mesa-sha1.h +++ b/src/util/mesa-sha1.h @@ -26,7 +26,7 @@ #include #include #include -#include "sha1/sha1.h" +#include "mesa-blake3.h" #ifdef __cplusplus extern "C" { @@ -37,20 +37,20 @@ extern "C" { static inline void _mesa_sha1_init(blake3_hasher *ctx) { - SHA1Init(ctx); + _mesa_blake3_init(ctx); } static inline void _mesa_sha1_update(blake3_hasher *ctx, const void *data, size_t size) { if (size) - SHA1Update(ctx, (const unsigned char *)data, size); + _mesa_blake3_update(ctx, (const unsigned char *)data, size); } static inline void _mesa_sha1_final(blake3_hasher *ctx, unsigned char result[BLAKE3_KEY_LEN]) { - SHA1Final(result, ctx); + _mesa_blake3_final(ctx, result); } void diff --git a/src/util/meson.build b/src/util/meson.build index 4f3b71dd730..f32ed488542 100644 --- a/src/util/meson.build +++ b/src/util/meson.build @@ -95,7 +95,6 @@ files_mesa_util = files( 'u_qsort.h', 'rwlock.c', 'rwlock.h', - 'sha1/sha1.h', 'ralloc.c', 'ralloc.h', 'rand_xor.c', diff --git a/src/util/sha1/sha1.h b/src/util/sha1/sha1.h deleted file mode 100644 index 9c6d4f2eadc..00000000000 --- a/src/util/sha1/sha1.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright 2025 Advanced Micro Devices, Inc. - * SPDX-License-Identifier: MIT - */ - -#ifndef _SHA1_H -#define _SHA1_H - -/* This is not SHA1. This is BLAKE3 exposed as SHA1 functions due to - * transitional and historic reasons. - * - * TODO: Remove this and use _mesa_blake3_* functions everywhere. - * All remnants of SHA1 should be removed from Mesa except build_id. - */ - -#include "util/mesa-blake3.h" - -#ifdef __cplusplus -extern "C" { -#endif - -static inline void -SHA1Init(blake3_hasher *context) -{ - _mesa_blake3_init(context); -} - -static inline void -SHA1Update(blake3_hasher *context, const uint8_t *data, size_t len) -{ - _mesa_blake3_update(context, data, len); -} - -static inline void -SHA1Final(uint8_t digest[BLAKE3_KEY_LEN], blake3_hasher *context) -{ - _mesa_blake3_final(context, digest); -} - -#ifdef __cplusplus -} -#endif - -#endif /* _SHA1_H */