HoviTron Video Pipeline
VulkanContext.h
Go to the documentation of this file.
1/* ----------------------
2* Copyright 2023 Université Libre de Bruxelles(ULB), Universidad Politécnica de Madrid(UPM), CREAL, Deutsches Zentrum für Luft - und Raumfahrt(DLR)
3
4* Licensed under the Apache License, Version 2.0 (the "License");
5* you may not use this file except in compliance with the License.
6* You may obtain a copy of the License at < http://www.apache.org/licenses/LICENSE-2.0>
7
8* Unless required by applicable law or agreed to in writing, software
9* distributed under the License is distributed on an "AS IS" BASIS,
10* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11* See the License for the specific language governing permissionsand
12* limitations under the License.
13---------------------- */
14
15/*****************************************************************/
21#ifndef RVSVULKAN_CONTEXT_H
22#define RVSVULKAN_CONTEXT_H
23
24#include "commonVulkan.h"
25
26#include<string>
27#include <optional>
28
29
30static std::string AppName = "RVS";
31static std::string EngineName = "RVS_Vulkan";
32
40 std::optional<uint32_t> graphicsFamily;
42 std::optional<uint32_t> presentFamily;
44 std::optional<uint32_t> transferFamily;
46 bool isComplete() {
47 return graphicsFamily.has_value() && presentFamily.has_value() && transferFamily.has_value();
48 }
49};
50
51class Window;
52class WindowAbstract;
60public:
64 void initVulkan();
66 void cleanUp();
68 bool isInitialized();
69
73 vk::Format findSupportedFormat(const std::vector<vk::Format>& candidates, vk::ImageTiling tiling, vk::FormatFeatureFlags features);
75 vk::Format findDepthFormat();
77 bool hasStencilComponent(vk::Format format);
78
81
83 vk::Instance instance;
85 vk::PhysicalDevice physicalDevice;
87 vk::Device device;
89 vk::Queue graphicsQueue;
91 vk::Queue presentQueue;
93 vk::Queue transferQueue;
95 uint32_t queueFamilyIndex=0;
96
99
100#ifdef __ANDROID__
101#ifdef USE_OPENXR
102 VkBool32 debugReportFunction(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType,
103 uint64_t object, size_t, int32_t, const char *pLayerPrefix,
104 #endif const char *pMessage);
105#endif
106
108 inline WindowAbstract* get_window() {return window;};
109private:
111 WindowAbstract* window;
113 bool initialized = false;
115 vk::DebugUtilsMessengerEXT debugMessenger;
116
117
118
120 void createInstance();
122 bool checkValidationLayerSupport();
124 void setupDebugMessenger();
126 void pickPhysicalDevice();
128 int rateDeviceSuitability(vk::PhysicalDevice device);
130 bool checkDeviceExtensionSupport(vk::PhysicalDevice device);
132 void createLogicalDevice();
133
134
135#ifdef __ANDROID__
136#ifdef USE_OPENXR
138 VkDebugReportCallbackEXT debugReport = VK_NULL_HANDLE;
140 void createDebugReport();
142 PFN_vkCreateDebugReportCallbackEXT vkCreateDebugReportCallbackEXT{nullptr};
144 PFN_vkDestroyDebugReportCallbackEXT vkDestroyDebugReportCallbackEXT{nullptr};
145#endif
146#endif
147
148
149
150};
151
152
153
154
155
156#endif
class that manages tasks related to Vulkan context (Vulkan Instance, Vulkan Physical device,...
Definition: VulkanContext.h:59
vk::Format findDepthFormat()
bool hasStencilComponent(vk::Format format)
vk::PhysicalDevice physicalDevice
Definition: VulkanContext.h:85
vk::Instance instance
Definition: VulkanContext.h:83
uint32_t queueFamilyIndex
Definition: VulkanContext.h:95
vk::Queue transferQueue
Definition: VulkanContext.h:93
vk::Format findSupportedFormat(const std::vector< vk::Format > &candidates, vk::ImageTiling tiling, vk::FormatFeatureFlags features)
vk::Device device
Definition: VulkanContext.h:87
uint32_t transferQueueFamilyIndex
Definition: VulkanContext.h:98
vk::Queue presentQueue
Definition: VulkanContext.h:91
WindowAbstract * get_window()
vk::Queue graphicsQueue
Definition: VulkanContext.h:89
bool isIndepFromWindowDimension()
QueueFamilyIndices findQueueFamilies(vk::PhysicalDevice device)
Abstraction of the way of the result is displayed (screen or HMD).
file that contains the common include for the Vulkan part
Struct to encapsulate the indice of the queues families.
Definition: VulkanContext.h:38
std::optional< uint32_t > transferFamily
Definition: VulkanContext.h:44
std::optional< uint32_t > graphicsFamily
Definition: VulkanContext.h:40
std::optional< uint32_t > presentFamily
Definition: VulkanContext.h:42