-
Notifications
You must be signed in to change notification settings - Fork 259
/
Copy pathgraphicsplugin.h
49 lines (37 loc) · 2.26 KB
/
graphicsplugin.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright (c) 2017-2024, The Khronos Group Inc.
//
// SPDX-License-Identifier: Apache-2.0
#pragma once
struct Cube {
XrPosef Pose;
XrVector3f Scale;
};
// Wraps a graphics API so the main openxr program can be graphics API-independent.
struct IGraphicsPlugin {
virtual ~IGraphicsPlugin() = default;
// OpenXR extensions required by this graphics API.
virtual std::vector<std::string> GetInstanceExtensions() const = 0;
// Create an instance of this graphics api for the provided instance and systemId.
virtual void InitializeDevice(XrInstance instance, XrSystemId systemId) = 0;
// Select the preferred swapchain format from the list of available formats.
virtual int64_t SelectColorSwapchainFormat(const std::vector<int64_t>& runtimeFormats) const = 0;
// Get the graphics binding header for session creation.
virtual const XrBaseInStructure* GetGraphicsBinding() const = 0;
// Allocate space for the swapchain image structures. These are different for each graphics API. The returned
// pointers are valid for the lifetime of the graphics plugin.
virtual std::vector<XrSwapchainImageBaseHeader*> AllocateSwapchainImageStructs(
uint32_t capacity, const XrSwapchainCreateInfo& swapchainCreateInfo) = 0;
// Render to a swapchain image for a projection view.
virtual void RenderView(const XrCompositionLayerProjectionView& layerView, const XrSwapchainImageBaseHeader* swapchainImage,
int64_t swapchainFormat, const std::vector<Cube>& cubes) = 0;
// Get recommended number of sub-data element samples in view (recommendedSwapchainSampleCount)
// if supported by the graphics plugin. A supported value otherwise.
virtual uint32_t GetSupportedSwapchainSampleCount(const XrViewConfigurationView& view) {
return view.recommendedSwapchainSampleCount;
}
// Perform required steps after updating Options
virtual void UpdateOptions(const std::shared_ptr<struct Options>& options) = 0;
};
// Create a graphics plugin for the graphics API specified in the options.
std::shared_ptr<IGraphicsPlugin> CreateGraphicsPlugin(const std::shared_ptr<struct Options>& options,
std::shared_ptr<struct IPlatformPlugin> platformPlugin);