22#include <wil/resource.h>
23#include <wil/result_macros.h>
32namespace xrt::compositor::client {
34using unique_swapchain_ref =
36 xrt::deleters::reference_deleter<struct xrt_swapchain, xrt_swapchain_reference>>;
52 std::vector<wil::unique_handle> const &handles,
53 const struct xrt_swapchain_create_info &vkinfo,
54 const std::uint64_t image_mem_size,
55 bool use_dedicated_allocation,
56 unique_swapchain_ref &out_xsc)
58 uint32_t image_count =
static_cast<uint32_t
>(handles.size());
60 std::vector<xrt_image_native> xins;
61 xins.reserve(image_count);
64 std::vector<wil::unique_handle> handlesForImport;
65 handlesForImport.reserve(image_count);
67 for (
const wil::unique_handle &handle : handles) {
68 wil::unique_handle duped{u_graphics_buffer_ref(handle.get())};
71 xin.size = image_mem_size;
72 xin.use_dedicated_allocation = use_dedicated_allocation;
74 handlesForImport.emplace_back(std::move(duped));
75 xins.emplace_back(xin);
80 xrt_result_t xret = xrt_comp_import_swapchain(&(xcn.base), &vkinfo, xins.data(), image_count, &xsc);
88 for (
auto &h : handlesForImport) {
107 std::vector<HANDLE>
const &handles,
109 bool use_dedicated_allocation,
110 unique_swapchain_ref &out_xsc)
112 uint32_t image_count =
static_cast<uint32_t
>(handles.size());
114 std::vector<xrt_image_native> xins;
115 xins.reserve(image_count);
117 for (HANDLE handle : handles) {
121 xin.use_dedicated_allocation = use_dedicated_allocation;
122 xin.is_dxgi_handle =
true;
124 xins.emplace_back(xin);
129 xrt_result_t xret = xrt_comp_import_swapchain(&(xcn.
base), &vkinfo, xins.data(), image_count, &xsc);
147 static constexpr uint64_t kKeyedMutexKey = 0;
162 init(
const std::vector<wil::com_ptr<ID3D11Texture2D1>> &images)
noexcept;
185 std::vector<wil::com_ptr<IDXGIKeyedMutex>> keyed_mutex_collection;
187 std::vector<bool> keyed_mutex_acquired;
A collection of DXGIKeyedMutex objects, one for each swapchain image in a swapchain.
Definition: comp_d3d_common.hpp:144
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, const std::uint64_t image_mem_size, 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:51
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:106
u_logging_level
Logging level enum.
Definition: u_logging.h:43
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.