v3dv: adopt wsi_common_create_swapchain_image
v2: drop unused variable for Android build Reviewed-by: Iago Toral Quiroga <itoral@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36035>
This commit is contained in:
@@ -512,31 +512,23 @@ v3dv_image_init(struct v3dv_device *device,
|
||||
explicit_mod_info);
|
||||
}
|
||||
|
||||
static VkResult
|
||||
create_image_from_swapchain(struct v3dv_device *device,
|
||||
const VkImageCreateInfo *pCreateInfo,
|
||||
const VkImageSwapchainCreateInfoKHR *swapchain_info,
|
||||
const VkAllocationCallbacks *pAllocator,
|
||||
VkImage *pImage);
|
||||
|
||||
static VkResult
|
||||
create_image(struct v3dv_device *device,
|
||||
const VkImageCreateInfo *pCreateInfo,
|
||||
const VkAllocationCallbacks *pAllocator,
|
||||
VkImage *pImage)
|
||||
{
|
||||
#if DETECT_OS_ANDROID
|
||||
/* VkImageSwapchainCreateInfoKHR is not useful at all */
|
||||
const VkImageSwapchainCreateInfoKHR *swapchain_info = NULL;
|
||||
#else
|
||||
#if !DETECT_OS_ANDROID
|
||||
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->pdevice->wsi_device,
|
||||
pCreateInfo,
|
||||
swapchain_info->swapchain,
|
||||
pImage);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (swapchain_info && swapchain_info->swapchain != VK_NULL_HANDLE)
|
||||
return create_image_from_swapchain(device, pCreateInfo, swapchain_info,
|
||||
pAllocator, pImage);
|
||||
|
||||
VkResult result;
|
||||
struct v3dv_image *image = NULL;
|
||||
|
||||
@@ -565,53 +557,6 @@ fail:
|
||||
return result;
|
||||
}
|
||||
|
||||
static VkResult
|
||||
create_image_from_swapchain(struct v3dv_device *device,
|
||||
const VkImageCreateInfo *pCreateInfo,
|
||||
const VkImageSwapchainCreateInfoKHR *swapchain_info,
|
||||
const VkAllocationCallbacks *pAllocator,
|
||||
VkImage *pImage)
|
||||
{
|
||||
struct v3dv_image *swapchain_image =
|
||||
v3dv_wsi_get_image_from_swapchain(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) ==
|
||||
local_create_info.usage);
|
||||
|
||||
return create_image(device, &local_create_info, pAllocator, pImage);
|
||||
}
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL
|
||||
v3dv_CreateImage(VkDevice _device,
|
||||
const VkImageCreateInfo *pCreateInfo,
|
||||
|
||||
Reference in New Issue
Block a user