Monado OpenXR Runtime
d3d_d3d11_fence.cpp File Reference

D3D11-backed fence (timeline semaphore) creation routine. More...

#include "d3d_d3d11_fence.hpp"
#include "util/u_misc.h"
#include "util/u_logging.h"
#include "util/u_debug.h"
#include "util/u_handles.h"
#include "util/u_time.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_fence.cpp:

Macros

#define DEFAULT_CATCH(...)
 

Functions

xrt_result_t xrt::auxiliary::d3d::d3d11::createSharedFence (ID3D11Device5 &device, bool share_cross_adapter, xrt_graphics_sync_handle_t *out_handle, wil::com_ptr< ID3D11Fence > &out_d3dfence)
 Allocate a fence (ID3D11Fence) that has a corresponding native handle. More...
 
xrt_result_t xrt::auxiliary::d3d::d3d11::waitOnFenceWithTimeout (wil::com_ptr< ID3D11Fence > fence, wil::unique_event_nothrow &event, uint64_t value, std::chrono::milliseconds timeout_ms)
 Wait for a fence to be signaled with value equal or greater than value within timeout_ns nanoseconds. More...
 

Detailed Description

D3D11-backed fence (timeline semaphore) creation routine.

Author
Rylie Pavlik rylie.nosp@m..pav.nosp@m.lik@c.nosp@m.olla.nosp@m.bora..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

◆ createSharedFence()

xrt_result_t xrt::auxiliary::d3d::d3d11::createSharedFence ( ID3D11Device5 &  device,
bool  share_cross_adapter,
xrt_graphics_sync_handle_t out_handle,
wil::com_ptr< ID3D11Fence > &  out_d3dfence 
)

Allocate a fence (ID3D11Fence) that has a corresponding native handle.

D3D fences are roughly equivalent to Vulkan timeline semaphores.

Parameters
deviceA D3D device to allocate with.
share_cross_adapterTrue if the fence should be shared across adapters, not only across ID3D11Device instances.
[out]out_handleA graphics sync handle to populate
[out]out_d3dfenceA COM pointer to the D3D11 fence to populate
Returns
xrt_result_t, one of:

References xrt::auxiliary::d3d::d3d11::createSharedFence(), and XRT_SUCCESS.

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

◆ waitOnFenceWithTimeout()

xrt_result_t xrt::auxiliary::d3d::d3d11::waitOnFenceWithTimeout ( wil::com_ptr< ID3D11Fence >  fence,
wil::unique_event_nothrow &  event,
uint64_t  value,
std::chrono::milliseconds  timeout_ms 
)

Wait for a fence to be signaled with value equal or greater than value within timeout_ns nanoseconds.

Parameters
fenceThe fence to wait on.
eventAn event to use to wait. Please use a dedicated event for a single thread's calls to this function.
valueThe desired fence value
timeout_msAfter this long, we may return early with XRT_TIMEOUT even before the fence reaches the value.

References xrt::auxiliary::d3d::d3d11::waitOnFenceWithTimeout(), XRT_SUCCESS, and XRT_TIMEOUT.

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