xrt: Define D3D12 interface

This commit is contained in:
Ryan Pavlik 2022-05-24 17:04:01 -05:00
parent 189be3300c
commit 5c24b8e637
5 changed files with 101 additions and 4 deletions

View file

@ -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;
}

View file

@ -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.

View file

@ -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

View file

@ -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

View file

@ -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;