diff options
| author | Lionel Landwerlin <lionel.g.landwerlin@intel.com> | 2025-07-29 10:35:04 +0300 |
|---|---|---|
| committer | Marge Bot <marge-bot@fdo.invalid> | 2025-11-06 15:27:20 +0000 |
| commit | cbc8ec2cc4d5238ff2579832e7e53b74c6b6ddeb (patch) | |
| tree | 5a29cf2069a7fedb557ca5352b8c6d38d560c25e | |
| parent | 6279645fed28179bf0d8b0fc4b8e826b4566a8fb (diff) | |
vulkan/runtime: drop blake3 hash on precomp shaders
In order to implement VK_KHR_pipeline_binary, we need to be able to
build hash from pipeline creation structures without looking at the
cache.
The blake3 hash on precomp shaders prevents that as its loading from
cache and potentially apply transformation to NIR.
Let's stick to the hash generated by vk_pipeline_hash_shader_stage(),
it does not look at NIR (except for internal shaders) and already hash
the same information :
* shader code (SPIR-V, identifier, hash)
* robustness state
* specialization constants
* pipeline flags
* entry point name
* subgroup information
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36647>
| -rw-r--r-- | src/vulkan/runtime/vk_pipeline.c | 34 |
1 files changed, 8 insertions, 26 deletions
diff --git a/src/vulkan/runtime/vk_pipeline.c b/src/vulkan/runtime/vk_pipeline.c index c2dfcdafa87..2e91b74ee79 100644 --- a/src/vulkan/runtime/vk_pipeline.c +++ b/src/vulkan/runtime/vk_pipeline.c @@ -667,16 +667,6 @@ struct vk_pipeline_precomp_shader { /* Tessellation info if the shader is a tessellation shader */ struct vk_pipeline_tess_info tess; - /* Hash of the vk_pipeline_precomp_shader - * - * This is the hash of the final compiled NIR together with tess info and - * robustness state. It's used as a key for final binary lookups. By - * having this as a separate key, we can de-duplicate cases where you have - * different SPIR-V or specialization constants but end up compiling the - * same NIR shader in the end anyway. - */ - blake3_hash blake3; - struct blob nir_blob; }; @@ -736,12 +726,6 @@ vk_pipeline_precomp_shader_create(struct vk_device *device, vk_pipeline_gather_nir_tess_info(nir, &shader->tess); - struct mesa_blake3 blake3_ctx; - _mesa_blake3_init(&blake3_ctx); - _mesa_blake3_update(&blake3_ctx, rs, sizeof(*rs)); - _mesa_blake3_update(&blake3_ctx, blob.data, blob.size); - _mesa_blake3_final(&blake3_ctx, shader->blake3); - shader->nir_blob = blob; return shader; @@ -762,7 +746,6 @@ vk_pipeline_precomp_shader_serialize(struct vk_pipeline_cache_object *obj, blob_write_uint32(blob, shader->stage); blob_write_bytes(blob, &shader->rs, sizeof(shader->rs)); blob_write_bytes(blob, &shader->tess, sizeof(shader->tess)); - blob_write_bytes(blob, shader->blake3, sizeof(shader->blake3)); blob_write_uint64(blob, shader->nir_blob.size); blob_write_bytes(blob, shader->nir_blob.data, shader->nir_blob.size); @@ -793,7 +776,6 @@ vk_pipeline_precomp_shader_deserialize(struct vk_pipeline_cache *cache, shader->stage = blob_read_uint32(blob); blob_copy_bytes(blob, &shader->rs, sizeof(shader->rs)); blob_copy_bytes(blob, &shader->tess, sizeof(shader->tess)); - blob_copy_bytes(blob, shader->blake3, sizeof(shader->blake3)); uint64_t nir_size = blob_read_uint64(blob); if (blob->overrun || nir_size > SIZE_MAX) @@ -1272,8 +1254,8 @@ vk_graphics_pipeline_compile_shaders(struct vk_device *device, for (uint32_t i = link_info->partition[p]; i < link_info->partition[p + 1]; i++) { const struct vk_pipeline_stage *stage = &stages[i]; - _mesa_blake3_update(&blake3_ctx, stage->precomp->blake3, - sizeof(stage->precomp->blake3)); + _mesa_blake3_update(&blake3_ctx, stage->precomp->cache_key, + sizeof(stage->precomp->cache_key)); VkShaderCreateFlagsEXT shader_flags = vk_pipeline_to_shader_flags(pipeline->base.flags, stage->stage); @@ -2055,8 +2037,8 @@ vk_pipeline_compile_compute_stage(struct vk_device *device, struct mesa_blake3 blake3_ctx; _mesa_blake3_init(&blake3_ctx); - _mesa_blake3_update(&blake3_ctx, stage->precomp->blake3, - sizeof(stage->precomp->blake3)); + _mesa_blake3_update(&blake3_ctx, stage->precomp->cache_key, + sizeof(stage->precomp->cache_key)); _mesa_blake3_update(&blake3_ctx, &shader_flags, sizeof(shader_flags)); @@ -2522,8 +2504,8 @@ vk_pipeline_compile_rt_shader(struct vk_device *device, pipeline_flags, push_range, pipeline_layout); - _mesa_blake3_update(&blake3_ctx, stage->precomp->blake3, - sizeof(stage->precomp->blake3)); + _mesa_blake3_update(&blake3_ctx, stage->precomp->cache_key, + sizeof(stage->precomp->cache_key)); struct vk_shader_pipeline_cache_key shader_key = { .stage = stage->stage, @@ -2646,8 +2628,8 @@ vk_pipeline_compile_rt_shader_group(struct vk_device *device, push_range, pipeline_layout); for (uint32_t j = 0; j < stage_count; j++) { - _mesa_blake3_update(&blake3_ctx, stages[j].precomp->blake3, - sizeof(stages[j].precomp->blake3)); + _mesa_blake3_update(&blake3_ctx, stages[j].precomp->cache_key, + sizeof(stages[j].precomp->cache_key)); } shader_keys[i] = (struct vk_shader_pipeline_cache_key) { |