21#include <wil/resource.h>
22#include <wil/result_macros.h>
31namespace xrt::compositor::client {
33using unique_swapchain_ref =
35 xrt::deleters::reference_deleter<struct xrt_swapchain, xrt_swapchain_reference>>;
50 std::vector<wil::unique_handle> const &handles,
51 const struct xrt_swapchain_create_info &vkinfo,
52 bool use_dedicated_allocation,
53 unique_swapchain_ref &out_xsc)
55 uint32_t image_count =
static_cast<uint32_t
>(handles.size());
57 std::vector<xrt_image_native> xins;
58 xins.reserve(image_count);
61 std::vector<wil::unique_handle> handlesForImport;
62 handlesForImport.reserve(image_count);
64 for (
const wil::unique_handle &handle : handles) {
65 wil::unique_handle duped{u_graphics_buffer_ref(handle.get())};
69 xin.use_dedicated_allocation = use_dedicated_allocation;
71 handlesForImport.emplace_back(std::move(duped));
72 xins.emplace_back(xin);
77 xrt_result_t xret = xrt_comp_import_swapchain(&(xcn.base), &vkinfo, xins.data(), image_count, &xsc);
85 for (
auto &h : handlesForImport) {
104 std::vector<HANDLE>
const &handles,
106 bool use_dedicated_allocation,
107 unique_swapchain_ref &out_xsc)
109 uint32_t image_count =
static_cast<uint32_t
>(handles.size());
111 std::vector<xrt_image_native> xins;
112 xins.reserve(image_count);
114 for (HANDLE handle : handles) {
118 xin.use_dedicated_allocation = use_dedicated_allocation;
119 xin.is_dxgi_handle =
true;
121 xins.emplace_back(xin);
126 xrt_result_t xret = xrt_comp_import_swapchain(&(xcn.
base), &vkinfo, xins.data(), image_count, &xsc);
144 static constexpr uint64_t kKeyedMutexKey = 0;
159 init(
const std::vector<wil::com_ptr<ID3D11Texture2D1>> &images)
noexcept;
182 std::vector<wil::com_ptr<IDXGIKeyedMutex>> keyed_mutex_collection;
184 std::vector<bool> keyed_mutex_acquired;
A collection of DXGIKeyedMutex objects, one for each swapchain image in a swapchain.
Definition: comp_d3d_common.hpp:141
xrt_result_t init(const std::vector< wil::com_ptr< ID3D11Texture2D1 > > &images) noexcept
Make the keyed mutex vector before starting to use the images.
Definition: comp_d3d_common.cpp:39
xrt_result_t releaseKeyedMutex(uint32_t index) noexcept
Release the keyed mutex.
Definition: comp_d3d_common.cpp:105
KeyedMutexCollection(u_logging_level log_level) noexcept
Construct a new Keyed Mutex Collection object.
Definition: comp_d3d_common.cpp:36
xrt_result_t waitKeyedMutex(uint32_t index, uint64_t timeout_ns) noexcept
Wait for acquisition of the keyed mutex.
Definition: comp_d3d_common.cpp:62
static xrt_result_t importFromHandleDuplicates(xrt_compositor_native &xcn, std::vector< wil::unique_handle > const &handles, const struct xrt_swapchain_create_info &vkinfo, bool use_dedicated_allocation, unique_swapchain_ref &out_xsc)
Import the provided handles into a native compositor, without consuming them.
Definition: comp_d3d_common.hpp:49
static xrt_result_t importFromDxgiHandles(xrt_compositor_native &xcn, std::vector< HANDLE > const &handles, const struct xrt_swapchain_create_info &vkinfo, bool use_dedicated_allocation, unique_swapchain_ref &out_xsc)
Import the provided handles into a native compositor.
Definition: comp_d3d_common.hpp:103
u_logging_level
Logging level enum.
Definition: u_logging.h:40
enum xrt_result xrt_result_t
Result type used across Monado.
@ XRT_SUCCESS
The operation succeeded.
Definition: xrt_results.h:26
Main compositor server interface.
Definition: xrt_compositor.h:2224
struct xrt_compositor base
Base.
Definition: xrt_compositor.h:2226
A single image of a swapchain based on native buffer handles.
Definition: xrt_compositor.h:2150
xrt_graphics_buffer_handle_t handle
Native buffer handle.
Definition: xrt_compositor.h:2154
Swapchain creation info.
Definition: xrt_compositor.h:876
Common swapchain interface/base.
Definition: xrt_compositor.h:536
Functions for dealing generically with various handle types defined in xrt_handles....
Basic logging functionality.
Header declaring XRT graphics interfaces.
Generic unique_ptr deleters for Monado types.
Internal result type for XRT.