The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

st/oxr: Detect VK_LAYER_MND_enable_timeline_semaphore

And enable timeline semaphore support if it is found.

+51 -3
+51 -3
src/xrt/state_trackers/oxr/oxr_session_gfx_vk.c
··· 8 8 * @ingroup comp_client 9 9 */ 10 10 11 - #include <stdlib.h> 12 - 13 - 14 11 #include "xrt/xrt_instance.h" 15 12 #include "xrt/xrt_gfx_vk.h" 16 13 17 14 #include "util/u_misc.h" 18 15 #include "util/u_debug.h" 19 16 17 + #include "vk/vk_helpers.h" 18 + 20 19 #include "oxr_objects.h" 21 20 #include "oxr_logger.h" 22 21 #include "oxr_two_call.h" 23 22 #include "oxr_handle.h" 24 23 24 + 25 25 DEBUG_GET_ONCE_BOOL_OPTION(force_timeline_semaphores, "OXR_DEBUG_FORCE_TIMELINE_SEMAPHORES", false) 26 26 27 27 28 + static bool 29 + check_for_layer_mnd_enable_timeline_semaphore(struct oxr_logger *log, 30 + VkInstance instance, 31 + VkPhysicalDevice physical_device) 32 + { 33 + PFN_vkEnumerateDeviceLayerProperties func = 34 + (PFN_vkEnumerateDeviceLayerProperties)vkGetInstanceProcAddr(instance, "vkEnumerateDeviceLayerProperties"); 35 + uint32_t prop_count = 0; 36 + VkResult ret = VK_SUCCESS; 37 + 38 + ret = func(physical_device, &prop_count, NULL); 39 + if (ret != VK_SUCCESS) { 40 + oxr_log(log, "vkEnumerateDeviceLayerProperties: %s", vk_result_string(ret)); 41 + return false; 42 + } 43 + 44 + if (prop_count == 0) { 45 + // No layers, nothing more to do. 46 + return false; 47 + } 48 + 49 + VkLayerProperties *props = NULL; 50 + props = U_TYPED_ARRAY_CALLOC(VkLayerProperties, prop_count); 51 + 52 + ret = func(physical_device, &prop_count, props); 53 + if (ret != VK_SUCCESS) { 54 + oxr_log(log, "vkEnumerateDeviceLayerProperties: %s", vk_result_string(ret)); 55 + free(props); 56 + return false; 57 + } 58 + 59 + for (uint32_t i = 0; i < prop_count; i++) { 60 + if (strcmp(props[i].layerName, "VK_LAYER_MND_enable_timeline_semaphore") == 0) { 61 + free(props); 62 + return true; 63 + } 64 + } 65 + 66 + free(props); 67 + return false; 68 + } 69 + 28 70 XrResult 29 71 oxr_session_populate_vk(struct oxr_logger *log, 30 72 struct oxr_system *sys, ··· 32 74 struct oxr_session *sess) 33 75 { 34 76 bool timeline_semaphore_enabled = sess->sys->vk.timeline_semaphore_enabled; 77 + 78 + if (!timeline_semaphore_enabled && 79 + check_for_layer_mnd_enable_timeline_semaphore(log, next->instance, next->physicalDevice)) { 80 + oxr_log(log, "Found VK_LAYER_MND_enable_timeline_semaphore and enabled them!"); 81 + timeline_semaphore_enabled = true; 82 + } 35 83 36 84 if (!timeline_semaphore_enabled && debug_get_bool_option_force_timeline_semaphores()) { 37 85 oxr_log(log, "Forcing timeline semaphores on, your app better have enabled them!");