Debian Codegraph @

modules/openxr/extensions/platform/openxr_d3d12_extension.h

raw symbols SCIP
1 /**************************************************************************/
2 /* openxr_d3d12_extension.h */
3 /**************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* https://godotengine.org */
7 /**************************************************************************/
8 /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9 /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10 /* */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the */
13 /* "Software"), to deal in the Software without restriction, including */
14 /* without limitation the rights to use, copy, modify, merge, publish, */
15 /* distribute, sublicense, and/or sell copies of the Software, and to */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions: */
18 /* */
19 /* The above copyright notice and this permission notice shall be */
20 /* included in all copies or substantial portions of the Software. */
21 /* */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29 /**************************************************************************/
30
31 #pragma once
32
33 #ifdef D3D12_ENABLED
34
35 #include "../../openxr_api.h"
36 #include "../../util.h"
37 #include "../openxr_extension_wrapper.h"
38
39 #include "core/templates/vector.h"
40 #include "drivers/d3d12/d3d12_hooks.h"
41
42 // Always include this as late as possible.
43 #include "../../openxr_platform_inc.h"
44
45 class OpenXRD3D12Extension : public OpenXRGraphicsExtensionWrapper, D3D12Hooks {
46 public:
47 virtual HashMap<String, bool *> get_requested_extensions(XrVersion p_version) override;
48
49 virtual void on_instance_created(const XrInstance p_instance) override;
50 virtual void *set_session_create_and_get_next_pointer(void *p_next_pointer) override;
51
52 virtual D3D_FEATURE_LEVEL get_feature_level() const override final;
53 virtual LUID get_adapter_luid() const override final;
54 virtual void set_device(ID3D12Device *p_device) override final;
55 virtual void set_command_queue(ID3D12CommandQueue *p_queue) override final;
56 virtual void cleanup_device() override final;
57
58 virtual void get_usable_swapchain_formats(Vector<int64_t> &p_usable_swap_chains) override;
59 virtual void get_usable_depth_formats(Vector<int64_t> &p_usable_swap_chains) override;
60 virtual String get_swapchain_format_name(int64_t p_swapchain_format) const override;
61 virtual bool get_swapchain_image_data(XrSwapchain p_swapchain, int64_t p_swapchain_format, uint32_t p_width, uint32_t p_height, uint32_t p_sample_count, uint32_t p_array_size, void **r_swapchain_graphics_data) override;
62 virtual void cleanup_swapchain_graphics_data(void **p_swapchain_graphics_data) override;
63 virtual bool create_projection_fov(const XrFovf p_fov, double p_z_near, double p_z_far, Projection &r_camera_matrix) override;
64 virtual RID get_texture(void *p_swapchain_graphics_data, int p_image_index) override;
65 virtual RID get_density_map(void *p_swapchain_graphics_data, int p_image_index) override { return RID(); }
66
67 private:
68 static OpenXRD3D12Extension *singleton;
69
70 static XrGraphicsBindingD3D12KHR graphics_binding_d3d12;
71
72 struct SwapchainGraphicsData {
73 bool is_multiview;
74 Vector<RID> texture_rids;
75 };
76
77 EXT_PROTO_XRRESULT_FUNC3(xrGetD3D12GraphicsRequirementsKHR, (XrInstance), p_instance, (XrSystemId), p_system_id, (XrGraphicsRequirementsD3D12KHR *), p_graphics_requirements)
78 EXT_PROTO_XRRESULT_FUNC4(xrEnumerateSwapchainImages, (XrSwapchain), p_swapchain, (uint32_t), p_image_capacity_input, (uint32_t *), p_image_count_output, (XrSwapchainImageBaseHeader *), p_images)
79
80 Microsoft::WRL::ComPtr<ID3D12Device> graphics_device;
81 Microsoft::WRL::ComPtr<ID3D12CommandQueue> command_queue;
82 };
83
84 #endif // D3D12_ENABLED