venus: add vn_wsi_create_scanout_image

A helper called from vn_wsi_create_scanout_image to hijack wsi scanout
image creation.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10294>
This commit is contained in:
Chia-I Wu
2021-04-16 12:43:51 -07:00
parent b7db6598df
commit 418da19f91
3 changed files with 46 additions and 13 deletions

View File

@@ -140,24 +140,22 @@ vn_CreateImage(VkDevice device,
struct vn_device *dev = vn_device_from_handle(device);
const VkAllocationCallbacks *alloc =
pAllocator ? pAllocator : &dev->base.base.alloc;
struct vn_image *img;
VkResult result;
/* TODO wsi_create_native_image uses modifiers or set wsi_info->scanout to
* true. Instead of forcing VK_IMAGE_TILING_LINEAR, we should ask wsi to
* use wsi_create_prime_image instead.
*/
#ifdef VN_USE_WSI_PLATFORM
const struct wsi_image_create_info *wsi_info =
vk_find_struct_const(pCreateInfo->pNext, WSI_IMAGE_CREATE_INFO_MESA);
VkImageCreateInfo local_create_info;
if (wsi_info && wsi_info->scanout) {
if (VN_DEBUG(WSI))
vn_log(dev->instance, "forcing scanout image linear");
local_create_info = *pCreateInfo;
local_create_info.tiling = VK_IMAGE_TILING_LINEAR;
pCreateInfo = &local_create_info;
if (wsi_info) {
assert(wsi_info->scanout);
result = vn_wsi_create_scanout_image(dev, pCreateInfo, alloc, &img);
goto out;
}
#endif
struct vn_image *img;
VkResult result = vn_image_create(dev, pCreateInfo, alloc, &img);
result = vn_image_create(dev, pCreateInfo, alloc, &img);
out:
if (result != VK_SUCCESS)
return vn_error(dev->instance, result);

View File

@@ -11,6 +11,7 @@
#include "vn_wsi.h"
#include "vn_device.h"
#include "vn_image.h"
#include "vn_queue.h"
/* The common WSI support makes some assumptions about the driver.
@@ -90,6 +91,30 @@ vn_wsi_fini(struct vn_physical_device *physical_dev)
wsi_device_finish(&physical_dev->wsi_device, alloc);
}
VkResult
vn_wsi_create_scanout_image(struct vn_device *dev,
const VkImageCreateInfo *create_info,
const VkAllocationCallbacks *alloc,
struct vn_image **out_img)
{
/* TODO This is the legacy path used by wsi_create_native_image when there
* is no modifier support. Instead of forcing VK_IMAGE_TILING_LINEAR, we
* should ask wsi to use wsi_create_prime_image instead.
*
* In fact, this is not enough when the image is truely used for scanout by
* the host compositor. There can be requirements we fail to meet. We
* should require modifier support at some point.
*/
VkImageCreateInfo local_create_info = *create_info;
local_create_info.tiling = VK_IMAGE_TILING_LINEAR;
create_info = &local_create_info;
if (VN_DEBUG(WSI))
vn_log(dev->instance, "forcing scanout image linear");
return vn_image_create(dev, create_info, alloc, out_img);
}
/* surface commands */
void

View File

@@ -16,12 +16,21 @@
#include "wsi_common.h"
#ifdef VN_USE_WSI_PLATFORM
VkResult
vn_wsi_init(struct vn_physical_device *physical_dev);
void
vn_wsi_fini(struct vn_physical_device *physical_dev);
VkResult
vn_wsi_create_scanout_image(struct vn_device *dev,
const VkImageCreateInfo *create_info,
const VkAllocationCallbacks *alloc,
struct vn_image **out_img);
#else
static inline VkResult
vn_wsi_init(UNUSED struct vn_physical_device *physical_dev)
{
@@ -32,6 +41,7 @@ static inline void
vn_wsi_fini(UNUSED struct vn_physical_device *physical_dev)
{
}
#endif
#endif /* VN_WSI_H */