kk: Fix compute pipeline cache

When deserializing the compute shader from a blob, we need to recreate the
pipeline because the blob may have been loaded from file and therefore the
reference to the Metal resource will be invalid.

Signed-off-by: Aitor Camacho <aitor@lunarg.com>
(cherry picked from commit 75f6f46c0f)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40092>
This commit is contained in:
Aitor Camacho 2026-01-19 12:06:44 +09:00 committed by Eric Engestrom
parent 024143cca4
commit 6152bf1cfb
2 changed files with 5 additions and 6 deletions

View file

@ -15974,7 +15974,7 @@
"description": "kk: Fix compute pipeline cache",
"nominated": false,
"nomination_type": 0,
"resolution": 4,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View file

@ -1129,9 +1129,7 @@ kk_shader_serialize(struct vk_device *vk_dev, const struct vk_shader *vk_shader,
/* We are building a new shader into the cache so we need to retain resources
*/
if (shader->info.stage == MESA_SHADER_COMPUTE)
mtl_retain(shader->pipeline.cs);
else if (shader->info.stage == MESA_SHADER_VERTEX) {
if (shader->info.stage == MESA_SHADER_VERTEX) {
mtl_retain(shader->pipeline.gfx.handle);
if (shader->pipeline.gfx.mtl_depth_stencil_state_handle)
mtl_retain(shader->pipeline.gfx.mtl_depth_stencil_state_handle);
@ -1185,8 +1183,9 @@ kk_deserialize_shader(struct vk_device *vk_dev, struct blob_reader *blob,
}
/* We are building a new shader so we need to retain resources */
VkResult result = VK_SUCCESS;
if (info.stage == MESA_SHADER_COMPUTE)
mtl_retain(shader->pipeline.cs);
result = kk_compile_compute_pipeline(dev, shader);
else if (info.stage == MESA_SHADER_VERTEX) {
mtl_retain(shader->pipeline.gfx.handle);
if (shader->pipeline.gfx.mtl_depth_stencil_state_handle)
@ -1195,7 +1194,7 @@ kk_deserialize_shader(struct vk_device *vk_dev, struct blob_reader *blob,
*shader_out = &shader->vk;
return VK_SUCCESS;
return result;
}
static void