Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
EngineCore::ApplicationContext Class Reference

The application context is the core class which stores the basic openxr and vulkan objects. More...

#include <ApplicationContext.h>

Collaboration diagram for EngineCore::ApplicationContext:

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.

Detailed Description

The application context is the core class which stores the basic openxr and vulkan objects.

Definition at line 35 of file ApplicationContext.h.

Constructor & Destructor Documentation

◆ ApplicationContext()

EngineCore::ApplicationContext::ApplicationContext ( )
default

◆ ~ApplicationContext()

EngineCore::ApplicationContext::~ApplicationContext ( )
default

Member Function Documentation

◆ checkRequiredEnvironmentBlendModeAvailability()

void EngineCore::ApplicationContext::checkRequiredEnvironmentBlendModeAvailability ( )
private

Gets the environment blend mode.

Date
2025-02-12
Author
Konstantin Passig

Definition at line 918 of file ApplicationContext.cpp.

References EngineCore::environmentBlendMode, TRACY_ZONE_SCOPED_FUNCTION, xrInstance, xrSystemId, and EngineCore::xrViewType.

Referenced by createResources().

Here is the caller graph for this function:

◆ cleanup()

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.

◆ createDevice()

void EngineCore::ApplicationContext::createDevice ( VkSurfaceKHR mirrorSurface)

Creates the vulkan device and all necessary components for it.

Parameters
mirrorSurfaceThe 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.

Here is the call graph for this function:

◆ createOpenXrInstance()

void EngineCore::ApplicationContext::createOpenXrInstance ( std::optional< std::filesystem::path > customOpenXrRuntimePath = std::optional<std::filesystem::path>())
private

Queries supported openxr instance extensions, openxr api layers and creates the XrInstance.

Date
2025-02-12
Author
Konstantin Passig
Exceptions
std::runtime_errorWhen something which should have been executed failed.
EnvironmentExceptionWhen 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().

Here is the caller graph for this function:

◆ 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.

Here is the call graph for this function:

◆ createVulkanInstance()

void EngineCore::ApplicationContext::createVulkanInstance ( )
private

Creates a vulkan instance.

Date
2025-02-08
Author
Konstantin Passig

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getGraphicsQueue()

const VkQueue & EngineCore::ApplicationContext::getGraphicsQueue ( ) const
nodiscard

Gets draw queue.

Returns
The draw queue.
Date
2025-02-15
Author
Konstantin Passig

Definition at line 617 of file ApplicationContext.cpp.

References queueFamily.

◆ getMaxPushConstantsSize()

uint32_t EngineCore::ApplicationContext::getMaxPushConstantsSize ( ) const
nodiscard

Gets max push constants size in bytes.

Returns
The maximum push constants size supported by the GPU.
Date
2025-10-15
Author
Konstantin Passig

Definition at line 652 of file ApplicationContext.cpp.

References maxPushConstantsSize.

◆ getMultisampleCount()

VkSampleCountFlagBits EngineCore::ApplicationContext::getMultisampleCount ( ) const
nodiscard

Gets multisample count.

Returns
The multisample count.
Date
2025-02-14
Author
Konstantin Passig

Definition at line 627 of file ApplicationContext.cpp.

References multisampleCount.

◆ getPresentQueue()

const VkQueue & EngineCore::ApplicationContext::getPresentQueue ( ) const
nodiscard

Gets the present queue.

Returns
The present queue.
Date
2025-02-15
Author
Konstantin Passig

Definition at line 612 of file ApplicationContext.cpp.

References queueFamily.

◆ getTransferQueue()

const VkQueue & EngineCore::ApplicationContext::getTransferQueue ( ) const
nodiscard

Gets the transfer queue.

Returns
The transfer queue.
Date
2025-04-02
Author
Konstantin Passig

Definition at line 622 of file ApplicationContext.cpp.

References queueFamily.

◆ getUniformBufferOffsetAlignment()

VkDeviceSize EngineCore::ApplicationContext::getUniformBufferOffsetAlignment ( ) const
nodiscard

Gets uniform buffer offset alignment.

