wsi/common: Set VK_IMAGE_CREATE_ALIAS_BIT

With Vulkan 1.1, we have a VkImageSwapchainCreateInfoKHR struct which
lets you create a new VkImage which aliases a swapchain image.  However,
there is no corresponding swapchain create flag so we have to set
VK_IMAGE_CREATE_ALIAS_BIT all the time.

We need to do a bit of work in ANV to prevent it from asserting the
moment it sees one of these.  Fortunately, they're already safe because
WSI images go through a different bind path for
VkBindImageMemorySwapchainInfoKHR.

Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12031>
This commit is contained in:
Jason Ekstrand 2021-08-09 10:23:18 -05:00 committed by Marge Bot
parent 1abab1a28f
commit ca791f5c5d
3 changed files with 8 additions and 2 deletions

View File

@ -903,9 +903,10 @@ check_memory_bindings(const struct anv_device *device,
: ANV_IMAGE_MEMORY_BINDING_MAIN;
/* Aliasing is incompatible with the private binding because it does not
* live in a VkDeviceMemory.
* live in a VkDeviceMemory. The one exception is swapchain images.
*/
assert(!(image->vk.create_flags & VK_IMAGE_CREATE_ALIAS_BIT) ||
image->from_wsi ||
image->bindings[ANV_IMAGE_MEMORY_BINDING_PRIVATE].memory_range.size == 0);
/* Check primary surface */

View File

@ -3872,6 +3872,11 @@ struct anv_image {
*/
bool disjoint;
/**
* Image is a WSI image
*/
bool from_wsi;
/**
* Image was imported from an struct AHardwareBuffer. We have to delay
* final image creation until bind time.

View File

@ -373,7 +373,7 @@ wsi_configure_image(const struct wsi_swapchain *chain,
info->create = (VkImageCreateInfo) {
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
.flags = 0,
.flags = VK_IMAGE_CREATE_ALIAS_BIT,
.imageType = VK_IMAGE_TYPE_2D,
.format = pCreateInfo->imageFormat,
.extent = {