From 721ccd02925ffd9cd8e0315a9d7165080c0de035 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Fri, 13 Sep 2024 17:11:03 +0200 Subject: [PATCH] radeonsi/sqtt: use XXH64_update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No functional change, but this is the way the XXH API is meant to be used. Also avoid setting the pipeline_code_hash twice. Reviewed-by: Marek Olšák Part-of: --- src/gallium/drivers/radeonsi/si_state_draw.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_state_draw.cpp b/src/gallium/drivers/radeonsi/si_state_draw.cpp index 0abdc240615..bb996daba8f 100644 --- a/src/gallium/drivers/radeonsi/si_state_draw.cpp +++ b/src/gallium/drivers/radeonsi/si_state_draw.cpp @@ -320,25 +320,27 @@ static bool si_update_shaders(struct si_context *sctx) * changes. */ uint64_t scratch_bo_size = sctx->scratch_buffer ? sctx->scratch_buffer->bo_size : 0; - uint64_t pipeline_code_hash = scratch_bo_size; uint32_t total_size = 0; /* Compute pipeline code hash. */ + XXH64_state_t* xh = XXH64_createState(); + XXH64_reset(xh, scratch_bo_size); + for (int i = 0; i < SI_NUM_GRAPHICS_SHADERS; i++) { struct si_shader *shader = sctx->shaders[i].current; if (sctx->shaders[i].cso && shader) { /* Hash the key. */ - pipeline_code_hash = XXH64(&shader->key, sizeof(shader->key), pipeline_code_hash); + XXH64_update(xh, &shader->key, sizeof(shader->key)); /* Hash the main part binary. */ - pipeline_code_hash = XXH64( - shader->binary.code_buffer, - shader->binary.code_size, - pipeline_code_hash); + XXH64_update(xh, shader->binary.code_buffer, shader->binary.code_size); total_size += (uint32_t)align_uintptr(shader->binary.uploaded_code_size, 256); } } + XXH64_hash_t pipeline_code_hash = XXH64_digest(xh); + XXH64_freeState(xh); + struct si_sqtt_fake_pipeline *pipeline = NULL; if (!si_sqtt_pipeline_is_registered(sctx->sqtt, pipeline_code_hash)) { /* This is a new pipeline. Allocate a new bo to hold all the shaders. Without @@ -402,10 +404,8 @@ static bool si_update_shaders(struct si_context *sctx) } assert(pipeline); - pipeline->code_hash = pipeline_code_hash; radeon_add_to_buffer_list(sctx, &sctx->gfx_cs, pipeline->bo, RADEON_USAGE_READ | RADEON_PRIO_SHADER_BINARY); - si_sqtt_describe_pipeline_bind(sctx, pipeline_code_hash, 0); si_pm4_bind_state(sctx, sqtt_pipeline, pipeline); }