-
Notifications
You must be signed in to change notification settings - Fork 519
Description
VUID-VkImageCreateInfo-pNext-01443:
If the pNext chain includes a VkExternalMemoryImageCreateInfo or VkExternalMemoryImageCreateInfoNV structure whose handleTypes member is not 0, initialLayout must be VK_IMAGE_LAYOUT_UNDEFINED
VUID-VkImageMemoryBarrier-oldLayout-01197
If layouts are not ignored, oldLayout must be VK_IMAGE_LAYOUT_UNDEFINED or the current layout of the image subresources affected by the barrier
Therefore, unless there is some other way to change the layout of the image subresource, it seems that an image created from external memory MUST initially be transitioned with oldLayout=VK_IMAGE_LAYOUT_UNDEFINED.
However, existing applications instead transition from oldLayout=VK_IMAGE_LAYOUT_GENERAL if they want to preserve the image contents. I've talked to mesa developers and it seems that oldLayout=VK_IMAGE_LAYOUT_GENERAL is supposed to be used for this usecase with oldLayout=VK_IMAGE_LAYOUT_UNDEFINED being incorrect.
The assumptions seem to be twofold:
- Since the contents of the memory have already been defined via some other mechanism (e.g. some other process has used that memory as an image and rendered to it), the memory itself is morally already in the VK_IMAGE_LAYOUT_GENERAL layout.
- The driver does not require the initial transition from VK_IMAGE_LAYOUT_UNDEFINED for bookkeeping. All work that it might do during this initial transition must instead already be done during vkCreateImage (except that the memory must not be modified).
I hope this can be clarified in the spec.