Returns
The uniform buffer offset alignment.
Date
2025-02-15
Author
Konstantin Passig

Definition at line 647 of file ApplicationContext.cpp.

References uniformBufferOffsetAlignment.

◆ getVkDevice()

const VkDevice EngineCore::ApplicationContext::getVkDevice ( ) const
nodiscard

Gets the vulkan device.

Returns
The vulkan device.
Date
2025-02-14
Author
Konstantin Passig

Definition at line 607 of file ApplicationContext.cpp.

References vkDevice.

Referenced by EngineCore::ComputePass::cleanup(), EngineCore::RenderTarget::cleanup(), and EngineCore::VulkanBuffer::VulkanBuffer().

Here is the caller graph for this function:

◆ getVkGraphicsQueueFamilyIndex()

uint32_t EngineCore::ApplicationContext::getVkGraphicsQueueFamilyIndex ( ) const
nodiscard

Gets the zero-based index of the vulkan draw queue family.

Returns
The vulkan draw queue family index.
Date
2025-02-14
Author
Konstantin Passig

Definition at line 637 of file ApplicationContext.cpp.

References queueFamily.

Referenced by VulkanHelper::recordBufferCopyMultiple(), EngineCore::VulkanStagedBuffer::uploadPartial(), and usesDedicatedTransferQueue().

Here is the caller graph for this function:

◆ getVkInstance()

VkInstance EngineCore::ApplicationContext::getVkInstance ( ) const
nodiscard

Gets vulkan instance.

Returns
The vulkan instance.

Definition at line 602 of file ApplicationContext.cpp.

References vkInstance.

◆ getVkPhysicalDevice()

const VkPhysicalDevice & EngineCore::ApplicationContext::getVkPhysicalDevice ( ) const
nodiscard

Gets vulkan physical device.

Returns
The vulkan physical device.
Date
2025-02-14
Author
Konstantin Passig

Definition at line 632 of file ApplicationContext.cpp.

References vkPhysicalDevice.

Referenced by EngineCore::VulkanBuffer::VulkanBuffer().

Here is the caller graph for this function:

◆ getVkTransferQueueFamilyIndex()

uint32_t EngineCore::ApplicationContext::getVkTransferQueueFamilyIndex ( ) const
nodiscard

gets the transfer queue family index

Returns
zero indexed transfer queue index
Date
2025-04-02
Author
Konstantin Passig

Definition at line 642 of file ApplicationContext.cpp.

References queueFamily.

Referenced by VulkanHelper::recordBufferCopyMultiple(), EngineCore::VulkanStagedBuffer::uploadPartial(), and usesDedicatedTransferQueue().

Here is the caller graph for this function:

◆ getVmaAllocator()

VmaAllocator EngineCore::ApplicationContext::getVmaAllocator ( ) const
nodiscard

Gets the VMA allocator for memory management.

Returns
The VMA allocator instance
Date
2026-01-24
Author
Konstantin Passig

Definition at line 662 of file ApplicationContext.cpp.

References vmaAllocator_.

Referenced by EngineCore::VulkanBuffer::VulkanBuffer().

Here is the caller graph for this function:

◆ getVulkanInstanceExtensions()

void EngineCore::ApplicationContext::getVulkanInstanceExtensions ( )
private

Gets vulkan instance extensions.

Date
2025-02-08
Author
Konstantin Passig

Definition at line 944 of file ApplicationContext.cpp.

References supportedVulkanInstanceExtensions, TRACY_ZONE_SCOPED_FUNCTION, and vulkanInstanceExtensions.

Referenced by createResources().

Here is the caller graph for this function:

◆ getXrInstance()

XrInstance EngineCore::ApplicationContext::getXrInstance ( ) const
nodiscard

Gets xr instance.

Returns
The xr instance.

Definition at line 592 of file ApplicationContext.cpp.

References xrInstance.

◆ getXrSystemId()

XrSystemId EngineCore::ApplicationContext::getXrSystemId ( ) const
nodiscard

Gets xr system identifier.

Returns
The xr system identifier.

Definition at line 597 of file ApplicationContext.cpp.

