mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-26 17:37:34 +00:00
xrt: Fixes #411, KHR_vulkan_swapchain_format_list not enabled client-side
* Fixes VK_KHR_image_format_list not being added to extension lists or not enabling flags on client-side vk_bundle / vk client compositor. * Fixes missing extension VK_KHR_image_format_list to the vulkan device extension list for XR_KHR_vulkan_enable * Fixes format lists for KHR_vulkan_swapchain_format_list not be used/applied on client vk images. * Fixes vulkan validation errors on client that attempt to use & chain format lists for image view creation outside of OpenXR / runtime Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2352>
This commit is contained in:
parent
b4fe9aaa56
commit
5fb1a02575
|
@ -1,4 +1,4 @@
|
||||||
// Copyright 2019-2023, Collabora, Ltd.
|
// Copyright 2019-2024, Collabora, Ltd.
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
/*!
|
/*!
|
||||||
* @file
|
* @file
|
||||||
|
@ -14,6 +14,7 @@
|
||||||
* @author Jakob Bornecrantz <jakob@collabora.com>
|
* @author Jakob Bornecrantz <jakob@collabora.com>
|
||||||
* @author Lubosz Sarnecki <lubosz.sarnecki@collabora.com>
|
* @author Lubosz Sarnecki <lubosz.sarnecki@collabora.com>
|
||||||
* @author Moses Turner <moses@collabora.com>
|
* @author Moses Turner <moses@collabora.com>
|
||||||
|
* @author Korcan Hussein <korcan.hussein@collabora.com>
|
||||||
* @ingroup aux_vk
|
* @ingroup aux_vk
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1395,6 +1396,7 @@ vk_init_from_given(struct vk_bundle *vk,
|
||||||
bool external_fence_fd_enabled,
|
bool external_fence_fd_enabled,
|
||||||
bool external_semaphore_fd_enabled,
|
bool external_semaphore_fd_enabled,
|
||||||
bool timeline_semaphore_enabled,
|
bool timeline_semaphore_enabled,
|
||||||
|
bool image_format_list_enabled,
|
||||||
bool debug_utils_enabled,
|
bool debug_utils_enabled,
|
||||||
enum u_logging_level log_level)
|
enum u_logging_level log_level)
|
||||||
{
|
{
|
||||||
|
@ -1435,6 +1437,11 @@ vk_init_from_given(struct vk_bundle *vk,
|
||||||
vk->has_KHR_external_semaphore_fd = true;
|
vk->has_KHR_external_semaphore_fd = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Vulkan does not let us read what extensions was enabled.
|
||||||
|
if (image_format_list_enabled) {
|
||||||
|
vk->has_KHR_image_format_list = image_format_list_enabled;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef VK_KHR_timeline_semaphore
|
#ifdef VK_KHR_timeline_semaphore
|
||||||
/*
|
/*
|
||||||
* Has the timeline semaphore extension and feature been enabled?
|
* Has the timeline semaphore extension and feature been enabled?
|
||||||
|
|
|
@ -1136,6 +1136,20 @@ vk_create_image_from_native(struct vk_bundle *vk,
|
||||||
.handleTypes = handle_type,
|
.handleTypes = handle_type,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef VK_KHR_image_format_list
|
||||||
|
VkImageFormatListCreateInfoKHR image_format_list_create_info = {
|
||||||
|
.sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO_KHR,
|
||||||
|
.pNext = NULL,
|
||||||
|
.viewFormatCount = info->format_count,
|
||||||
|
.pViewFormats = info->formats,
|
||||||
|
};
|
||||||
|
const bool has_mutable_format_list =
|
||||||
|
has_mutable_usage && vk->has_KHR_image_format_list && info->format_count > 0;
|
||||||
|
if (has_mutable_format_list) {
|
||||||
|
external_memory_image_create_info.pNext = &image_format_list_create_info;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// In
|
// In
|
||||||
VkImageCreateInfo vk_info = {
|
VkImageCreateInfo vk_info = {
|
||||||
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright 2019-2023, Collabora, Ltd.
|
// Copyright 2019-2024, Collabora, Ltd.
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
/*!
|
/*!
|
||||||
* @file
|
* @file
|
||||||
|
@ -14,6 +14,7 @@
|
||||||
* @author Jakob Bornecrantz <jakob@collabora.com>
|
* @author Jakob Bornecrantz <jakob@collabora.com>
|
||||||
* @author Lubosz Sarnecki <lubosz.sarnecki@collabora.com>
|
* @author Lubosz Sarnecki <lubosz.sarnecki@collabora.com>
|
||||||
* @author Moses Turner <moses@collabora.com>
|
* @author Moses Turner <moses@collabora.com>
|
||||||
|
* @author Korcan Hussein <korcan.hussein@collabora.com>
|
||||||
* @ingroup aux_vk
|
* @ingroup aux_vk
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1049,6 +1050,7 @@ vk_init_from_given(struct vk_bundle *vk,
|
||||||
bool external_fence_fd_enabled,
|
bool external_fence_fd_enabled,
|
||||||
bool external_semaphore_fd_enabled,
|
bool external_semaphore_fd_enabled,
|
||||||
bool timeline_semaphore_enabled,
|
bool timeline_semaphore_enabled,
|
||||||
|
bool image_format_list_enabled,
|
||||||
bool debug_utils_enabled,
|
bool debug_utils_enabled,
|
||||||
enum u_logging_level log_level);
|
enum u_logging_level log_level);
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
// Copyright 2019-2023, Collabora, Ltd.
|
// Copyright 2019-2024, Collabora, Ltd.
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
/*!
|
/*!
|
||||||
* @file
|
* @file
|
||||||
* @brief Vulkan client side glue to compositor implementation.
|
* @brief Vulkan client side glue to compositor implementation.
|
||||||
* @author Jakob Bornecrantz <jakob@collabora.com>
|
* @author Jakob Bornecrantz <jakob@collabora.com>
|
||||||
* @author Lubosz Sarnecki <lubosz.sarnecki@collabora.com>
|
* @author Lubosz Sarnecki <lubosz.sarnecki@collabora.com>
|
||||||
|
* @author Korcan Hussein <korcan.hussein@collabora.com>
|
||||||
* @ingroup comp_client
|
* @ingroup comp_client
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -816,6 +817,7 @@ client_vk_compositor_create(struct xrt_compositor_native *xcn,
|
||||||
bool external_fence_fd_enabled,
|
bool external_fence_fd_enabled,
|
||||||
bool external_semaphore_fd_enabled,
|
bool external_semaphore_fd_enabled,
|
||||||
bool timeline_semaphore_enabled,
|
bool timeline_semaphore_enabled,
|
||||||
|
bool image_format_list_enabled,
|
||||||
bool debug_utils_enabled,
|
bool debug_utils_enabled,
|
||||||
bool renderdoc_enabled,
|
bool renderdoc_enabled,
|
||||||
uint32_t queueFamilyIndex,
|
uint32_t queueFamilyIndex,
|
||||||
|
@ -872,6 +874,7 @@ client_vk_compositor_create(struct xrt_compositor_native *xcn,
|
||||||
external_fence_fd_enabled, // external_fence_fd_enabled
|
external_fence_fd_enabled, // external_fence_fd_enabled
|
||||||
external_semaphore_fd_enabled, // external_semaphore_fd_enabled
|
external_semaphore_fd_enabled, // external_semaphore_fd_enabled
|
||||||
timeline_semaphore_enabled, // timeline_semaphore_enabled
|
timeline_semaphore_enabled, // timeline_semaphore_enabled
|
||||||
|
image_format_list_enabled, // image_format_list_enabled
|
||||||
debug_utils_enabled, // debug_utils_enabled
|
debug_utils_enabled, // debug_utils_enabled
|
||||||
log_level); // log_level
|
log_level); // log_level
|
||||||
if (ret != VK_SUCCESS) {
|
if (ret != VK_SUCCESS) {
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
// Copyright 2019-2023, Collabora, Ltd.
|
// Copyright 2019-2024, Collabora, Ltd.
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
/*!
|
/*!
|
||||||
* @file
|
* @file
|
||||||
* @brief Vulkan client side glue to compositor header.
|
* @brief Vulkan client side glue to compositor header.
|
||||||
* @author Jakob Bornecrantz <jakob@collabora.com>
|
* @author Jakob Bornecrantz <jakob@collabora.com>
|
||||||
* @author Lubosz Sarnecki <lubosz.sarnecki@collabora.com>
|
* @author Lubosz Sarnecki <lubosz.sarnecki@collabora.com>
|
||||||
|
* @author Korcan Hussein <korcan.hussein@collabora.com>
|
||||||
* @ingroup comp_client
|
* @ingroup comp_client
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -108,6 +109,7 @@ client_vk_compositor_create(struct xrt_compositor_native *xcn,
|
||||||
bool external_fence_fd_enabled,
|
bool external_fence_fd_enabled,
|
||||||
bool external_semaphore_fd_enabled,
|
bool external_semaphore_fd_enabled,
|
||||||
bool timeline_semaphore_enabled,
|
bool timeline_semaphore_enabled,
|
||||||
|
bool image_format_list_enabled,
|
||||||
bool debug_utils_enabled,
|
bool debug_utils_enabled,
|
||||||
bool renderdoc_enabled,
|
bool renderdoc_enabled,
|
||||||
uint32_t queueFamilyIndex,
|
uint32_t queueFamilyIndex,
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
// Copyright 2019, Collabora, Ltd.
|
// Copyright 2019-2024, Collabora, Ltd.
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
/*!
|
/*!
|
||||||
* @file
|
* @file
|
||||||
* @brief Glue code to vulkan client side code.
|
* @brief Glue code to vulkan client side code.
|
||||||
* @author Jakob Bornecrantz <jakob@collabora.com>
|
* @author Jakob Bornecrantz <jakob@collabora.com>
|
||||||
|
* @author Korcan Hussein <korcan.hussein@collabora.com>
|
||||||
* @ingroup comp_client
|
* @ingroup comp_client
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -26,6 +27,7 @@ const char *xrt_gfx_vk_instance_extensions = VK_KHR_EXTERNAL_FENCE_CAPABILITIES_
|
||||||
const char *xrt_gfx_vk_device_extensions = VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME
|
const char *xrt_gfx_vk_device_extensions = VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME
|
||||||
" " VK_KHR_EXTERNAL_FENCE_EXTENSION_NAME " " VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME
|
" " VK_KHR_EXTERNAL_FENCE_EXTENSION_NAME " " VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME
|
||||||
" " VK_KHR_EXTERNAL_SEMAPHORE_EXTENSION_NAME " " VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME
|
" " VK_KHR_EXTERNAL_SEMAPHORE_EXTENSION_NAME " " VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME
|
||||||
|
" " VK_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME
|
||||||
|
|
||||||
// Platform version of "external_memory"
|
// Platform version of "external_memory"
|
||||||
#if defined(XRT_GRAPHICS_BUFFER_HANDLE_IS_FD)
|
#if defined(XRT_GRAPHICS_BUFFER_HANDLE_IS_FD)
|
||||||
|
@ -76,6 +78,7 @@ xrt_gfx_vk_provider_create(struct xrt_compositor_native *xcn,
|
||||||
bool external_fence_fd_enabled,
|
bool external_fence_fd_enabled,
|
||||||
bool external_semaphore_fd_enabled,
|
bool external_semaphore_fd_enabled,
|
||||||
bool timeline_semaphore_enabled,
|
bool timeline_semaphore_enabled,
|
||||||
|
bool image_format_list_enabled,
|
||||||
bool debug_utils_enabled,
|
bool debug_utils_enabled,
|
||||||
bool renderdoc_enabled,
|
bool renderdoc_enabled,
|
||||||
uint32_t queue_family_index,
|
uint32_t queue_family_index,
|
||||||
|
@ -90,6 +93,7 @@ xrt_gfx_vk_provider_create(struct xrt_compositor_native *xcn,
|
||||||
external_fence_fd_enabled, //
|
external_fence_fd_enabled, //
|
||||||
external_semaphore_fd_enabled, //
|
external_semaphore_fd_enabled, //
|
||||||
timeline_semaphore_enabled, //
|
timeline_semaphore_enabled, //
|
||||||
|
image_format_list_enabled, //
|
||||||
debug_utils_enabled, //
|
debug_utils_enabled, //
|
||||||
renderdoc_enabled, //
|
renderdoc_enabled, //
|
||||||
queue_family_index, //
|
queue_family_index, //
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
// Copyright 2019, Collabora, Ltd.
|
// Copyright 2019-2024, Collabora, Ltd.
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
/*!
|
/*!
|
||||||
* @file
|
* @file
|
||||||
* @brief Header defining an XRT graphics provider.
|
* @brief Header defining an XRT graphics provider.
|
||||||
* @author Jakob Bornecrantz <jakob@collabora.com>
|
* @author Jakob Bornecrantz <jakob@collabora.com>
|
||||||
|
* @author Korcan Hussein <korcan.hussein@collabora.com>
|
||||||
* @ingroup xrt_iface
|
* @ingroup xrt_iface
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -64,6 +65,7 @@ xrt_gfx_vk_provider_create(struct xrt_compositor_native *xcn,
|
||||||
bool external_fence_fd_enabled,
|
bool external_fence_fd_enabled,
|
||||||
bool external_semaphore_fd_enabled,
|
bool external_semaphore_fd_enabled,
|
||||||
bool timeline_semaphore_enabled,
|
bool timeline_semaphore_enabled,
|
||||||
|
bool image_format_list_enabled,
|
||||||
bool debug_utils_enabled,
|
bool debug_utils_enabled,
|
||||||
bool renderdoc_enabled,
|
bool renderdoc_enabled,
|
||||||
uint32_t queue_family_index,
|
uint32_t queue_family_index,
|
||||||
|
|
|
@ -1503,6 +1503,7 @@ struct oxr_system
|
||||||
bool external_semaphore_fd_enabled;
|
bool external_semaphore_fd_enabled;
|
||||||
bool timeline_semaphore_enabled;
|
bool timeline_semaphore_enabled;
|
||||||
bool debug_utils_enabled;
|
bool debug_utils_enabled;
|
||||||
|
bool image_format_list_enabled;
|
||||||
} vk;
|
} vk;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
// Copyright 2018-2022, Collabora, Ltd.
|
// Copyright 2018-2024, Collabora, Ltd.
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
/*!
|
/*!
|
||||||
* @file
|
* @file
|
||||||
* @brief Holds Vulkan specific session functions.
|
* @brief Holds Vulkan specific session functions.
|
||||||
* @author Jakob Bornecrantz <jakob@collabora.com>
|
* @author Jakob Bornecrantz <jakob@collabora.com>
|
||||||
|
* @author Korcan Hussein <korcan.hussein@collabora.com>
|
||||||
* @ingroup oxr_main
|
* @ingroup oxr_main
|
||||||
* @ingroup comp_client
|
* @ingroup comp_client
|
||||||
*/
|
*/
|
||||||
|
@ -82,6 +83,8 @@ oxr_session_populate_vk(struct oxr_logger *log,
|
||||||
bool timeline_semaphore_enabled = sess->sys->vk.timeline_semaphore_enabled;
|
bool timeline_semaphore_enabled = sess->sys->vk.timeline_semaphore_enabled;
|
||||||
bool external_fence_fd_enabled = sess->sys->vk.external_fence_fd_enabled;
|
bool external_fence_fd_enabled = sess->sys->vk.external_fence_fd_enabled;
|
||||||
bool external_semaphore_fd_enabled = sess->sys->vk.external_semaphore_fd_enabled;
|
bool external_semaphore_fd_enabled = sess->sys->vk.external_semaphore_fd_enabled;
|
||||||
|
bool image_format_list_enabled =
|
||||||
|
sys->inst->extensions.KHR_vulkan_enable || sess->sys->vk.image_format_list_enabled;
|
||||||
bool debug_utils_enabled = false;
|
bool debug_utils_enabled = false;
|
||||||
bool renderdoc_enabled = false;
|
bool renderdoc_enabled = false;
|
||||||
|
|
||||||
|
@ -146,6 +149,7 @@ oxr_session_populate_vk(struct oxr_logger *log,
|
||||||
external_fence_fd_enabled, //
|
external_fence_fd_enabled, //
|
||||||
external_semaphore_fd_enabled, //
|
external_semaphore_fd_enabled, //
|
||||||
timeline_semaphore_enabled, //
|
timeline_semaphore_enabled, //
|
||||||
|
image_format_list_enabled, //
|
||||||
debug_utils_enabled, //
|
debug_utils_enabled, //
|
||||||
renderdoc_enabled, //
|
renderdoc_enabled, //
|
||||||
next->queueFamilyIndex, //
|
next->queueFamilyIndex, //
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
// Copyright 2018-2020, Collabora, Ltd.
|
// Copyright 2018-2024, Collabora, Ltd.
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
/*!
|
/*!
|
||||||
* @file
|
* @file
|
||||||
* @brief Holds Vulkan related functions.
|
* @brief Holds Vulkan related functions.
|
||||||
* @author Jakob Bornecrantz <jakob@collabora.com>
|
* @author Jakob Bornecrantz <jakob@collabora.com>
|
||||||
|
* @author Korcan Hussein <korcan.hussein@collabora.com>
|
||||||
* @ingroup oxr_main
|
* @ingroup oxr_main
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -428,6 +429,7 @@ oxr_vk_create_vulkan_device(struct oxr_logger *log,
|
||||||
bool external_fence_fd_enabled = false;
|
bool external_fence_fd_enabled = false;
|
||||||
bool external_semaphore_fd_enabled = false;
|
bool external_semaphore_fd_enabled = false;
|
||||||
#endif
|
#endif
|
||||||
|
bool image_format_list_enabled = false;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < ARRAY_SIZE(optional_device_extensions); i++) {
|
for (uint32_t i = 0; i < ARRAY_SIZE(optional_device_extensions); i++) {
|
||||||
// Empty list or a not supported extension.
|
// Empty list or a not supported extension.
|
||||||
|
@ -446,6 +448,10 @@ oxr_vk_create_vulkan_device(struct oxr_logger *log,
|
||||||
external_semaphore_fd_enabled = true;
|
external_semaphore_fd_enabled = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (strcmp(optional_device_extensions[i], VK_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME) == 0) {
|
||||||
|
image_format_list_enabled = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(props);
|
free(props);
|
||||||
|
@ -549,6 +555,12 @@ oxr_vk_create_vulkan_device(struct oxr_logger *log,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef VK_KHR_image_format_list
|
||||||
|
if (*vulkanResult == VK_SUCCESS) {
|
||||||
|
sys->vk.image_format_list_enabled = image_format_list_enabled;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
u_string_list_destroy(&device_extension_list);
|
u_string_list_destroy(&device_extension_list);
|
||||||
|
|
||||||
return XR_SUCCESS;
|
return XR_SUCCESS;
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
// Copyright 2022, Collabora, Ltd.
|
// Copyright 2022-2024, Collabora, Ltd.
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
/*!
|
/*!
|
||||||
* @file
|
* @file
|
||||||
* @brief Basic Vulkan compositor tests.
|
* @brief Basic Vulkan compositor tests.
|
||||||
* @author Rylie Pavlik <rylie.pavlik@collabora.com>
|
* @author Rylie Pavlik <rylie.pavlik@collabora.com>
|
||||||
|
* @author Korcan Hussein <korcan.hussein@collabora.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -148,9 +149,10 @@ TEST_CASE("client_compositor", "[.][needgpu]")
|
||||||
#else
|
#else
|
||||||
#error "Need port for fence sync handles checkers"
|
#error "Need port for fence sync handles checkers"
|
||||||
#endif
|
#endif
|
||||||
false, // debug_utils_enabled
|
vk->has_KHR_image_format_list, // image_format_list_enabled
|
||||||
false, // renderdoc_enabled
|
false, // debug_utils_enabled
|
||||||
vk->queue_family_index, //
|
false, // renderdoc_enabled
|
||||||
|
vk->queue_family_index, //
|
||||||
vk->queue_index);
|
vk->queue_index);
|
||||||
struct xrt_compositor *xc = &xcvk->base;
|
struct xrt_compositor *xc = &xcvk->base;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue