diff --git a/src/xrt/auxiliary/util/u_pretty_print.c b/src/xrt/auxiliary/util/u_pretty_print.c index 69e5213f7..807e686ba 100644 --- a/src/xrt/auxiliary/util/u_pretty_print.c +++ b/src/xrt/auxiliary/util/u_pretty_print.c @@ -280,7 +280,9 @@ u_pp_xrt_result(struct u_pp_delegate dg, xrt_result_t xret) case XRT_ERROR_PROBER_LIST_NOT_LOCKED: DG("XRT_ERROR_PROBER_LIST_NOT_LOCKED"); return; case XRT_ERROR_PROBING_FAILED: DG("XRT_ERROR_PROBING_FAILED"); return; case XRT_ERROR_DEVICE_CREATION_FAILED: DG("XRT_ERROR_DEVICE_CREATION_FAILED"); return; + case XRT_ERROR_D3D: DG("XRT_ERROR_D3D"); return; case XRT_ERROR_D3D11: DG("XRT_ERROR_D3D11"); return; + case XRT_ERROR_D3D12: DG("XRT_ERROR_D3D12"); return; // clang-format on default: break; } diff --git a/src/xrt/include/xrt/xrt_compositor.h b/src/xrt/include/xrt/xrt_compositor.h index b5d3e330a..8fa4c2ba5 100644 --- a/src/xrt/include/xrt/xrt_compositor.h +++ b/src/xrt/include/xrt/xrt_compositor.h @@ -15,14 +15,21 @@ #include "xrt/xrt_defines.h" #include "xrt/xrt_handles.h" #include "xrt/xrt_config_os.h" - -#if defined(XRT_OS_WINDOWS) +#include "xrt/xrt_config_have.h" #include "xrt/xrt_windows.h" + +#if defined(XRT_HAVE_D3D11) #include <d3d11.h> #elif defined(XRT_DOXYGEN) struct ID3D11Texture2D; #endif +#if defined(XRT_HAVE_D3D12) +#include <d3d12.h> +#elif defined(XRT_DOXYGEN) +struct ID3D12Resource; +#endif + #ifdef __cplusplus extern "C" { #endif @@ -1650,7 +1657,7 @@ xrt_compositor_vk(struct xrt_compositor *xc) return (struct xrt_compositor_vk *)xc; } -#if defined(XRT_OS_WINDOWS) || defined(XRT_DOXYGEN) +#if defined(XRT_HAVE_D3D11) || defined(XRT_DOXYGEN) /* * @@ -1698,6 +1705,42 @@ struct xrt_d3d_requirements #endif // XRT_OS_WINDOWS + +#if defined(XRT_HAVE_D3D12) || defined(XRT_DOXYGEN) +/* + * + * D3D12 interface. + * + */ + +/*! + * Base class for a D3D12 client swapchain. + * + * @ingroup xrt_iface comp_client + * @extends xrt_swapchain + */ +struct xrt_swapchain_d3d12 +{ + //! @public Base + struct xrt_swapchain base; + + //! Images to be used by the caller. + ID3D12Resource *images[XRT_MAX_SWAPCHAIN_IMAGES]; +}; + +/*! + * Base class for a D3D12 client compositor. + * + * @ingroup xrt_iface comp_client + * @extends xrt_compositor + */ +struct xrt_compositor_d3d12 +{ + //! @public Base + struct xrt_compositor base; +}; +#endif + /* * * Native interface. diff --git a/src/xrt/include/xrt/xrt_config_have.h.cmake_in b/src/xrt/include/xrt/xrt_config_have.h.cmake_in index f9654da5a..91e8df0b0 100644 --- a/src/xrt/include/xrt/xrt_config_have.h.cmake_in +++ b/src/xrt/include/xrt/xrt_config_have.h.cmake_in @@ -14,6 +14,7 @@ #cmakedefine XRT_HAVE_BASALT_SLAM #cmakedefine XRT_HAVE_BLUETOOTH #cmakedefine XRT_HAVE_D3D11 +#cmakedefine XRT_HAVE_D3D12 #cmakedefine XRT_HAVE_DBUS #cmakedefine XRT_HAVE_DXGI #cmakedefine XRT_HAVE_EGL diff --git a/src/xrt/include/xrt/xrt_gfx_d3d12.h b/src/xrt/include/xrt/xrt_gfx_d3d12.h new file mode 100644 index 000000000..39f29073c --- /dev/null +++ b/src/xrt/include/xrt/xrt_gfx_d3d12.h @@ -0,0 +1,43 @@ +// Copyright 2022, Collabora, Ltd. +// SPDX-License-Identifier: BSL-1.0 +/*! + * @file + * @brief Header defining a D3D12 graphics interface + * @author Ryan Pavlik <ryan.pavlik@collabora.com> + * @ingroup xrt_iface + */ + +#pragma once + +#include "xrt/xrt_device.h" +#include "xrt/xrt_compositor.h" +#include "xrt/xrt_config_have.h" +#include "xrt/xrt_windows.h" + +#if defined(XRT_HAVE_D3D12) +#include "d3d12.h" +#elif defined(XRT_DOXYGEN) +struct ID3D12Device; +struct ID3D12CommandQueue; +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(XRT_OS_WINDOWS) || defined(XRT_DOXYGEN) + +/*! + * Create a D3D12 compositor client. + * + * @ingroup xrt_iface + * @public @memberof xrt_compositor_native + */ +struct xrt_compositor_d3d12 * +xrt_gfx_d3d12_provider_create(struct xrt_compositor_native *xcn, ID3D12Device *device, ID3D12CommandQueue *queue); + +#endif // XRT_OS_WINDOWS || XRT_DOXYGEN + +#ifdef __cplusplus +} +#endif diff --git a/src/xrt/include/xrt/xrt_results.h b/src/xrt/include/xrt/xrt_results.h index 73aaa2243..5804a4fb5 100644 --- a/src/xrt/include/xrt/xrt_results.h +++ b/src/xrt/include/xrt/xrt_results.h @@ -146,8 +146,16 @@ typedef enum xrt_result * Creating a @ref xrt_device failed. */ XRT_ERROR_DEVICE_CREATION_FAILED = -22, + /*! + * Some D3D error, from code shared between D3D11 and D3D12 + */ + XRT_ERROR_D3D = -23, /*! * Some D3D11 error */ - XRT_ERROR_D3D11 = -23, + XRT_ERROR_D3D11 = -24, + /*! + * Some D3D12 error + */ + XRT_ERROR_D3D12 = -25, } xrt_result_t;