Monado OpenXR Runtime
d3d_d3d12_allocator.cpp File Reference

D3D12 backed image buffer allocator. More...

#include "d3d_d3d12_allocator.h"
#include "d3d_d3d12_allocator.hpp"
#include "d3d_d3d12_bits.h"
#include "d3d_dxgi_formats.h"
#include "util/u_misc.h"
#include "util/u_logging.h"
#include "util/u_debug.h"
#include "util/u_handles.h"
#include "xrt/xrt_windows.h"
#include <Unknwn.h>
#include <d3d12.h>
#include <wil/com.h>
#include <wil/result.h>
#include <memory>
Include dependency graph for d3d_d3d12_allocator.cpp:

Data Structures

struct  d3d12_allocator
 

Macros

#define DEFAULT_CATCH(...)
 
#define D3DA_TRACE(...)   U_LOG_IFL_T(debug_get_log_option_d3d12_log(), __VA_ARGS__)
 
#define D3DA_DEBUG(...)   U_LOG_IFL_D(debug_get_log_option_d3d12_log(), __VA_ARGS__)
 
#define D3DA_INFO(...)   U_LOG_IFL_I(debug_get_log_option_d3d12_log(), __VA_ARGS__)
 
#define D3DA_WARN(...)   U_LOG_IFL_W(debug_get_log_option_d3d12_log(), __VA_ARGS__)
 
#define D3DA_ERROR(...)   U_LOG_IFL_E(debug_get_log_option_d3d12_log(), __VA_ARGS__)
 

Functions

static wil::unique_handle xrt::auxiliary::d3d::d3d12::createSharedHandle (ID3D12Device &device, const wil::com_ptr< ID3D12Resource > &image)
 
xrt_result_t xrt::auxiliary::d3d::d3d12::allocateSharedImages (ID3D12Device &device, const xrt_swapchain_create_info &xsci, size_t image_count, std::vector< wil::com_ptr< ID3D12Resource > > &out_images, std::vector< wil::unique_handle > &out_handles, std::uint64_t &out_image_mem_size)
 Allocate images (ID3D12Resource) that have a corresponding native handle. More...
 
static xrt_result_t d3d12_images_allocate (struct xrt_image_native_allocator *xina, const struct xrt_swapchain_create_info *xsci, size_t image_count, struct xrt_image_native *out_images)
 
static xrt_result_t d3d12_images_free (struct xrt_image_native_allocator *xina, size_t image_count, struct xrt_image_native *images)
 
static void d3d12_destroy (struct xrt_image_native_allocator *xina)
 
struct xrt_image_native_allocatord3d12_allocator_create (ID3D11Device *device)
 

Detailed Description

Macro Definition Documentation

◆ DEFAULT_CATCH

#define DEFAULT_CATCH (   ...)
Value:
catch (wil::ResultException const &e) \
{ \
U_LOG_E("Caught exception: %s", e.what()); \
return __VA_ARGS__; \
} \
catch (std::exception const &e) \
{ \
U_LOG_E("Caught exception: %s", e.what()); \
return __VA_ARGS__; \
} \
catch (...) \
{ \
U_LOG_E("Caught exception"); \
return __VA_ARGS__; \
}

Function Documentation

◆ allocateSharedImages()

xrt_result_t xrt::auxiliary::d3d::d3d12::allocateSharedImages ( ID3D12Device &  device,
const xrt_swapchain_create_info xsci,
size_t  image_count,
std::vector< wil::com_ptr< ID3D12Resource > > &  out_images,
std::vector< wil::unique_handle > &  out_handles,
std::uint64_t &  out_image_mem_size 
)

Allocate images (ID3D12Resource) that have a corresponding native handle.

Parameters
deviceA D3D12 device to allocate with.
xsciSwapchain create info: note that the format is assumed to be a DXGI_FORMAT (conversion to typeless is automatic)
image_countThe number of images to create.
keyed_mutexWhether to create images with a shared "keyed mutex" as well
[out]out_imagesA vector that will be cleared and populated with the images.
[out]out_handlesA vector that will be cleared and populated with the corresponding native handles.
[out]out_image_mem_sizeThe image memory allocation size in bytes
Returns
xrt_result_t, one of:

References XRT_ERROR_SWAPCHAIN_FLAG_VALID_BUT_UNSUPPORTED, XRT_SWAPCHAIN_CREATE_PROTECTED_CONTENT, and XRT_SWAPCHAIN_CREATE_STATIC_IMAGE.