Monado OpenXR Runtime
d3d_d3d11_allocator.cpp File Reference

D3D11 backed image buffer allocator. More...

#include "d3d_d3d11_allocator.h"
#include "d3d_d3d11_allocator.hpp"
#include "d3d_d3d11_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 <d3d11_3.h>
#include <wil/com.h>
#include <wil/result.h>
#include <memory>
Include dependency graph for d3d_d3d11_allocator.cpp:

Data Structures

struct  d3d11_allocator
 

Macros

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

Functions

HANDLE xrt::auxiliary::d3d::d3d11::getSharedHandle (const wil::com_ptr< ID3D11Texture2D1 > &image)
 
xrt_result_t xrt::auxiliary::d3d::d3d11::allocateSharedImages (ID3D11Device5 &device, const xrt_swapchain_create_info &xsci, size_t image_count, bool keyed_mutex, std::vector< wil::com_ptr< ID3D11Texture2D1 > > &out_images, std::vector< HANDLE > &out_handles)
 Allocate images (ID3D11Texture2D1) that have a corresponding native handle. More...
 
static xrt_result_t d3d11_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 d3d11_images_free (struct xrt_image_native_allocator *xina, size_t image_count, struct xrt_image_native *images)
 
static void d3d11_destroy (struct xrt_image_native_allocator *xina)
 
struct xrt_image_native_allocatord3d11_allocator_create (ID3D11Device *device)
 Create a XINA that allocates D3D11 textures. More...
 

Detailed Description

D3D11 backed image buffer allocator.

Author
Rylie Pavlik rylie.nosp@m..pav.nosp@m.lik@c.nosp@m.olla.nosp@m.bora..nosp@m.com
Fernando Velazquez Innella finne.nosp@m.lla@.nosp@m.magic.nosp@m.leap.nosp@m..com

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::d3d11::allocateSharedImages ( ID3D11Device5 &  device,
const xrt_swapchain_create_info xsci,
size_t  image_count,
bool  keyed_mutex,
std::vector< wil::com_ptr< ID3D11Texture2D1 > > &  out_images,
std::vector< HANDLE > &  out_handles 
)

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

Parameters
deviceA D3D 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.
Returns
xrt_result_t, one of:

References xrt::auxiliary::d3d::d3d11::allocateSharedImages(), XRT_ERROR_SWAPCHAIN_FLAG_VALID_BUT_UNSUPPORTED, XRT_SWAPCHAIN_CREATE_PROTECTED_CONTENT, and XRT_SWAPCHAIN_CREATE_STATIC_IMAGE.

Referenced by xrt::auxiliary::d3d::d3d11::allocateSharedImages().

◆ d3d11_allocator_create()

struct xrt_image_native_allocator * d3d11_allocator_create ( ID3D11Device *  device)

Create a XINA that allocates D3D11 textures.

Parameters
deviceA device to allocate the textures with. Be sure it will not be used from other threads while this allocator allocates.
Returns
struct xrt_image_native_allocator*

References U_ZERO.