From fb9ebe8b88780a728341fb8c8f7543d0381fd0c2 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 23 Jul 2020 15:30:41 +0100 Subject: [PATCH] st/oxr: Add support for MND_swapchain_usage_input_attachment_bit --- doc/changes/state_trackers/mr.459.md | 1 + scripts/generate_oxr_ext_support.py | 1 + .../state_trackers/oxr/oxr_api_swapchain.c | 31 ++++++++++++++++--- .../oxr/oxr_extension_support.h | 14 +++++++++ src/xrt/state_trackers/oxr/oxr_swapchain.c | 3 ++ 5 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 doc/changes/state_trackers/mr.459.md diff --git a/doc/changes/state_trackers/mr.459.md b/doc/changes/state_trackers/mr.459.md new file mode 100644 index 000000000..2b937a899 --- /dev/null +++ b/doc/changes/state_trackers/mr.459.md @@ -0,0 +1 @@ +OpenXR: Implement the MND_swapchain_usage_input_attachment_bit extension. diff --git a/scripts/generate_oxr_ext_support.py b/scripts/generate_oxr_ext_support.py index e2f739b29..d517dcd45 100755 --- a/scripts/generate_oxr_ext_support.py +++ b/scripts/generate_oxr_ext_support.py @@ -16,6 +16,7 @@ EXTENSIONS = ( ['XR_KHR_vulkan_enable', 'XR_USE_GRAPHICS_API_VULKAN'], ['XR_EXT_debug_utils'], ['XR_MND_headless'], + ['XR_MND_swapchain_usage_input_attachment_bit'], ['XR_EXTX_overlay'], ['XR_MNDX_egl_enable', 'XR_USE_PLATFORM_EGL', 'XR_USE_GRAPHICS_API_OPENGL'], ['XR_MNDX_ball_on_a_stick_controller'], diff --git a/src/xrt/state_trackers/oxr/oxr_api_swapchain.c b/src/xrt/state_trackers/oxr/oxr_api_swapchain.c index aa15a828f..bcce3592c 100644 --- a/src/xrt/state_trackers/oxr/oxr_api_swapchain.c +++ b/src/xrt/state_trackers/oxr/oxr_api_swapchain.c @@ -7,10 +7,6 @@ * @ingroup oxr_api */ -#include -#include -#include - #include "xrt/xrt_compiler.h" #include "util/u_debug.h" @@ -22,6 +18,11 @@ #include "oxr_api_funcs.h" #include "oxr_api_verify.h" +#include +#include +#include +#include + XrResult oxr_xrEnumerateSwapchainFormats(XrSession session, @@ -62,6 +63,28 @@ oxr_xrCreateSwapchain(XrSession session, OXR_VERIFY_ARG_NOT_ZERO(&log, createInfo->width); OXR_VERIFY_ARG_NOT_ZERO(&log, createInfo->height); + // Short hand. + struct oxr_instance *inst = sess->sys->inst; + + XrSwapchainUsageFlags flags = 0; + flags |= XR_SWAPCHAIN_USAGE_COLOR_ATTACHMENT_BIT; + flags |= XR_SWAPCHAIN_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; + flags |= XR_SWAPCHAIN_USAGE_UNORDERED_ACCESS_BIT; + flags |= XR_SWAPCHAIN_USAGE_TRANSFER_SRC_BIT; + flags |= XR_SWAPCHAIN_USAGE_TRANSFER_DST_BIT; + flags |= XR_SWAPCHAIN_USAGE_SAMPLED_BIT; + flags |= XR_SWAPCHAIN_USAGE_MUTABLE_FORMAT_BIT; + if (inst->extensions.MND_swapchain_usage_input_attachment_bit) { + flags |= XR_SWAPCHAIN_USAGE_INPUT_ATTACHMENT_BIT_MND; + } + + if ((createInfo->usageFlags & ~flags) != 0) { + return oxr_error(&log, XR_ERROR_VALIDATION_FAILURE, + "(createInfo->usageFlags == 0x08%" PRIx64 + ") contains invalid flags", + createInfo->usageFlags); + } + ret = sess->create_swapchain(&log, sess, createInfo, &sc); if (ret != XR_SUCCESS) { return ret; diff --git a/src/xrt/state_trackers/oxr/oxr_extension_support.h b/src/xrt/state_trackers/oxr/oxr_extension_support.h index 0c1ae3db0..dbd0863e4 100644 --- a/src/xrt/state_trackers/oxr/oxr_extension_support.h +++ b/src/xrt/state_trackers/oxr/oxr_extension_support.h @@ -89,6 +89,19 @@ #endif +/* + * XR_MND_swapchain_usage_input_attachment_bit + */ +#if defined(XR_MND_swapchain_usage_input_attachment_bit) +#define OXR_HAVE_MND_swapchain_usage_input_attachment_bit +#define OXR_EXTENSION_SUPPORT_MND_swapchain_usage_input_attachment_bit(_) \ + _(MND_swapchain_usage_input_attachment_bit, \ + MND_SWAPCHAIN_USAGE_INPUT_ATTACHMENT_BIT) +#else +#define OXR_EXTENSION_SUPPORT_MND_swapchain_usage_input_attachment_bit(_) +#endif + + /* * XR_EXTX_overlay */ @@ -154,6 +167,7 @@ OXR_EXTENSION_SUPPORT_KHR_vulkan_enable(_) \ OXR_EXTENSION_SUPPORT_EXT_debug_utils(_) \ OXR_EXTENSION_SUPPORT_MND_headless(_) \ + OXR_EXTENSION_SUPPORT_MND_swapchain_usage_input_attachment_bit(_) \ OXR_EXTENSION_SUPPORT_EXTX_overlay(_) \ OXR_EXTENSION_SUPPORT_MNDX_egl_enable(_) \ OXR_EXTENSION_SUPPORT_MNDX_ball_on_a_stick_controller(_) diff --git a/src/xrt/state_trackers/oxr/oxr_swapchain.c b/src/xrt/state_trackers/oxr/oxr_swapchain.c index a4ebab0ad..2ee9b4ab1 100644 --- a/src/xrt/state_trackers/oxr/oxr_swapchain.c +++ b/src/xrt/state_trackers/oxr/oxr_swapchain.c @@ -192,6 +192,9 @@ convert_usage_bits(XrSwapchainUsageFlags xr_usage) if ((xr_usage & XR_SWAPCHAIN_USAGE_MUTABLE_FORMAT_BIT) != 0) { usage |= XRT_SWAPCHAIN_USAGE_MUTABLE_FORMAT; } + if ((xr_usage & XR_SWAPCHAIN_USAGE_INPUT_ATTACHMENT_BIT_MND) != 0) { + usage |= XRT_SWAPCHAIN_USAGE_INPUT_ATTACHMENT; + } return usage; }