Monado OpenXR Runtime
d3d_d3d12_helpers.cpp File Reference

Misc D3D12 helper routines. More...

#include "d3d_d3d12_helpers.hpp"
#include "d3d_d3d12_bits.h"
#include "util/u_logging.h"
#include <d3d12.h>
#include <wil/com.h>
#include <wil/result.h>
#include <vector>
#include <stdexcept>
Include dependency graph for d3d_d3d12_helpers.cpp:

Functions

wil::com_ptr< ID3D12Device > xrt::auxiliary::d3d::d3d12::createDevice (const wil::com_ptr< IDXGIAdapter > &adapter=nullptr, u_logging_level log_level=U_LOGGING_INFO)
 Create a D3D12 Device object. More...
 
HRESULT xrt::auxiliary::d3d::d3d12::createCommandLists (ID3D12Device &device, ID3D12CommandAllocator &command_allocator, ID3D12Resource &resource, enum xrt_swapchain_usage_bits bits, wil::com_ptr< ID3D12CommandList > out_acquire_command_list, wil::com_ptr< ID3D12CommandList > out_release_command_list)
 Create command lists for a resource transitioning to/from app control. More...
 
HRESULT xrt::auxiliary::d3d::d3d12::createCommandListImageCopy (ID3D12Device &device, ID3D12CommandAllocator &command_allocator, ID3D12Resource &resource_src, ID3D12Resource &resource_dst, D3D12_RESOURCE_STATES src_resource_state, D3D12_RESOURCE_STATES dst_resource_state, wil::com_ptr< ID3D12CommandList > &out_copy_command_list)
 Create a command list for image resource copying. More...
 
wil::com_ptr< ID3D12Resource > xrt::auxiliary::d3d::d3d12::importImage (ID3D12Device &device, HANDLE h)
 Imports an image into D3D12 from a handle. More...
 
wil::com_ptr< ID3D12Fence1 > xrt::auxiliary::d3d::d3d12::importFence (ID3D12Device &device, HANDLE h)
 Imports a fence into D3D12 from a handle. More...
 

Detailed Description

Misc D3D12 helper routines.

Author
Rylie Pavlik rylie.nosp@m..pav.nosp@m.lik@c.nosp@m.olla.nosp@m.bora..nosp@m.com

Function Documentation

◆ createCommandListImageCopy()

HRESULT xrt::auxiliary::d3d::d3d12::createCommandListImageCopy ( ID3D12Device &  device,
ID3D12CommandAllocator &  command_allocator,
ID3D12Resource &  resource_src,
ID3D12Resource &  resource_dst,
D3D12_RESOURCE_STATES  src_resource_state,
D3D12_RESOURCE_STATES  dst_resource_state,
wil::com_ptr< ID3D12CommandList > &  out_copy_command_list 
)

Create a command list for image resource copying.

Parameters
deviceD3D12 device
command_allocator
resource_srcSource image
resource_dstDestination image
src_resource_state
dst_resource_state
[out]out_copy_command_listCommand list output
Returns
HRESULT

References xrt::auxiliary::d3d::d3d12::createCommandListImageCopy().

Referenced by xrt::auxiliary::d3d::d3d12::createCommandListImageCopy().

◆ createCommandLists()

HRESULT xrt::auxiliary::d3d::d3d12::createCommandLists ( ID3D12Device &  device,
ID3D12CommandAllocator &  command_allocator,
ID3D12Resource &  resource,
enum xrt_swapchain_usage_bits  bits,
wil::com_ptr< ID3D12CommandList >  out_acquire_command_list,
wil::com_ptr< ID3D12CommandList >  out_release_command_list 
)

Create command lists for a resource transitioning to/from app control.

Parameters
deviceD3D12 device
command_allocator
resourceimage
bitsSwapchain usage bits
[out]out_acquire_command_listCommand list to populate for xrAcquireSwapchainImage
[out]out_release_command_listCommand list to populate for xrReleaseSwapchainImage
Returns
HRESULT
Todo:
do we need to set queue access somehow?
Todo:
No idea if this is right, might depend on whether it's the compute or graphics compositor!

References xrt::auxiliary::d3d::d3d12::createCommandLists().

Referenced by xrt::auxiliary::d3d::d3d12::createCommandLists().

◆ createDevice()

wil::com_ptr< ID3D12Device > xrt::auxiliary::d3d::d3d12::createDevice ( const wil::com_ptr< IDXGIAdapter > &  adapter = nullptr,
u_logging_level  log_level = U_LOGGING_INFO 
)

Create a D3D12 Device object.

Parameters
adapteroptional: adapter to create on.
log_levelThe level to compare against for internal log messages
Exceptions
wil::ResultExceptionin case of error
Returns
wil::com_ptr<ID3D12Device>

◆ importFence()

wil::com_ptr< ID3D12Fence1 > xrt::auxiliary::d3d::d3d12::importFence ( ID3D12Device &  device,
HANDLE  h 
)

Imports a fence into D3D12 from a handle.

Parameters
deviceD3D12 device
hhandle corresponding to a shared fence
Exceptions
std::logic_errorif the handle is invalid, wil exceptions if the operation failed.

References xrt::auxiliary::d3d::d3d12::importFence().

Referenced by xrt::auxiliary::d3d::d3d12::importFence().

◆ importImage()

wil::com_ptr< ID3D12Resource > xrt::auxiliary::d3d::d3d12::importImage ( ID3D12Device &  device,
HANDLE  h 
)

Imports an image into D3D12 from a handle.

Parameters
deviceD3D12 device
hhandle corresponding to a shared image
Exceptions
std::logic_errorif the handle is invalid, wil exceptions if the operation failed.

References xrt::auxiliary::d3d::d3d12::importImage().

Referenced by xrt::auxiliary::d3d::d3d12::importImage().