|
Vulkan Schnee 0.0.1
High-performance rendering engine
|
The application context is the core class which stores the basic openxr and vulkan objects. More...
#include <ApplicationContext.h>
Classes | |
| struct | QueueFamily |
Public Member Functions | |
| ApplicationContext ()=default | |
| ~ApplicationContext ()=default | |
| void | createDevice (VkSurfaceKHR mirrorSurface) |
| Creates the vulkan device and all necessary components for it. | |
| XrInstance | getXrInstance () const |
| Gets xr instance. | |
| XrSystemId | getXrSystemId () const |
| Gets xr system identifier. | |
| VkInstance | getVkInstance () const |
| Gets vulkan instance. | |
| const VkDevice | getVkDevice () const |
| Gets the vulkan device. | |
| const VkQueue & | getPresentQueue () const |
| Gets the present queue. | |
| const VkQueue & | getGraphicsQueue () const |
| Gets draw queue. | |
| const VkQueue & | getTransferQueue () const |
| Gets the transfer queue. | |
| VkSampleCountFlagBits | getMultisampleCount () const |
| Gets multisample count. | |
| const VkPhysicalDevice & | getVkPhysicalDevice () const |
| Gets vulkan physical device. | |
| uint32_t | getVkGraphicsQueueFamilyIndex () const |
| Gets the zero-based index of the vulkan draw queue family. | |
| uint32_t | getVkTransferQueueFamilyIndex () const |
| gets the transfer queue family index | |
| VkDeviceSize | getUniformBufferOffsetAlignment () const |
| Gets uniform buffer offset alignment. | |
| uint32_t | getMaxPushConstantsSize () const |
| Gets max push constants size in bytes. | |
| const XrViewConfigurationType | getXrViewType () const |
| Gets xr view type which should be stereo for any typical VR application. | |
| void | createResources () |
| creates all openxr and vulkan resources | |
| void | cleanup () |
| performs the cleanup by removing all vulkan and openxr pointers | |
| bool | usesDedicatedTransferQueue () const |
| Check if the transfer queue index is its own, dedicated queue. | |
| VmaAllocator | getVmaAllocator () const |
| Gets the VMA allocator for memory management. | |
Private Member Functions | |
| void | pickQueueFamilies (VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t &outGraphicsIndex, uint32_t &outPresentIndex, uint32_t &outTransferIndex) |
| gets the device queues needed | |
| 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. | |
| void | LoadOpenXrExtensionFunctions () |
| Loads all dynamically loaded xr functions. | |
| void | retrieveXrSystemId () |
| Gets the XrSystemId. | |
| void | checkRequiredEnvironmentBlendModeAvailability () |
| Gets the environment blend mode. | |
| void | getVulkanInstanceExtensions () |
| Gets vulkan instance extensions. | |
| void | logVulkanRequirements () |
| Logs vulkan requirements. | |
| void | createVulkanInstance () |
| Creates a vulkan instance. | |
Private Attributes | |
| PFN_xrGetVulkanInstanceExtensionsKHR | xrGetVulkanInstanceExtensionsKHR = nullptr |
| PFN_xrGetVulkanGraphicsDevice2KHR | xrGetVulkanGraphicsDevice2KHR = nullptr |
| PFN_xrGetVulkanGraphicsRequirements2KHR | xrGetVulkanGraphicsRequirements2KHR = nullptr |
| PFN_xrCreateVulkanInstanceKHR | xrCreateVulkanInstanceKHR = nullptr |
| PFN_xrCreateVulkanDeviceKHR | xrCreateVulkanDeviceKHR = nullptr |
| std::vector< XrExtensionProperties > | supportedOpenXRInstanceExtensions |
| The supported open xr instance extensions. | |
| std::vector< XrApiLayerProperties > | supportedOpenXRApiLayers |
| The supported open xr API layers. | |
| XrInstance | xrInstance = XR_NULL_HANDLE |
| The xr instance. | |
| XrSystemId | xrSystemId = XR_NULL_SYSTEM_ID |
| Identifier for the xr device. So the identifier for the headset. | |
| std::vector< VkExtensionProperties > | supportedVulkanInstanceExtensions |
| The supported vulkan instance extensions. | |
| std::vector< const char * > | vulkanInstanceExtensions |
| (Immutable) the vulkan instance extensions which should get enabled | |
| VkInstance | vkInstance = VK_NULL_HANDLE |
| The vulkan instance. | |
| VkPhysicalDevice | vkPhysicalDevice = VK_NULL_HANDLE |
| The vulkan physical device. | |
| std::vector< VkExtensionProperties > | supportedVulkanDeviceExtensions |
| The supported vulkan device extensions. | |
| std::vector< const char * > | vulkanDeviceExtensions |
| (Immutable) the vulkan device extensions | |
| VkDeviceSize | uniformBufferOffsetAlignment = 0u |
| The uniform buffer offset alignment. | |
| VkSampleCountFlagBits | multisampleCount = VK_SAMPLE_COUNT_1_BIT |
| Number of multisamples. | |
| uint32_t | maxPushConstantsSize = 128u |
| Maximum push constants size in bytes. | |
| struct EngineCore::ApplicationContext::QueueFamily | queueFamily |
| VkDevice | vkDevice = VK_NULL_HANDLE |
| VmaAllocator | vmaAllocator_ = VK_NULL_HANDLE |
| VMA allocator for efficient GPU memory management. | |
The application context is the core class which stores the basic openxr and vulkan objects.
Definition at line 35 of file ApplicationContext.h.
|
default |
|
default |
|
private |
Gets the environment blend mode.
Definition at line 918 of file ApplicationContext.cpp.
References EngineCore::environmentBlendMode, TRACY_ZONE_SCOPED_FUNCTION, xrInstance, xrSystemId, and EngineCore::xrViewType.
Referenced by createResources().
| void EngineCore::ApplicationContext::cleanup | ( | ) |
performs the cleanup by removing all vulkan and openxr pointers
Definition at line 60 of file ApplicationContext.cpp.
References vkDevice, vkInstance, vmaAllocator_, xrInstance, and xrSystemId.
| void EngineCore::ApplicationContext::createDevice | ( | VkSurfaceKHR | mirrorSurface | ) |
Creates the vulkan device and all necessary components for it.
| mirrorSurface | The mirror surface. |
Definition at line 94 of file ApplicationContext.cpp.
References Vulkan::ChainBuilder::add(), EngineCore::OpenXrHelper::LoadXrFunction(), maxPushConstantsSize, multisampleCount, pickQueueFamilies(), queueFamily, VulkanHelper::setObjectName(), supportedVulkanDeviceExtensions, TRACY_ZONE_SCOPED_FUNCTION, TRACY_ZONE_SCOPED_NAMED, uniformBufferOffsetAlignment, VALIDATE_FEATURE, vkDevice, vkInstance, vkPhysicalDevice, vmaAllocator_, vulkanDeviceExtensions, xrCreateVulkanDeviceKHR, xrGetVulkanGraphicsDevice2KHR, xrInstance, and xrSystemId.
|
private |
Queries supported openxr instance extensions, openxr api layers and creates the XrInstance.
| std::runtime_error | When something which should have been executed failed. |
| EnvironmentException | When for example SteamVR has not been started before launching the application. |
Definition at line 667 of file ApplicationContext.cpp.
References supportedOpenXRApiLayers, supportedOpenXRInstanceExtensions, TRACY_ZONE_SCOPED_FUNCTION, and xrInstance.
Referenced by createResources().
| void EngineCore::ApplicationContext::createResources | ( | ) |
creates all openxr and vulkan resources
Definition at line 25 of file ApplicationContext.cpp.
References checkRequiredEnvironmentBlendModeAvailability(), createOpenXrInstance(), createVulkanInstance(), DEFAULT, DEFAULT_OPENXR_LAUNCH_MODE, getVulkanInstanceExtensions(), VulkanHelper::initializeDebugFunctions(), LoadOpenXrExtensionFunctions(), OCULUS_LAUNCH, retrieveXrSystemId(), TRACY_ZONE_SCOPED_FUNCTION, and vkInstance.
|
private |
Creates a vulkan instance.
Definition at line 1018 of file ApplicationContext.cpp.
References ARE_VALIDATION_LAYERS_ENABLED, GPU_PRINTF, GPU_VALIDATION, logVulkanRequirements(), NONE, TRACY_ZONE_SCOPED_FUNCTION, USE_GPU_PRINTF, vkInstance, vulkanInstanceExtensions, xrCreateVulkanInstanceKHR, xrInstance, and xrSystemId.
Referenced by createResources().
|
nodiscard |
Gets draw queue.
Definition at line 617 of file ApplicationContext.cpp.
References queueFamily.
|
nodiscard |
Gets max push constants size in bytes.
Definition at line 652 of file ApplicationContext.cpp.
References maxPushConstantsSize.
|
nodiscard |
Gets multisample count.
Definition at line 627 of file ApplicationContext.cpp.
References multisampleCount.
|
nodiscard |
Gets the present queue.
Definition at line 612 of file ApplicationContext.cpp.
References queueFamily.
|
nodiscard |
Gets the transfer queue.
Definition at line 622 of file ApplicationContext.cpp.
References queueFamily.
|
nodiscard |
Gets uniform buffer offset alignment.
Definition at line 647 of file ApplicationContext.cpp.
References uniformBufferOffsetAlignment.
|
nodiscard |
Gets the vulkan device.
Definition at line 607 of file ApplicationContext.cpp.
References vkDevice.
Referenced by EngineCore::ComputePass::cleanup(), EngineCore::RenderTarget::cleanup(), and EngineCore::VulkanBuffer::VulkanBuffer().
|
nodiscard |
Gets the zero-based index of the vulkan draw queue family.
Definition at line 637 of file ApplicationContext.cpp.
References queueFamily.
Referenced by VulkanHelper::recordBufferCopyMultiple(), EngineCore::VulkanStagedBuffer::uploadPartial(), and usesDedicatedTransferQueue().
|
nodiscard |
Gets vulkan instance.
Definition at line 602 of file ApplicationContext.cpp.
References vkInstance.
|
nodiscard |
Gets vulkan physical device.
Definition at line 632 of file ApplicationContext.cpp.
References vkPhysicalDevice.
Referenced by EngineCore::VulkanBuffer::VulkanBuffer().
|
nodiscard |
gets the transfer queue family index
Definition at line 642 of file ApplicationContext.cpp.
References queueFamily.
Referenced by VulkanHelper::recordBufferCopyMultiple(), EngineCore::VulkanStagedBuffer::uploadPartial(), and usesDedicatedTransferQueue().
|
nodiscard |
Gets the VMA allocator for memory management.
Definition at line 662 of file ApplicationContext.cpp.
References vmaAllocator_.
Referenced by EngineCore::VulkanBuffer::VulkanBuffer().
|
private |
Gets vulkan instance extensions.
Definition at line 944 of file ApplicationContext.cpp.
References supportedVulkanInstanceExtensions, TRACY_ZONE_SCOPED_FUNCTION, and vulkanInstanceExtensions.
Referenced by createResources().
|
nodiscard |
Gets xr instance.
Definition at line 592 of file ApplicationContext.cpp.
References xrInstance.
|
nodiscard |
Gets xr system identifier.
Definition at line 597 of file ApplicationContext.cpp.
References xrSystemId.
|
nodiscard |
Gets xr view type which should be stereo for any typical VR application.
Definition at line 657 of file ApplicationContext.cpp.
References EngineCore::xrViewType.
|
private |
Loads all dynamically loaded xr functions.
Definition at line 823 of file ApplicationContext.cpp.
References EngineCore::OpenXrHelper::LoadXrFunction(), TRACY_ZONE_SCOPED_FUNCTION, xrCreateVulkanDeviceKHR, xrCreateVulkanInstanceKHR, xrGetVulkanGraphicsDevice2KHR, xrGetVulkanGraphicsRequirements2KHR, and xrInstance.
Referenced by createResources().
|
private |
Logs vulkan requirements.
Definition at line 1010 of file ApplicationContext.cpp.
References xrGetVulkanGraphicsRequirements2KHR, xrInstance, and xrSystemId.
Referenced by createVulkanInstance().
|
private |
gets the device queues needed
| physicalDevice | the vulkan physical device |
| surface | the mirror surface |
| outGraphicsIndex | |
| outPresentIndex | |
| outTransferIndex |
Definition at line 468 of file ApplicationContext.cpp.
Referenced by createDevice().
|
private |
Gets the XrSystemId.
Definition at line 887 of file ApplicationContext.cpp.
References DEFAULT, DEFAULT_OPENXR_LAUNCH_MODE, OCULUS_LAUNCH, TRACY_ZONE_SCOPED_FUNCTION, xrInstance, and xrSystemId.
Referenced by createResources().
|
nodiscard |
Check if the transfer queue index is its own, dedicated queue.
Definition at line 89 of file ApplicationContext.cpp.
References getVkGraphicsQueueFamilyIndex(), and getVkTransferQueueFamilyIndex().
|
private |
Maximum push constants size in bytes.
Definition at line 370 of file ApplicationContext.h.
Referenced by createDevice(), and getMaxPushConstantsSize().
|
private |
Number of multisamples.
Definition at line 366 of file ApplicationContext.h.
Referenced by createDevice(), and getMultisampleCount().
|
private |
|
private |
The supported open xr API layers.
Definition at line 312 of file ApplicationContext.h.
Referenced by createOpenXrInstance().
|
private |
The supported open xr instance extensions.
Definition at line 307 of file ApplicationContext.h.
Referenced by createOpenXrInstance().
|
private |
The supported vulkan device extensions.
Definition at line 354 of file ApplicationContext.h.
Referenced by createDevice().
|
private |
The supported vulkan instance extensions.
Definition at line 334 of file ApplicationContext.h.
Referenced by getVulkanInstanceExtensions().
|
private |
The uniform buffer offset alignment.
Definition at line 362 of file ApplicationContext.h.
Referenced by createDevice(), and getUniformBufferOffsetAlignment().
|
private |
Definition at line 385 of file ApplicationContext.h.
Referenced by cleanup(), createDevice(), and getVkDevice().
|
private |
The vulkan instance.
Definition at line 344 of file ApplicationContext.h.
Referenced by cleanup(), createDevice(), createResources(), createVulkanInstance(), and getVkInstance().
|
private |
The vulkan physical device.
Definition at line 349 of file ApplicationContext.h.
Referenced by createDevice(), and getVkPhysicalDevice().
|
private |
VMA allocator for efficient GPU memory management.
Definition at line 390 of file ApplicationContext.h.
Referenced by cleanup(), createDevice(), and getVmaAllocator().
|
private |
(Immutable) the vulkan device extensions
Definition at line 358 of file ApplicationContext.h.
Referenced by createDevice().
|
private |
(Immutable) the vulkan instance extensions which should get enabled
Definition at line 339 of file ApplicationContext.h.
Referenced by createVulkanInstance(), and getVulkanInstanceExtensions().
|
private |
Definition at line 255 of file ApplicationContext.h.
Referenced by createDevice(), and LoadOpenXrExtensionFunctions().
|
private |
Definition at line 254 of file ApplicationContext.h.
Referenced by createVulkanInstance(), and LoadOpenXrExtensionFunctions().
|
private |
Definition at line 251 of file ApplicationContext.h.
Referenced by createDevice(), and LoadOpenXrExtensionFunctions().
|
private |
Definition at line 252 of file ApplicationContext.h.
Referenced by LoadOpenXrExtensionFunctions(), and logVulkanRequirements().
|
private |
Definition at line 250 of file ApplicationContext.h.
|
private |
The xr instance.
Definition at line 317 of file ApplicationContext.h.
Referenced by checkRequiredEnvironmentBlendModeAvailability(), cleanup(), createDevice(), createOpenXrInstance(), createVulkanInstance(), getXrInstance(), LoadOpenXrExtensionFunctions(), logVulkanRequirements(), and retrieveXrSystemId().
|
private |
Identifier for the xr device. So the identifier for the headset.
Definition at line 329 of file ApplicationContext.h.
Referenced by checkRequiredEnvironmentBlendModeAvailability(), cleanup(), createDevice(), createVulkanInstance(), getXrSystemId(), logVulkanRequirements(), and retrieveXrSystemId().