Add support for Direct3D 12 OpenXR backend.

This change adds support for running XR projects built with the `d3d12`
rendering backend. The XR backend hooks into the setup for the D3D12
render context in order to use the desired device and command queue for
submission to OpenXR. The XR backend takes care of importing the D3D12
swapchain images into the render context.

As part of this process, three issues are addressed:
- Ensuring that resource state transitions are only done on textures
  that require them.
- Enabling view instancing in the PSOs for multiview render passes.
- Addressing a bug in the D3D12 runtime where PSO creation may fail
  when front face detection is used.

Please refer to #86283 for additional discussions on the implementation
details.
This commit is contained in:
Matthieu Bucchianeri 2025-03-07 18:29:52 -08:00
parent 2d3bdcac35
commit e3c215fc13
11 changed files with 826 additions and 6 deletions

View file

@ -52,6 +52,10 @@
#include "extensions/platform/openxr_opengl_extension.h"
#endif
#ifdef D3D12_ENABLED
#include "extensions/platform/openxr_d3d12_extension.h"
#endif
#include "extensions/openxr_composition_layer_depth_extension.h"
#include "extensions/openxr_debug_utils_extension.h"
#include "extensions/openxr_eye_gaze_interaction.h"
@ -1679,6 +1683,14 @@ bool OpenXRAPI::initialize(const String &p_rendering_driver) {
#else
// shouldn't be possible...
ERR_FAIL_V(false);
#endif
} else if (p_rendering_driver == "d3d12") {
#ifdef D3D12_ENABLED
graphics_extension = memnew(OpenXRD3D12Extension);
register_extension_wrapper(graphics_extension);
#else
// shouldn't be possible...
ERR_FAIL_V(false);
#endif
} else {
ERR_FAIL_V_MSG(false, "OpenXR: Unsupported rendering device.");