References xrSystemId.

◆ getXrViewType()

const XrViewConfigurationType EngineCore::ApplicationContext::getXrViewType ( ) const
nodiscard

Gets xr view type which should be stereo for any typical VR application.

Returns
The xr view type.
Date
2025-02-15
Author
Konstantin Passig

Definition at line 657 of file ApplicationContext.cpp.

References EngineCore::xrViewType.

◆ LoadOpenXrExtensionFunctions()

void EngineCore::ApplicationContext::LoadOpenXrExtensionFunctions ( )
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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ logVulkanRequirements()

void EngineCore::ApplicationContext::logVulkanRequirements ( )
private

Logs vulkan requirements.

Date
2025-02-08
Author
Konstantin Passig

Definition at line 1010 of file ApplicationContext.cpp.

References xrGetVulkanGraphicsRequirements2KHR, xrInstance, and xrSystemId.

Referenced by createVulkanInstance().

Here is the caller graph for this function:

◆ pickQueueFamilies()

void EngineCore::ApplicationContext::pickQueueFamilies ( VkPhysicalDevice physicalDevice,
VkSurfaceKHR surface,
uint32_t & outGraphicsIndex,
uint32_t & outPresentIndex,
uint32_t & outTransferIndex )
private

gets the device queues needed

Parameters
physicalDevicethe vulkan physical device
surfacethe mirror surface
outGraphicsIndex
outPresentIndex
outTransferIndex
Date
2025-04-02
Author
Konstantin Passig

Definition at line 468 of file ApplicationContext.cpp.

Referenced by createDevice().

Here is the caller graph for this function:

◆ retrieveXrSystemId()

void EngineCore::ApplicationContext::retrieveXrSystemId ( )
private

Gets the XrSystemId.

Date
2025-02-12
Author
Konstantin Passig

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().

Here is the caller graph for this function:

◆ usesDedicatedTransferQueue()

bool EngineCore::ApplicationContext::usesDedicatedTransferQueue ( ) const
nodiscard

Check if the transfer queue index is its own, dedicated queue.

Returns
if the transfer queue index != graphics queue index
Date
2025-06-18
Author
Konstantin Passig

Definition at line 89 of file ApplicationContext.cpp.

References getVkGraphicsQueueFamilyIndex(), and getVkTransferQueueFamilyIndex().

Here is the call graph for this function:

Member Data Documentation

◆ maxPushConstantsSize

uint32_t EngineCore::ApplicationContext::maxPushConstantsSize = 128u
private

Maximum push constants size in bytes.

Definition at line 370 of file ApplicationContext.h.

Referenced by createDevice(), and getMaxPushConstantsSize().

◆ multisampleCount

VkSampleCountFlagBits EngineCore::ApplicationContext::multisampleCount = VK_SAMPLE_COUNT_1_BIT
private

Number of multisamples.

Definition at line 366 of file ApplicationContext.h.

Referenced by createDevice(), and getMultisampleCount().

◆ queueFamily

◆ supportedOpenXRApiLayers

std::vector<XrApiLayerProperties> EngineCore::ApplicationContext::supportedOpenXRApiLayers
private

The supported open xr API layers.

Definition at line 312 of file ApplicationContext.h.

Referenced by createOpenXrInstance().

◆ supportedOpenXRInstanceExtensions

std::vector<XrExtensionProperties> EngineCore::ApplicationContext::supportedOpenXRInstanceExtensions
private

The supported open xr instance extensions.

Definition at line 307 of file ApplicationContext.h.

Referenced by createOpenXrInstance().

◆ supportedVulkanDeviceExtensions

std::vector<VkExtensionProperties> EngineCore::ApplicationContext::supportedVulkanDeviceExtensions
private

The supported vulkan device extensions.

Definition at line 354 of file ApplicationContext.h.

Referenced by createDevice().

◆ supportedVulkanInstanceExtensions

std::vector<VkExtensionProperties> EngineCore::ApplicationContext::supportedVulkanInstanceExtensions
private

The supported vulkan instance extensions.

Definition at line 334 of file ApplicationContext.h.

