Use try_unbox in VkDescriptorBufferInfo

* We are currently crashing the emulator when binding to
  DescriptorBindings that have been deleted. This will WARN without
  crashing.
* A side effect of this is that it will enable a wider interaction with
  VulkanBatchUpdateDescriptorSet feature as it will not immediately
  crash if it interacts with something that was removed.
* https://registry.khronos.org/vulkan/specs/latest/man/html/vkUpdateDescriptorSetWithTemplate.html

Reviewed-by: Marcin Radomski <dextero@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33018>
This commit is contained in:
sergiuferentz 2024-12-03 18:07:35 +00:00 committed by Marge Bot
parent 9603450ea4
commit 82317d6d24
3 changed files with 17 additions and 4 deletions

View file

@ -763,7 +763,7 @@ class VulkanMarshaling(VulkanWrapperGenerator):
self.module.appendHeader(
self.cgenHeader.makeFuncDecl(marshalPrototype))
if name in CUSTOM_MARSHAL_TYPES:
if name in CUSTOM_MARSHAL_TYPES and CUSTOM_MARSHAL_TYPES[name].get("marshaling"):
self.module.appendImpl(
self.cgenImpl.makeFuncImpl(
marshalPrototype, structMarshalingCustom))
@ -838,7 +838,7 @@ class VulkanMarshaling(VulkanWrapperGenerator):
self.module.appendHeader(
self.cgenHeader.makeFuncDecl(unmarshalPrototype))
if name in CUSTOM_MARSHAL_TYPES:
if name in CUSTOM_MARSHAL_TYPES and CUSTOM_MARSHAL_TYPES[name].get("unmarshaling"):
self.module.appendImpl(
self.cgenImpl.makeFuncImpl(
unmarshalPrototype, structUnmarshalingCustom))

View file

@ -488,6 +488,19 @@ memcpy((uint64_t*)&{newInputVarName}->accelerationStructureReference, *ptr, size
*ptr += sizeof(uint64_t);
""",
},
"VkDescriptorBufferInfo": {
"common":"",
"reservedunmarshaling": """
uint64_t cgen_var_0;
memcpy((uint64_t*)&cgen_var_0, *ptr, 1 * 8);
*ptr += 1 * 8;
*(VkBuffer*)&forUnmarshaling->buffer = (VkBuffer)try_unbox_VkBuffer((VkBuffer)(*&cgen_var_0));
memcpy((VkDeviceSize*)&forUnmarshaling->offset, *ptr, sizeof(VkDeviceSize));
*ptr += sizeof(VkDeviceSize);
memcpy((VkDeviceSize*)&forUnmarshaling->range, *ptr, sizeof(VkDeviceSize));
*ptr += sizeof(VkDeviceSize);
"""
},
"VkXcbSurfaceCreateInfoKHR": {
"common": """
// This struct should never be marshaled / unmarshaled.

View file

@ -867,7 +867,7 @@ class VulkanReservedMarshaling(VulkanWrapperGenerator):
self.module.appendHeader(
self.cgenHeader.makeFuncDecl(marshalPrototype))
if name in CUSTOM_MARSHAL_TYPES:
if name in CUSTOM_MARSHAL_TYPES and CUSTOM_MARSHAL_TYPES[name].get("reservedmarshaling"):
self.module.appendImpl(
self.cgenImpl.makeFuncImpl(
marshalPrototype, structMarshalingCustom))
@ -937,7 +937,7 @@ class VulkanReservedMarshaling(VulkanWrapperGenerator):
self.module.appendHeader(
self.cgenHeader.makeFuncDecl(unmarshalPrototype))
if name in CUSTOM_MARSHAL_TYPES:
if name in CUSTOM_MARSHAL_TYPES and CUSTOM_MARSHAL_TYPES[name].get("reservedunmarshaling"):
self.module.appendImpl(
self.cgenImpl.makeFuncImpl(
unmarshalPrototype, structUnmarshalingCustom))