venus: add extension check for ANDROID_native_buffer

We only do it on Android for now, to keep the driver working with older
renderers on X11.

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/10556>
This commit is contained in:
Chia-I Wu 2021-04-30 12:52:52 -07:00 committed by Marge Bot
parent 203e64eadd
commit 9171b981bf
2 changed files with 24 additions and 17 deletions

View File

@ -1436,23 +1436,34 @@ vn_physical_device_get_native_extensions(
const struct vn_physical_device *physical_dev, const struct vn_physical_device *physical_dev,
struct vk_device_extension_table *exts) struct vk_device_extension_table *exts)
{ {
*exts = (struct vk_device_extension_table){ const struct vn_instance *instance = physical_dev->instance;
#ifdef VN_USE_WSI_PLATFORM const struct vn_renderer_info *renderer_info = &instance->renderer_info;
.KHR_incremental_present = true, const struct vk_device_extension_table *renderer_exts =
.KHR_swapchain = true, &physical_dev->renderer_extensions;
.KHR_swapchain_mutable_format = true,
#endif memset(exts, 0, sizeof(*exts));
#ifdef ANDROID
.ANDROID_native_buffer = true,
#endif
};
/* see vn_physical_device_init_external_memory */ /* see vn_physical_device_init_external_memory */
if (physical_dev->renderer_extensions.EXT_external_memory_dma_buf && if (renderer_exts->EXT_external_memory_dma_buf &&
physical_dev->instance->renderer_info.has_dmabuf_import) { renderer_info->has_dmabuf_import) {
exts->KHR_external_memory_fd = true; exts->KHR_external_memory_fd = true;
exts->EXT_external_memory_dma_buf = true; exts->EXT_external_memory_dma_buf = true;
} }
/* TODO join Android to do proper checks */
#ifdef VN_USE_WSI_PLATFORM
exts->KHR_incremental_present = true;
exts->KHR_swapchain = true;
exts->KHR_swapchain_mutable_format = true;
#endif
#ifdef ANDROID
if (renderer_exts->EXT_image_drm_format_modifier &&
renderer_exts->EXT_queue_family_foreign &&
exts->EXT_external_memory_dma_buf) {
exts->ANDROID_native_buffer = true;
}
#endif
} }
static void static void

View File

@ -103,11 +103,7 @@ vn_image_android_wsi_init(struct vn_device *dev,
img->sharing_mode == VK_SHARING_MODE_EXCLUSIVE img->sharing_mode == VK_SHARING_MODE_EXCLUSIVE
? 0 ? 0
: VK_QUEUE_FAMILY_IGNORED; : VK_QUEUE_FAMILY_IGNORED;
const uint32_t external_index = const uint32_t external_index = VK_QUEUE_FAMILY_FOREIGN_EXT;
(dev->base.base.enabled_extensions.EXT_queue_family_foreign ||
dev->physical_device->renderer_extensions.EXT_queue_family_foreign)
? VK_QUEUE_FAMILY_FOREIGN_EXT
: VK_QUEUE_FAMILY_EXTERNAL;
const uint32_t count = dev->physical_device->queue_family_count; const uint32_t count = dev->physical_device->queue_family_count;
struct vn_image_ownership_cmds *local_cmds = struct vn_image_ownership_cmds *local_cmds =