vulkan: Handle alignment failure in the pipeline cache.

On malloc failure, or more likely a passed in pDataSize < pipeline cache
data size, we should return incomplete.  Otherwise,
vk_pipeline_cache_object_serialize will assertion fail about the start not
being aligned.

Closes: #8868
Fixes: 591da98779 ("vulkan: Add a common VkPipelineCache implementation")
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22700>
(cherry picked from commit bc257928d7)
This commit is contained in:
Emma Anholt 2023-04-25 13:17:26 -07:00 committed by Eric Engestrom
parent e561939b05
commit 4514207d25
2 changed files with 5 additions and 2 deletions

View file

@ -121,7 +121,7 @@
"description": "vulkan: Handle alignment failure in the pipeline cache.",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "591da9877900c56434f9e23e0ad0058b118b0be8"
},

View file

@ -760,7 +760,10 @@ vk_common_GetPipelineCacheData(VkDevice _device,
intptr_t data_size_resv = blob_reserve_uint32(&blob);
blob_write_bytes(&blob, object->key_data, object->key_size);
blob_align(&blob, VK_PIPELINE_CACHE_BLOB_ALIGN);
if (!blob_align(&blob, VK_PIPELINE_CACHE_BLOB_ALIGN)) {
result = VK_INCOMPLETE;
break;
}
uint32_t data_size;
if (!vk_pipeline_cache_object_serialize(cache, object,