Inline SHA1* functions, remove sha1.h

Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com>
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40383>
This commit is contained in:
Marek Olšák 2026-03-12 21:18:29 -04:00 committed by Marge Bot
parent a965ada6ee
commit 3ae8f910ad
18 changed files with 18 additions and 65 deletions

View file

@ -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"

View file

@ -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')

View file

@ -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;

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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)
};

View file

@ -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_.*',

View file

@ -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"

View file

@ -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;

View file

@ -247,7 +247,7 @@
#include <util/rounding.h>
#include <util/rwlock.h>
#include <util/set.h>
#include <util/sha1/sha1.h>
#include <util/mesa-blake3.h>
#include <util/simple_mtx.h>
#include <util/slab.h>
#include <util/softfloat.h>

View file

@ -41,7 +41,7 @@ extern "C" {
#define BUILD_ID_EXPECTED_HASH_LENGTH 20 /* sha1 */
#include <stdint.h>
#include "sha1/sha1.h"
#include "mesa-blake3.h"
struct build_id_note;

View file

@ -45,7 +45,7 @@
#include <stdint.h>
#include <stdio.h>
#include "sha1/sha1.h"
#include "mesa-blake3.h"
#include "simple_mtx.h"
/* Max number of DBs our implementation can read from at once */

View file

@ -24,7 +24,7 @@
* DEALINGS IN THE SOFTWARE.
*/
#include "sha1/sha1.h"
#include "mesa-blake3.h"
#include "mesa-sha1.h"
#include "hex.h"
#include <string.h>

View file

@ -26,7 +26,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#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

View file

@ -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',

View file

@ -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 */