From 8e020fac2d0e11b8b0214069f36259363b814e0d Mon Sep 17 00:00:00 2001 From: Christoph Haag Date: Thu, 9 Dec 2021 00:11:08 +0100 Subject: [PATCH] c/main: Add and enable VK_EXT_display_control optional device ext --- scripts/generate_vk_helpers.py | 1 + src/xrt/auxiliary/vk/vk_helpers.c | 34 +++++++++++++++++++++++ src/xrt/auxiliary/vk/vk_helpers.h | 1 + src/xrt/compositor/main/comp_compositor.c | 10 ++++--- 4 files changed, 42 insertions(+), 4 deletions(-) diff --git a/scripts/generate_vk_helpers.py b/scripts/generate_vk_helpers.py index 38fd456b8..118ac04ee 100755 --- a/scripts/generate_vk_helpers.py +++ b/scripts/generate_vk_helpers.py @@ -227,6 +227,7 @@ DEVICE_EXTENSIONS_TO_CHECK = [ "VK_EXT_global_priority", "VK_EXT_robustness2", "VK_GOOGLE_display_timing", + "VK_EXT_display_control", ] ROOT = Path(__file__).resolve().parent.parent diff --git a/src/xrt/auxiliary/vk/vk_helpers.c b/src/xrt/auxiliary/vk/vk_helpers.c index eef1640e3..2d7d964a8 100644 --- a/src/xrt/auxiliary/vk/vk_helpers.c +++ b/src/xrt/auxiliary/vk/vk_helpers.c @@ -1262,6 +1262,7 @@ fill_in_has_device_extensions(struct vk_bundle *vk, struct u_string_list *ext_li vk->has_EXT_global_priority = false; vk->has_EXT_robustness2 = false; vk->has_GOOGLE_display_timing = false; + vk->has_EXT_display_control = false; const char *const *exts = u_string_list_get_data(ext_list); uint32_t ext_count = u_string_list_get_size(ext_list); @@ -1296,6 +1297,13 @@ fill_in_has_device_extensions(struct vk_bundle *vk, struct u_string_list *ext_li continue; } #endif // defined(VK_GOOGLE_display_timing) + +#if defined(VK_EXT_display_control) + if (strcmp(ext, VK_EXT_DISPLAY_CONTROL_EXTENSION_NAME) == 0) { + vk->has_EXT_display_control = true; + continue; + } +#endif // defined(VK_EXT_display_control) } // end of GENERATED device extension code - do not modify - used by scripts } @@ -1397,6 +1405,27 @@ vk_get_device_ext_props(struct vk_bundle *vk, return VK_SUCCESS; } +static bool +vk_should_skip_optional_device_ext(struct vk_bundle *vk, + struct u_string_list *required_device_ext_list, + struct u_string_list *optional_device_ext_listconst, + const char *ext) +{ +#ifdef VK_EXT_display_control + // only enable VK_EXT_display_control when we enabled VK_EXT_display_surface_counter instance ext + if (strcmp(ext, VK_EXT_DISPLAY_CONTROL_EXTENSION_NAME) == 0) { + if (!vk->has_EXT_display_surface_counter) { + VK_DEBUG(vk, "Skipping optional instance extension %s because %s instance ext is not enabled", + ext, VK_EXT_DISPLAY_SURFACE_COUNTER_EXTENSION_NAME); + return true; + } + VK_DEBUG(vk, "Not skipping optional instance extension %s because %s instance ext is enabled", ext, + VK_EXT_DISPLAY_SURFACE_COUNTER_EXTENSION_NAME); + } +#endif + return false; +} + static bool vk_build_device_extensions(struct vk_bundle *vk, VkPhysicalDevice physical_device, @@ -1433,6 +1462,11 @@ vk_build_device_extensions(struct vk_bundle *vk, for (uint32_t i = 0; i < optional_device_ext_count; i++) { const char *ext = optional_device_exts[i]; + + if (vk_should_skip_optional_device_ext(vk, required_device_ext_list, optional_device_ext_list, ext)) { + continue; + } + if (vk_check_extension(vk, props, prop_count, ext)) { U_LOG_D("Using optional device ext %s", ext); int added = u_string_list_append_unique(*out_device_ext_list, ext); diff --git a/src/xrt/auxiliary/vk/vk_helpers.h b/src/xrt/auxiliary/vk/vk_helpers.h index bdc447a84..f66d66519 100644 --- a/src/xrt/auxiliary/vk/vk_helpers.h +++ b/src/xrt/auxiliary/vk/vk_helpers.h @@ -66,6 +66,7 @@ struct vk_bundle bool has_EXT_global_priority; bool has_EXT_robustness2; bool has_GOOGLE_display_timing; + bool has_EXT_display_control; // end of GENERATED device extension code - do not modify - used by scripts bool is_tegra; diff --git a/src/xrt/compositor/main/comp_compositor.c b/src/xrt/compositor/main/comp_compositor.c index 1580b8440..62f05fcd3 100644 --- a/src/xrt/compositor/main/comp_compositor.c +++ b/src/xrt/compositor/main/comp_compositor.c @@ -620,11 +620,13 @@ static const char *required_device_extensions[] = { #endif }; -static const char *optional_device_extensions[] = { - VK_GOOGLE_DISPLAY_TIMING_EXTENSION_NAME, - VK_EXT_GLOBAL_PRIORITY_EXTENSION_NAME, +static const char *optional_device_extensions[] = {VK_GOOGLE_DISPLAY_TIMING_EXTENSION_NAME, + VK_EXT_GLOBAL_PRIORITY_EXTENSION_NAME, #ifdef VK_EXT_robustness2 - VK_EXT_ROBUSTNESS_2_EXTENSION_NAME, + VK_EXT_ROBUSTNESS_2_EXTENSION_NAME, +#endif +#ifdef VK_EXT_display_control + VK_EXT_DISPLAY_CONTROL_EXTENSION_NAME #endif };