Inline _mesa_sha1_compute/format, remove the other unused ones
_mesa_sha1_format has a few remaining uses, so it's moved to build_id.c, which is its last user. 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:
parent
52d5dfc7d3
commit
53c64973e8
58 changed files with 105 additions and 205 deletions
|
|
@ -573,8 +573,8 @@ radv_dump_shader(struct radv_device *device, struct radv_pipeline *pipeline, str
|
|||
unsigned char sha1[BLAKE3_KEY_LEN + 1];
|
||||
char sha1buf[BLAKE3_HEX_LEN];
|
||||
|
||||
_mesa_sha1_compute(shader->spirv, shader->spirv_size, sha1);
|
||||
_mesa_sha1_format(sha1buf, sha1);
|
||||
_mesa_blake3_compute(shader->spirv, shader->spirv_size, sha1);
|
||||
_mesa_blake3_format(sha1buf, sha1);
|
||||
|
||||
if (device->vk.enabled_features.deviceFaultVendorBinary) {
|
||||
spirv_print_asm(f, (const uint32_t *)shader->spirv, shader->spirv_size / 4);
|
||||
|
|
|
|||
|
|
@ -255,7 +255,7 @@ radv_shader_object_init_binary(struct radv_device *device, struct blob_reader *b
|
|||
const struct radv_shader_binary *binary = blob_read_bytes(blob, binary_size);
|
||||
unsigned char sha1[BLAKE3_KEY_LEN];
|
||||
|
||||
_mesa_sha1_compute(binary, binary->total_size, sha1);
|
||||
_mesa_blake3_compute(binary, binary->total_size, sha1);
|
||||
if (memcmp(sha1, binary_sha1, BLAKE3_KEY_LEN))
|
||||
return VK_ERROR_INCOMPATIBLE_SHADER_BINARY_EXT;
|
||||
|
||||
|
|
@ -652,7 +652,7 @@ radv_write_shader_binary(struct blob *blob, const struct radv_shader_binary *bin
|
|||
blob_write_uint32(blob, !!binary);
|
||||
|
||||
if (binary) {
|
||||
_mesa_sha1_compute(binary, binary->total_size, binary_sha1);
|
||||
_mesa_blake3_compute(binary, binary->total_size, binary_sha1);
|
||||
|
||||
blob_write_bytes(blob, binary_sha1, sizeof(binary_sha1));
|
||||
blob_write_uint32(blob, binary->total_size);
|
||||
|
|
|
|||
|
|
@ -1132,7 +1132,7 @@ hk_physical_device_init_pipeline_cache(struct hk_physical_device *pdev)
|
|||
assert(len == sizeof(renderer) - 2);
|
||||
|
||||
char timestamp[BLAKE3_HEX_LEN];
|
||||
_mesa_sha1_format(timestamp, instance->driver_build_sha);
|
||||
_mesa_blake3_format(timestamp, instance->driver_build_sha);
|
||||
|
||||
const uint64_t driver_flags = hk_physical_device_compiler_flags(pdev);
|
||||
pdev->vk.disk_cache = disk_cache_create(renderer, timestamp, driver_flags);
|
||||
|
|
|
|||
|
|
@ -855,7 +855,7 @@ v3dv_physical_device_init_disk_cache(struct v3dv_physical_device *device)
|
|||
{
|
||||
#ifdef ENABLE_SHADER_CACHE
|
||||
char timestamp[BLAKE3_HEX_LEN];
|
||||
_mesa_sha1_format(timestamp, device->driver_build_sha1);
|
||||
_mesa_blake3_format(timestamp, device->driver_build_sha1);
|
||||
|
||||
assert(device->name);
|
||||
device->disk_cache = disk_cache_create(device->name, timestamp, v3d_mesa_debug);
|
||||
|
|
|
|||
|
|
@ -402,7 +402,7 @@ shader_module_compile_to_nir(struct v3dv_device *device,
|
|||
|
||||
if (V3D_DBG(SHADERDB) && (!stage->module || stage->module->nir == NULL)) {
|
||||
char sha1buf[BLAKE3_HEX_LEN];
|
||||
_mesa_sha1_format(sha1buf, stage->pipeline->sha1);
|
||||
_mesa_blake3_format(sha1buf, stage->pipeline->sha1);
|
||||
nir->info.name = ralloc_strdup(nir, sha1buf);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ v3dv_pipeline_cache_upload_nir(struct v3dv_pipeline *pipeline,
|
|||
cache->nir_stats.count++;
|
||||
if (debug_cache) {
|
||||
char sha1buf[BLAKE3_HEX_LEN];
|
||||
_mesa_sha1_format(sha1buf, snir->sha1_key);
|
||||
_mesa_blake3_format(sha1buf, snir->sha1_key);
|
||||
mesa_logi("pipeline cache %p, new nir entry %s\n", cache, sha1buf);
|
||||
if (dump_stats)
|
||||
cache_dump_stats(cache);
|
||||
|
|
@ -152,7 +152,7 @@ v3dv_pipeline_cache_search_for_nir(struct v3dv_pipeline *pipeline,
|
|||
|
||||
if (debug_cache) {
|
||||
char sha1buf[BLAKE3_HEX_LEN];
|
||||
_mesa_sha1_format(sha1buf, sha1_key);
|
||||
_mesa_blake3_format(sha1buf, sha1_key);
|
||||
|
||||
mesa_logi("pipeline cache %p, search for nir %s\n", cache, sha1buf);
|
||||
}
|
||||
|
|
@ -257,7 +257,7 @@ v3dv_pipeline_cache_search_for_pipeline(struct v3dv_pipeline_cache *cache,
|
|||
|
||||
if (debug_cache) {
|
||||
char sha1buf[BLAKE3_HEX_LEN];
|
||||
_mesa_sha1_format(sha1buf, sha1_key);
|
||||
_mesa_blake3_format(sha1buf, sha1_key);
|
||||
|
||||
mesa_logi("pipeline cache %p, search pipeline with key %s\n", cache, sha1buf);
|
||||
}
|
||||
|
|
@ -313,7 +313,7 @@ v3dv_pipeline_cache_search_for_pipeline(struct v3dv_pipeline_cache *cache,
|
|||
uint8_t *buffer = disk_cache_get(disk_cache, cache_key, &buffer_size);
|
||||
if (V3D_DBG(CACHE)) {
|
||||
char sha1buf[BLAKE3_HEX_LEN];
|
||||
_mesa_sha1_format(sha1buf, cache_key);
|
||||
_mesa_blake3_format(sha1buf, cache_key);
|
||||
mesa_logi("[v3dv on-disk cache] %s %s\n",
|
||||
buffer ? "hit" : "miss", sha1buf);
|
||||
}
|
||||
|
|
@ -453,7 +453,7 @@ pipeline_cache_upload_shared_data(struct v3dv_pipeline_cache *cache,
|
|||
cache->stats.count++;
|
||||
if (debug_cache) {
|
||||
char sha1buf[BLAKE3_HEX_LEN];
|
||||
_mesa_sha1_format(sha1buf, shared_data->sha1_key);
|
||||
_mesa_blake3_format(sha1buf, shared_data->sha1_key);
|
||||
|
||||
mesa_logi("pipeline cache %p, new cache entry with sha1 key %s:%p\n\n",
|
||||
cache, sha1buf, shared_data);
|
||||
|
|
@ -481,7 +481,7 @@ pipeline_cache_upload_shared_data(struct v3dv_pipeline_cache *cache,
|
|||
|
||||
if (V3D_DBG(CACHE)) {
|
||||
char sha1buf[BLAKE3_HEX_LEN];
|
||||
_mesa_sha1_format(sha1buf, shared_data->sha1_key);
|
||||
_mesa_blake3_format(sha1buf, shared_data->sha1_key);
|
||||
mesa_logi("[v3dv on-disk cache] storing %s\n", sha1buf);
|
||||
}
|
||||
disk_cache_put(disk_cache, cache_key, binary.data, binary.size, NULL);
|
||||
|
|
@ -819,7 +819,7 @@ v3dv_MergePipelineCaches(VkDevice device,
|
|||
dst->nir_stats.count++;
|
||||
if (debug_cache) {
|
||||
char sha1buf[BLAKE3_HEX_LEN];
|
||||
_mesa_sha1_format(sha1buf, snir_dst->sha1_key);
|
||||
_mesa_blake3_format(sha1buf, snir_dst->sha1_key);
|
||||
|
||||
mesa_logi("pipeline cache %p, added nir entry %s "
|
||||
"from pipeline cache %p\n",
|
||||
|
|
@ -842,7 +842,7 @@ v3dv_MergePipelineCaches(VkDevice device,
|
|||
dst->stats.count++;
|
||||
if (debug_cache) {
|
||||
char sha1buf[BLAKE3_HEX_LEN];
|
||||
_mesa_sha1_format(sha1buf, cache_entry->sha1_key);
|
||||
_mesa_blake3_format(sha1buf, cache_entry->sha1_key);
|
||||
|
||||
mesa_logi("pipeline cache %p, added entry %s "
|
||||
"from pipeline cache %p\n",
|
||||
|
|
|
|||
|
|
@ -1377,7 +1377,7 @@ v3dv_EnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR(
|
|||
counter->storage = VK_PERFORMANCE_COUNTER_STORAGE_UINT64_KHR;
|
||||
|
||||
unsigned char sha1_result[BLAKE3_KEY_LEN];
|
||||
_mesa_sha1_compute(perfcntr_desc->name, strlen(perfcntr_desc->name), sha1_result);
|
||||
_mesa_blake3_compute(perfcntr_desc->name, strlen(perfcntr_desc->name), sha1_result);
|
||||
|
||||
memcpy(counter->uuid, sha1_result, sizeof(counter->uuid));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2338,7 +2338,7 @@ can_skip_compile(struct gl_context *ctx, struct gl_shader *shader,
|
|||
if (disk_cache_has_key(ctx->Cache, shader->disk_cache_sha1)) {
|
||||
/* We've seen this shader before and know it compiles */
|
||||
if (ctx->_Shader->Flags & GLSL_CACHE_INFO) {
|
||||
_mesa_sha1_format(buf, shader->disk_cache_sha1);
|
||||
_mesa_blake3_format(buf, shader->disk_cache_sha1);
|
||||
fprintf(stderr, "deferring compile of shader: %s\n", buf);
|
||||
}
|
||||
shader->CompileStatus = COMPILE_SKIPPED;
|
||||
|
|
@ -2547,7 +2547,7 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,
|
|||
char sha1_buf[BLAKE3_HEX_LEN];
|
||||
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);
|
||||
_mesa_blake3_format(sha1_buf, shader->disk_cache_sha1);
|
||||
fprintf(stderr, "marking shader: %s\n", sha1_buf);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ shader_cache_write_program_metadata(struct gl_context *ctx,
|
|||
|
||||
char sha1_buf[BLAKE3_HEX_LEN];
|
||||
if (ctx->_Shader->Flags & GLSL_CACHE_INFO) {
|
||||
_mesa_sha1_format(sha1_buf, prog->data->sha1);
|
||||
_mesa_blake3_format(sha1_buf, prog->data->sha1);
|
||||
fprintf(stderr, "putting program metadata in cache: %s\n", sha1_buf);
|
||||
}
|
||||
|
||||
|
|
@ -196,12 +196,12 @@ shader_cache_read_program_metadata(struct gl_context *ctx,
|
|||
* include them as an input to sha1 creation.
|
||||
*/
|
||||
char sha1buf[BLAKE3_HEX_LEN];
|
||||
_mesa_sha1_format(sha1buf, ctx->Const.dri_config_options_sha1);
|
||||
_mesa_blake3_format(sha1buf, ctx->Const.dri_config_options_sha1);
|
||||
ralloc_strcat(&buf, sha1buf);
|
||||
|
||||
for (unsigned i = 0; i < prog->NumShaders; i++) {
|
||||
struct gl_shader *sh = prog->Shaders[i];
|
||||
_mesa_sha1_format(sha1buf, sh->disk_cache_sha1);
|
||||
_mesa_blake3_format(sha1buf, sh->disk_cache_sha1);
|
||||
ralloc_asprintf_append(&buf, "%s: %s\n",
|
||||
_mesa_shader_stage_to_abbrev(sh->Stage), sha1buf);
|
||||
}
|
||||
|
|
@ -227,7 +227,7 @@ shader_cache_read_program_metadata(struct gl_context *ctx,
|
|||
}
|
||||
|
||||
if (ctx->_Shader->Flags & GLSL_CACHE_INFO) {
|
||||
_mesa_sha1_format(sha1buf, prog->data->sha1);
|
||||
_mesa_blake3_format(sha1buf, prog->data->sha1);
|
||||
fprintf(stderr, "loading shader program meta data from cache: %s\n",
|
||||
sha1buf);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ ir3_disk_cache_init(struct ir3_compiler *compiler)
|
|||
_mesa_blake3_final(&ctx, sha1);
|
||||
|
||||
char timestamp[BLAKE3_HEX_LEN];
|
||||
_mesa_sha1_format(timestamp, sha1);
|
||||
_mesa_blake3_format(timestamp, sha1);
|
||||
|
||||
uint64_t driver_flags = ir3_shader_debug_hash_key();
|
||||
compiler->disk_cache = disk_cache_create(renderer, timestamp, driver_flags);
|
||||
|
|
@ -226,7 +226,7 @@ ir3_disk_cache_retrieve(struct ir3_shader *shader,
|
|||
|
||||
if (debug) {
|
||||
char sha1[BLAKE3_HEX_LEN];
|
||||
_mesa_sha1_format(sha1, cache_key);
|
||||
_mesa_blake3_format(sha1, cache_key);
|
||||
fprintf(stderr, "[mesa disk cache] retrieving variant %s: ", sha1);
|
||||
}
|
||||
|
||||
|
|
@ -265,7 +265,7 @@ ir3_disk_cache_store(struct ir3_shader *shader,
|
|||
|
||||
if (debug) {
|
||||
char sha1[BLAKE3_HEX_LEN];
|
||||
_mesa_sha1_format(sha1, cache_key);
|
||||
_mesa_blake3_format(sha1, cache_key);
|
||||
fprintf(stderr, "[mesa disk cache] storing variant %s\n", sha1);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -406,7 +406,7 @@ assemble_variant(struct ir3_shader_variant *v, bool internal)
|
|||
_mesa_blake3_update(&ctx, &v->info.double_threadsize,
|
||||
sizeof(v->info.double_threadsize));
|
||||
_mesa_blake3_final(&ctx, sha1);
|
||||
_mesa_sha1_format(v->sha1_str, sha1);
|
||||
_mesa_blake3_format(v->sha1_str, sha1);
|
||||
|
||||
bool dbg_enabled = shader_debug_enabled(v->type, internal) ||
|
||||
ir3_shader_bisect_disasm_select(v);
|
||||
|
|
|
|||
|
|
@ -2225,7 +2225,7 @@ tu_EnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR(
|
|||
fd_perfcntr_type_to_vk_storage[group[i].countables[j].query_type];
|
||||
|
||||
unsigned char sha1_result[BLAKE3_KEY_LEN];
|
||||
_mesa_sha1_compute(group[i].countables[j].name,
|
||||
_mesa_blake3_compute(group[i].countables[j].name,
|
||||
strlen(group[i].countables[j].name),
|
||||
sha1_result);
|
||||
memcpy(counter->uuid, sha1_result, sizeof(counter->uuid));
|
||||
|
|
@ -2257,7 +2257,7 @@ tu_EnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR(
|
|||
counter->storage = fd_perfcntr_type_to_vk_storage[derived_counter->type];
|
||||
|
||||
unsigned char sha1_result[BLAKE3_KEY_LEN];
|
||||
_mesa_sha1_compute(derived_counter->name, strlen(derived_counter->name),
|
||||
_mesa_blake3_compute(derived_counter->name, strlen(derived_counter->name),
|
||||
sha1_result);
|
||||
memcpy(counter->uuid, sha1_result, sizeof(counter->uuid));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1862,7 +1862,7 @@ agx_shader_initialize(struct agx_device *dev, struct agx_uncompiled_shader *so,
|
|||
|
||||
blob_init(&so->serialized_nir);
|
||||
nir_serialize(&so->serialized_nir, nir, true);
|
||||
_mesa_sha1_compute(so->serialized_nir.data, so->serialized_nir.size,
|
||||
_mesa_blake3_compute(so->serialized_nir.data, so->serialized_nir.size,
|
||||
so->nir_sha1);
|
||||
|
||||
so->has_xfb_info = (nir->xfb_info != NULL);
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ crocus_disk_cache_store(struct disk_cache *cache,
|
|||
|
||||
if (debug) {
|
||||
char sha1[BLAKE3_HEX_LEN];
|
||||
_mesa_sha1_format(sha1, cache_key);
|
||||
_mesa_blake3_format(sha1, cache_key);
|
||||
fprintf(stderr, "[mesa disk cache] storing %s\n", sha1);
|
||||
}
|
||||
|
||||
|
|
@ -147,7 +147,7 @@ crocus_disk_cache_retrieve(struct crocus_context *ice,
|
|||
|
||||
if (debug) {
|
||||
char sha1[BLAKE3_HEX_LEN];
|
||||
_mesa_sha1_format(sha1, cache_key);
|
||||
_mesa_blake3_format(sha1, cache_key);
|
||||
fprintf(stderr, "[mesa disk cache] retrieving %s: ", sha1);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2711,7 +2711,7 @@ crocus_create_uncompiled_shader(struct pipe_context *ctx,
|
|||
struct blob blob;
|
||||
blob_init(&blob);
|
||||
nir_serialize(&blob, nir, true);
|
||||
_mesa_sha1_compute(blob.data, blob.size, ish->nir_sha1);
|
||||
_mesa_blake3_compute(blob.data, blob.size, ish->nir_sha1);
|
||||
blob_finish(&blob);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1743,7 +1743,7 @@ d3d12_init_screen(struct d3d12_screen *screen, IUnknown *adapter)
|
|||
* share memory need to also check the device UUID or LUID so all this
|
||||
* needs to be is the build-id.
|
||||
*/
|
||||
_mesa_sha1_compute(mesa_version, strlen(mesa_version), sha1);
|
||||
_mesa_blake3_compute(mesa_version, strlen(mesa_version), sha1);
|
||||
memcpy(screen->driver_uuid, sha1, PIPE_UUID_SIZE);
|
||||
|
||||
/* The device UUID uniquely identifies the given device within the machine. */
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ etna_disk_cache_retrieve(struct etna_compiler *compiler, struct etna_shader_vari
|
|||
if (debug) {
|
||||
char sha1[BLAKE3_HEX_LEN];
|
||||
|
||||
_mesa_sha1_format(sha1, cache_key);
|
||||
_mesa_blake3_format(sha1, cache_key);
|
||||
fprintf(stderr, "[mesa disk cache] retrieving variant %s: ", sha1);
|
||||
}
|
||||
|
||||
|
|
@ -169,7 +169,7 @@ etna_disk_cache_store(struct etna_compiler *compiler, struct etna_shader_variant
|
|||
if (debug) {
|
||||
char sha1[BLAKE3_HEX_LEN];
|
||||
|
||||
_mesa_sha1_format(sha1, cache_key);
|
||||
_mesa_blake3_format(sha1, cache_key);
|
||||
fprintf(stderr, "[mesa disk cache] storing variant %s\n", sha1);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ iris_disk_cache_store(struct disk_cache *cache,
|
|||
|
||||
if (debug) {
|
||||
char sha1[BLAKE3_HEX_LEN];
|
||||
_mesa_sha1_format(sha1, cache_key);
|
||||
_mesa_blake3_format(sha1, cache_key);
|
||||
fprintf(stderr, "[mesa disk cache] storing %s\n", sha1);
|
||||
}
|
||||
|
||||
|
|
@ -183,7 +183,7 @@ iris_disk_cache_retrieve(struct iris_screen *screen,
|
|||
|
||||
if (debug) {
|
||||
char sha1[BLAKE3_HEX_LEN];
|
||||
_mesa_sha1_format(sha1, cache_key);
|
||||
_mesa_blake3_format(sha1, cache_key);
|
||||
fprintf(stderr, "[mesa disk cache] retrieving %s: ", sha1);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1825,7 +1825,7 @@ iris_debug_archiver_open(void *tmp_ctx, struct iris_screen *screen,
|
|||
_mesa_blake3_update(&ctx, key, key_size);
|
||||
_mesa_blake3_final(&ctx, hash);
|
||||
|
||||
_mesa_sha1_format(name, hash);
|
||||
_mesa_blake3_format(name, hash);
|
||||
}
|
||||
memcpy(&name[BLAKE3_HEX_LEN - 1], ".iris", 5);
|
||||
|
||||
|
|
@ -3380,7 +3380,7 @@ iris_create_uncompiled_shader(struct iris_screen *screen,
|
|||
struct blob blob;
|
||||
blob_init(&blob);
|
||||
nir_serialize(&blob, nir, true);
|
||||
_mesa_sha1_compute(blob.data, blob.size, ish->nir_sha1);
|
||||
_mesa_blake3_compute(blob.data, blob.size, ish->nir_sha1);
|
||||
blob_finish(&blob);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ lima_vs_disk_cache_store(struct disk_cache *cache,
|
|||
|
||||
if (lima_debug & LIMA_DEBUG_DISK_CACHE) {
|
||||
char sha1[BLAKE3_HEX_LEN];
|
||||
_mesa_sha1_format(sha1, cache_key);
|
||||
_mesa_blake3_format(sha1, cache_key);
|
||||
fprintf(stderr, "[mesa disk cache] storing %s\n", sha1);
|
||||
}
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ lima_fs_disk_cache_store(struct disk_cache *cache,
|
|||
|
||||
if (lima_debug & LIMA_DEBUG_DISK_CACHE) {
|
||||
char sha1[BLAKE3_HEX_LEN];
|
||||
_mesa_sha1_format(sha1, cache_key);
|
||||
_mesa_blake3_format(sha1, cache_key);
|
||||
fprintf(stderr, "[mesa disk cache] storing %s\n", sha1);
|
||||
}
|
||||
|
||||
|
|
@ -102,7 +102,7 @@ lima_vs_disk_cache_retrieve(struct disk_cache *cache,
|
|||
|
||||
if (lima_debug & LIMA_DEBUG_DISK_CACHE) {
|
||||
char sha1[BLAKE3_HEX_LEN];
|
||||
_mesa_sha1_format(sha1, cache_key);
|
||||
_mesa_blake3_format(sha1, cache_key);
|
||||
fprintf(stderr, "[mesa disk cache] retrieving %s: ", sha1);
|
||||
}
|
||||
|
||||
|
|
@ -154,7 +154,7 @@ lima_fs_disk_cache_retrieve(struct disk_cache *cache,
|
|||
|
||||
if (lima_debug & LIMA_DEBUG_DISK_CACHE) {
|
||||
char sha1[BLAKE3_HEX_LEN];
|
||||
_mesa_sha1_format(sha1, cache_key);
|
||||
_mesa_blake3_format(sha1, cache_key);
|
||||
fprintf(stderr, "[mesa disk cache] retrieving %s: ", sha1);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -467,7 +467,7 @@ lima_create_fs_state(struct pipe_context *pctx,
|
|||
struct blob blob;
|
||||
blob_init(&blob);
|
||||
nir_serialize(&blob, nir, true);
|
||||
_mesa_sha1_compute(blob.data, blob.size, so->nir_sha1);
|
||||
_mesa_blake3_compute(blob.data, blob.size, so->nir_sha1);
|
||||
blob_finish(&blob);
|
||||
|
||||
if (lima_debug & LIMA_DEBUG_PRECOMPILE) {
|
||||
|
|
@ -720,7 +720,7 @@ lima_create_vs_state(struct pipe_context *pctx,
|
|||
struct blob blob;
|
||||
blob_init(&blob);
|
||||
nir_serialize(&blob, nir, true);
|
||||
_mesa_sha1_compute(blob.data, blob.size, so->nir_sha1);
|
||||
_mesa_blake3_compute(blob.data, blob.size, so->nir_sha1);
|
||||
blob_finish(&blob);
|
||||
|
||||
if (lima_debug & LIMA_DEBUG_PRECOMPILE) {
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ panfrost_disk_cache_store(struct disk_cache *cache,
|
|||
|
||||
if (debug) {
|
||||
char sha1[BLAKE3_HEX_LEN];
|
||||
_mesa_sha1_format(sha1, cache_key);
|
||||
_mesa_blake3_format(sha1, cache_key);
|
||||
fprintf(stderr, "[mesa disk cache] storing %s\n", sha1);
|
||||
}
|
||||
|
||||
|
|
@ -109,7 +109,7 @@ panfrost_disk_cache_retrieve(struct disk_cache *cache,
|
|||
|
||||
if (debug) {
|
||||
char sha1[BLAKE3_HEX_LEN];
|
||||
_mesa_sha1_format(sha1, cache_key);
|
||||
_mesa_blake3_format(sha1, cache_key);
|
||||
fprintf(stderr, "[mesa disk cache] retrieving %s: ", sha1);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ panfrost_alloc_shader(const nir_shader *nir)
|
|||
struct blob blob;
|
||||
blob_init(&blob);
|
||||
nir_serialize(&blob, nir, true);
|
||||
_mesa_sha1_compute(blob.data, blob.size, so->nir_sha1);
|
||||
_mesa_blake3_compute(blob.data, blob.size, so->nir_sha1);
|
||||
blob_finish(&blob);
|
||||
|
||||
return so;
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ v3d_disk_cache_retrieve(struct v3d_context *v3d,
|
|||
|
||||
if (V3D_DBG(CACHE)) {
|
||||
char sha1[BLAKE3_HEX_LEN];
|
||||
_mesa_sha1_format(sha1, cache_key);
|
||||
_mesa_blake3_format(sha1, cache_key);
|
||||
fprintf(stderr, "[v3d on-disk cache] %s %s\n",
|
||||
buffer ? "hit" : "miss",
|
||||
sha1);
|
||||
|
|
@ -198,7 +198,7 @@ v3d_disk_cache_store(struct v3d_context *v3d,
|
|||
|
||||
if (V3D_DBG(CACHE)) {
|
||||
char sha1[BLAKE3_HEX_LEN];
|
||||
_mesa_sha1_format(sha1, cache_key);
|
||||
_mesa_blake3_format(sha1, cache_key);
|
||||
fprintf(stderr, "[v3d on-disk cache] storing %s\n", sha1);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -416,7 +416,7 @@ v3d_uncompiled_shader_create(struct pipe_context *pctx,
|
|||
blob_init(&blob);
|
||||
nir_serialize(&blob, s, true);
|
||||
assert(!blob.out_of_memory);
|
||||
_mesa_sha1_compute(blob.data, blob.size, so->sha1);
|
||||
_mesa_blake3_compute(blob.data, blob.size, so->sha1);
|
||||
blob_finish(&blob);
|
||||
|
||||
if (V3D_DBG(NIR) || v3d_debug_flag_for_shader_stage(s->info.stage)) {
|
||||
|
|
|
|||
|
|
@ -925,7 +925,7 @@ static void virgl_disk_cache_create(struct virgl_screen *screen)
|
|||
uint8_t sha1[BLAKE3_KEY_LEN];
|
||||
_mesa_blake3_final(&sha1_ctx, sha1);
|
||||
char timestamp[BLAKE3_HEX_LEN];
|
||||
_mesa_sha1_format(timestamp, sha1);
|
||||
_mesa_blake3_format(timestamp, sha1);
|
||||
|
||||
screen->disk_cache = disk_cache_create("virgl", timestamp, 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -865,8 +865,8 @@ static bool pvr_physical_device_setup_pipeline_cache(
|
|||
char device_id[BLAKE3_KEY_LEN * 2 + 1];
|
||||
char driver_id[BLAKE3_KEY_LEN * 2 + 1];
|
||||
|
||||
_mesa_sha1_format(device_id, pdevice->device_uuid);
|
||||
_mesa_sha1_format(driver_id, instance->driver_build_sha);
|
||||
_mesa_blake3_format(device_id, pdevice->device_uuid);
|
||||
_mesa_blake3_format(driver_id, instance->driver_build_sha);
|
||||
|
||||
pdevice->vk.disk_cache = disk_cache_create(device_id, driver_id, 0U);
|
||||
return !!pdevice->vk.disk_cache;
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@ blorp_debug_archiver_open(void *mem_ctx,
|
|||
return NULL;
|
||||
|
||||
uint8_t sha1[BLAKE3_KEY_LEN];
|
||||
_mesa_sha1_compute(key, key_size, sha1);
|
||||
_mesa_blake3_compute(key, key_size, sha1);
|
||||
char name[BLAKE3_HEX_LEN + 6] = {};
|
||||
_mesa_sha1_format(name, sha1);
|
||||
_mesa_blake3_format(name, sha1);
|
||||
memcpy(&name[BLAKE3_HEX_LEN - 1], ".blorp", 6);
|
||||
|
||||
debug_archiver *archiver = debug_archiver_open(mem_ctx, name, "blorp");
|
||||
|
|
|
|||
|
|
@ -287,7 +287,7 @@ brw_device_sha1(char *hex,
|
|||
brw_device_sha1_update(&ctx, devinfo);
|
||||
unsigned char result[BLAKE3_KEY_LEN];
|
||||
_mesa_blake3_final(&ctx, result);
|
||||
_mesa_sha1_format(hex, result);
|
||||
_mesa_blake3_format(hex, result);
|
||||
}
|
||||
|
||||
unsigned
|
||||
|
|
|
|||
|
|
@ -1350,9 +1350,9 @@ brw_generator::generate_code(const brw_shader &s,
|
|||
auto override_path = debug_get_option_shader_bin_override_path();
|
||||
if (unlikely(debug_flag || dump_shader_bin || override_path != NULL ||
|
||||
params->archiver)) {
|
||||
_mesa_sha1_compute(p->store + start_offset / sizeof(brw_eu_inst),
|
||||
_mesa_blake3_compute(p->store + start_offset / sizeof(brw_eu_inst),
|
||||
after_size, sha1);
|
||||
_mesa_sha1_format(sha1buf, sha1);
|
||||
_mesa_blake3_format(sha1buf, sha1);
|
||||
}
|
||||
|
||||
if (unlikely(dump_shader_bin))
|
||||
|
|
|
|||
|
|
@ -2192,9 +2192,9 @@ elk_fs_generator::generate_code(const elk_cfg_t *cfg, int dispatch_width,
|
|||
char sha1buf[BLAKE3_HEX_LEN];
|
||||
|
||||
if (unlikely(debug_flag || dump_shader_bin)) {
|
||||
_mesa_sha1_compute(p->store + start_offset / sizeof(elk_inst),
|
||||
_mesa_blake3_compute(p->store + start_offset / sizeof(elk_inst),
|
||||
after_size, sha1);
|
||||
_mesa_sha1_format(sha1buf, sha1);
|
||||
_mesa_blake3_format(sha1buf, sha1);
|
||||
}
|
||||
|
||||
if (unlikely(dump_shader_bin))
|
||||
|
|
|
|||
|
|
@ -2225,8 +2225,8 @@ generate_code(struct elk_codegen *p,
|
|||
char sha1buf[BLAKE3_HEX_LEN];
|
||||
|
||||
if (unlikely(debug_enabled || dump_shader_bin)) {
|
||||
_mesa_sha1_compute(p->store, p->next_insn_offset, sha1);
|
||||
_mesa_sha1_format(sha1buf, sha1);
|
||||
_mesa_blake3_compute(p->store, p->next_insn_offset, sha1);
|
||||
_mesa_blake3_format(sha1buf, sha1);
|
||||
}
|
||||
|
||||
if (unlikely(dump_shader_bin))
|
||||
|
|
|
|||
|
|
@ -820,7 +820,7 @@ intel_perf_store_configuration(struct intel_perf_config *perf_cfg, int fd,
|
|||
_mesa_blake3_final(&sha1_ctx, hash);
|
||||
|
||||
char formatted_hash[BLAKE3_HEX_LEN];
|
||||
_mesa_sha1_format(formatted_hash, hash);
|
||||
_mesa_blake3_format(formatted_hash, hash);
|
||||
|
||||
char generated_guid[37];
|
||||
snprintf(generated_guid, sizeof(generated_guid),
|
||||
|
|
|
|||
|
|
@ -2662,10 +2662,10 @@ anv_nir_apply_pipeline_layout(nir_shader *shader,
|
|||
* bind map, hash them. This lets us quickly determine if the actual
|
||||
* mapping has changed and not just a no-op pipeline change.
|
||||
*/
|
||||
_mesa_sha1_compute(map->surface_to_descriptor,
|
||||
_mesa_blake3_compute(map->surface_to_descriptor,
|
||||
map->surface_count * sizeof(struct anv_pipeline_binding),
|
||||
map->surface_sha1);
|
||||
_mesa_sha1_compute(map->sampler_to_descriptor,
|
||||
_mesa_blake3_compute(map->sampler_to_descriptor,
|
||||
map->sampler_count * sizeof(struct anv_pipeline_binding),
|
||||
map->sampler_sha1);
|
||||
return progress;
|
||||
|
|
|
|||
|
|
@ -767,7 +767,7 @@ anv_nir_compute_push_layout(nir_shader *nir,
|
|||
* bind map, hash it. This lets us quickly determine if the actual
|
||||
* mapping has changed and not just a no-op pipeline change.
|
||||
*/
|
||||
_mesa_sha1_compute(map->push_ranges,
|
||||
_mesa_blake3_compute(map->push_ranges,
|
||||
sizeof(map->push_ranges),
|
||||
map->push_sha1);
|
||||
return progress;
|
||||
|
|
|
|||
|
|
@ -374,7 +374,7 @@ VkResult anv_EnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR(
|
|||
counter->storage = intel_perf_counter_data_type_to_vk_storage[intel_counter->data_type];
|
||||
|
||||
unsigned char sha1_result[BLAKE3_KEY_LEN];
|
||||
_mesa_sha1_compute(intel_counter->symbol_name,
|
||||
_mesa_blake3_compute(intel_counter->symbol_name,
|
||||
strlen(intel_counter->symbol_name),
|
||||
sha1_result);
|
||||
memcpy(counter->uuid, sha1_result, sizeof(counter->uuid));
|
||||
|
|
|
|||
|
|
@ -2406,7 +2406,7 @@ anv_physical_device_init_disk_cache(struct anv_physical_device *device)
|
|||
assert(len == sizeof(renderer) - 2);
|
||||
|
||||
char timestamp[BLAKE3_HEX_LEN];
|
||||
_mesa_sha1_format(timestamp, device->driver_build_sha1);
|
||||
_mesa_blake3_format(timestamp, device->driver_build_sha1);
|
||||
|
||||
const uint64_t driver_flags =
|
||||
brw_get_compiler_config_value(device->compiler);
|
||||
|
|
|
|||
|
|
@ -1845,7 +1845,7 @@ anv_debug_archiver_init(void *mem_ctx, struct anv_shader_data *shaders_data,
|
|||
_mesa_blake3_update(&ctx, linked_hash, BLAKE3_KEY_LEN);
|
||||
_mesa_blake3_final(&ctx, hash);
|
||||
|
||||
_mesa_sha1_format(name, hash);
|
||||
_mesa_blake3_format(name, hash);
|
||||
}
|
||||
memcpy(&name[BLAKE3_HEX_LEN - 1], ".anv", 4);
|
||||
|
||||
|
|
|
|||
|
|
@ -1459,7 +1459,7 @@ anv_physical_device_init_disk_cache(struct anv_physical_device *device)
|
|||
assert(len == sizeof(renderer) - 2);
|
||||
|
||||
char timestamp[BLAKE3_HEX_LEN];
|
||||
_mesa_sha1_format(timestamp, device->driver_build_sha1);
|
||||
_mesa_blake3_format(timestamp, device->driver_build_sha1);
|
||||
|
||||
const uint64_t driver_flags =
|
||||
elk_get_compiler_config_value(device->compiler);
|
||||
|
|
|
|||
|
|
@ -1464,10 +1464,10 @@ anv_nir_apply_pipeline_layout(nir_shader *shader,
|
|||
* bind map, hash them. This lets us quickly determine if the actual
|
||||
* mapping has changed and not just a no-op pipeline change.
|
||||
*/
|
||||
_mesa_sha1_compute(map->surface_to_descriptor,
|
||||
_mesa_blake3_compute(map->surface_to_descriptor,
|
||||
map->surface_count * sizeof(struct anv_pipeline_binding),
|
||||
map->surface_sha1);
|
||||
_mesa_sha1_compute(map->sampler_to_descriptor,
|
||||
_mesa_blake3_compute(map->sampler_to_descriptor,
|
||||
map->sampler_count * sizeof(struct anv_pipeline_binding),
|
||||
map->sampler_sha1);
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -245,7 +245,7 @@ anv_nir_compute_push_layout(nir_shader *nir,
|
|||
* bind map, hash it. This lets us quickly determine if the actual
|
||||
* mapping has changed and not just a no-op pipeline change.
|
||||
*/
|
||||
_mesa_sha1_compute(map->push_ranges,
|
||||
_mesa_blake3_compute(map->push_ranges,
|
||||
sizeof(map->push_ranges),
|
||||
map->push_sha1);
|
||||
return has_push_intrinsic;
|
||||
|
|
|
|||
|
|
@ -312,7 +312,7 @@ VkResult anv_EnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR(
|
|||
counter->storage = intel_perf_counter_data_type_to_vk_storage[intel_counter->data_type];
|
||||
|
||||
unsigned char sha1_result[BLAKE3_KEY_LEN];
|
||||
_mesa_sha1_compute(intel_counter->symbol_name,
|
||||
_mesa_blake3_compute(intel_counter->symbol_name,
|
||||
strlen(intel_counter->symbol_name),
|
||||
sha1_result);
|
||||
memcpy(counter->uuid, sha1_result, sizeof(counter->uuid));
|
||||
|
|
|
|||
|
|
@ -374,7 +374,7 @@ dzn_physical_device_init_uuids(struct dzn_physical_device *pdev)
|
|||
* share memory need to also check the device UUID (below) so all this
|
||||
* needs to be is the build-id.
|
||||
*/
|
||||
_mesa_sha1_compute(mesa_version, strlen(mesa_version), sha1);
|
||||
_mesa_blake3_compute(mesa_version, strlen(mesa_version), sha1);
|
||||
memcpy(pdev->driver_uuid, sha1, VK_UUID_SIZE);
|
||||
|
||||
/* The device UUID uniquely identifies the given device within the machine. */
|
||||
|
|
|
|||
|
|
@ -1349,7 +1349,7 @@ nvk_physical_device_init_pipeline_cache(struct nvk_physical_device *pdev)
|
|||
assert(len == sizeof(renderer) - 2);
|
||||
|
||||
char timestamp[BLAKE3_HEX_LEN];
|
||||
_mesa_sha1_format(timestamp, instance->driver_build_sha);
|
||||
_mesa_blake3_format(timestamp, instance->driver_build_sha);
|
||||
|
||||
const uint64_t driver_flags = nvk_physical_device_compiler_flags(pdev);
|
||||
pdev->vk.disk_cache = disk_cache_create(renderer, timestamp, driver_flags);
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ init_shader_caches(struct panvk_physical_device *device,
|
|||
assert(len == sizeof(renderer) - 1);
|
||||
|
||||
char timestamp[BLAKE3_HEX_LEN];
|
||||
_mesa_sha1_format(timestamp, instance->driver_build_sha);
|
||||
_mesa_blake3_format(timestamp, instance->driver_build_sha);
|
||||
|
||||
const uint64_t driver_flags = 0;
|
||||
device->vk.disk_cache = disk_cache_create(renderer, timestamp, driver_flags);
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
*/
|
||||
|
||||
#include "build_id.h"
|
||||
#include "hex.h"
|
||||
|
||||
#if HAVE_BUILD_ID
|
||||
#include <dlfcn.h>
|
||||
|
|
@ -200,3 +201,9 @@ copy_build_id_to_sha1(uint8_t sha1[BLAKE3_KEY_LEN],
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
void
|
||||
_mesa_sha1_format(char *buf, const unsigned char *sha1)
|
||||
{
|
||||
mesa_bytes_to_hex(buf, sha1, BLAKE3_KEY_LEN);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,13 +36,12 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "mesa-blake3.h"
|
||||
|
||||
#if HAVE_BUILD_ID
|
||||
|
||||
#define BUILD_ID_EXPECTED_HASH_LENGTH 20 /* sha1 */
|
||||
|
||||
#include <stdint.h>
|
||||
#include "mesa-blake3.h"
|
||||
|
||||
struct build_id_note;
|
||||
|
||||
const struct build_id_note *
|
||||
|
|
@ -60,6 +59,9 @@ copy_build_id_to_sha1(uint8_t sha1[BLAKE3_KEY_LEN],
|
|||
|
||||
#endif
|
||||
|
||||
void
|
||||
_mesa_sha1_format(char *buf, const unsigned char *sha1);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ disk_cache_get_function_identifier(void *ptr, blake3_hasher *ctx)
|
|||
* In all cases, the keys are sequences of 20 bytes. It is anticipated
|
||||
* that callers will compute appropriate SHA-1 signatures for keys,
|
||||
* (though nothing in this implementation directly relies on how the
|
||||
* names are computed). See mesa-sha1.h and _mesa_sha1_compute for
|
||||
* names are computed). See mesa-sha1.h and _mesa_blake3_compute for
|
||||
* assistance in computing SHA-1 signatures.
|
||||
*/
|
||||
struct disk_cache *
|
||||
|
|
|
|||
|
|
@ -443,7 +443,7 @@ make_cache_file_directory(struct disk_cache *cache, const cache_key key)
|
|||
char *dir;
|
||||
char buf[BLAKE3_HEX_LEN];
|
||||
|
||||
_mesa_sha1_format(buf, key);
|
||||
_mesa_blake3_format(buf, key);
|
||||
if (asprintf(&dir, "%s/%c%c", cache->path, buf[0], buf[1]) == -1)
|
||||
return;
|
||||
|
||||
|
|
@ -684,7 +684,7 @@ disk_cache_get_cache_filename(struct disk_cache *cache, const cache_key key)
|
|||
if (cache->path_init_failed)
|
||||
return NULL;
|
||||
|
||||
_mesa_sha1_format(buf, key);
|
||||
_mesa_blake3_format(buf, key);
|
||||
if (asprintf(&filename, "%s/%c%c/%s", cache->path, buf[0],
|
||||
buf[1], buf + 2) == -1)
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ update_foz_index(struct foz_db *foz_db, FILE *db_idx, unsigned file_idx)
|
|||
struct foz_db_entry);
|
||||
entry->header = *header;
|
||||
entry->file_idx = file_idx;
|
||||
_mesa_sha1_hex_to_sha1(entry->key, hash_str);
|
||||
_mesa_blake3_hex_to_blake3(entry->key, hash_str);
|
||||
|
||||
/* Truncate the entry's hash string to a 64bit hash for use with a
|
||||
* 64bit hash table for looking up file offsets.
|
||||
|
|
@ -698,7 +698,7 @@ foz_write_entry(struct foz_db *foz_db, const uint8_t *cache_key_160bit,
|
|||
|
||||
/* Write hash header to db */
|
||||
char hash_str[BLAKE3_HEX_LEN];
|
||||
_mesa_sha1_format(hash_str, cache_key_160bit);
|
||||
_mesa_blake3_format(hash_str, cache_key_160bit);
|
||||
if (fwrite(hash_str, 1, FOSSILIZE_BLOB_HASH_LENGTH, foz_db->file[0]) !=
|
||||
FOSSILIZE_BLOB_HASH_LENGTH)
|
||||
goto fail;
|
||||
|
|
@ -741,7 +741,7 @@ foz_write_entry(struct foz_db *foz_db, const uint8_t *cache_key_160bit,
|
|||
entry->header = header;
|
||||
entry->offset = offset;
|
||||
entry->file_idx = 0;
|
||||
_mesa_sha1_hex_to_sha1(entry->key, hash_str);
|
||||
_mesa_blake3_hex_to_blake3(entry->key, hash_str);
|
||||
_mesa_hash_table_u64_insert(foz_db->index_db, hash, entry);
|
||||
|
||||
simple_mtx_unlock(&foz_db->mtx);
|
||||
|
|
|
|||
|
|
@ -30,6 +30,9 @@ void _mesa_blake3_format(char *buf, const unsigned char *blake3)
|
|||
mesa_bytes_to_hex(buf, blake3, BLAKE3_OUT_LEN);
|
||||
}
|
||||
|
||||
/* Convert the string hexadecimal representation into its more compact
|
||||
* form.
|
||||
*/
|
||||
void _mesa_blake3_hex_to_blake3(unsigned char *buf, const char *hex)
|
||||
{
|
||||
mesa_hex_to_bytes(buf, hex, BLAKE3_OUT_LEN);
|
||||
|
|
|
|||
|
|
@ -1,87 +0,0 @@
|
|||
/* Copyright © 2007 Carl Worth
|
||||
* Copyright © 2009 Jeremy Huddleston, Julien Cristau, and Matthieu Herrb
|
||||
* Copyright © 2009-2010 Mikhail Gusarov
|
||||
* Copyright © 2012 Yaakov Selkowitz and Keith Packard
|
||||
* Copyright © 2014 Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "mesa-blake3.h"
|
||||
#include "mesa-sha1.h"
|
||||
#include "hex.h"
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
void
|
||||
_mesa_sha1_compute(const void *data, size_t size, unsigned char result[BLAKE3_KEY_LEN])
|
||||
{
|
||||
blake3_hasher ctx;
|
||||
|
||||
_mesa_blake3_init(&ctx);
|
||||
_mesa_blake3_update(&ctx, data, size);
|
||||
_mesa_blake3_final(&ctx, result);
|
||||
}
|
||||
|
||||
void
|
||||
_mesa_sha1_format(char *buf, const unsigned char *sha1)
|
||||
{
|
||||
mesa_bytes_to_hex(buf, sha1, BLAKE3_KEY_LEN);
|
||||
}
|
||||
|
||||
/* Convert a hashs string hexidecimal representation into its more compact
|
||||
* form.
|
||||
*/
|
||||
void
|
||||
_mesa_sha1_hex_to_sha1(unsigned char *buf, const char *hex)
|
||||
{
|
||||
mesa_hex_to_bytes(buf, hex, BLAKE3_KEY_LEN);
|
||||
}
|
||||
|
||||
static void
|
||||
sha1_to_uint32(const uint8_t sha1[BLAKE3_KEY_LEN],
|
||||
uint32_t out[BLAKE3_OUT_LEN32])
|
||||
{
|
||||
memset(out, 0, BLAKE3_KEY_LEN);
|
||||
|
||||
for (unsigned i = 0; i < BLAKE3_KEY_LEN; i++)
|
||||
out[i / 4] |= (uint32_t)sha1[i] << ((i % 4) * 8);
|
||||
}
|
||||
|
||||
void
|
||||
_mesa_sha1_print(FILE *f, const uint8_t sha1[BLAKE3_KEY_LEN])
|
||||
{
|
||||
uint32_t u32[BLAKE3_KEY_LEN];
|
||||
sha1_to_uint32(sha1, u32);
|
||||
|
||||
for (unsigned i = 0; i < BLAKE3_OUT_LEN32; i++) {
|
||||
fprintf(f, i ? ", 0x%08" PRIx32 : "0x%08" PRIx32, u32[i]);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
_mesa_printed_sha1_equal(const uint8_t sha1[BLAKE3_KEY_LEN],
|
||||
const uint32_t printed_sha1[BLAKE3_OUT_LEN32])
|
||||
{
|
||||
uint32_t u32[BLAKE3_OUT_LEN32];
|
||||
sha1_to_uint32(sha1, u32);
|
||||
|
||||
return memcmp(u32, printed_sha1, sizeof(u32)) == 0;
|
||||
}
|
||||
|
|
@ -28,28 +28,4 @@
|
|||
#include <stdbool.h>
|
||||
#include "mesa-blake3.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void
|
||||
_mesa_sha1_format(char *buf, const unsigned char *sha1);
|
||||
|
||||
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[BLAKE3_KEY_LEN]);
|
||||
|
||||
void
|
||||
_mesa_sha1_print(FILE *f, const uint8_t sha1[BLAKE3_KEY_LEN]);
|
||||
|
||||
bool
|
||||
_mesa_printed_sha1_equal(const uint8_t sha1[BLAKE3_KEY_LEN],
|
||||
const uint32_t printed_sha1[BLAKE3_OUT_LEN32]);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern C */
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -69,7 +69,6 @@ files_mesa_util = files(
|
|||
'macros.h',
|
||||
'memstream.c',
|
||||
'memstream.h',
|
||||
'mesa-sha1.c',
|
||||
'mesa-sha1.h',
|
||||
'mesa-blake3.c',
|
||||
'mesa-blake3.h',
|
||||
|
|
|
|||
|
|
@ -50,10 +50,10 @@ TEST_P(MesaSHA1TestFixture, Match)
|
|||
Params p = GetParam();
|
||||
|
||||
unsigned char sha1[BLAKE3_KEY_LEN];
|
||||
_mesa_sha1_compute(p.string, strlen(p.string), sha1);
|
||||
_mesa_blake3_compute(p.string, strlen(p.string), sha1);
|
||||
|
||||
char buf[BLAKE3_HEX_LEN];
|
||||
_mesa_sha1_format(buf, sha1);
|
||||
_mesa_blake3_format(buf, sha1);
|
||||
|
||||
ASSERT_TRUE(memcmp(buf, p.expected_sha1, SHA1_LENGTH) == 0)
|
||||
<< "For string \"" << p.string << "\", length " << strlen(p.string) << ":\n"
|
||||
|
|
|
|||
|
|
@ -783,8 +783,8 @@ parseAppAttr(struct OptConfData *data, const char **attr)
|
|||
(content = os_read_file(path, &len))) {
|
||||
uint8_t sha1x[BLAKE3_KEY_LEN];
|
||||
char sha1s[BLAKE3_HEX_LEN];
|
||||
_mesa_sha1_compute(content, len, sha1x);
|
||||
_mesa_sha1_format((char*) sha1s, sha1x);
|
||||
_mesa_blake3_compute(content, len, sha1x);
|
||||
_mesa_blake3_format((char*) sha1s, sha1x);
|
||||
free(content);
|
||||
|
||||
if (strcmp(sha1, sha1s)) {
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ driComputeOptionsSha1(const driOptionCache *cache, unsigned char *sha1)
|
|||
}
|
||||
}
|
||||
|
||||
_mesa_sha1_compute(dri_options, strlen(dri_options), sha1);
|
||||
_mesa_blake3_compute(dri_options, strlen(dri_options), sha1);
|
||||
ralloc_free(ctx);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -313,7 +313,7 @@ vk_pipeline_hash_shader_stage(VkPipelineCreateFlags2KHR pipeline_flags,
|
|||
blake3_hash blake_hash;
|
||||
|
||||
vk_pipeline_hash_shader_stage_blake3(pipeline_flags, info, rstate, blake_hash);
|
||||
_mesa_sha1_compute(blake_hash, sizeof(blake_hash), stage_sha1);
|
||||
_mesa_blake3_compute(blake_hash, sizeof(blake_hash), stage_sha1);
|
||||
}
|
||||
|
||||
static VkPipelineRobustnessBufferBehaviorEXT
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue