anv/image: Call into WSI to create swapchain images
This guarantees that we get an image that's created with exactly the swapchain image creation parameters instead of trying to emulate it inside the driver. Ideally, we'd use the fancy new bind helper too but our magic ANV_IMAGE_MEMORY_BINDING_PRIVATE gets in the way and we really do want to re-bind ourself. 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:

committed by
Marge Bot

parent
a2e986b6d9
commit
d85a9d658f
@@ -1430,53 +1430,6 @@ anv_swapchain_get_image(VkSwapchainKHR swapchain,
|
||||
return anv_image_from_handle(image);
|
||||
}
|
||||
|
||||
static VkResult
|
||||
anv_image_init_from_swapchain(struct anv_device *device,
|
||||
struct anv_image *image,
|
||||
const VkImageCreateInfo *pCreateInfo,
|
||||
const VkImageSwapchainCreateInfoKHR *swapchain_info)
|
||||
{
|
||||
struct anv_image *swapchain_image = anv_swapchain_get_image(swapchain_info->swapchain, 0);
|
||||
assert(swapchain_image);
|
||||
|
||||
VkImageCreateInfo local_create_info = *pCreateInfo;
|
||||
local_create_info.pNext = NULL;
|
||||
|
||||
/* Added by wsi code. */
|
||||
local_create_info.usage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||
|
||||
/* The spec requires TILING_OPTIMAL as input, but the swapchain image may
|
||||
* privately use a different tiling. See spec anchor
|
||||
* #swapchain-wsi-image-create-info .
|
||||
*/
|
||||
assert(local_create_info.tiling == VK_IMAGE_TILING_OPTIMAL);
|
||||
local_create_info.tiling = swapchain_image->vk.tiling;
|
||||
|
||||
VkImageDrmFormatModifierListCreateInfoEXT local_modifier_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_LIST_CREATE_INFO_EXT,
|
||||
.drmFormatModifierCount = 1,
|
||||
.pDrmFormatModifiers = &swapchain_image->vk.drm_format_mod,
|
||||
};
|
||||
|
||||
if (swapchain_image->vk.drm_format_mod != DRM_FORMAT_MOD_INVALID)
|
||||
__vk_append_struct(&local_create_info, &local_modifier_info);
|
||||
|
||||
assert(swapchain_image->vk.image_type == local_create_info.imageType);
|
||||
assert(swapchain_image->vk.format == local_create_info.format);
|
||||
assert(swapchain_image->vk.extent.width == local_create_info.extent.width);
|
||||
assert(swapchain_image->vk.extent.height == local_create_info.extent.height);
|
||||
assert(swapchain_image->vk.extent.depth == local_create_info.extent.depth);
|
||||
assert(swapchain_image->vk.array_layers == local_create_info.arrayLayers);
|
||||
assert(swapchain_image->vk.samples == local_create_info.samples);
|
||||
assert(swapchain_image->vk.tiling == local_create_info.tiling);
|
||||
assert(swapchain_image->vk.usage == local_create_info.usage);
|
||||
|
||||
return anv_image_init(device, image,
|
||||
&(struct anv_image_create_info) {
|
||||
.vk_info = &local_create_info,
|
||||
});
|
||||
}
|
||||
|
||||
static VkResult
|
||||
anv_image_init_from_create_info(struct anv_device *device,
|
||||
struct anv_image *image,
|
||||
@@ -1488,19 +1441,6 @@ anv_image_init_from_create_info(struct anv_device *device,
|
||||
return anv_image_init_from_gralloc(device, image, pCreateInfo,
|
||||
gralloc_info);
|
||||
|
||||
#ifndef VK_USE_PLATFORM_ANDROID_KHR
|
||||
/* Ignore swapchain creation info on Android. Since we don't have an
|
||||
* implementation in Mesa, we're guaranteed to access an Android object
|
||||
* incorrectly.
|
||||
*/
|
||||
const VkImageSwapchainCreateInfoKHR *swapchain_info =
|
||||
vk_find_struct_const(pCreateInfo->pNext, IMAGE_SWAPCHAIN_CREATE_INFO_KHR);
|
||||
if (swapchain_info && swapchain_info->swapchain != VK_NULL_HANDLE) {
|
||||
return anv_image_init_from_swapchain(device, image, pCreateInfo,
|
||||
swapchain_info);
|
||||
}
|
||||
#endif
|
||||
|
||||
return anv_image_init(device, image,
|
||||
&(struct anv_image_create_info) {
|
||||
.vk_info = pCreateInfo,
|
||||
@@ -1515,6 +1455,21 @@ VkResult anv_CreateImage(
|
||||
{
|
||||
ANV_FROM_HANDLE(anv_device, device, _device);
|
||||
|
||||
#ifndef VK_USE_PLATFORM_ANDROID_KHR
|
||||
/* Ignore swapchain creation info on Android. Since we don't have an
|
||||
* implementation in Mesa, we're guaranteed to access an Android object
|
||||
* incorrectly.
|
||||
*/
|
||||
const VkImageSwapchainCreateInfoKHR *swapchain_info =
|
||||
vk_find_struct_const(pCreateInfo->pNext, IMAGE_SWAPCHAIN_CREATE_INFO_KHR);
|
||||
if (swapchain_info && swapchain_info->swapchain != VK_NULL_HANDLE) {
|
||||
return wsi_common_create_swapchain_image(&device->physical->wsi_device,
|
||||
pCreateInfo,
|
||||
swapchain_info->swapchain,
|
||||
pImage);
|
||||
}
|
||||
#endif
|
||||
|
||||
struct anv_image *image =
|
||||
vk_object_zalloc(&device->vk, pAllocator, sizeof(*image),
|
||||
VK_OBJECT_TYPE_IMAGE);
|
||||
|
Reference in New Issue
Block a user