vulkan/wsi: provide more info in wsi_image_create_info

Always chain wsi_image_create_info to VkImageCreateInfo, which indicates
that the image is a wsi image and can be transitioned to/from
VK_IMAGE_LAYOUT_PRESENT_SRC_KHR.

Add prime_blit_buffer to the struct as well.  When set, it indicates the
prime blit destination and implies that the image is a prime blit
source.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10789>
This commit is contained in:
Chia-I Wu 2021-05-12 13:11:52 -07:00 committed by Marge Bot
parent 64fa67dd2f
commit 447e80ac9b
5 changed files with 25 additions and 10 deletions

View file

@ -291,7 +291,7 @@ create_image(struct v3dv_device *device,
} else {
const struct wsi_image_create_info *wsi_info =
vk_find_struct_const(pCreateInfo->pNext, WSI_IMAGE_CREATE_INFO_MESA);
if (wsi_info)
if (wsi_info && wsi_info->scanout)
modifier = DRM_FORMAT_MOD_LINEAR;
}

View file

@ -399,8 +399,7 @@ vn_CreateImage(VkDevice device,
external_info->handleTypes ==
VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID;
if (wsi_info) {
assert(wsi_info->scanout);
if (wsi_info && wsi_info->scanout) {
result = vn_wsi_create_scanout_image(dev, pCreateInfo, alloc, &img);
} else if (anb_info) {
result =

View file

@ -38,10 +38,19 @@
#define VK_STRUCTURE_TYPE_WSI_SURFACE_SUPPORTED_COUNTERS_MESA (VkStructureType)1000001005
#define VK_STRUCTURE_TYPE_WSI_MEMORY_SIGNAL_SUBMIT_INFO_MESA (VkStructureType)1000001006
/* This is always chained to VkImageCreateInfo when a wsi image is created.
* It indicates that the image can be transitioned to/from
* VK_IMAGE_LAYOUT_PRESENT_SRC_KHR.
*/
struct wsi_image_create_info {
VkStructureType sType;
const void *pNext;
bool scanout;
/* If set, the buffer is the prime blit destination and the image is the
* source.
*/
VkBuffer prime_blit_buffer;
};
struct wsi_memory_allocate_info {

View file

@ -104,8 +104,12 @@ wsi_create_native_image(const struct wsi_swapchain *chain,
for (int i = 0; i < ARRAY_SIZE(image->fds); i++)
image->fds[i] = -1;
struct wsi_image_create_info image_wsi_info = {
.sType = VK_STRUCTURE_TYPE_WSI_IMAGE_CREATE_INFO_MESA,
};
VkImageCreateInfo image_info = {
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
.pNext = &image_wsi_info,
.flags = 0,
.imageType = VK_IMAGE_TYPE_2D,
.format = pCreateInfo->imageFormat,
@ -148,7 +152,6 @@ wsi_create_native_image(const struct wsi_swapchain *chain,
__vk_append_struct(&image_info, &image_format_list);
}
struct wsi_image_create_info image_wsi_info;
VkImageDrmFormatModifierListCreateInfoEXT image_modifier_list;
uint32_t image_modifier_count = 0, modifier_prop_count = 0;
@ -156,11 +159,7 @@ wsi_create_native_image(const struct wsi_swapchain *chain,
uint64_t *image_modifiers = NULL;
if (num_modifier_lists == 0) {
/* If we don't have modifiers, fall back to the legacy "scanout" flag */
image_wsi_info = (struct wsi_image_create_info) {
.sType = VK_STRUCTURE_TYPE_WSI_IMAGE_CREATE_INFO_MESA,
.scanout = true,
};
__vk_append_struct(&image_info, &image_wsi_info);
image_wsi_info.scanout = true;
} else {
/* The winsys can't request modifiers if we don't support them. */
assert(wsi->supports_modifiers);
@ -490,9 +489,13 @@ wsi_create_prime_image(const struct wsi_swapchain *chain,
if (result != VK_SUCCESS)
goto fail;
const struct wsi_image_create_info image_wsi_info = {
.sType = VK_STRUCTURE_TYPE_WSI_IMAGE_CREATE_INFO_MESA,
.prime_blit_buffer = image->prime.buffer,
};
const VkImageCreateInfo image_info = {
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
.pNext = NULL,
.pNext = &image_wsi_info,
.flags = 0,
.imageType = VK_IMAGE_TYPE_2D,
.format = pCreateInfo->imageFormat,

View file

@ -310,8 +310,12 @@ wsi_create_native_image(const struct wsi_swapchain *chain,
for (int i = 0; i < ARRAY_SIZE(image->fds); i++)
image->fds[i] = -1;
const struct wsi_image_create_info image_wsi_info = {
.sType = VK_STRUCTURE_TYPE_WSI_IMAGE_CREATE_INFO_MESA,
};
VkImageCreateInfo image_info = {
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
.pNext = &image_wsi_info,
.flags = 0,
.imageType = VK_IMAGE_TYPE_2D,
.format = pCreateInfo->imageFormat,