Monado OpenXR Runtime
d3d_d3d11_allocator.hpp
Go to the documentation of this file.
1 // Copyright 2020-2022, Collabora, Ltd.
2 // SPDX-License-Identifier: BSL-1.0
3 /*!
4  * @file
5  * @brief Higher-level D3D11-backed image buffer allocation routine.
6  * @author Rylie Pavlik <rylie.pavlik@collabora.com>
7  * @ingroup aux_d3d
8  */
9 
10 #pragma once
11 
12 #include "xrt/xrt_compositor.h"
13 
14 #include <Unknwn.h>
15 #include <d3d11_3.h>
16 #include <d3d11_4.h>
17 #include <wil/com.h>
18 #include <wil/resource.h>
19 
20 #include <vector>
21 
22 
23 namespace xrt::auxiliary::d3d::d3d11 {
24 
25 /**
26  * Allocate images (ID3D11Texture2D1) that have a corresponding native handle.
27  *
28  * @param device A D3D device to allocate with.
29  * @param xsci Swapchain create info: note that the format is assumed to be a DXGI_FORMAT (conversion to typeless is
30  * automatic)
31  * @param image_count The number of images to create.
32  * @param keyed_mutex Whether to create images with a shared "keyed mutex" as well
33  * @param[out] out_images A vector that will be cleared and populated with the images.
34  * @param[out] out_handles A vector that will be cleared and populated with the corresponding native handles.
35  *
36  * @return xrt_result_t, one of:
37  * - @ref XRT_SUCCESS
38  * - @ref XRT_ERROR_ALLOCATION
39  * - @ref XRT_ERROR_SWAPCHAIN_FORMAT_UNSUPPORTED
40  * - @ref XRT_ERROR_SWAPCHAIN_FLAG_VALID_BUT_UNSUPPORTED
41  * - @ref XRT_ERROR_D3D11
42  */
44 allocateSharedImages(ID3D11Device5 &device,
45  const xrt_swapchain_create_info &xsci,
46  size_t image_count,
47  bool keyed_mutex,
48  std::vector<wil::com_ptr<ID3D11Texture2D1>> &out_images,
49  std::vector<HANDLE> &out_handles);
50 
51 }; // namespace xrt::auxiliary::d3d::d3d11
xrt_result_t 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.
Definition: d3d_d3d11_allocator.cpp:70
enum xrt_result xrt_result_t
Result type used across Monado.
Swapchain creation info.
Definition: xrt_compositor.h:876
Header declaring XRT graphics interfaces.