Monado OpenXR Runtime
d3d_d3d12_allocator.hpp
Go to the documentation of this file.
1// Copyright 2020-2023, Collabora, Ltd.
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief Higher-level D3D12-backed image buffer allocation routine.
6 * @author Rylie Pavlik <rylie.pavlik@collabora.com>
7 * @author Fernando Velazquez Innella <finnella@magicleap.com>
8 * @ingroup aux_d3d
9 */
10
11#pragma once
12
13#include "xrt/xrt_compositor.h"
14
15#include <Unknwn.h>
16#include <d3d12.h>
17#include <wil/com.h>
18#include <wil/resource.h>
19
20#include <vector>
21
22
23namespace xrt::auxiliary::d3d::d3d12 {
24
25/**
26 * Allocate images (ID3D12Resource) that have a corresponding native handle.
27 *
28 * @param device A D3D12 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_D3D12
42 */
44allocateSharedImages(ID3D12Device &device,
45 const xrt_swapchain_create_info &xsci,
46 size_t image_count,
47 std::vector<wil::com_ptr<ID3D12Resource>> &out_images,
48 std::vector<wil::unique_handle> &out_handles);
49
50}; // namespace xrt::auxiliary::d3d::d3d12
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.