Special treatment of UNDEFINED layout for external images to preserve contents #3713
+22
−9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
External images have to be created with VK_IMAGE_LAYOUT_UNDEFINED: "If the pNext chain includes a VkExternalMemoryImageCreateInfo or VkExternalMemoryImageCreateInfoNV structure whose handleTypes member is not 0, initialLayout must be VK_IMAGE_LAYOUT_UNDEFINED" (https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#VUID-VkImageCreateInfo-pNext-01443)
So even if image has contents that importing application would like to be preserved, it will have a transition from UNDEFINED to new layout.
This section https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#resources-external-sharing adds that "Therefore, the layout specified as part of this transition will be the true initial layout of the image. The undefined layout specified when creating it is a placeholder to simplify valid usage requirements."