a/vk: Also check for d3d12 fence semaphores

This commit is contained in:
Jakob Bornecrantz 2022-05-21 00:54:46 +01:00
parent ea35e79ec7
commit 490e90b493
4 changed files with 55 additions and 27 deletions

View file

@ -210,8 +210,11 @@ is_fence_bit_supported(struct vk_bundle *vk, VkExternalFenceHandleTypeFlagBits h
return true; return true;
} }
static bool static void
is_binary_semaphore_bit_supported(struct vk_bundle *vk, VkExternalSemaphoreHandleTypeFlagBits handle_type) get_binary_semaphore_bit_support(struct vk_bundle *vk,
VkExternalSemaphoreHandleTypeFlagBits handle_type,
bool *out_importable,
bool *out_exportable)
{ {
VkPhysicalDeviceExternalSemaphoreInfo external_semaphore_info = { VkPhysicalDeviceExternalSemaphoreInfo external_semaphore_info = {
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_SEMAPHORE_INFO, .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_SEMAPHORE_INFO,
@ -227,29 +230,37 @@ is_binary_semaphore_bit_supported(struct vk_bundle *vk, VkExternalSemaphoreHandl
&external_semaphore_info, // pExternalSemaphoreInfo &external_semaphore_info, // pExternalSemaphoreInfo
&external_semaphore_props); // pExternalSemaphoreProperties &external_semaphore_props); // pExternalSemaphoreProperties
const VkExternalSemaphoreFeatureFlagBits bits = // const VkExternalSemaphoreFeatureFlagBits bits = external_semaphore_props.externalSemaphoreFeatures;
VK_EXTERNAL_SEMAPHORE_FEATURE_EXPORTABLE_BIT | //
VK_EXTERNAL_SEMAPHORE_FEATURE_IMPORTABLE_BIT; //
VkExternalSemaphoreFeatureFlagBits masked = bits & external_semaphore_props.externalSemaphoreFeatures; *out_importable = (bits & VK_EXTERNAL_SEMAPHORE_FEATURE_IMPORTABLE_BIT) != 0;
if (masked != bits) { *out_exportable = (bits & VK_EXTERNAL_SEMAPHORE_FEATURE_EXPORTABLE_BIT) != 0;
// All must be supported.
return false;
}
return true;
} }
static bool static bool
is_timeline_semaphore_bit_supported(struct vk_bundle *vk, VkExternalSemaphoreHandleTypeFlagBits handle_type) is_binary_semaphore_bit_supported(struct vk_bundle *vk, VkExternalSemaphoreHandleTypeFlagBits handle_type)
{ {
bool importable = false, exportable = false;
get_binary_semaphore_bit_support(vk, handle_type, &importable, &exportable);
return importable && exportable;
}
static void
get_timeline_semaphore_bit_support(struct vk_bundle *vk,
VkExternalSemaphoreHandleTypeFlagBits handle_type,
bool *out_importable,
bool *out_exportable)
{
*out_importable = false;
*out_exportable = false;
#ifdef VK_KHR_timeline_semaphore #ifdef VK_KHR_timeline_semaphore
/* /*
* This technically is for the device not the physical device, * This technically is for the device not the physical device,
* but we can use it as a way to gate running the detection code. * but we can use it as a way to gate running the detection code.
*/ */
if (!vk->features.timeline_semaphore) { if (!vk->features.timeline_semaphore) {
return false; return;
} }
VkSemaphoreTypeCreateInfo semaphore_type_create_info = { VkSemaphoreTypeCreateInfo semaphore_type_create_info = {
@ -271,22 +282,22 @@ is_timeline_semaphore_bit_supported(struct vk_bundle *vk, VkExternalSemaphoreHan
&external_semaphore_info, // pExternalSemaphoreInfo &external_semaphore_info, // pExternalSemaphoreInfo
&external_semaphore_props); // pExternalSemaphoreProperties &external_semaphore_props); // pExternalSemaphoreProperties
const VkExternalSemaphoreFeatureFlagBits bits = // const VkExternalSemaphoreFeatureFlagBits bits = external_semaphore_props.externalSemaphoreFeatures;
VK_EXTERNAL_SEMAPHORE_FEATURE_EXPORTABLE_BIT | //
VK_EXTERNAL_SEMAPHORE_FEATURE_IMPORTABLE_BIT; //
VkExternalSemaphoreFeatureFlagBits masked = bits & external_semaphore_props.externalSemaphoreFeatures; *out_importable = (bits & VK_EXTERNAL_SEMAPHORE_FEATURE_IMPORTABLE_BIT) != 0;
if (masked != bits) { *out_exportable = (bits & VK_EXTERNAL_SEMAPHORE_FEATURE_EXPORTABLE_BIT) != 0;
// All must be supported.
return false;
}
return true;
#else
return false;
#endif #endif
} }
bool
is_timeline_semaphore_bit_supported(struct vk_bundle *vk, VkExternalSemaphoreHandleTypeFlagBits handle_type)
{
bool importable = false, exportable = false;
get_timeline_semaphore_bit_support(vk, handle_type, &importable, &exportable);
return importable && exportable;
}
static void static void
fill_in_external_object_properties(struct vk_bundle *vk) fill_in_external_object_properties(struct vk_bundle *vk)
{ {
@ -322,13 +333,18 @@ fill_in_external_object_properties(struct vk_bundle *vk)
vk, VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT); vk, VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT);
#elif defined(XRT_GRAPHICS_SYNC_HANDLE_IS_WIN32_HANDLE) #elif defined(XRT_GRAPHICS_SYNC_HANDLE_IS_WIN32_HANDLE)
vk->external.fence_win32_handle = is_fence_bit_supported( // vk->external.fence_win32_handle = is_fence_bit_supported( //
vk, VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_BIT); vk, VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_BIT);
vk->external.binary_semaphore_d3d12_fence = is_binary_semaphore_bit_supported( //
vk, VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT);
vk->external.binary_semaphore_win32_handle = is_binary_semaphore_bit_supported( // vk->external.binary_semaphore_win32_handle = is_binary_semaphore_bit_supported( //
vk, VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT); vk, VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT);
//! @todo Is this safe to assume working, do we need to check an extension? //! @todo Is this safe to assume working, do we need to check an extension?
vk->external.timeline_semaphore_d3d12_fence = is_timeline_semaphore_bit_supported( //
vk, VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT);
vk->external.timeline_semaphore_win32_handle = is_timeline_semaphore_bit_supported( // vk->external.timeline_semaphore_win32_handle = is_timeline_semaphore_bit_supported( //
vk, VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT); vk, VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT);

View file

@ -72,8 +72,10 @@ struct vk_bundle
#elif defined(XRT_GRAPHICS_SYNC_HANDLE_IS_WIN32_HANDLE) #elif defined(XRT_GRAPHICS_SYNC_HANDLE_IS_WIN32_HANDLE)
bool fence_win32_handle; bool fence_win32_handle;
bool binary_semaphore_d3d12_fence;
bool binary_semaphore_win32_handle; bool binary_semaphore_win32_handle;
bool timeline_semaphore_d3d12_fence;
bool timeline_semaphore_win32_handle; bool timeline_semaphore_win32_handle;
#else #else
#error "Need port for fence sync handles checkers" #error "Need port for fence sync handles checkers"

View file

@ -91,9 +91,13 @@ vk_print_external_handles_info(struct vk_bundle *vk, enum u_logging_level log_le
vk->external.fence_win32_handle ? "true" : "false"); // vk->external.fence_win32_handle ? "true" : "false"); //
U_LOG_IFL(log_level, vk->log_level, // U_LOG_IFL(log_level, vk->log_level, //
"Supported semaphores:\n\t%s: %s\n\t%s: %s", // "Supported semaphores:\n\t%s: %s\n\t%s: %s\n\t%s: %s\n\t%s: %s", //
"VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT(binary)", //
vk->external.binary_semaphore_d3d12_fence ? "true" : "false", //
"VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT(binary)", // "VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT(binary)", //
vk->external.binary_semaphore_win32_handle ? "true" : "false", // vk->external.binary_semaphore_win32_handle ? "true" : "false", //
"VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT(timeline)", //
vk->external.timeline_semaphore_d3d12_fence ? "true" : "false", //
"VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT(timeline)", // "VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT(timeline)", //
vk->external.timeline_semaphore_win32_handle ? "true" : "false"); // vk->external.timeline_semaphore_win32_handle ? "true" : "false"); //

View file

@ -32,6 +32,9 @@ vk_get_semaphore_handle_type(struct vk_bundle *vk)
} }
#elif defined(XRT_GRAPHICS_SYNC_HANDLE_IS_WIN32_HANDLE) #elif defined(XRT_GRAPHICS_SYNC_HANDLE_IS_WIN32_HANDLE)
if (vk->external.binary_semaphore_d3d12_fence) {
return VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT;
}
if (vk->external.binary_semaphore_win32_handle) { if (vk->external.binary_semaphore_win32_handle) {
return VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT; return VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT;
} }
@ -50,6 +53,9 @@ vk_get_timeline_semaphore_handle_type(struct vk_bundle *vk)
return VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT; return VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT;
} }
#elif defined(XRT_GRAPHICS_SYNC_HANDLE_IS_WIN32_HANDLE) #elif defined(XRT_GRAPHICS_SYNC_HANDLE_IS_WIN32_HANDLE)
if (vk->external.timeline_semaphore_d3d12_fence) {
return VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT;
}
if (vk->external.timeline_semaphore_win32_handle) { if (vk->external.timeline_semaphore_win32_handle) {
return VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT; return VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT;
} }