Monado OpenXR Runtime
d3d_d3d12_allocator.hpp
Go to the documentation of this file.
1// Copyright 2020-2024, 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 * @author Korcan Hussein <korcan.hussein@collabora.com>
9 * @ingroup aux_d3d
10 */
11
12#pragma once
13
14#include "xrt/xrt_compositor.h"
15
16#include <Unknwn.h>
17#include <d3d12.h>
18#include <wil/com.h>
19#include <wil/resource.h>
20
21#include <cstdint>
22#include <vector>
23
24
25namespace xrt::auxiliary::d3d::d3d12 {
26
27/**
28 * Allocate images (ID3D12Resource) that have a corresponding native handle.
29 *
30 * @param device A D3D12 device to allocate with.
31 * @param xsci Swapchain create info: note that the format is assumed to be a DXGI_FORMAT (conversion to typeless is
32 * automatic)
33 * @param image_count The number of images to create.
34 * @param keyed_mutex Whether to create images with a shared "keyed mutex" as well
35 * @param[out] out_images A vector that will be cleared and populated with the images.
36 * @param[out] out_handles A vector that will be cleared and populated with the corresponding native handles.
37 * @param[out] out_image_mem_size The image memory allocation size in bytes
38 *
39 * @return xrt_result_t, one of:
40 * - @ref XRT_SUCCESS
41 * - @ref XRT_ERROR_ALLOCATION
42 * - @ref XRT_ERROR_SWAPCHAIN_FORMAT_UNSUPPORTED
43 * - @ref XRT_ERROR_SWAPCHAIN_FLAG_VALID_BUT_UNSUPPORTED
44 * - @ref XRT_ERROR_D3D12
45 */
47allocateSharedImages(ID3D12Device &device,
48 const xrt_swapchain_create_info &xsci,
49 size_t image_count,
50 std::vector<wil::com_ptr<ID3D12Resource>> &out_images,
51 std::vector<wil::unique_handle> &out_handles,
52 std::uint64_t &out_image_mem_size);
53
54}; // 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:69
enum xrt_result xrt_result_t
Result type used across Monado.
Swapchain creation info.
Definition: xrt_compositor.h:876
Header declaring XRT graphics interfaces.