evan 2026.1.4
Evan
Loading...
Searching...
No Matches
XrDeviceBackend.hpp
1/*
2** ETIB PROJECT, 2026
3** evan
4** File description:
5** XrBackend
6*/
7
8#pragma once
9
10#include "evan/openxr/IXrPlatform.hpp"
11#include "evan/openxr/OpenXrOptions.hpp"
12#include "evan/openxr/XrManageActions.hpp"
13
14#include "evan/ADeviceBackend.hpp"
15
16#include <cstring>
17#include <iostream>
18#include <openxr/openxr.h>
19#include <openxr/openxr_platform.h>
20#include <vector>
21
22#define LEFT_HAND_INDEX 0
23#define RIGHT_HAND_INDEX 1
24
25namespace evan
26{
39 {
40 public:
53
54 ~XrDeviceBackend() override;
55
91
111
138
154
167 uint32_t countSwapchainFormats() const override;
168
185 std::vector<int64_t> enumerateSwapchainFormats(
186 uint32_t swapchainFormatCount) const override;
187
206 std::vector<XrViewConfigurationView>
208
228 std::vector<std::shared_ptr<utility::event::Event>> pollActions();
229
237 {
238 return _session;
239 }
240
252 {
253 return _viewConfigurationType;
254 }
255
264 {
265 return _openXrOptions;
266 }
267
275 std::vector<XrViewConfigurationType>
277
293 const std::vector<XrViewConfigurationType> &configurations);
294
303
312
320
329
343 std::unique_ptr<XrManageActions> _actionManager;
344
352 bool _sessionRunning = false;
353
361
369 const static size_t _handCount = 2;
370
378 std::array<XrPath, _handCount> _handActionSubactionPath;
379
380 protected:
400 const std::string &appName,
401 Version &appVersion) override;
402
419 void createLogicalDevice() override;
420
438 void pickPhysicalDevice() override;
439
453
470 std::vector<VkExtensionProperties> getInstanceExtensions() const;
471
472 private:
495 void createXrInstance(const IPlatform &platform);
496
509 void getSystem();
510
520 void createSession();
521
542 std::vector<const char *> getRequiredInstanceExtensions() const;
543
554 std::vector<const char *> getRequiredInstanceExtensionsAndroid();
555
560 XrViewConfigurationType _viewConfigurationType =
562
571 uint32_t _vulkanApiVersion = VK_API_VERSION_1_0;
572
577 OpenXrOptions _openXrOptions;
578 };
579} // namespace evan
Abstract base class for Vulkan device backends.
Represents the context for managing the swapchain in the rendering system.
ASwapchainImage is a class that represents an image in the swapchain of the Evan engine....
Abstract interface for platform-specific functionality.
Definition IPlatform.hpp:36
Represents a software version using major, minor, and patch numbers.
Definition Version.hpp:35
The XrDeviceBackend class is responsible for managing the OpenXR device backend, including instance c...
void createLogicalDevice() override
Creates a logical device for the OpenXR session.
std::vector< int64_t > enumerateSwapchainFormats(uint32_t swapchainFormatCount) const override
Enumerates the available swapchain formats for the Vulkan device.
uint32_t countSwapchainFormats() const override
Count the number of available swapchain formats for the Vulkan device.
std::array< XrPath, _handCount > _handActionSubactionPath
const OpenXrOptions & getOpenXrOptions() const
Retrieves the user-configurable OpenXR options.
std::vector< VkExtensionProperties > getInstanceExtensions() const
XrSession getSession() const
Retrieves the OpenXR session handle.
void createVisualizedSpace()
Creates a visualized space for the XR session.
std::vector< std::shared_ptr< utility::event::Event > > pollActions()
Polls input actions for the OpenXR session.
Error postprocessFrame(ASwapchainContext &swapchainContext) override
Postprocesses a frame and submits it to the OpenXR compositor.
std::vector< XrViewConfigurationType > enumerateViewConfigurationTypes() const
Enumerates the primary view configuration types supported by the OpenXR system.
void createInstance(const IPlatform &platform, const std::string &appName, Version &appVersion) override
Creates an OpenXR instance with the specified application name and version.
QueueFamilyIndices findQueueFamilies() override
Finds the queue family indices for graphics and presentation operations.
static const size_t _handCount
Error processFrame(VkPresentInfoKHR presentInfo, ASwapchainImage &swapchainImage) override
Processes a frame by releasing the OpenXR swapchain image.
static XrViewConfigurationType selectViewConfigurationType(const std::vector< XrViewConfigurationType > &configurations)
Selects a primary view configuration type from the ones supported by the runtime.
XrViewConfigurationType getViewConfigurationType() const
Retrieves the primary view configuration type selected for this OpenXR system.
Error preprocessFrame(ASwapchainContext &swapchainContext) override
Prepares the current frame for rendering in an OpenXR session.
std::unique_ptr< XrManageActions > _actionManager
The action manager for handling input actions in the OpenXR session.
std::vector< XrViewConfigurationView > enumerateViewConfigurations() const
Enumerates the available view configurations for the OpenXR system.
void pickPhysicalDevice() override
Picks a physical device that is compatible with the OpenXR session.
User-configurable options for the OpenXR backend.
A structure to represent Vulkan queue family indices.
Small result wrapper used by helpers that must return both a status and a value (e....
Definition Error.hpp:89