Make it not crash during vk snapshot load

We are trying to make vk snapshot load the google Chrome home page
without crashing. With this CL it does not crash during load but would
crash with a device lost after submitting a queue (which is
unsurprising because everything is missing to snapshot vk queue).

Content of this commit includes:

 - Add dependencies for VkImageView, VkGraphicsPipelines, VkFramebuffer.
   They are necessary to tell the snapshot module the order of vk object
   creation.
 - Add vkBindImageMemory into the loading sequencey of VkImage, so that
   it would be executed before vkCreateImageView.
 - Delay the destruction of VkShaderModule. This is because other
   objects can still refer to it after it is destroyed.
 - Initialize VK backend for color buffer properly on snapshot load.
 - Save and load vk images in the same order by sorting them according
   to their boxed handle.
 - Record all the placeholder handles for vkCreateDescriptorPool. For
   performance purpose this function creates a lot of extra handles
   without real contents. We need to snapshot those handles as well.

Reviewed-by: Aaron Ruby <aruby@blackberry.com>
Acked-by: Yonggang Luo <luoyonggang@gmail.com>
Acked-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27246>
This commit is contained in:
Yahan Zhou
2024-03-08 15:39:38 -08:00
committed by Marge Bot
parent 2f958ad3f8
commit b1b8eb9301
2 changed files with 74 additions and 11 deletions

View File

@@ -22,6 +22,10 @@ DELAYED_DECODER_DELETES = [
"vkDestroyPipelineLayout",
]
DELAYED_DECODER_DELETE_DICT_ENTRIES = [
"vkDestroyShaderModule",
]
global_state_prefix = "m_state->on_"
decoder_decl_preamble = """
@@ -282,7 +286,10 @@ def emit_decode_parameters(typeInfo: VulkanTypeInfo, api: VulkanAPI, cgen, globa
lenAccess = cgen.generalLengthAccess(p)
if p.dispatchHandle:
emit_dispatch_unmarshal(typeInfo, p, cgen, globalWrapped)
if api.name in DELAYED_DECODER_DELETE_DICT_ENTRIES:
emit_dispatch_unmarshal(typeInfo, p, cgen, False)
else:
emit_dispatch_unmarshal(typeInfo, p, cgen, globalWrapped)
else:
destroy = p.nonDispatchableHandleDestroy or p.dispatchableHandleDestroy
noUnbox = api.name in ["vkQueueFlushCommandsGOOGLE", "vkQueueFlushCommandsFromAuxMemoryGOOGLE"] and p.paramName == "commandBuffer"
@@ -427,6 +434,8 @@ def emit_destroyed_handle_cleanup(api, cgen):
if None == lenAccess or "1" == lenAccess:
if api.name in DELAYED_DECODER_DELETES:
cgen.stmt("delayed_delete_%s(boxed_%s_preserve, unboxed_device, delayed_remove_callback)" % (p.typeName, p.paramName))
elif api.name in DELAYED_DECODER_DELETE_DICT_ENTRIES:
cgen.stmt("delayed_delete_%s(boxed_%s_preserve, unboxed_device, nullptr)" % (p.typeName, p.paramName))
else:
cgen.stmt("delete_%s(boxed_%s_preserve)" % (p.typeName, p.paramName))
else: