6#include <openxr/openxr.h>
7#include <vulkan/vulkan_core.h>
8#include <vk_mem_alloc.h>
9#include <openxr/openxr_platform.h>
12#include <unordered_map>
46 VkSampler
getOrCreate(VkDevice device, VkSamplerAddressMode addressMode);
49 std::unordered_map<VkSamplerAddressMode, VkSampler>
cache_;
252 VkPhysicalDevice physicalDevice,
253 VkSurfaceKHR surface,
254 uint32_t & outGraphicsIndex,
255 uint32_t & outPresentIndex,
256 uint32_t & outTransferIndex
271 std::optional<std::filesystem::path> customOpenXrRuntimePath =
272 std::optional<std::filesystem::path>()
287 PFN_xrCreateDebugUtilsMessengerEXT xrCreateDebugUtilsMessengerEXT =
nullptr;
288 PFN_xrDestroyDebugUtilsMessengerEXT xrDestroyDebugUtilsMessengerEXT =
nullptr;
290 void createOpenXrDebugMessenger();
352 XrDebugUtilsMessengerEXT xrDebugMessenger = XR_NULL_HANDLE;
const VkQueue & getPresentQueue() const
Gets the present queue.
VkDeviceSize uniformBufferOffsetAlignment
The uniform buffer offset alignment.
const VkPhysicalDevice & getVkPhysicalDevice() const
Gets vulkan physical device.
void logVulkanRequirements()
Logs vulkan requirements.
VkSampleCountFlagBits multisampleCount
Number of multisamples.
std::vector< XrApiLayerProperties > supportedOpenXRApiLayers
The supported open xr API layers.
const VkDevice getVkDevice() const
Gets the vulkan device.
PFN_xrCreateVulkanDeviceKHR xrCreateVulkanDeviceKHR
bool meshShaderSupported_
std::vector< XrExtensionProperties > supportedOpenXRInstanceExtensions
The supported open xr instance extensions.
const VkQueue & getGraphicsQueue() const
Gets draw queue.
SamplerCache & getSamplerCache()
PFN_xrCreateVulkanInstanceKHR xrCreateVulkanInstanceKHR
void createOpenXrInstance(std::optional< std::filesystem::path > customOpenXrRuntimePath=std::optional< std::filesystem::path >())
Queries supported openxr instance extensions, openxr api layers and creates the XrInstance.
ApplicationContext()=default
VkPhysicalDevice vkPhysicalDevice
The vulkan physical device.
struct Engine::Core::ApplicationContext::QueueFamily queueFamily
XrInstance getXrInstance() const
Gets xr instance.
uint32_t getVkGraphicsQueueFamilyIndex() const
Gets the zero-based index of the vulkan draw queue family.
XrInstance xrInstance
The xr instance.
std::vector< VkExtensionProperties > supportedVulkanInstanceExtensions
The supported vulkan instance extensions.
VmaAllocator getVmaAllocator() const
Gets the VMA allocator for memory management.
bool usesDedicatedTransferQueue() const
Check if the transfer queue index is its own, dedicated queue.
const VkQueue & getTransferQueue() const
Gets the transfer queue.
PFN_xrGetVulkanGraphicsDevice2KHR xrGetVulkanGraphicsDevice2KHR
SamplerCache samplerCache_
VkInstance getVkInstance() const
Gets vulkan instance.
void retrieveXrSystemId()
Gets the XrSystemId.
bool isFbColorSpaceSupported() const
bool fbColorSpaceSupported_
bool isMeshShaderSupported() const
VkDeviceSize getUniformBufferOffsetAlignment() const
Gets uniform buffer offset alignment.
void createResources()
creates all openxr and vulkan resources
static void validateFeature(VkBool32 feature, const std::string &errorMessage)
void pickQueueFamilies(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t &outGraphicsIndex, uint32_t &outPresentIndex, uint32_t &outTransferIndex)
gets the device queues needed
void LoadOpenXrExtensionFunctions()
Loads all dynamically loaded xr functions.
void getVulkanInstanceExtensions()
Gets vulkan instance extensions.
VkSampleCountFlagBits getMultisampleCount() const
Gets multisample count.
void createVulkanInstance()
Creates a vulkan instance.
void checkRequiredEnvironmentBlendModeAvailability()
Gets the environment blend mode.
std::vector< const char * > vulkanInstanceExtensions
(Immutable) the vulkan instance extensions which should get enabled
uint32_t getVkTransferQueueFamilyIndex() const
gets the transfer queue family index
XrSystemId getXrSystemId() const
Gets xr system identifier.
void cleanup()
performs the cleanup by removing all vulkan and openxr pointers
VmaAllocator vmaAllocator_
VMA allocator for efficient GPU memory management.
VkInstance vkInstance
The vulkan instance.
void createDevice(VkSurfaceKHR mirrorSurface)
Creates the vulkan device and all necessary components for it.
std::vector< VkExtensionProperties > supportedVulkanDeviceExtensions
The supported vulkan device extensions.
uint32_t getMaxPushConstantsSize() const
Gets max push constants size in bytes.
XrSystemId xrSystemId
Identifier for the xr device. So the identifier for the headset.
uint32_t maxPushConstantsSize
Maximum push constants size in bytes.
~ApplicationContext()=default
const XrViewConfigurationType getXrViewType() const
Gets xr view type which should be stereo for any typical VR application.
PFN_xrGetVulkanGraphicsRequirements2KHR xrGetVulkanGraphicsRequirements2KHR
std::vector< const char * > vulkanDeviceExtensions
(Immutable) the vulkan device extensions
PFN_xrGetVulkanInstanceExtensionsKHR xrGetVulkanInstanceExtensionsKHR
std::unordered_map< VkSamplerAddressMode, VkSampler > cache_
VkSampler getOrCreate(VkDevice device, VkSamplerAddressMode addressMode)
void cleanup(VkDevice device)
Environment(const std::string &message)
Environment(const std::stringstream &message)
Exception(const std::string &message)
MissingVulkanFeature(const std::string &message)
MissingVulkanFeature(const std::stringstream &message)