Referenced by getVulkanInstanceExtensions().

◆ uniformBufferOffsetAlignment

VkDeviceSize EngineCore::ApplicationContext::uniformBufferOffsetAlignment = 0u
private

The uniform buffer offset alignment.

Definition at line 362 of file ApplicationContext.h.

Referenced by createDevice(), and getUniformBufferOffsetAlignment().

◆ vkDevice

VkDevice EngineCore::ApplicationContext::vkDevice = VK_NULL_HANDLE
private

Definition at line 385 of file ApplicationContext.h.

Referenced by cleanup(), createDevice(), and getVkDevice().

◆ vkInstance

VkInstance EngineCore::ApplicationContext::vkInstance = VK_NULL_HANDLE
private

The vulkan instance.

Definition at line 344 of file ApplicationContext.h.

Referenced by cleanup(), createDevice(), createResources(), createVulkanInstance(), and getVkInstance().

◆ vkPhysicalDevice

VkPhysicalDevice EngineCore::ApplicationContext::vkPhysicalDevice = VK_NULL_HANDLE
private

The vulkan physical device.

Definition at line 349 of file ApplicationContext.h.

Referenced by createDevice(), and getVkPhysicalDevice().

◆ vmaAllocator_

VmaAllocator EngineCore::ApplicationContext::vmaAllocator_ = VK_NULL_HANDLE
private

VMA allocator for efficient GPU memory management.

Definition at line 390 of file ApplicationContext.h.

Referenced by cleanup(), createDevice(), and getVmaAllocator().

◆ vulkanDeviceExtensions

std::vector<const char *> EngineCore::ApplicationContext::vulkanDeviceExtensions
private

(Immutable) the vulkan device extensions

Definition at line 358 of file ApplicationContext.h.

Referenced by createDevice().

◆ vulkanInstanceExtensions

std::vector<const char *> EngineCore::ApplicationContext::vulkanInstanceExtensions
private

(Immutable) the vulkan instance extensions which should get enabled

Definition at line 339 of file ApplicationContext.h.

Referenced by createVulkanInstance(), and getVulkanInstanceExtensions().

◆ xrCreateVulkanDeviceKHR

PFN_xrCreateVulkanDeviceKHR EngineCore::ApplicationContext::xrCreateVulkanDeviceKHR = nullptr
private

Definition at line 255 of file ApplicationContext.h.

Referenced by createDevice(), and LoadOpenXrExtensionFunctions().

◆ xrCreateVulkanInstanceKHR

PFN_xrCreateVulkanInstanceKHR EngineCore::ApplicationContext::xrCreateVulkanInstanceKHR = nullptr
private

Definition at line 254 of file ApplicationContext.h.

Referenced by createVulkanInstance(), and LoadOpenXrExtensionFunctions().

◆ xrGetVulkanGraphicsDevice2KHR

PFN_xrGetVulkanGraphicsDevice2KHR EngineCore::ApplicationContext::xrGetVulkanGraphicsDevice2KHR = nullptr
private

Definition at line 251 of file ApplicationContext.h.

Referenced by createDevice(), and LoadOpenXrExtensionFunctions().

◆ xrGetVulkanGraphicsRequirements2KHR

PFN_xrGetVulkanGraphicsRequirements2KHR EngineCore::ApplicationContext::xrGetVulkanGraphicsRequirements2KHR = nullptr
private

Definition at line 252 of file ApplicationContext.h.

Referenced by LoadOpenXrExtensionFunctions(), and logVulkanRequirements().

◆ xrGetVulkanInstanceExtensionsKHR

PFN_xrGetVulkanInstanceExtensionsKHR EngineCore::ApplicationContext::xrGetVulkanInstanceExtensionsKHR = nullptr
private

Definition at line 250 of file ApplicationContext.h.

◆ xrInstance

XrInstance EngineCore::ApplicationContext::xrInstance = XR_NULL_HANDLE
private

◆ xrSystemId

XrSystemId EngineCore::ApplicationContext::xrSystemId = XR_NULL_SYSTEM_ID
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().


The documentation for this class was generated from the following files: