From 1912a00a9155937bf8b3ef291091f8602910e38f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Tue, 30 Dec 2025 10:59:19 -0500 Subject: [PATCH] ALL: use SHA1_DIGEST_LENGTH etc. instead of hardcoding the numbers only build_id is switched to use literal 20 instead of SHA1_DIGEST_LENGTH because we will increase SHA1_DIGEST_LENGTH to BLAKE3_KEY_LEN Part-of: --- src/amd/common/ac_surface_modifier_test.c | 2 +- src/amd/vulkan/radv_debug.c | 4 +- src/amd/vulkan/radv_physical_device.c | 2 +- src/amd/vulkan/radv_pipeline_rt.c | 2 +- src/amd/vulkan/radv_shader.h | 3 +- src/asahi/vulkan/hk_instance.c | 2 +- src/asahi/vulkan/hk_instance.h | 2 +- src/asahi/vulkan/hk_physical_device.c | 4 +- src/broadcom/vulkan/v3dv_device.c | 4 +- src/broadcom/vulkan/v3dv_pipeline.c | 8 ++-- src/broadcom/vulkan/v3dv_pipeline_cache.c | 44 +++++++++---------- src/broadcom/vulkan/v3dv_private.h | 16 +++---- src/broadcom/vulkan/v3dv_query.c | 2 +- src/compiler/clc/nir_load_libclc.c | 2 +- src/compiler/glsl/glsl_parser_extras.cpp | 4 +- src/compiler/glsl/shader_cache.cpp | 4 +- src/freedreno/ir3/ir3_disk_cache.c | 6 +-- src/freedreno/ir3/ir3_shader.c | 2 +- src/freedreno/vulkan/tu_descriptor_set.h | 2 +- src/freedreno/vulkan/tu_device.cc | 4 +- src/freedreno/vulkan/tu_pipeline.cc | 12 ++--- src/freedreno/vulkan/tu_query_pool.cc | 4 +- src/freedreno/vulkan/tu_shader.cc | 6 +-- src/gallium/auxiliary/draw/draw_context.c | 4 +- src/gallium/auxiliary/draw/draw_context.h | 5 ++- src/gallium/auxiliary/draw/draw_llvm.c | 10 ++--- src/gallium/auxiliary/draw/draw_private.h | 5 ++- .../auxiliary/util/u_live_shader_cache.c | 2 +- .../auxiliary/util/u_live_shader_cache.h | 3 +- src/gallium/drivers/asahi/agx_disk_cache.c | 2 +- src/gallium/drivers/asahi/agx_state.h | 2 +- src/gallium/drivers/crocus/crocus_context.h | 2 +- .../drivers/crocus/crocus_disk_cache.c | 6 +-- .../drivers/etnaviv/etnaviv_disk_cache.c | 6 +-- src/gallium/drivers/iris/iris_context.h | 2 +- src/gallium/drivers/iris/iris_disk_cache.c | 8 ++-- src/gallium/drivers/lima/lima_context.h | 9 ++-- src/gallium/drivers/lima/lima_disk_cache.c | 10 ++--- src/gallium/drivers/llvmpipe/lp_context.c | 4 +- src/gallium/drivers/llvmpipe/lp_screen.c | 10 ++--- src/gallium/drivers/llvmpipe/lp_screen.h | 5 ++- src/gallium/drivers/llvmpipe/lp_state_cs.c | 4 +- src/gallium/drivers/llvmpipe/lp_state_fs.c | 4 +- src/gallium/drivers/nouveau/nouveau_screen.c | 8 ++-- src/gallium/drivers/panfrost/pan_context.h | 2 +- src/gallium/drivers/panfrost/pan_disk_cache.c | 6 +-- src/gallium/drivers/r300/r300_screen.c | 6 +-- src/gallium/drivers/r600/r600_pipe_common.c | 6 +-- src/gallium/drivers/radeonsi/si_compute.c | 2 +- src/gallium/drivers/radeonsi/si_pipe.c | 6 +-- src/gallium/drivers/radeonsi/si_state.h | 6 +-- .../drivers/radeonsi/si_state_shaders.cpp | 8 ++-- src/gallium/drivers/v3d/v3d_context.h | 2 +- src/gallium/drivers/v3d/v3d_disk_cache.c | 8 ++-- src/gallium/drivers/v3d/v3d_program.c | 8 ++-- src/gallium/drivers/virgl/virgl_screen.c | 4 +- src/gallium/drivers/zink/zink_screen.c | 4 +- src/gallium/frontends/lavapipe/lvp_pipeline.c | 2 +- src/gallium/include/frontend/api.h | 3 +- src/intel/common/intel_uuid.c | 2 +- src/intel/compiler/brw/brw_compiler.c | 2 +- src/intel/compiler/brw/brw_generator.cpp | 4 +- src/intel/compiler/elk/elk_fs_generator.cpp | 4 +- src/intel/compiler/elk/elk_vec4_generator.cpp | 4 +- src/intel/perf/intel_perf.c | 4 +- src/intel/tools/intel_dev_info.c | 2 +- src/intel/vulkan/anv_perf.c | 2 +- src/intel/vulkan/anv_physical_device.c | 6 +-- src/intel/vulkan/anv_pipeline_cache.c | 2 +- src/intel/vulkan/anv_private.h | 18 ++++---- src/intel/vulkan/anv_shader_compile.c | 2 +- src/intel/vulkan_hasvk/anv_device.c | 4 +- src/intel/vulkan_hasvk/anv_perf.c | 2 +- src/intel/vulkan_hasvk/anv_pipeline.c | 6 +-- src/intel/vulkan_hasvk/anv_private.h | 20 ++++----- src/mesa/main/program_binary.c | 6 +-- src/mesa/main/shader_types.h | 2 +- src/nouveau/vulkan/nvk_instance.c | 2 +- src/nouveau/vulkan/nvk_instance.h | 2 +- src/nouveau/vulkan/nvk_physical_device.c | 2 +- src/panfrost/vulkan/panvk_instance.c | 2 +- src/panfrost/vulkan/panvk_instance.h | 2 +- src/util/disk_cache.h | 2 +- src/util/disk_cache_os.c | 4 +- src/util/fossilize_db.h | 3 +- src/util/mesa-sha1.c | 2 +- src/util/mesa-sha1.h | 4 +- src/util/tests/cache_test.cpp | 34 +++++++------- src/util/tests/mesa-sha1_test.cpp | 4 +- src/virtio/vulkan/vn_device.c | 2 +- 90 files changed, 245 insertions(+), 237 deletions(-) diff --git a/src/amd/common/ac_surface_modifier_test.c b/src/amd/common/ac_surface_modifier_test.c index 2e2601b3549..3b4b4379fa3 100644 --- a/src/amd/common/ac_surface_modifier_test.c +++ b/src/amd/common/ac_surface_modifier_test.c @@ -38,7 +38,7 @@ struct test_entry { uint8_t se; /* value to determine uniqueness */ - unsigned char hash[20]; + unsigned char hash[SHA1_DIGEST_LENGTH]; /* u_vector requires power of two sizing */ char padding[sizeof(void*) == 8 ? 8 : 16]; diff --git a/src/amd/vulkan/radv_debug.c b/src/amd/vulkan/radv_debug.c index 3134c4d042c..e9aecbeda22 100644 --- a/src/amd/vulkan/radv_debug.c +++ b/src/amd/vulkan/radv_debug.c @@ -570,8 +570,8 @@ radv_dump_shader(struct radv_device *device, struct radv_pipeline *pipeline, str fprintf(f, "%s:\n\n", radv_get_shader_name(&shader->info, stage)); if (shader->spirv) { - unsigned char sha1[21]; - char sha1buf[41]; + unsigned char sha1[SHA1_DIGEST_LENGTH + 1]; + char sha1buf[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_compute(shader->spirv, shader->spirv_size, sha1); _mesa_sha1_format(sha1buf, sha1); diff --git a/src/amd/vulkan/radv_physical_device.c b/src/amd/vulkan/radv_physical_device.c index fb6e0d355ec..129adcc3b89 100644 --- a/src/amd/vulkan/radv_physical_device.c +++ b/src/amd/vulkan/radv_physical_device.c @@ -308,7 +308,7 @@ static int radv_device_get_cache_uuid(struct radv_physical_device *pdev, void *uuid) { struct mesa_sha1 ctx; - unsigned char sha1[20]; + unsigned char sha1[SHA1_DIGEST_LENGTH]; memset(uuid, 0, VK_UUID_SIZE); _mesa_sha1_init(&ctx); diff --git a/src/amd/vulkan/radv_pipeline_rt.c b/src/amd/vulkan/radv_pipeline_rt.c index 6298bce9b9e..8c45d0b390c 100644 --- a/src/amd/vulkan/radv_pipeline_rt.c +++ b/src/amd/vulkan/radv_pipeline_rt.c @@ -28,7 +28,7 @@ struct rt_handle_hash_entry { uint32_t key; - char hash[20]; + char hash[SHA1_DIGEST_LENGTH]; }; static uint32_t diff --git a/src/amd/vulkan/radv_shader.h b/src/amd/vulkan/radv_shader.h index ceb0d9f0d85..91e251378a3 100644 --- a/src/amd/vulkan/radv_shader.h +++ b/src/amd/vulkan/radv_shader.h @@ -12,6 +12,7 @@ #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" @@ -269,7 +270,7 @@ struct radv_shader_stage { const char *entrypoint; const VkSpecializationInfo *spec_info; - unsigned char shader_sha1[20]; + unsigned char shader_sha1[SHA1_DIGEST_LENGTH]; nir_shader *nir; nir_shader *gs_copy_shader; diff --git a/src/asahi/vulkan/hk_instance.c b/src/asahi/vulkan/hk_instance.c index a75247c127a..0212275b7d4 100644 --- a/src/asahi/vulkan/hk_instance.c +++ b/src/asahi/vulkan/hk_instance.c @@ -170,7 +170,7 @@ hk_CreateInstance(const VkInstanceCreateInfo *pCreateInfo, } unsigned build_id_len = build_id_length(note); - if (build_id_len < SHA1_DIGEST_LENGTH) { + if (build_id_len < 20) { result = vk_errorf(NULL, VK_ERROR_INITIALIZATION_FAILED, "build-id too short. It needs to be a SHA"); goto fail_init; diff --git a/src/asahi/vulkan/hk_instance.h b/src/asahi/vulkan/hk_instance.h index 261cc301a89..29f6fb549e8 100644 --- a/src/asahi/vulkan/hk_instance.h +++ b/src/asahi/vulkan/hk_instance.h @@ -16,7 +16,7 @@ struct hk_instance { struct driOptionCache dri_options; struct driOptionCache available_dri_options; - uint8_t driver_build_sha[20]; + uint8_t driver_build_sha[SHA1_DIGEST_LENGTH]; uint32_t force_vk_vendor; bool no_border; diff --git a/src/asahi/vulkan/hk_physical_device.c b/src/asahi/vulkan/hk_physical_device.c index eddf042aef4..e9a5fd8d376 100644 --- a/src/asahi/vulkan/hk_physical_device.c +++ b/src/asahi/vulkan/hk_physical_device.c @@ -1067,7 +1067,7 @@ hk_get_device_properties(const struct agx_device *dev, { struct mesa_sha1 sha1_ctx; - uint8_t sha1[20]; + uint8_t sha1[SHA1_DIGEST_LENGTH]; _mesa_sha1_init(&sha1_ctx); /* Make sure we don't match with other vendors */ @@ -1108,7 +1108,7 @@ hk_physical_device_init_pipeline_cache(struct hk_physical_device *pdev) assert(len == sizeof(renderer) - 2); - char timestamp[41]; + char timestamp[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(timestamp, instance->driver_build_sha); const uint64_t driver_flags = hk_physical_device_compiler_flags(pdev); diff --git a/src/broadcom/vulkan/v3dv_device.c b/src/broadcom/vulkan/v3dv_device.c index 33af35eb040..07f2b3eb59f 100644 --- a/src/broadcom/vulkan/v3dv_device.c +++ b/src/broadcom/vulkan/v3dv_device.c @@ -779,7 +779,7 @@ init_uuids(struct v3dv_physical_device *device) uint32_t device_id = v3dv_physical_device_device_id(device); struct mesa_sha1 sha1_ctx; - uint8_t sha1[20]; + uint8_t sha1[SHA1_DIGEST_LENGTH]; STATIC_ASSERT(VK_UUID_SIZE <= sizeof(sha1)); /* The pipeline cache UUID is used for determining when a pipeline cache is @@ -815,7 +815,7 @@ static void v3dv_physical_device_init_disk_cache(struct v3dv_physical_device *device) { #ifdef ENABLE_SHADER_CACHE - char timestamp[41]; + char timestamp[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(timestamp, device->driver_build_sha1); assert(device->name); diff --git a/src/broadcom/vulkan/v3dv_pipeline.c b/src/broadcom/vulkan/v3dv_pipeline.c index f63a6d28642..dad3cb6db8e 100644 --- a/src/broadcom/vulkan/v3dv_pipeline.c +++ b/src/broadcom/vulkan/v3dv_pipeline.c @@ -402,7 +402,7 @@ shader_module_compile_to_nir(struct v3dv_device *device, assert(nir->info.stage == gl_stage); if (V3D_DBG(SHADERDB) && (!stage->module || stage->module->nir == NULL)) { - char sha1buf[41]; + char sha1buf[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(sha1buf, stage->pipeline->sha1); nir->info.name = ralloc_strdup(nir, sha1buf); } @@ -1439,7 +1439,7 @@ pipeline_stage_create_binning(const struct v3dv_pipeline_stage *src, p_stage->spec_info = src->spec_info; p_stage->feedback = (VkPipelineCreationFeedback) { 0 }; p_stage->robustness = src->robustness; - memcpy(p_stage->shader_sha1, src->shader_sha1, 20); + memcpy(p_stage->shader_sha1, src->shader_sha1, SHA1_DIGEST_LENGTH); return p_stage; } @@ -2118,7 +2118,7 @@ pipeline_populate_compute_key(struct v3dv_pipeline *pipeline, } static struct v3dv_pipeline_shared_data * -v3dv_pipeline_shared_data_new_empty(const unsigned char sha1_key[20], +v3dv_pipeline_shared_data_new_empty(const unsigned char sha1_key[SHA1_DIGEST_LENGTH], struct v3dv_pipeline *pipeline, bool is_graphics_pipeline) { @@ -2172,7 +2172,7 @@ v3dv_pipeline_shared_data_new_empty(const unsigned char sha1_key[20], new_entry->maps[BROADCOM_SHADER_GEOMETRY]; new_entry->ref_cnt = 1; - memcpy(new_entry->sha1_key, sha1_key, 20); + memcpy(new_entry->sha1_key, sha1_key, SHA1_DIGEST_LENGTH); return new_entry; diff --git a/src/broadcom/vulkan/v3dv_pipeline_cache.c b/src/broadcom/vulkan/v3dv_pipeline_cache.c index 1553d56c758..5f249763ed3 100644 --- a/src/broadcom/vulkan/v3dv_pipeline_cache.c +++ b/src/broadcom/vulkan/v3dv_pipeline_cache.c @@ -36,7 +36,7 @@ static const bool dump_stats_on_destroy = false; static uint32_t sha1_hash_func(const void *sha1) { - return _mesa_hash_data(sha1, 20); + return _mesa_hash_data(sha1, SHA1_DIGEST_LENGTH); } static bool @@ -46,7 +46,7 @@ sha1_compare_func(const void *sha1_a, const void *sha1_b) } struct serialized_nir { - unsigned char sha1_key[20]; + unsigned char sha1_key[SHA1_DIGEST_LENGTH]; size_t size; char data[0]; }; @@ -83,7 +83,7 @@ void v3dv_pipeline_cache_upload_nir(struct v3dv_pipeline *pipeline, struct v3dv_pipeline_cache *cache, nir_shader *nir, - unsigned char sha1_key[20]) + unsigned char sha1_key[SHA1_DIGEST_LENGTH]) { if (!cache || !cache->nir_cache) return; @@ -121,7 +121,7 @@ v3dv_pipeline_cache_upload_nir(struct v3dv_pipeline *pipeline, struct serialized_nir *snir = ralloc_size(cache->nir_cache, sizeof(*snir) + blob.size); - memcpy(snir->sha1_key, sha1_key, 20); + memcpy(snir->sha1_key, sha1_key, SHA1_DIGEST_LENGTH); snir->size = blob.size; memcpy(snir->data, blob.data, blob.size); @@ -129,7 +129,7 @@ v3dv_pipeline_cache_upload_nir(struct v3dv_pipeline *pipeline, cache->nir_stats.count++; if (debug_cache) { - char sha1buf[41]; + char sha1buf[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(sha1buf, snir->sha1_key); mesa_logi("pipeline cache %p, new nir entry %s\n", cache, sha1buf); if (dump_stats) @@ -145,13 +145,13 @@ nir_shader* v3dv_pipeline_cache_search_for_nir(struct v3dv_pipeline *pipeline, struct v3dv_pipeline_cache *cache, const nir_shader_compiler_options *nir_options, - unsigned char sha1_key[20]) + unsigned char sha1_key[SHA1_DIGEST_LENGTH]) { if (!cache || !cache->nir_cache) return NULL; if (debug_cache) { - char sha1buf[41]; + char sha1buf[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(sha1buf, sha1_key); mesa_logi("pipeline cache %p, search for nir %s\n", cache, sha1buf); @@ -249,14 +249,14 @@ v3dv_pipeline_shared_data_write_to_blob(const struct v3dv_pipeline_shared_data * */ struct v3dv_pipeline_shared_data * v3dv_pipeline_cache_search_for_pipeline(struct v3dv_pipeline_cache *cache, - unsigned char sha1_key[20], + unsigned char sha1_key[SHA1_DIGEST_LENGTH], bool *cache_hit) { if (!cache || !cache->cache) return NULL; if (debug_cache) { - char sha1buf[41]; + char sha1buf[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(sha1buf, sha1_key); mesa_logi("pipeline cache %p, search pipeline with key %s\n", cache, sha1buf); @@ -312,7 +312,7 @@ v3dv_pipeline_cache_search_for_pipeline(struct v3dv_pipeline_cache *cache, size_t buffer_size; uint8_t *buffer = disk_cache_get(disk_cache, cache_key, &buffer_size); if (V3D_DBG(CACHE)) { - char sha1buf[41]; + char sha1buf[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(sha1buf, cache_key); mesa_logi("[v3dv on-disk cache] %s %s\n", buffer ? "hit" : "miss", sha1buf); @@ -370,7 +370,7 @@ v3dv_pipeline_shared_data_destroy(struct v3dv_device *device, static struct v3dv_pipeline_shared_data * v3dv_pipeline_shared_data_new(struct v3dv_pipeline_cache *cache, - const unsigned char sha1_key[20], + const unsigned char sha1_key[SHA1_DIGEST_LENGTH], struct v3dv_descriptor_maps **maps, struct v3dv_shader_variant **variants, const uint64_t *total_assembly, @@ -390,7 +390,7 @@ v3dv_pipeline_shared_data_new(struct v3dv_pipeline_cache *cache, return NULL; new_entry->ref_cnt = 1; - memcpy(new_entry->sha1_key, sha1_key, 20); + memcpy(new_entry->sha1_key, sha1_key, SHA1_DIGEST_LENGTH); for (uint8_t stage = 0; stage < BROADCOM_SHADER_STAGES; stage++) { new_entry->maps[stage] = maps[stage]; @@ -452,7 +452,7 @@ pipeline_cache_upload_shared_data(struct v3dv_pipeline_cache *cache, _mesa_hash_table_insert(cache->cache, shared_data->sha1_key, shared_data); cache->stats.count++; if (debug_cache) { - char sha1buf[41]; + char sha1buf[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(sha1buf, shared_data->sha1_key); mesa_logi("pipeline cache %p, new cache entry with sha1 key %s:%p\n\n", @@ -480,7 +480,7 @@ pipeline_cache_upload_shared_data(struct v3dv_pipeline_cache *cache, disk_cache_compute_key(disk_cache, shared_data->sha1_key, 20, cache_key); if (V3D_DBG(CACHE)) { - char sha1buf[41]; + char sha1buf[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(sha1buf, shared_data->sha1_key); mesa_logi("[v3dv on-disk cache] storing %s\n", sha1buf); } @@ -504,7 +504,7 @@ static struct serialized_nir* serialized_nir_create_from_blob(struct v3dv_pipeline_cache *cache, struct blob_reader *blob) { - const unsigned char *sha1_key = blob_read_bytes(blob, 20); + const unsigned char *sha1_key = blob_read_bytes(blob, SHA1_DIGEST_LENGTH); uint32_t snir_size = blob_read_uint32(blob); const char* snir_data = blob_read_bytes(blob, snir_size); if (blob->overrun) @@ -512,7 +512,7 @@ serialized_nir_create_from_blob(struct v3dv_pipeline_cache *cache, struct serialized_nir *snir = ralloc_size(cache->nir_cache, sizeof(*snir) + snir_size); - memcpy(snir->sha1_key, sha1_key, 20); + memcpy(snir->sha1_key, sha1_key, SHA1_DIGEST_LENGTH); snir->size = snir_size; memcpy(snir->data, snir_data, snir_size); @@ -574,7 +574,7 @@ static struct v3dv_pipeline_shared_data * v3dv_pipeline_shared_data_create_from_blob(struct v3dv_pipeline_cache *cache, struct blob_reader *blob) { - const unsigned char *sha1_key = blob_read_bytes(blob, 20); + const unsigned char *sha1_key = blob_read_bytes(blob, SHA1_DIGEST_LENGTH); struct v3dv_descriptor_maps *maps[BROADCOM_SHADER_STAGES] = { 0 }; struct v3dv_shader_variant *variants[BROADCOM_SHADER_STAGES] = { 0 }; @@ -811,14 +811,14 @@ v3dv_MergePipelineCaches(VkDevice device, */ struct serialized_nir *snir_dst = ralloc_size(dst->nir_cache, sizeof(*snir_dst) + src_snir->size); - memcpy(snir_dst->sha1_key, src_snir->sha1_key, 20); + memcpy(snir_dst->sha1_key, src_snir->sha1_key, SHA1_DIGEST_LENGTH); snir_dst->size = src_snir->size; memcpy(snir_dst->data, src_snir->data, src_snir->size); _mesa_hash_table_insert(dst->nir_cache, snir_dst->sha1_key, snir_dst); dst->nir_stats.count++; if (debug_cache) { - char sha1buf[41]; + char sha1buf[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(sha1buf, snir_dst->sha1_key); mesa_logi("pipeline cache %p, added nir entry %s " @@ -841,7 +841,7 @@ v3dv_MergePipelineCaches(VkDevice device, dst->stats.count++; if (debug_cache) { - char sha1buf[41]; + char sha1buf[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(sha1buf, cache_entry->sha1_key); mesa_logi("pipeline cache %p, added entry %s " @@ -880,7 +880,7 @@ static bool v3dv_pipeline_shared_data_write_to_blob(const struct v3dv_pipeline_shared_data *cache_entry, struct blob *blob) { - blob_write_bytes(blob, cache_entry->sha1_key, 20); + blob_write_bytes(blob, cache_entry->sha1_key, SHA1_DIGEST_LENGTH); uint8_t descriptor_maps_count = 0; for (uint8_t stage = 0; stage < BROADCOM_SHADER_STAGES; stage++) { @@ -988,7 +988,7 @@ v3dv_GetPipelineCacheData(VkDevice _device, size_t save_size = blob.size; - blob_write_bytes(&blob, snir->sha1_key, 20); + blob_write_bytes(&blob, snir->sha1_key, SHA1_DIGEST_LENGTH); blob_write_uint32(&blob, snir->size); blob_write_bytes(&blob, snir->data, snir->size); diff --git a/src/broadcom/vulkan/v3dv_private.h b/src/broadcom/vulkan/v3dv_private.h index 78c019ad12b..62787181894 100644 --- a/src/broadcom/vulkan/v3dv_private.h +++ b/src/broadcom/vulkan/v3dv_private.h @@ -145,7 +145,7 @@ struct v3dv_physical_device { dev_t primary_devid; dev_t render_devid; - uint8_t driver_build_sha1[20]; + uint8_t driver_build_sha1[SHA1_DIGEST_LENGTH]; uint8_t pipeline_cache_uuid[VK_UUID_SIZE]; uint8_t device_uuid[VK_UUID_SIZE]; uint8_t driver_uuid[VK_UUID_SIZE]; @@ -1958,7 +1958,7 @@ struct v3dv_pipeline_stage { nir_shader *nir; /* The following is the combined hash of module+entrypoint+spec_info+nir */ - unsigned char shader_sha1[20]; + unsigned char shader_sha1[SHA1_DIGEST_LENGTH]; /** A name for this program, so you can track it in shader-db output. */ uint32_t program_id; @@ -2135,7 +2135,7 @@ struct v3dv_pipeline_layout { */ uint32_t ref_cnt; - unsigned char sha1[20]; + unsigned char sha1[SHA1_DIGEST_LENGTH]; }; void @@ -2231,7 +2231,7 @@ struct v3dv_descriptor_maps { struct v3dv_pipeline_shared_data { uint32_t ref_cnt; - unsigned char sha1_key[20]; + unsigned char sha1_key[SHA1_DIGEST_LENGTH]; struct v3dv_descriptor_maps *maps[BROADCOM_SHADER_STAGES]; struct v3dv_shader_variant *variants[BROADCOM_SHADER_STAGES]; @@ -2317,7 +2317,7 @@ struct v3dv_pipeline { struct v3dv_pipeline_shared_data *shared_data; /* It is the combined stages sha1, layout sha1, plus the pipeline key sha1. */ - unsigned char sha1[20]; + unsigned char sha1[SHA1_DIGEST_LENGTH]; /* In general we can reuse v3dv_device->default_attribute_float, so note * that the following can be NULL. In 7.x this is not used, so it will be @@ -2519,16 +2519,16 @@ void v3dv_pipeline_cache_finish(struct v3dv_pipeline_cache *cache); void v3dv_pipeline_cache_upload_nir(struct v3dv_pipeline *pipeline, struct v3dv_pipeline_cache *cache, nir_shader *nir, - unsigned char sha1_key[20]); + unsigned char sha1_key[SHA1_DIGEST_LENGTH]); nir_shader* v3dv_pipeline_cache_search_for_nir(struct v3dv_pipeline *pipeline, struct v3dv_pipeline_cache *cache, const nir_shader_compiler_options *nir_options, - unsigned char sha1_key[20]); + unsigned char sha1_key[SHA1_DIGEST_LENGTH]); struct v3dv_pipeline_shared_data * v3dv_pipeline_cache_search_for_pipeline(struct v3dv_pipeline_cache *cache, - unsigned char sha1_key[20], + unsigned char sha1_key[SHA1_DIGEST_LENGTH], bool *cache_hit); void diff --git a/src/broadcom/vulkan/v3dv_query.c b/src/broadcom/vulkan/v3dv_query.c index 4f9d44595de..842f857adff 100644 --- a/src/broadcom/vulkan/v3dv_query.c +++ b/src/broadcom/vulkan/v3dv_query.c @@ -1376,7 +1376,7 @@ v3dv_EnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR( counter->scope = VK_PERFORMANCE_COUNTER_SCOPE_COMMAND_KHR; counter->storage = VK_PERFORMANCE_COUNTER_STORAGE_UINT64_KHR; - unsigned char sha1_result[20]; + unsigned char sha1_result[SHA1_DIGEST_LENGTH]; _mesa_sha1_compute(perfcntr_desc->name, strlen(perfcntr_desc->name), sha1_result); memcpy(counter->uuid, sha1_result, sizeof(counter->uuid)); diff --git a/src/compiler/clc/nir_load_libclc.c b/src/compiler/clc/nir_load_libclc.c index 128cc6781e1..f650c223217 100644 --- a/src/compiler/clc/nir_load_libclc.c +++ b/src/compiler/clc/nir_load_libclc.c @@ -88,7 +88,7 @@ get_libclc_file(unsigned ptr_bit_size) struct clc_data { const struct clc_file *file; - unsigned char cache_key[20]; + unsigned char cache_key[SHA1_DIGEST_LENGTH]; int fd; const void *data; diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp index e56de9aadcb..3bcf7872764 100644 --- a/src/compiler/glsl/glsl_parser_extras.cpp +++ b/src/compiler/glsl/glsl_parser_extras.cpp @@ -2330,7 +2330,7 @@ can_skip_compile(struct gl_context *ctx, struct gl_shader *shader, { if (!force_recompile) { if (ctx->Cache) { - char buf[41]; + char buf[SHA1_DIGEST_STRING_LENGTH]; disk_cache_compute_key(ctx->Cache, source, strlen(source), shader->disk_cache_sha1); if (disk_cache_has_key(ctx->Cache, shader->disk_cache_sha1)) { @@ -2542,7 +2542,7 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader, ralloc_free(state); if (ctx->Cache && shader->CompileStatus == COMPILE_SUCCESS) { - char sha1_buf[41]; + char sha1_buf[SHA1_DIGEST_STRING_LENGTH]; disk_cache_put_key(ctx->Cache, shader->disk_cache_sha1); if (ctx->_Shader->Flags & GLSL_CACHE_INFO) { _mesa_sha1_format(sha1_buf, shader->disk_cache_sha1); diff --git a/src/compiler/glsl/shader_cache.cpp b/src/compiler/glsl/shader_cache.cpp index 6ee16c880b5..be4dabdecfb 100644 --- a/src/compiler/glsl/shader_cache.cpp +++ b/src/compiler/glsl/shader_cache.cpp @@ -128,7 +128,7 @@ shader_cache_write_program_metadata(struct gl_context *ctx, disk_cache_put(cache, prog->data->sha1, metadata.data, metadata.size, &cache_item_metadata); - char sha1_buf[41]; + char sha1_buf[SHA1_DIGEST_STRING_LENGTH]; if (ctx->_Shader->Flags & GLSL_CACHE_INFO) { _mesa_sha1_format(sha1_buf, prog->data->sha1); fprintf(stderr, "putting program metadata in cache: %s\n", sha1_buf); @@ -195,7 +195,7 @@ shader_cache_read_program_metadata(struct gl_context *ctx, /* DRI config options may also change the output from the compiler so * include them as an input to sha1 creation. */ - char sha1buf[41]; + char sha1buf[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(sha1buf, ctx->Const.dri_config_options_sha1); ralloc_strcat(&buf, sha1buf); diff --git a/src/freedreno/ir3/ir3_disk_cache.c b/src/freedreno/ir3/ir3_disk_cache.c index 459677207ac..b25ecbca8c6 100644 --- a/src/freedreno/ir3/ir3_disk_cache.c +++ b/src/freedreno/ir3/ir3_disk_cache.c @@ -50,7 +50,7 @@ ir3_disk_cache_init(struct ir3_compiler *compiler) sizeof(compiler->options.uche_trap_base)); _mesa_sha1_final(&ctx, sha1); - char timestamp[41]; + char timestamp[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(timestamp, sha1); uint64_t driver_flags = ir3_shader_debug_hash_key(); @@ -225,7 +225,7 @@ ir3_disk_cache_retrieve(struct ir3_shader *shader, compute_variant_key(shader, v, cache_key); if (debug) { - char sha1[41]; + char sha1[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(sha1, cache_key); fprintf(stderr, "[mesa disk cache] retrieving variant %s: ", sha1); } @@ -264,7 +264,7 @@ ir3_disk_cache_store(struct ir3_shader *shader, compute_variant_key(shader, v, cache_key); if (debug) { - char sha1[41]; + char sha1[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(sha1, cache_key); fprintf(stderr, "[mesa disk cache] storing variant %s\n", sha1); } diff --git a/src/freedreno/ir3/ir3_shader.c b/src/freedreno/ir3/ir3_shader.c index 5376f2b0d8a..d94cc2e73f3 100644 --- a/src/freedreno/ir3/ir3_shader.c +++ b/src/freedreno/ir3/ir3_shader.c @@ -395,7 +395,7 @@ assemble_variant(struct ir3_shader_variant *v, bool internal) { v->bin = ir3_shader_assemble(v); - unsigned char sha1[21]; + unsigned char sha1[SHA1_DIGEST_LENGTH + 1]; struct mesa_sha1 ctx; diff --git a/src/freedreno/vulkan/tu_descriptor_set.h b/src/freedreno/vulkan/tu_descriptor_set.h index 3e757367911..b9d66f73ea2 100644 --- a/src/freedreno/vulkan/tu_descriptor_set.h +++ b/src/freedreno/vulkan/tu_descriptor_set.h @@ -110,7 +110,7 @@ struct tu_pipeline_layout uint32_t num_sets; uint32_t push_constant_size; - unsigned char sha1[20]; + unsigned char sha1[SHA1_DIGEST_LENGTH]; }; VK_DEFINE_NONDISP_HANDLE_CASTS(tu_pipeline_layout, base, VkPipelineLayout, VK_OBJECT_TYPE_PIPELINE_LAYOUT) diff --git a/src/freedreno/vulkan/tu_device.cc b/src/freedreno/vulkan/tu_device.cc index 92b075a98f2..89396ba7f9f 100644 --- a/src/freedreno/vulkan/tu_device.cc +++ b/src/freedreno/vulkan/tu_device.cc @@ -55,7 +55,7 @@ static int tu_device_get_cache_uuid(struct tu_physical_device *device, void *uuid) { struct mesa_sha1 ctx; - unsigned char sha1[20]; + unsigned char sha1[SHA1_DIGEST_LENGTH]; /* Note: IR3_SHADER_DEBUG also affects compilation, but it's not * initialized until after compiler creation so we have to add it to the * shader hash instead, since the compiler is only created with the logical @@ -1451,7 +1451,7 @@ tu_get_properties(struct tu_physical_device *pdevice, { struct mesa_sha1 sha1_ctx; - uint8_t sha1[20]; + uint8_t sha1[SHA1_DIGEST_LENGTH]; _mesa_sha1_init(&sha1_ctx); diff --git a/src/freedreno/vulkan/tu_pipeline.cc b/src/freedreno/vulkan/tu_pipeline.cc index f04992bda43..2237b8ef9d9 100644 --- a/src/freedreno/vulkan/tu_pipeline.cc +++ b/src/freedreno/vulkan/tu_pipeline.cc @@ -1936,26 +1936,26 @@ tu_pipeline_builder_compile_shaders(struct tu_pipeline_builder *builder, !builder->rasterizer_discard && msaa_info && msaa_info->sampleShadingEnable; } - unsigned char pipeline_sha1[20]; + unsigned char pipeline_sha1[SHA1_DIGEST_LENGTH]; tu_hash_shaders(pipeline_sha1, builder->create_flags, stage_infos, nir, &builder->layout, keys, builder->state); - unsigned char nir_sha1[21]; + unsigned char nir_sha1[SHA1_DIGEST_LENGTH + 1]; memcpy(nir_sha1, pipeline_sha1, sizeof(pipeline_sha1)); - nir_sha1[20] = 'N'; + nir_sha1[SHA1_DIGEST_LENGTH] = 'N'; if (!executable_info) { cache_hit = true; bool application_cache_hit = false; - unsigned char shader_sha1[21]; + unsigned char shader_sha1[SHA1_DIGEST_LENGTH + 1]; memcpy(shader_sha1, pipeline_sha1, sizeof(pipeline_sha1)); for (mesa_shader_stage stage = MESA_SHADER_VERTEX; stage < ARRAY_SIZE(nir); stage = (mesa_shader_stage) (stage + 1)) { if (stage_infos[stage] || nir[stage]) { bool shader_application_cache_hit; - shader_sha1[20] = (unsigned char) stage; + shader_sha1[SHA1_DIGEST_LENGTH] = (unsigned char) stage; shaders[stage] = tu_pipeline_cache_lookup(builder->cache, &shader_sha1, sizeof(shader_sha1), @@ -4856,7 +4856,7 @@ tu_compute_pipeline_create(VkDevice device, void *pipeline_mem_ctx = ralloc_context(NULL); - unsigned char pipeline_sha1[20]; + unsigned char pipeline_sha1[SHA1_DIGEST_LENGTH]; tu_hash_compute(pipeline_sha1, flags, stage_info, layout, &key); struct tu_shader *shader = NULL; diff --git a/src/freedreno/vulkan/tu_query_pool.cc b/src/freedreno/vulkan/tu_query_pool.cc index fc535bf37b5..b99fb88c135 100644 --- a/src/freedreno/vulkan/tu_query_pool.cc +++ b/src/freedreno/vulkan/tu_query_pool.cc @@ -2211,7 +2211,7 @@ tu_EnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR( counter->storage = fd_perfcntr_type_to_vk_storage[group[i].countables[j].query_type]; - unsigned char sha1_result[20]; + unsigned char sha1_result[SHA1_DIGEST_LENGTH]; _mesa_sha1_compute(group[i].countables[j].name, strlen(group[i].countables[j].name), sha1_result); @@ -2243,7 +2243,7 @@ tu_EnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR( counter->unit = fd_perfcntr_type_to_vk_unit[derived_counter->type]; counter->storage = fd_perfcntr_type_to_vk_storage[derived_counter->type]; - unsigned char sha1_result[20]; + unsigned char sha1_result[SHA1_DIGEST_LENGTH]; _mesa_sha1_compute(derived_counter->name, strlen(derived_counter->name), sha1_result); memcpy(counter->uuid, sha1_result, sizeof(counter->uuid)); diff --git a/src/freedreno/vulkan/tu_shader.cc b/src/freedreno/vulkan/tu_shader.cc index 375343ab32e..626bb9e90f7 100644 --- a/src/freedreno/vulkan/tu_shader.cc +++ b/src/freedreno/vulkan/tu_shader.cc @@ -3319,9 +3319,9 @@ tu_compile_shaders(struct tu_device *device, int64_t stage_start = os_time_get_nano(); - unsigned char shader_sha1[21]; - memcpy(shader_sha1, pipeline_sha1, 20); - shader_sha1[20] = (unsigned char) stage; + unsigned char shader_sha1[SHA1_DIGEST_LENGTH + 1]; + memcpy(shader_sha1, pipeline_sha1, SHA1_DIGEST_LENGTH); + shader_sha1[SHA1_DIGEST_LENGTH] = (unsigned char) stage; result = tu_shader_create(device, &shaders[stage], nir[stage], &keys[stage], diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c index 0d5351a969d..5749afec7bd 100644 --- a/src/gallium/auxiliary/draw/draw_context.c +++ b/src/gallium/auxiliary/draw/draw_context.c @@ -1276,10 +1276,10 @@ draw_set_disk_cache_callbacks(struct draw_context *draw, void *data_cookie, void (*find_shader)(void *cookie, struct lp_cached_code *cache, - unsigned char ir_sha1_cache_key[20]), + unsigned char ir_sha1_cache_key[SHA1_DIGEST_LENGTH]), void (*insert_shader)(void *cookie, struct lp_cached_code *cache, - unsigned char ir_sha1_cache_key[20])) + unsigned char ir_sha1_cache_key[SHA1_DIGEST_LENGTH])) { draw->disk_cache_find_shader = find_shader; draw->disk_cache_insert_shader = insert_shader; diff --git a/src/gallium/auxiliary/draw/draw_context.h b/src/gallium/auxiliary/draw/draw_context.h index 95b4c38d575..5ce05d3f928 100644 --- a/src/gallium/auxiliary/draw/draw_context.h +++ b/src/gallium/auxiliary/draw/draw_context.h @@ -40,6 +40,7 @@ #include "pipe/p_state.h" #include "pipe/p_shader_tokens.h" +#include "util/sha1/sha1.h" #include "nir.h" struct pipe_context; @@ -422,10 +423,10 @@ draw_set_disk_cache_callbacks(struct draw_context *draw, void *data_cookie, void (*find_shader)(void *cookie, struct lp_cached_code *cache, - unsigned char ir_sha1_cache_key[20]), + unsigned char ir_sha1_cache_key[SHA1_DIGEST_LENGTH]), void (*insert_shader)(void *cookie, struct lp_cached_code *cache, - unsigned char ir_sha1_cache_key[20])); + unsigned char ir_sha1_cache_key[SHA1_DIGEST_LENGTH])); #endif /* DRAW_CONTEXT_H */ diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c index 8bf477b1d67..6934e897f9e 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.c +++ b/src/gallium/auxiliary/draw/draw_llvm.c @@ -442,7 +442,7 @@ static void draw_get_ir_cache_key(struct nir_shader *nir, const void *key, size_t key_size, uint32_t val_32bit, - unsigned char ir_sha1_cache_key[20]) + unsigned char ir_sha1_cache_key[SHA1_DIGEST_LENGTH]) { struct blob blob = { 0 }; unsigned ir_size; @@ -476,7 +476,7 @@ draw_llvm_create_variant(struct draw_llvm *llvm, struct llvm_vertex_shader *shader = llvm_vertex_shader(llvm->draw->vs.vertex_shader); char module_name[64]; - unsigned char ir_sha1_cache_key[20]; + unsigned char ir_sha1_cache_key[SHA1_DIGEST_LENGTH]; struct lp_cached_code cached = { 0 }; bool needs_caching = false; variant = MALLOC(sizeof *variant + @@ -2505,7 +2505,7 @@ draw_gs_llvm_create_variant(struct draw_llvm *llvm, struct llvm_geometry_shader *shader = llvm_geometry_shader(llvm->draw->gs.geometry_shader); char module_name[64]; - unsigned char ir_sha1_cache_key[20]; + unsigned char ir_sha1_cache_key[SHA1_DIGEST_LENGTH]; struct lp_cached_code cached = { 0 }; bool needs_caching = false; @@ -3177,7 +3177,7 @@ draw_tcs_llvm_create_variant(struct draw_llvm *llvm, struct draw_tcs_llvm_variant *variant; struct llvm_tess_ctrl_shader *shader = llvm_tess_ctrl_shader(llvm->draw->tcs.tess_ctrl_shader); char module_name[64]; - unsigned char ir_sha1_cache_key[20]; + unsigned char ir_sha1_cache_key[SHA1_DIGEST_LENGTH]; struct lp_cached_code cached = { 0 }; bool needs_caching = false; @@ -3715,7 +3715,7 @@ draw_tes_llvm_create_variant(struct draw_llvm *llvm, struct draw_tes_llvm_variant *variant; struct llvm_tess_eval_shader *shader = llvm_tess_eval_shader(llvm->draw->tes.tess_eval_shader); char module_name[64]; - unsigned char ir_sha1_cache_key[20]; + unsigned char ir_sha1_cache_key[SHA1_DIGEST_LENGTH]; struct lp_cached_code cached = { 0 }; bool needs_caching = false; diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h index 75fc76fea74..7fdf5c3de1b 100644 --- a/src/gallium/auxiliary/draw/draw_private.h +++ b/src/gallium/auxiliary/draw/draw_private.h @@ -44,6 +44,7 @@ #include "pipe/p_state.h" #include "pipe/p_defines.h" #include "pipe/p_shader_tokens.h" +#include "util/sha1/sha1.h" #include "draw_vertex_header.h" @@ -399,10 +400,10 @@ struct draw_context void *disk_cache_cookie; void (*disk_cache_find_shader)(void *cookie, struct lp_cached_code *cache, - unsigned char ir_sha1_cache_key[20]); + unsigned char ir_sha1_cache_key[SHA1_DIGEST_LENGTH]); void (*disk_cache_insert_shader)(void *cookie, struct lp_cached_code *cache, - unsigned char ir_sha1_cache_key[20]); + unsigned char ir_sha1_cache_key[SHA1_DIGEST_LENGTH]); void *driver_private; }; diff --git a/src/gallium/auxiliary/util/u_live_shader_cache.c b/src/gallium/auxiliary/util/u_live_shader_cache.c index 021b9ed2f4d..8cce68c6193 100644 --- a/src/gallium/auxiliary/util/u_live_shader_cache.c +++ b/src/gallium/auxiliary/util/u_live_shader_cache.c @@ -99,7 +99,7 @@ util_live_shader_cache_get(struct pipe_context *ctx, /* Compute SHA1 of pipe_shader_state. */ struct mesa_sha1 sha1_ctx; - unsigned char sha1[20]; + unsigned char sha1[SHA1_DIGEST_LENGTH]; _mesa_sha1_init(&sha1_ctx); _mesa_sha1_update(&sha1_ctx, ir_binary, ir_size); if ((stage == MESA_SHADER_VERTEX || diff --git a/src/gallium/auxiliary/util/u_live_shader_cache.h b/src/gallium/auxiliary/util/u_live_shader_cache.h index 99ed5ec9789..6c5aa07f371 100644 --- a/src/gallium/auxiliary/util/u_live_shader_cache.h +++ b/src/gallium/auxiliary/util/u_live_shader_cache.h @@ -49,6 +49,7 @@ #ifndef U_LIVE_SHADER_CACHE_H #define U_LIVE_SHADER_CACHE_H +#include "util/sha1/sha1.h" #include "util/simple_mtx.h" #include "pipe/p_state.h" @@ -69,7 +70,7 @@ struct util_live_shader_cache { struct util_live_shader { struct pipe_reference reference; - unsigned char sha1[20]; + unsigned char sha1[SHA1_DIGEST_LENGTH]; }; void diff --git a/src/gallium/drivers/asahi/agx_disk_cache.c b/src/gallium/drivers/asahi/agx_disk_cache.c index 7b7907060c8..9bdcbb9a69e 100644 --- a/src/gallium/drivers/asahi/agx_disk_cache.c +++ b/src/gallium/drivers/asahi/agx_disk_cache.c @@ -215,7 +215,7 @@ agx_disk_cache_init(struct agx_screen *screen) const uint8_t *id_sha1 = build_id_data(note); assert(id_sha1); - char timestamp[41]; + char timestamp[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(timestamp, id_sha1); uint64_t driver_flags = screen->dev.debug; diff --git a/src/gallium/drivers/asahi/agx_state.h b/src/gallium/drivers/asahi/agx_state.h index f1666e7561c..cee0ade722f 100644 --- a/src/gallium/drivers/asahi/agx_state.h +++ b/src/gallium/drivers/asahi/agx_state.h @@ -270,7 +270,7 @@ struct agx_uncompiled_shader { mesa_shader_stage type; struct blob early_serialized_nir; struct blob serialized_nir; - uint8_t nir_sha1[20]; + uint8_t nir_sha1[SHA1_DIGEST_LENGTH]; struct { uint64_t inputs_flat_shaded; diff --git a/src/gallium/drivers/crocus/crocus_context.h b/src/gallium/drivers/crocus/crocus_context.h index d15d55f8671..58446159802 100644 --- a/src/gallium/drivers/crocus/crocus_context.h +++ b/src/gallium/drivers/crocus/crocus_context.h @@ -309,7 +309,7 @@ struct crocus_uncompiled_shader { struct pipe_stream_output_info stream_output; /* A SHA1 of the serialized NIR for the disk cache. */ - unsigned char nir_sha1[20]; + unsigned char nir_sha1[SHA1_DIGEST_LENGTH]; unsigned program_id; diff --git a/src/gallium/drivers/crocus/crocus_disk_cache.c b/src/gallium/drivers/crocus/crocus_disk_cache.c index 79e8c8b1a50..934ad386706 100644 --- a/src/gallium/drivers/crocus/crocus_disk_cache.c +++ b/src/gallium/drivers/crocus/crocus_disk_cache.c @@ -93,7 +93,7 @@ crocus_disk_cache_store(struct disk_cache *cache, crocus_disk_cache_compute_key(cache, ish, prog_key, prog_key_size, cache_key); if (debug) { - char sha1[41]; + char sha1[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(sha1, cache_key); fprintf(stderr, "[mesa disk cache] storing %s\n", sha1); } @@ -146,7 +146,7 @@ crocus_disk_cache_retrieve(struct crocus_context *ice, crocus_disk_cache_compute_key(cache, ish, prog_key, key_size, cache_key); if (debug) { - char sha1[41]; + char sha1[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(sha1, cache_key); fprintf(stderr, "[mesa disk cache] retrieving %s: ", sha1); } @@ -250,7 +250,7 @@ crocus_disk_cache_init(struct crocus_screen *screen) const uint8_t *id_sha1 = build_id_data(note); assert(id_sha1); - char timestamp[41]; + char timestamp[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(timestamp, id_sha1); const uint64_t driver_flags = diff --git a/src/gallium/drivers/etnaviv/etnaviv_disk_cache.c b/src/gallium/drivers/etnaviv/etnaviv_disk_cache.c index 7d43fe0560a..68d54a8e747 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_disk_cache.c +++ b/src/gallium/drivers/etnaviv/etnaviv_disk_cache.c @@ -44,7 +44,7 @@ etna_disk_cache_init(struct etna_compiler *compiler, const char *renderer) const uint8_t *id_sha1 = build_id_data(note); assert(id_sha1); - char timestamp[41]; + char timestamp[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(timestamp, id_sha1); compiler->disk_cache = disk_cache_create(renderer, timestamp, etna_mesa_debug); @@ -131,7 +131,7 @@ etna_disk_cache_retrieve(struct etna_compiler *compiler, struct etna_shader_vari compute_variant_key(compiler, v, cache_key); if (debug) { - char sha1[41]; + char sha1[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(sha1, cache_key); fprintf(stderr, "[mesa disk cache] retrieving variant %s: ", sha1); @@ -167,7 +167,7 @@ etna_disk_cache_store(struct etna_compiler *compiler, struct etna_shader_variant compute_variant_key(compiler, v, cache_key); if (debug) { - char sha1[41]; + char sha1[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(sha1, cache_key); fprintf(stderr, "[mesa disk cache] storing variant %s\n", sha1); diff --git a/src/gallium/drivers/iris/iris_context.h b/src/gallium/drivers/iris/iris_context.h index 279748c1c75..d0193799e65 100644 --- a/src/gallium/drivers/iris/iris_context.h +++ b/src/gallium/drivers/iris/iris_context.h @@ -575,7 +575,7 @@ struct iris_uncompiled_shader { struct pipe_stream_output_info stream_output; /* A SHA1 of the serialized NIR for the disk cache. */ - unsigned char nir_sha1[20]; + unsigned char nir_sha1[SHA1_DIGEST_LENGTH]; /* Hash value based on shader source program */ unsigned source_hash; diff --git a/src/gallium/drivers/iris/iris_disk_cache.c b/src/gallium/drivers/iris/iris_disk_cache.c index f0ee2dfd1ff..4c623efe267 100644 --- a/src/gallium/drivers/iris/iris_disk_cache.c +++ b/src/gallium/drivers/iris/iris_disk_cache.c @@ -102,7 +102,7 @@ iris_disk_cache_store(struct disk_cache *cache, iris_disk_cache_compute_key(cache, ish, prog_key, prog_key_size, cache_key); if (debug) { - char sha1[41]; + char sha1[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(sha1, cache_key); fprintf(stderr, "[mesa disk cache] storing %s\n", sha1); } @@ -203,7 +203,7 @@ iris_disk_cache_retrieve(struct iris_screen *screen, iris_disk_cache_compute_key(cache, ish, prog_key, key_size, cache_key); if (debug) { - char sha1[41]; + char sha1[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(sha1, cache_key); fprintf(stderr, "[mesa disk cache] retrieving %s: ", sha1); } @@ -361,7 +361,7 @@ iris_disk_cache_init(struct iris_screen *screen) char renderer[5 + 40 + 1] = {0}; if (screen->brw) { - char device_info_sha[41]; + char device_info_sha[SHA1_DIGEST_STRING_LENGTH]; brw_device_sha1(device_info_sha, screen->devinfo); memcpy(renderer, "iris_", 5); memcpy(renderer + 5, device_info_sha, 40); @@ -379,7 +379,7 @@ iris_disk_cache_init(struct iris_screen *screen) const uint8_t *id_sha1 = build_id_data(note); assert(id_sha1); - char timestamp[41]; + char timestamp[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(timestamp, id_sha1); const uint64_t driver_flags = diff --git a/src/gallium/drivers/lima/lima_context.h b/src/gallium/drivers/lima/lima_context.h index 05e75f9f180..0d4b17f334f 100644 --- a/src/gallium/drivers/lima/lima_context.h +++ b/src/gallium/drivers/lima/lima_context.h @@ -26,6 +26,7 @@ #define H_LIMA_CONTEXT #include "util/list.h" +#include "util/sha1/sha1.h" #include "util/slab.h" #include "util/u_debug.h" @@ -56,11 +57,11 @@ struct lima_fs_compiled_shader { struct lima_fs_uncompiled_shader { struct pipe_shader_state base; - unsigned char nir_sha1[20]; + unsigned char nir_sha1[SHA1_DIGEST_LENGTH]; }; struct lima_fs_key { - unsigned char nir_sha1[20]; + unsigned char nir_sha1[SHA1_DIGEST_LENGTH]; struct { uint8_t swizzle[4]; } tex[PIPE_MAX_SAMPLERS]; @@ -94,11 +95,11 @@ struct lima_vs_compiled_shader { struct lima_vs_uncompiled_shader { struct pipe_shader_state base; - unsigned char nir_sha1[20]; + unsigned char nir_sha1[SHA1_DIGEST_LENGTH]; }; struct lima_vs_key { - unsigned char nir_sha1[20]; + unsigned char nir_sha1[SHA1_DIGEST_LENGTH]; }; struct lima_rasterizer_state { diff --git a/src/gallium/drivers/lima/lima_disk_cache.c b/src/gallium/drivers/lima/lima_disk_cache.c index 0c3bef74eed..e441bcbcc6e 100644 --- a/src/gallium/drivers/lima/lima_disk_cache.c +++ b/src/gallium/drivers/lima/lima_disk_cache.c @@ -45,7 +45,7 @@ lima_vs_disk_cache_store(struct disk_cache *cache, disk_cache_compute_key(cache, key, sizeof(*key), cache_key); if (lima_debug & LIMA_DEBUG_DISK_CACHE) { - char sha1[41]; + char sha1[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(sha1, cache_key); fprintf(stderr, "[mesa disk cache] storing %s\n", sha1); } @@ -73,7 +73,7 @@ lima_fs_disk_cache_store(struct disk_cache *cache, disk_cache_compute_key(cache, key, sizeof(*key), cache_key); if (lima_debug & LIMA_DEBUG_DISK_CACHE) { - char sha1[41]; + char sha1[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(sha1, cache_key); fprintf(stderr, "[mesa disk cache] storing %s\n", sha1); } @@ -101,7 +101,7 @@ lima_vs_disk_cache_retrieve(struct disk_cache *cache, disk_cache_compute_key(cache, key, sizeof(*key), cache_key); if (lima_debug & LIMA_DEBUG_DISK_CACHE) { - char sha1[41]; + char sha1[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(sha1, cache_key); fprintf(stderr, "[mesa disk cache] retrieving %s: ", sha1); } @@ -153,7 +153,7 @@ lima_fs_disk_cache_retrieve(struct disk_cache *cache, disk_cache_compute_key(cache, key, sizeof(*key), cache_key); if (lima_debug & LIMA_DEBUG_DISK_CACHE) { - char sha1[41]; + char sha1[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(sha1, cache_key); fprintf(stderr, "[mesa disk cache] retrieving %s: ", sha1); } @@ -198,7 +198,7 @@ lima_disk_cache_init(struct lima_screen *screen) const uint8_t *id_sha1 = build_id_data(note); assert(id_sha1); - char timestamp[41]; + char timestamp[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(timestamp, id_sha1); screen->disk_cache = disk_cache_create(screen->base.get_name(&screen->base), timestamp, 0); diff --git a/src/gallium/drivers/llvmpipe/lp_context.c b/src/gallium/drivers/llvmpipe/lp_context.c index b137e25247c..1847db6096c 100644 --- a/src/gallium/drivers/llvmpipe/lp_context.c +++ b/src/gallium/drivers/llvmpipe/lp_context.c @@ -174,7 +174,7 @@ llvmpipe_texture_barrier(struct pipe_context *pipe, unsigned flags) static void lp_draw_disk_cache_find_shader(void *cookie, struct lp_cached_code *cache, - unsigned char ir_sha1_cache_key[20]) + unsigned char ir_sha1_cache_key[SHA1_DIGEST_LENGTH]) { struct llvmpipe_screen *screen = cookie; lp_disk_cache_find_shader(screen, cache, ir_sha1_cache_key); @@ -184,7 +184,7 @@ lp_draw_disk_cache_find_shader(void *cookie, static void lp_draw_disk_cache_insert_shader(void *cookie, struct lp_cached_code *cache, - unsigned char ir_sha1_cache_key[20]) + unsigned char ir_sha1_cache_key[SHA1_DIGEST_LENGTH]) { struct llvmpipe_screen *screen = cookie; lp_disk_cache_insert_shader(screen, cache, ir_sha1_cache_key); diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index b644e1d0c58..aaf9308dbe7 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -848,8 +848,8 @@ lp_disk_cache_create(struct llvmpipe_screen *screen) { struct mesa_sha1 ctx; unsigned gallivm_perf = gallivm_get_perf_flags(); - unsigned char sha1[20]; - char cache_id[20 * 2 + 1]; + unsigned char sha1[SHA1_DIGEST_LENGTH]; + char cache_id[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_init(&ctx); if (!disk_cache_get_function_identifier(lp_disk_cache_create, &ctx) || @@ -859,7 +859,7 @@ lp_disk_cache_create(struct llvmpipe_screen *screen) _mesa_sha1_update(&ctx, &gallivm_perf, sizeof(gallivm_perf)); update_cache_sha1_cpu(&ctx); _mesa_sha1_final(&ctx, sha1); - mesa_bytes_to_hex(cache_id, sha1, 20); + mesa_bytes_to_hex(cache_id, sha1, SHA1_DIGEST_LENGTH); screen->disk_shader_cache = disk_cache_create("llvmpipe", cache_id, 0); } @@ -889,7 +889,7 @@ llvmpipe_screen_get_fd(struct pipe_screen *_screen) void lp_disk_cache_find_shader(struct llvmpipe_screen *screen, struct lp_cached_code *cache, - unsigned char ir_sha1_cache_key[20]) + unsigned char ir_sha1_cache_key[SHA1_DIGEST_LENGTH]) { unsigned char sha1[CACHE_KEY_SIZE]; @@ -913,7 +913,7 @@ lp_disk_cache_find_shader(struct llvmpipe_screen *screen, void lp_disk_cache_insert_shader(struct llvmpipe_screen *screen, struct lp_cached_code *cache, - unsigned char ir_sha1_cache_key[20]) + unsigned char ir_sha1_cache_key[SHA1_DIGEST_LENGTH]) { unsigned char sha1[CACHE_KEY_SIZE]; diff --git a/src/gallium/drivers/llvmpipe/lp_screen.h b/src/gallium/drivers/llvmpipe/lp_screen.h index f7dd29b5df3..1414a844813 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.h +++ b/src/gallium/drivers/llvmpipe/lp_screen.h @@ -38,6 +38,7 @@ #include "pipe/p_defines.h" #include "util/u_thread.h" #include "util/list.h" +#include "util/sha1/sha1.h" #include "util/vma.h" #include "gallivm/lp_bld.h" #include "gallivm/lp_bld_misc.h" @@ -92,13 +93,13 @@ struct llvmpipe_screen void lp_disk_cache_find_shader(struct llvmpipe_screen *screen, struct lp_cached_code *cache, - unsigned char ir_sha1_cache_key[20]); + unsigned char ir_sha1_cache_key[SHA1_DIGEST_LENGTH]); void lp_disk_cache_insert_shader(struct llvmpipe_screen *screen, struct lp_cached_code *cache, - unsigned char ir_sha1_cache_key[20]); + unsigned char ir_sha1_cache_key[SHA1_DIGEST_LENGTH]); bool llvmpipe_screen_late_init(struct llvmpipe_screen *screen); diff --git a/src/gallium/drivers/llvmpipe/lp_state_cs.c b/src/gallium/drivers/llvmpipe/lp_state_cs.c index 75d1dc38241..90a90eed1ea 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_cs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_cs.c @@ -1251,7 +1251,7 @@ lp_debug_cs_variant(const struct lp_compute_shader_variant *variant) static void lp_cs_get_ir_cache_key(struct lp_compute_shader_variant *variant, - unsigned char ir_sha1_cache_key[20]) + unsigned char ir_sha1_cache_key[SHA1_DIGEST_LENGTH]) { struct blob blob = { 0 }; unsigned ir_size; @@ -1296,7 +1296,7 @@ generate_variant(struct llvmpipe_context *lp, variant->shader = shader; memcpy(&variant->key, key, shader->variant_key_size); - unsigned char ir_sha1_cache_key[20]; + unsigned char ir_sha1_cache_key[SHA1_DIGEST_LENGTH]; struct lp_cached_code cached = { 0 }; bool needs_caching = false; diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 2033dbdc7c0..df9db51babc 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -3811,7 +3811,7 @@ lp_debug_fs_variant(struct lp_fragment_shader_variant *variant) static void lp_fs_get_ir_cache_key(struct lp_fragment_shader_variant *variant, - unsigned char ir_sha1_cache_key[20]) + unsigned char ir_sha1_cache_key[SHA1_DIGEST_LENGTH]) { struct blob blob = { 0 }; unsigned ir_size; @@ -3856,7 +3856,7 @@ generate_variant(struct llvmpipe_context *lp, struct llvmpipe_screen *screen = llvmpipe_screen(lp->pipe.screen); struct lp_cached_code cached = { 0 }; - unsigned char ir_sha1_cache_key[20]; + unsigned char ir_sha1_cache_key[SHA1_DIGEST_LENGTH]; bool needs_caching = false; if (shader->base.ir.nir) { lp_fs_get_ir_cache_key(variant, ir_sha1_cache_key); diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c index fcb67a31f88..0abe9625f60 100644 --- a/src/gallium/drivers/nouveau/nouveau_screen.c +++ b/src/gallium/drivers/nouveau/nouveau_screen.c @@ -176,8 +176,8 @@ static void nouveau_disk_cache_create(struct nouveau_screen *screen) { struct mesa_sha1 ctx; - unsigned char sha1[20]; - char cache_id[20 * 2 + 1]; + unsigned char sha1[SHA1_DIGEST_LENGTH]; + char cache_id[SHA1_DIGEST_STRING_LENGTH]; uint64_t driver_flags = 0; _mesa_sha1_init(&ctx); @@ -186,7 +186,7 @@ nouveau_disk_cache_create(struct nouveau_screen *screen) return; _mesa_sha1_final(&ctx, sha1); - mesa_bytes_to_hex(cache_id, sha1, 20); + mesa_bytes_to_hex(cache_id, sha1, SHA1_DIGEST_LENGTH); driver_flags |= NOUVEAU_SHADER_CACHE_FLAGS_IR_NIR; @@ -276,7 +276,7 @@ nouveau_driver_uuid(struct pipe_screen *screen, char *uuid) { const char* driver = PACKAGE_VERSION MESA_GIT_SHA1; struct mesa_sha1 sha1_ctx; - uint8_t sha1[20]; + uint8_t sha1[SHA1_DIGEST_LENGTH]; _mesa_sha1_init(&sha1_ctx); _mesa_sha1_update(&sha1_ctx, driver, strlen(driver)); diff --git a/src/gallium/drivers/panfrost/pan_context.h b/src/gallium/drivers/panfrost/pan_context.h index 32a52426cd4..e7a558c3690 100644 --- a/src/gallium/drivers/panfrost/pan_context.h +++ b/src/gallium/drivers/panfrost/pan_context.h @@ -413,7 +413,7 @@ struct panfrost_uncompiled_shader { const nir_shader *nir; /* A SHA1 of the serialized NIR for the disk cache. */ - unsigned char nir_sha1[20]; + unsigned char nir_sha1[SHA1_DIGEST_LENGTH]; /* Stream output information */ struct pipe_stream_output_info stream_output; diff --git a/src/gallium/drivers/panfrost/pan_disk_cache.c b/src/gallium/drivers/panfrost/pan_disk_cache.c index 426c334d54c..6a1a3a0bcf4 100644 --- a/src/gallium/drivers/panfrost/pan_disk_cache.c +++ b/src/gallium/drivers/panfrost/pan_disk_cache.c @@ -80,7 +80,7 @@ panfrost_disk_cache_store(struct disk_cache *cache, panfrost_disk_cache_compute_key(cache, uncompiled, key, cache_key); if (debug) { - char sha1[41]; + char sha1[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(sha1, cache_key); fprintf(stderr, "[mesa disk cache] storing %s\n", sha1); } @@ -124,7 +124,7 @@ panfrost_disk_cache_retrieve(struct disk_cache *cache, panfrost_disk_cache_compute_key(cache, uncompiled, key, cache_key); if (debug) { - char sha1[41]; + char sha1[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(sha1, cache_key); fprintf(stderr, "[mesa disk cache] retrieving %s: ", sha1); } @@ -174,7 +174,7 @@ panfrost_disk_cache_init(struct panfrost_screen *screen) const uint8_t *id_sha1 = build_id_data(note); assert(id_sha1); - char timestamp[41]; + char timestamp[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(timestamp, id_sha1); /* Consider any flags affecting the compile when caching */ diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index 0dbc4d30964..453aac435bf 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -80,8 +80,8 @@ static const char* r300_get_name(struct pipe_screen* pscreen) static void r300_disk_cache_create(struct r300_screen* r300screen) { struct mesa_sha1 ctx; - unsigned char sha1[20]; - char cache_id[20 * 2 + 1]; + unsigned char sha1[SHA1_DIGEST_LENGTH]; + char cache_id[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_init(&ctx); if (!disk_cache_get_function_identifier(r300_disk_cache_create, @@ -89,7 +89,7 @@ static void r300_disk_cache_create(struct r300_screen* r300screen) return; _mesa_sha1_final(&ctx, sha1); - mesa_bytes_to_hex(cache_id, sha1, 20); + mesa_bytes_to_hex(cache_id, sha1, SHA1_DIGEST_LENGTH); r300screen->disk_shader_cache = disk_cache_create(r300_get_family_name(r300screen), diff --git a/src/gallium/drivers/r600/r600_pipe_common.c b/src/gallium/drivers/r600/r600_pipe_common.c index 69d0995431d..04c9b277de7 100644 --- a/src/gallium/drivers/r600/r600_pipe_common.c +++ b/src/gallium/drivers/r600/r600_pipe_common.c @@ -754,8 +754,8 @@ static void r600_disk_cache_create(struct r600_common_screen *rscreen) return; struct mesa_sha1 ctx; - unsigned char sha1[20]; - char cache_id[20 * 2 + 1]; + unsigned char sha1[SHA1_DIGEST_LENGTH]; + char cache_id[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_init(&ctx); if (!disk_cache_get_function_identifier(r600_disk_cache_create, @@ -763,7 +763,7 @@ static void r600_disk_cache_create(struct r600_common_screen *rscreen) return; _mesa_sha1_final(&ctx, sha1); - mesa_bytes_to_hex(cache_id, sha1, 20); + mesa_bytes_to_hex(cache_id, sha1, SHA1_DIGEST_LENGTH); /* These flags affect shader compilation. */ rscreen->disk_shader_cache = diff --git a/src/gallium/drivers/radeonsi/si_compute.c b/src/gallium/drivers/radeonsi/si_compute.c index 148d1a86b26..0018d5197e1 100644 --- a/src/gallium/drivers/radeonsi/si_compute.c +++ b/src/gallium/drivers/radeonsi/si_compute.c @@ -44,7 +44,7 @@ static void si_create_compute_state_async(void *job, void *gdata, int thread_ind program->shader.is_monolithic = true; program->shader.wave_size = si_determine_wave_size(sscreen, &program->shader); - unsigned char ir_sha1_cache_key[20]; + unsigned char ir_sha1_cache_key[SHA1_DIGEST_LENGTH]; si_get_ir_cache_key(sel, false, false, shader->wave_size, ir_sha1_cache_key); /* Try to load the shader from the shader cache. */ diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c index b8050612dc5..f9235783eba 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -1162,8 +1162,8 @@ static void si_disk_cache_create(struct si_screen *sscreen) return; struct mesa_sha1 ctx; - unsigned char sha1[20]; - char cache_id[20 * 2 + 1]; + unsigned char sha1[SHA1_DIGEST_LENGTH]; + char cache_id[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_init(&ctx); @@ -1190,7 +1190,7 @@ static void si_disk_cache_create(struct si_screen *sscreen) _mesa_sha1_update(&ctx, &sscreen->use_aco, sizeof(sscreen->use_aco)); _mesa_sha1_final(&ctx, sha1); - mesa_bytes_to_hex(cache_id, sha1, 20); + mesa_bytes_to_hex(cache_id, sha1, SHA1_DIGEST_LENGTH); sscreen->disk_shader_cache = disk_cache_create(ac_get_family_name(sscreen->info.family), cache_id, sscreen->info.address32_hi); diff --git a/src/gallium/drivers/radeonsi/si_state.h b/src/gallium/drivers/radeonsi/si_state.h index 0574fadd2cf..d839134cdc6 100644 --- a/src/gallium/drivers/radeonsi/si_state.h +++ b/src/gallium/drivers/radeonsi/si_state.h @@ -475,10 +475,10 @@ void si_emit_dpbb_state(struct si_context *sctx, unsigned index); /* si_state_shaders.cpp */ void si_get_ir_cache_key(struct si_shader_selector *sel, bool ngg, bool es, - unsigned wave_size, unsigned char ir_sha1_cache_key[20]); -bool si_shader_cache_load_shader(struct si_screen *sscreen, unsigned char ir_sha1_cache_key[20], + unsigned wave_size, unsigned char ir_sha1_cache_key[SHA1_DIGEST_LENGTH]); +bool si_shader_cache_load_shader(struct si_screen *sscreen, unsigned char ir_sha1_cache_key[SHA1_DIGEST_LENGTH], struct si_shader *shader); -void si_shader_cache_insert_shader(struct si_screen *sscreen, unsigned char ir_sha1_cache_key[20], +void si_shader_cache_insert_shader(struct si_screen *sscreen, unsigned char ir_sha1_cache_key[SHA1_DIGEST_LENGTH], struct si_shader *shader, bool insert_into_disk_cache); bool si_shader_mem_ordered(struct si_shader *shader); void si_init_screen_live_shader_cache(struct si_screen *sscreen); diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.cpp b/src/gallium/drivers/radeonsi/si_state_shaders.cpp index 82a88e41e51..1cea01a6856 100644 --- a/src/gallium/drivers/radeonsi/si_state_shaders.cpp +++ b/src/gallium/drivers/radeonsi/si_state_shaders.cpp @@ -130,7 +130,7 @@ static bool si_shader_uses_bindless_images(struct si_shader_selector *selector) * Return the IR key for the shader cache. */ void si_get_ir_cache_key(struct si_shader_selector *sel, bool ngg, bool es, - unsigned wave_size, unsigned char ir_sha1_cache_key[20]) + unsigned wave_size, unsigned char ir_sha1_cache_key[SHA1_DIGEST_LENGTH]) { struct blob blob = {}; unsigned ir_size; @@ -344,7 +344,7 @@ static bool si_load_shader_binary(struct si_shader *shader, void *binary) * Insert a shader into the cache. It's assumed the shader is not in the cache. * Use si_shader_cache_load_shader before calling this. */ -void si_shader_cache_insert_shader(struct si_screen *sscreen, unsigned char ir_sha1_cache_key[20], +void si_shader_cache_insert_shader(struct si_screen *sscreen, unsigned char ir_sha1_cache_key[SHA1_DIGEST_LENGTH], struct si_shader *shader, bool insert_into_disk_cache) { uint32_t *hw_binary; @@ -408,7 +408,7 @@ void si_shader_cache_insert_shader(struct si_screen *sscreen, unsigned char ir_s FREE(hw_binary); } -bool si_shader_cache_load_shader(struct si_screen *sscreen, unsigned char ir_sha1_cache_key[20], +bool si_shader_cache_load_shader(struct si_screen *sscreen, unsigned char ir_sha1_cache_key[SHA1_DIGEST_LENGTH], struct si_shader *shader) { struct hash_entry *entry = _mesa_hash_table_search(sscreen->shader_cache, ir_sha1_cache_key); @@ -3442,7 +3442,7 @@ static void si_init_shader_selector_async(void *job, void *gdata, int thread_ind */ if (!sscreen->use_monolithic_shaders) { struct si_shader *shader = CALLOC_STRUCT(si_shader); - unsigned char ir_sha1_cache_key[20]; + unsigned char ir_sha1_cache_key[SHA1_DIGEST_LENGTH]; if (!shader) { mesa_loge("can't allocate a main shader part"); diff --git a/src/gallium/drivers/v3d/v3d_context.h b/src/gallium/drivers/v3d/v3d_context.h index a0c5e4a2d5c..7b1d98f2d5a 100644 --- a/src/gallium/drivers/v3d/v3d_context.h +++ b/src/gallium/drivers/v3d/v3d_context.h @@ -231,7 +231,7 @@ struct v3d_uncompiled_shader { uint32_t num_tf_specs; /* For caching */ - unsigned char sha1[20]; + unsigned char sha1[SHA1_DIGEST_LENGTH]; }; struct v3d_compiled_shader { diff --git a/src/gallium/drivers/v3d/v3d_disk_cache.c b/src/gallium/drivers/v3d/v3d_disk_cache.c index 705d94cd964..c508f03469c 100644 --- a/src/gallium/drivers/v3d/v3d_disk_cache.c +++ b/src/gallium/drivers/v3d/v3d_disk_cache.c @@ -59,7 +59,7 @@ void v3d_disk_cache_init(struct v3d_screen *screen) const uint8_t *id_sha1 = build_id_data(note); assert(id_sha1); - char timestamp[41]; + char timestamp[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(timestamp, id_sha1); screen->disk_cache = @@ -85,7 +85,7 @@ v3d_disk_cache_compute_key(struct disk_cache *cache, struct blob blob; blob_init(&blob); blob_write_bytes(&blob, ckey, ckey_size); - blob_write_bytes(&blob, uncompiled->sha1, 20); + blob_write_bytes(&blob, uncompiled->sha1, SHA1_DIGEST_LENGTH); disk_cache_compute_key(cache, blob.data, blob.size, cache_key); @@ -114,7 +114,7 @@ v3d_disk_cache_retrieve(struct v3d_context *v3d, void *buffer = disk_cache_get(cache, cache_key, &buffer_size); if (V3D_DBG(CACHE)) { - char sha1[41]; + char sha1[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(sha1, cache_key); fprintf(stderr, "[v3d on-disk cache] %s %s\n", buffer ? "hit" : "miss", @@ -197,7 +197,7 @@ v3d_disk_cache_store(struct v3d_context *v3d, v3d_disk_cache_compute_key(cache, key, cache_key, uncompiled); if (V3D_DBG(CACHE)) { - char sha1[41]; + char sha1[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(sha1, cache_key); fprintf(stderr, "[v3d on-disk cache] storing %s\n", sha1); } diff --git a/src/gallium/drivers/v3d/v3d_program.c b/src/gallium/drivers/v3d/v3d_program.c index 5ffc86e3c1e..64dd86aa294 100644 --- a/src/gallium/drivers/v3d/v3d_program.c +++ b/src/gallium/drivers/v3d/v3d_program.c @@ -460,7 +460,7 @@ v3d_shader_state_create(struct pipe_context *pctx, /* Key ued with the RAM cache */ struct v3d_cache_key { struct v3d_key *key; - unsigned char sha1[20]; + unsigned char sha1[SHA1_DIGEST_LENGTH]; }; struct v3d_compiled_shader * @@ -970,12 +970,12 @@ cache_hash(const void *_key, uint32_t key_size) const struct v3d_cache_key *key = (struct v3d_cache_key *) _key; struct mesa_sha1 ctx; - unsigned char sha1[20]; + unsigned char sha1[SHA1_DIGEST_LENGTH]; _mesa_sha1_init(&ctx); _mesa_sha1_update(&ctx, key->key, key_size); - _mesa_sha1_update(&ctx, key->sha1, 20); + _mesa_sha1_update(&ctx, key->sha1, SHA1_DIGEST_LENGTH); _mesa_sha1_final(&ctx, sha1); - return _mesa_hash_data(sha1, 20); + return _mesa_hash_data(sha1, SHA1_DIGEST_LENGTH); } static inline bool diff --git a/src/gallium/drivers/virgl/virgl_screen.c b/src/gallium/drivers/virgl/virgl_screen.c index 91d0748160b..eadc8326247 100644 --- a/src/gallium/drivers/virgl/virgl_screen.c +++ b/src/gallium/drivers/virgl/virgl_screen.c @@ -922,9 +922,9 @@ static void virgl_disk_cache_create(struct virgl_screen *screen) * apply different lowering. */ _mesa_sha1_update(&sha1_ctx, &screen->caps, sizeof(screen->caps)); - uint8_t sha1[20]; + uint8_t sha1[SHA1_DIGEST_LENGTH]; _mesa_sha1_final(&sha1_ctx, sha1); - char timestamp[41]; + char timestamp[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(timestamp, sha1); screen->disk_cache = disk_cache_create("virgl", timestamp, 0); diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c index 3640820bb3a..c39b10ac5f3 100644 --- a/src/gallium/drivers/zink/zink_screen.c +++ b/src/gallium/drivers/zink/zink_screen.c @@ -345,8 +345,8 @@ disk_cache_init(struct zink_screen *screen) blake3_hash blake3; _mesa_blake3_final(&ctx, blake3); - char cache_id[20 * 2 + 1]; - mesa_bytes_to_hex(cache_id, blake3, 20); + char cache_id[SHA1_DIGEST_STRING_LENGTH]; + mesa_bytes_to_hex(cache_id, blake3, SHA1_DIGEST_LENGTH); screen->disk_cache = disk_cache_create("zink", cache_id, 0); diff --git a/src/gallium/frontends/lavapipe/lvp_pipeline.c b/src/gallium/frontends/lavapipe/lvp_pipeline.c index 7aea2456fac..a86b1b737f3 100644 --- a/src/gallium/frontends/lavapipe/lvp_pipeline.c +++ b/src/gallium/frontends/lavapipe/lvp_pipeline.c @@ -1177,7 +1177,7 @@ create_shader_object(struct lvp_device *device, const VkShaderCreateInfoEXT *pCr if (memcmp(uuid, data, VK_UUID_SIZE)) return VK_NULL_HANDLE; size_t size = pCreateInfo->codeSize - SHA1_DIGEST_LENGTH - VK_UUID_SIZE; - unsigned char sha1[20]; + unsigned char sha1[SHA1_DIGEST_LENGTH]; struct mesa_sha1 sctx; _mesa_sha1_init(&sctx); diff --git a/src/gallium/include/frontend/api.h b/src/gallium/include/frontend/api.h index f2c0da31eb3..042272f0e63 100644 --- a/src/gallium/include/frontend/api.h +++ b/src/gallium/include/frontend/api.h @@ -28,6 +28,7 @@ #define _API_H_ #include "util/format/u_formats.h" +#include "util/sha1/sha1.h" struct st_context; @@ -207,7 +208,7 @@ struct st_config_options bool allow_multisampled_copyteximage; bool vertex_program_default_out; - unsigned char config_options_sha1[20]; + unsigned char config_options_sha1[SHA1_DIGEST_LENGTH]; }; struct pipe_frontend_screen; diff --git a/src/intel/common/intel_uuid.c b/src/intel/common/intel_uuid.c index 532df9b959a..a5290b9f44e 100644 --- a/src/intel/common/intel_uuid.c +++ b/src/intel/common/intel_uuid.c @@ -76,7 +76,7 @@ intel_uuid_compute_driver_id(uint8_t *uuid, { const char* intelDriver = PACKAGE_VERSION MESA_GIT_SHA1; struct mesa_sha1 sha1_ctx; - uint8_t sha1[20]; + uint8_t sha1[SHA1_DIGEST_LENGTH]; assert(size <= sizeof(sha1)); diff --git a/src/intel/compiler/brw/brw_compiler.c b/src/intel/compiler/brw/brw_compiler.c index 331eb64c8be..84733ba2073 100644 --- a/src/intel/compiler/brw/brw_compiler.c +++ b/src/intel/compiler/brw/brw_compiler.c @@ -308,7 +308,7 @@ brw_device_sha1(char *hex, struct mesa_sha1 ctx; _mesa_sha1_init(&ctx); brw_device_sha1_update(&ctx, devinfo); - unsigned char result[20]; + unsigned char result[SHA1_DIGEST_LENGTH]; _mesa_sha1_final(&ctx, result); _mesa_sha1_format(hex, result); } diff --git a/src/intel/compiler/brw/brw_generator.cpp b/src/intel/compiler/brw/brw_generator.cpp index 44a7ae0a916..6452acc5535 100644 --- a/src/intel/compiler/brw/brw_generator.cpp +++ b/src/intel/compiler/brw/brw_generator.cpp @@ -1483,8 +1483,8 @@ brw_generator::generate_code(const brw_shader &s, int after_size = p->next_insn_offset - start_offset; bool dump_shader_bin = brw_should_dump_shader_bin(); - unsigned char sha1[21]; - char sha1buf[41]; + unsigned char sha1[SHA1_DIGEST_LENGTH + 1]; + char sha1buf[SHA1_DIGEST_STRING_LENGTH]; auto override_path = debug_get_option_shader_bin_override_path(); if (unlikely(debug_flag || dump_shader_bin || override_path != NULL || diff --git a/src/intel/compiler/elk/elk_fs_generator.cpp b/src/intel/compiler/elk/elk_fs_generator.cpp index dc7a79e88c5..cae529dda87 100644 --- a/src/intel/compiler/elk/elk_fs_generator.cpp +++ b/src/intel/compiler/elk/elk_fs_generator.cpp @@ -2206,8 +2206,8 @@ elk_fs_generator::generate_code(const elk_cfg_t *cfg, int dispatch_width, int after_size = p->next_insn_offset - start_offset; bool dump_shader_bin = elk_should_dump_shader_bin(); - unsigned char sha1[21]; - char sha1buf[41]; + unsigned char sha1[SHA1_DIGEST_LENGTH + 1]; + char sha1buf[SHA1_DIGEST_STRING_LENGTH]; if (unlikely(debug_flag || dump_shader_bin)) { _mesa_sha1_compute(p->store + start_offset / sizeof(elk_inst), diff --git a/src/intel/compiler/elk/elk_vec4_generator.cpp b/src/intel/compiler/elk/elk_vec4_generator.cpp index c7dc89126f7..9c3eb7c96cb 100644 --- a/src/intel/compiler/elk/elk_vec4_generator.cpp +++ b/src/intel/compiler/elk/elk_vec4_generator.cpp @@ -2238,8 +2238,8 @@ generate_code(struct elk_codegen *p, int after_size = p->next_insn_offset; bool dump_shader_bin = elk_should_dump_shader_bin(); - unsigned char sha1[21]; - char sha1buf[41]; + unsigned char sha1[SHA1_DIGEST_LENGTH + 1]; + char sha1buf[SHA1_DIGEST_STRING_LENGTH]; if (unlikely(debug_enabled || dump_shader_bin)) { _mesa_sha1_compute(p->store, p->next_insn_offset, sha1); diff --git a/src/intel/perf/intel_perf.c b/src/intel/perf/intel_perf.c index cb566ff3aec..64d13255697 100644 --- a/src/intel/perf/intel_perf.c +++ b/src/intel/perf/intel_perf.c @@ -815,10 +815,10 @@ intel_perf_store_configuration(struct intel_perf_config *perf_cfg, int fd, config->n_b_counter_regs); } - uint8_t hash[20]; + uint8_t hash[SHA1_DIGEST_LENGTH]; _mesa_sha1_final(&sha1_ctx, hash); - char formatted_hash[41]; + char formatted_hash[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(formatted_hash, hash); char generated_guid[37]; diff --git a/src/intel/tools/intel_dev_info.c b/src/intel/tools/intel_dev_info.c index e04e939ed39..1e36403af92 100644 --- a/src/intel/tools/intel_dev_info.c +++ b/src/intel/tools/intel_dev_info.c @@ -271,7 +271,7 @@ main(int argc, char *argv[]) */ if (devinfo.ver >= 9) { JSON_Object *obj = json_object(json); - char device_info_sha[41]; + char device_info_sha[SHA1_DIGEST_STRING_LENGTH]; brw_device_sha1(device_info_sha, &devinfo); json_object_set_string(obj, "shader_cache_sha1", device_info_sha); } diff --git a/src/intel/vulkan/anv_perf.c b/src/intel/vulkan/anv_perf.c index a3cee161fb2..820851e2af3 100644 --- a/src/intel/vulkan/anv_perf.c +++ b/src/intel/vulkan/anv_perf.c @@ -381,7 +381,7 @@ VkResult anv_EnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR( counter->scope = VK_PERFORMANCE_COUNTER_SCOPE_COMMAND_KHR; counter->storage = intel_perf_counter_data_type_to_vk_storage[intel_counter->data_type]; - unsigned char sha1_result[20]; + unsigned char sha1_result[SHA1_DIGEST_LENGTH]; _mesa_sha1_compute(intel_counter->symbol_name, strlen(intel_counter->symbol_name), sha1_result); diff --git a/src/intel/vulkan/anv_physical_device.c b/src/intel/vulkan/anv_physical_device.c index 7416d06da5e..d1c5ba4490b 100644 --- a/src/intel/vulkan/anv_physical_device.c +++ b/src/intel/vulkan/anv_physical_device.c @@ -1783,7 +1783,7 @@ get_properties(const struct anv_physical_device *pdevice, */ { struct mesa_sha1 sha1_ctx; - uint8_t sha1[20]; + uint8_t sha1[SHA1_DIGEST_LENGTH]; _mesa_sha1_init(&sha1_ctx); _mesa_sha1_update(&sha1_ctx, pdevice->driver_build_sha1, @@ -2362,7 +2362,7 @@ anv_physical_device_init_uuids(struct anv_physical_device *device) memcpy(device->driver_build_sha1, build_id_data(note), 20); struct mesa_sha1 sha1_ctx; - uint8_t sha1[20]; + uint8_t sha1[SHA1_DIGEST_LENGTH]; STATIC_ASSERT(VK_UUID_SIZE <= sizeof(sha1)); /* The pipeline cache UUID is used for determining when a pipeline cache is @@ -2392,7 +2392,7 @@ anv_physical_device_init_disk_cache(struct anv_physical_device *device) device->info.pci_device_id); assert(len == sizeof(renderer) - 2); - char timestamp[41]; + char timestamp[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(timestamp, device->driver_build_sha1); const uint64_t driver_flags = diff --git a/src/intel/vulkan/anv_pipeline_cache.c b/src/intel/vulkan/anv_pipeline_cache.c index bf60fb0d186..d334a2ba5c4 100644 --- a/src/intel/vulkan/anv_pipeline_cache.c +++ b/src/intel/vulkan/anv_pipeline_cache.c @@ -436,7 +436,7 @@ anv_load_fp64_shader(struct anv_device *device) const char* shader_name = "float64_spv_lib"; struct mesa_sha1 sha1_ctx; - uint8_t sha1[20]; + uint8_t sha1[SHA1_DIGEST_LENGTH]; _mesa_sha1_init(&sha1_ctx); _mesa_sha1_update(&sha1_ctx, shader_name, strlen(shader_name)); _mesa_sha1_final(&sha1_ctx, sha1); diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index e642f0b953a..58373def08e 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -1172,9 +1172,9 @@ enum anv_pipeline_bind_mask { #define ANV_PIPELINE_BIND_MASK_SET(i) (ANV_PIPELINE_BIND_MASK_SET0 << i) struct anv_pipeline_bind_map { - unsigned char surface_sha1[20]; - unsigned char sampler_sha1[20]; - unsigned char push_sha1[20]; + unsigned char surface_sha1[SHA1_DIGEST_LENGTH]; + unsigned char sampler_sha1[SHA1_DIGEST_LENGTH]; + unsigned char push_sha1[SHA1_DIGEST_LENGTH]; /* enum anv_descriptor_set_layout_type */ uint16_t layout_type; @@ -1649,7 +1649,7 @@ struct anv_physical_device { struct anv_memregion vram_mappable; struct anv_memregion vram_non_mappable; struct anv_memregion sys; - uint8_t driver_build_sha1[20]; + uint8_t driver_build_sha1[SHA1_DIGEST_LENGTH]; uint8_t shader_binary_uuid[VK_UUID_SIZE]; uint8_t pipeline_cache_uuid[VK_UUID_SIZE]; uint8_t driver_uuid[VK_UUID_SIZE]; @@ -1876,14 +1876,14 @@ struct nir_shader * anv_device_search_for_nir(struct anv_device *device, struct vk_pipeline_cache *cache, const struct nir_shader_compiler_options *nir_options, - unsigned char sha1_key[20], + unsigned char sha1_key[SHA1_DIGEST_LENGTH], void *mem_ctx); void anv_device_upload_nir(struct anv_device *device, struct vk_pipeline_cache *cache, const struct nir_shader *nir, - unsigned char sha1_key[20]); + unsigned char sha1_key[SHA1_DIGEST_LENGTH]); void anv_load_fp64_shader(struct anv_device *device); @@ -4720,9 +4720,9 @@ struct anv_cmd_state { struct anv_state binding_tables[MESA_VULKAN_SHADER_STAGES]; struct anv_state samplers[MESA_VULKAN_SHADER_STAGES]; - unsigned char sampler_sha1s[MESA_VULKAN_SHADER_STAGES][20]; - unsigned char surface_sha1s[MESA_VULKAN_SHADER_STAGES][20]; - unsigned char push_sha1s[MESA_VULKAN_SHADER_STAGES][20]; + unsigned char sampler_sha1s[MESA_VULKAN_SHADER_STAGES][SHA1_DIGEST_LENGTH]; + unsigned char surface_sha1s[MESA_VULKAN_SHADER_STAGES][SHA1_DIGEST_LENGTH]; + unsigned char push_sha1s[MESA_VULKAN_SHADER_STAGES][SHA1_DIGEST_LENGTH]; /* The last auxiliary surface operation (or equivalent operation) provided * to genX(cmd_buffer_update_color_aux_op). diff --git a/src/intel/vulkan/anv_shader_compile.c b/src/intel/vulkan/anv_shader_compile.c index eaa4460fff7..56376b88ae9 100644 --- a/src/intel/vulkan/anv_shader_compile.c +++ b/src/intel/vulkan/anv_shader_compile.c @@ -179,7 +179,7 @@ anv_shader_init_uuid(struct anv_physical_device *device) device->instance->large_workgroup_non_coherent_image_workaround; _mesa_sha1_update(&ctx, &large_wg_wa, sizeof(large_wg_wa)); - uint8_t sha1[20]; + uint8_t sha1[SHA1_DIGEST_LENGTH]; _mesa_sha1_final(&ctx, sha1); memcpy(device->shader_binary_uuid, sha1, sizeof(device->shader_binary_uuid)); } diff --git a/src/intel/vulkan_hasvk/anv_device.c b/src/intel/vulkan_hasvk/anv_device.c index 9da3c1fe7be..fe91e6890fe 100644 --- a/src/intel/vulkan_hasvk/anv_device.c +++ b/src/intel/vulkan_hasvk/anv_device.c @@ -1412,7 +1412,7 @@ anv_physical_device_init_uuids(struct anv_physical_device *device) memcpy(device->driver_build_sha1, build_id_data(note), 20); struct mesa_sha1 sha1_ctx; - uint8_t sha1[20]; + uint8_t sha1[SHA1_DIGEST_LENGTH]; STATIC_ASSERT(VK_UUID_SIZE <= sizeof(sha1)); /* The pipeline cache UUID is used for determining when a pipeline cache is @@ -1446,7 +1446,7 @@ anv_physical_device_init_disk_cache(struct anv_physical_device *device) device->info.pci_device_id); assert(len == sizeof(renderer) - 2); - char timestamp[41]; + char timestamp[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(timestamp, device->driver_build_sha1); const uint64_t driver_flags = diff --git a/src/intel/vulkan_hasvk/anv_perf.c b/src/intel/vulkan_hasvk/anv_perf.c index 383d101dba6..6232cf01e09 100644 --- a/src/intel/vulkan_hasvk/anv_perf.c +++ b/src/intel/vulkan_hasvk/anv_perf.c @@ -325,7 +325,7 @@ VkResult anv_EnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR( counter->scope = VK_PERFORMANCE_COUNTER_SCOPE_COMMAND_KHR; counter->storage = intel_perf_counter_data_type_to_vk_storage[intel_counter->data_type]; - unsigned char sha1_result[20]; + unsigned char sha1_result[SHA1_DIGEST_LENGTH]; _mesa_sha1_compute(intel_counter->symbol_name, strlen(intel_counter->symbol_name), sha1_result); diff --git a/src/intel/vulkan_hasvk/anv_pipeline.c b/src/intel/vulkan_hasvk/anv_pipeline.c index 342535cd46a..aa298b48ffc 100644 --- a/src/intel/vulkan_hasvk/anv_pipeline.c +++ b/src/intel/vulkan_hasvk/anv_pipeline.c @@ -337,13 +337,13 @@ struct anv_pipeline_stage { VkPipelineCreateFlags2KHR pipeline_flags; const VkPipelineShaderStageCreateInfo *info; - unsigned char shader_sha1[20]; + unsigned char shader_sha1[SHA1_DIGEST_LENGTH]; union elk_any_prog_key key; struct { mesa_shader_stage stage; - unsigned char sha1[20]; + unsigned char sha1[SHA1_DIGEST_LENGTH]; } cache_key; nir_shader *nir; @@ -1230,7 +1230,7 @@ anv_graphics_pipeline_compile(struct anv_graphics_pipeline *pipeline, anv_graphics_pipeline_init_keys(pipeline, state, stages); - unsigned char sha1[20]; + unsigned char sha1[SHA1_DIGEST_LENGTH]; anv_pipeline_hash_graphics(pipeline, layout, stages, sha1); for (unsigned s = 0; s < ARRAY_SIZE(stages); s++) { diff --git a/src/intel/vulkan_hasvk/anv_private.h b/src/intel/vulkan_hasvk/anv_private.h index c6851813dd7..aa81d393c8f 100644 --- a/src/intel/vulkan_hasvk/anv_private.h +++ b/src/intel/vulkan_hasvk/anv_private.h @@ -886,7 +886,7 @@ struct anv_physical_device { } memory; struct anv_memregion sys; - uint8_t driver_build_sha1[20]; + uint8_t driver_build_sha1[SHA1_DIGEST_LENGTH]; uint8_t pipeline_cache_uuid[VK_UUID_SIZE]; uint8_t driver_uuid[VK_UUID_SIZE]; uint8_t device_uuid[VK_UUID_SIZE]; @@ -981,14 +981,14 @@ struct nir_shader * anv_device_search_for_nir(struct anv_device *device, struct vk_pipeline_cache *cache, const struct nir_shader_compiler_options *nir_options, - unsigned char sha1_key[20], + unsigned char sha1_key[SHA1_DIGEST_LENGTH], void *mem_ctx); void anv_device_upload_nir(struct anv_device *device, struct vk_pipeline_cache *cache, const struct nir_shader *nir, - unsigned char sha1_key[20]); + unsigned char sha1_key[SHA1_DIGEST_LENGTH]); struct anv_device { struct vk_device vk; @@ -1932,7 +1932,7 @@ struct anv_pipeline_layout { uint32_t num_sets; - unsigned char sha1[20]; + unsigned char sha1[SHA1_DIGEST_LENGTH]; }; struct anv_buffer { @@ -2481,9 +2481,9 @@ struct anv_cmd_state { struct anv_state binding_tables[MESA_VULKAN_SHADER_STAGES]; struct anv_state samplers[MESA_VULKAN_SHADER_STAGES]; - unsigned char sampler_sha1s[MESA_VULKAN_SHADER_STAGES][20]; - unsigned char surface_sha1s[MESA_VULKAN_SHADER_STAGES][20]; - unsigned char push_sha1s[MESA_VULKAN_SHADER_STAGES][20]; + unsigned char sampler_sha1s[MESA_VULKAN_SHADER_STAGES][SHA1_DIGEST_LENGTH]; + unsigned char surface_sha1s[MESA_VULKAN_SHADER_STAGES][SHA1_DIGEST_LENGTH]; + unsigned char push_sha1s[MESA_VULKAN_SHADER_STAGES][SHA1_DIGEST_LENGTH]; /** * Whether or not the gfx8 PMA fix is enabled. We ensure that, at the top @@ -2702,9 +2702,9 @@ struct anv_event { __tmp &= ~(1 << (stage))) struct anv_pipeline_bind_map { - unsigned char surface_sha1[20]; - unsigned char sampler_sha1[20]; - unsigned char push_sha1[20]; + unsigned char surface_sha1[SHA1_DIGEST_LENGTH]; + unsigned char sampler_sha1[SHA1_DIGEST_LENGTH]; + unsigned char push_sha1[SHA1_DIGEST_LENGTH]; uint32_t surface_count; uint32_t sampler_count; diff --git a/src/mesa/main/program_binary.c b/src/mesa/main/program_binary.c index dacb9bac897..f78c71b558a 100644 --- a/src/mesa/main/program_binary.c +++ b/src/mesa/main/program_binary.c @@ -56,7 +56,7 @@ struct program_binary_header { * something besides a sha1, then a new internal_format value can be added. */ uint32_t internal_format; - uint8_t sha1[20]; + uint8_t sha1[SHA1_DIGEST_LENGTH]; /* Fields following sha1 can be changed since the sha1 will guarantee that * the binary only works with the same Mesa version. */ @@ -236,7 +236,7 @@ _mesa_get_program_binary(struct gl_context *ctx, GLenum *binary_format, GLvoid *binary) { struct blob blob; - uint8_t driver_sha1[20]; + uint8_t driver_sha1[SHA1_DIGEST_LENGTH]; unsigned header_size = get_program_binary_header_size(); st_get_program_binary_driver_sha1(ctx, driver_sha1); @@ -273,7 +273,7 @@ _mesa_program_binary(struct gl_context *ctx, struct gl_shader_program *sh_prog, GLenum binary_format, const GLvoid *binary, GLsizei length) { - uint8_t driver_sha1[20]; + uint8_t driver_sha1[SHA1_DIGEST_LENGTH]; unsigned header_size = get_program_binary_header_size(); st_get_program_binary_driver_sha1(ctx, driver_sha1); diff --git a/src/mesa/main/shader_types.h b/src/mesa/main/shader_types.h index 3bd6f1395a8..b672a50ae76 100644 --- a/src/mesa/main/shader_types.h +++ b/src/mesa/main/shader_types.h @@ -324,7 +324,7 @@ struct gl_shader_program_data GLint RefCount; /**< Reference count */ /** SHA1 hash of linked shader program */ - unsigned char sha1[20]; + unsigned char sha1[SHA1_DIGEST_LENGTH]; unsigned NumUniformStorage; unsigned NumHiddenUniforms; diff --git a/src/nouveau/vulkan/nvk_instance.c b/src/nouveau/vulkan/nvk_instance.c index 4fc96884114..9fb7005d9ca 100644 --- a/src/nouveau/vulkan/nvk_instance.c +++ b/src/nouveau/vulkan/nvk_instance.c @@ -174,7 +174,7 @@ nvk_CreateInstance(const VkInstanceCreateInfo *pCreateInfo, } unsigned build_id_len = build_id_length(note); - if (build_id_len < SHA1_DIGEST_LENGTH) { + if (build_id_len < 20) { result = vk_errorf(NULL, VK_ERROR_INITIALIZATION_FAILED, "build-id too short. It needs to be a SHA"); goto fail_init; diff --git a/src/nouveau/vulkan/nvk_instance.h b/src/nouveau/vulkan/nvk_instance.h index 780cafbc11f..a5d0cc23d7a 100644 --- a/src/nouveau/vulkan/nvk_instance.h +++ b/src/nouveau/vulkan/nvk_instance.h @@ -19,7 +19,7 @@ struct nvk_instance { struct driOptionCache dri_options; struct driOptionCache available_dri_options; - uint8_t driver_build_sha[20]; + uint8_t driver_build_sha[SHA1_DIGEST_LENGTH]; uint32_t force_vk_vendor; }; diff --git a/src/nouveau/vulkan/nvk_physical_device.c b/src/nouveau/vulkan/nvk_physical_device.c index 663c1a804e4..3d54e4cf969 100644 --- a/src/nouveau/vulkan/nvk_physical_device.c +++ b/src/nouveau/vulkan/nvk_physical_device.c @@ -1329,7 +1329,7 @@ nvk_physical_device_init_pipeline_cache(struct nvk_physical_device *pdev) pdev->info.chipset); assert(len == sizeof(renderer) - 2); - char timestamp[41]; + char timestamp[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(timestamp, instance->driver_build_sha); const uint64_t driver_flags = nvk_physical_device_compiler_flags(pdev); diff --git a/src/panfrost/vulkan/panvk_instance.c b/src/panfrost/vulkan/panvk_instance.c index 53a6aa316ce..e57a9448847 100644 --- a/src/panfrost/vulkan/panvk_instance.c +++ b/src/panfrost/vulkan/panvk_instance.c @@ -240,7 +240,7 @@ panvk_CreateInstance(const VkInstanceCreateInfo *pCreateInfo, } unsigned build_id_len = build_id_length(note); - if (build_id_len < SHA1_DIGEST_LENGTH) { + if (build_id_len < 20) { return panvk_errorf(NULL, VK_ERROR_INITIALIZATION_FAILED, "build-id too short. It needs to be a SHA"); } diff --git a/src/panfrost/vulkan/panvk_instance.h b/src/panfrost/vulkan/panvk_instance.h index 1189a118f39..cf22ea78744 100644 --- a/src/panfrost/vulkan/panvk_instance.h +++ b/src/panfrost/vulkan/panvk_instance.h @@ -52,7 +52,7 @@ struct panvk_instance { struct driOptionCache dri_options; struct driOptionCache available_dri_options; - uint8_t driver_build_sha[20]; + uint8_t driver_build_sha[SHA1_DIGEST_LENGTH]; uint32_t force_vk_vendor; bool enable_vertex_pipeline_stores_atomics; diff --git a/src/util/disk_cache.h b/src/util/disk_cache.h index dd760f3a57b..c928d9be256 100644 --- a/src/util/disk_cache.h +++ b/src/util/disk_cache.h @@ -41,7 +41,7 @@ extern "C" { #endif /* Size of cache keys in bytes. */ -#define CACHE_KEY_SIZE 20 +#define CACHE_KEY_SIZE SHA1_DIGEST_LENGTH #define CACHE_DIR_NAME "mesa_shader_cache" #define CACHE_DIR_NAME_SF "mesa_shader_cache_sf" diff --git a/src/util/disk_cache_os.c b/src/util/disk_cache_os.c index 398bda97250..f31c8dce1b9 100644 --- a/src/util/disk_cache_os.c +++ b/src/util/disk_cache_os.c @@ -441,7 +441,7 @@ static void make_cache_file_directory(struct disk_cache *cache, const cache_key key) { char *dir; - char buf[41]; + char buf[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(buf, key); if (asprintf(&dir, "%s/%c%c", cache->path, buf[0], buf[1]) == -1) @@ -678,7 +678,7 @@ disk_cache_load_item(struct disk_cache *cache, char *filename, size_t *size) char * disk_cache_get_cache_filename(struct disk_cache *cache, const cache_key key) { - char buf[41]; + char buf[SHA1_DIGEST_STRING_LENGTH]; char *filename; if (cache->path_init_failed) diff --git a/src/util/fossilize_db.h b/src/util/fossilize_db.h index 4e24e3ff6af..2889476f6af 100644 --- a/src/util/fossilize_db.h +++ b/src/util/fossilize_db.h @@ -45,6 +45,7 @@ #include #include +#include "sha1/sha1.h" #include "simple_mtx.h" /* Max number of DBs our implementation can read from at once */ @@ -71,7 +72,7 @@ struct foz_payload_header { struct foz_db_entry { uint8_t file_idx; - uint8_t key[20]; + uint8_t key[SHA1_DIGEST_LENGTH]; uint64_t offset; struct foz_payload_header header; }; diff --git a/src/util/mesa-sha1.c b/src/util/mesa-sha1.c index eed6e34fa5e..18866cd083b 100644 --- a/src/util/mesa-sha1.c +++ b/src/util/mesa-sha1.c @@ -31,7 +31,7 @@ #include void -_mesa_sha1_compute(const void *data, size_t size, unsigned char result[20]) +_mesa_sha1_compute(const void *data, size_t size, unsigned char result[SHA1_DIGEST_LENGTH]) { struct mesa_sha1 ctx; diff --git a/src/util/mesa-sha1.h b/src/util/mesa-sha1.h index c264927d572..aaf893391b1 100644 --- a/src/util/mesa-sha1.h +++ b/src/util/mesa-sha1.h @@ -49,7 +49,7 @@ _mesa_sha1_update(struct mesa_sha1 *ctx, const void *data, size_t size) } static inline void -_mesa_sha1_final(struct mesa_sha1 *ctx, unsigned char result[20]) +_mesa_sha1_final(struct mesa_sha1 *ctx, unsigned char result[SHA1_DIGEST_LENGTH]) { SHA1Final(result, ctx); } @@ -61,7 +61,7 @@ void _mesa_sha1_hex_to_sha1(unsigned char *buf, const char *hex); void -_mesa_sha1_compute(const void *data, size_t size, unsigned char result[20]); +_mesa_sha1_compute(const void *data, size_t size, unsigned char result[SHA1_DIGEST_LENGTH]); void _mesa_sha1_print(FILE *f, const uint8_t sha1[SHA1_DIGEST_LENGTH]); diff --git a/src/util/tests/cache_test.cpp b/src/util/tests/cache_test.cpp index e1e81e70fff..5779fba3cb5 100644 --- a/src/util/tests/cache_test.cpp +++ b/src/util/tests/cache_test.cpp @@ -118,7 +118,7 @@ does_cache_contain(struct disk_cache *cache, const cache_key key) static bool cache_exists(struct disk_cache *cache) { - uint8_t key[20]; + uint8_t key[SHA1_DIGEST_LENGTH]; char data[] = "some test data"; if (!cache) @@ -273,13 +273,13 @@ test_put_and_get(bool test_cache_size_limit, const char *driver_id) { struct disk_cache *cache; char blob[] = "This is a blob of thirty-seven bytes"; - uint8_t blob_key[20]; + uint8_t blob_key[SHA1_DIGEST_LENGTH]; char string[] = "While this string has thirty-four"; - uint8_t string_key[20]; + uint8_t string_key[SHA1_DIGEST_LENGTH]; char *result; size_t size; uint8_t *one_KB, *one_MB; - uint8_t one_KB_key[20], one_MB_key[20]; + uint8_t one_KB_key[SHA1_DIGEST_LENGTH], one_MB_key[SHA1_DIGEST_LENGTH]; int count; #ifdef SHADER_CACHE_DISABLE_BY_DEFAULT @@ -452,11 +452,11 @@ test_put_key_and_get_key(const char *driver_id) struct disk_cache *cache; bool result; - uint8_t key_a[20] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19}; - uint8_t key_b[20] = { 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 33, 32, 33, 34, 35, 36, 37, 38, 39}; - uint8_t key_a_collide[20] = + uint8_t key_a[SHA1_DIGEST_LENGTH] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19}; + uint8_t key_b[SHA1_DIGEST_LENGTH] = { 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 33, 32, 33, 34, 35, 36, 37, 38, 39}; + uint8_t key_a_collide[SHA1_DIGEST_LENGTH] = { 0, 1, 42, 43, 44, 45, 46, 47, 48, 49, 50, 55, 52, 53, 54, 55, 56, 57, 58, 59}; @@ -510,9 +510,9 @@ static void test_put_and_get_between_instances(const char *driver_id) { char blob[] = "This is a blob of thirty-seven bytes"; - uint8_t blob_key[20]; + uint8_t blob_key[SHA1_DIGEST_LENGTH]; char string[] = "While this string has thirty-four"; - uint8_t string_key[20]; + uint8_t string_key[SHA1_DIGEST_LENGTH]; char *result; size_t size; @@ -699,7 +699,7 @@ static void test_put_big_sized_entry_to_empty_cache(const char *driver_id) { static uint8_t blob[4096]; - uint8_t blob_key[20]; + uint8_t blob_key[SHA1_DIGEST_LENGTH]; struct disk_cache *cache; char *result; size_t size; @@ -861,9 +861,9 @@ TEST_F(Cache, Combined) const char *driver_id = "make_check"; char blob[] = "This is a RO blob"; char blob2[] = "This is a RW blob"; - uint8_t dummy_key[20] = { 0 }; - uint8_t blob_key[20]; - uint8_t blob_key2[20]; + uint8_t dummy_key[SHA1_DIGEST_LENGTH] = { 0 }; + uint8_t blob_key[SHA1_DIGEST_LENGTH]; + uint8_t blob_key2[SHA1_DIGEST_LENGTH]; char foz_rw_idx_file[1024]; char foz_ro_idx_file[1024]; char foz_rw_file[1024]; @@ -1088,7 +1088,7 @@ TEST_F(Cache, List) { const char *driver_id = "make_check"; char blob[] = "This is a RO blob"; - uint8_t blob_key[20]; + uint8_t blob_key[SHA1_DIGEST_LENGTH]; char foz_rw_idx_file[1024]; char foz_ro_idx_file[1024]; char foz_rw_file[1024]; @@ -1355,7 +1355,7 @@ test_put_and_get_disabled(const char *driver_id) { struct disk_cache *cache; char blob[] = "This is a blob of thirty-seven bytes"; - uint8_t blob_key[20]; + uint8_t blob_key[SHA1_DIGEST_LENGTH]; char *result; size_t size; diff --git a/src/util/tests/mesa-sha1_test.cpp b/src/util/tests/mesa-sha1_test.cpp index bc3c5172d91..c918eac872c 100644 --- a/src/util/tests/mesa-sha1_test.cpp +++ b/src/util/tests/mesa-sha1_test.cpp @@ -49,10 +49,10 @@ TEST_P(MesaSHA1TestFixture, Match) { Params p = GetParam(); - unsigned char sha1[20]; + unsigned char sha1[SHA1_DIGEST_LENGTH]; _mesa_sha1_compute(p.string, strlen(p.string), sha1); - char buf[41]; + char buf[SHA1_DIGEST_STRING_LENGTH]; _mesa_sha1_format(buf, sha1); ASSERT_TRUE(memcmp(buf, p.expected_sha1, SHA1_LENGTH) == 0) diff --git a/src/virtio/vulkan/vn_device.c b/src/virtio/vulkan/vn_device.c index 02f417d50f4..686745e5d46 100644 --- a/src/virtio/vulkan/vn_device.c +++ b/src/virtio/vulkan/vn_device.c @@ -424,7 +424,7 @@ vn_device_update_shader_cache_id(struct vn_device *dev) /* The entry header is what contains the cache id / timestamp so we * need to create a fake entry. */ - uint8_t key[20]; + uint8_t key[SHA1_DIGEST_LENGTH]; char data[] = "Fake Shader"; disk_cache_compute_key(cache, data, sizeof(data), key);