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

#include <Engine.h>

Collaboration diagram for EngineCore::Engine:

Public Member Functions

 Engine ()=default
 ~Engine ()
void initRenderDoc ()
 Initialization point for software driven captures.
void run (std::unique_ptr< GameModule > module)
 Runs the engine. Is the entry point for this module.
std::shared_ptr< InputHandler > getInputHandler ()
 Gets a shared handle to the input handler. This is used for any type of input.
const std::unique_ptr< AssetManager > & getAssetManager () const
double getDeltaTimeSeconds ()
 gets the time between frames
double getGlobalTimeSeconds ()
 Gets the time since the beginning of the simulation (sum of all delta times)
ApplicationContextgetContext () const
 Gets the application context which stores the vulkan instance the device and queues.
uint32_t getRenderableSceneObjectCount () const
 Counts the amount of entities which have renderable components.
RenderergetRenderer () const
 Getter for the renderer.
Input::XrInputHandlergetXrInputHandler () const
 Getter for the XR input handler.
HeadsetgetHeadset () const
 Getter for the VR headset.
void processMirrorWindowEvents ()
 processes glfw window events like key presses or window events
const std::unique_ptr< SceneManager > & getSceneManager () const
template<typename T>
void loadScene ()
 Triggers the load of a new scene. Will be executed once the current frame has finished processing.
PhysicsEnginegetPhysicsEngine () const
 Getter for the pointer to the physics engine.

Private Member Functions

void createInputManager ()
void initWindow ()
void createVulkanDebugMessenger ()
void populateDebugMessengerCreateInfo (VkDebugUtilsMessengerCreateInfoEXT &createInfo)
bool checkValidationLayerSupport ()
void completeFrameAsync (VkFence graphicsFence, bool presentMirror)
 Runs on background thread: waits for GPU fence, ends XR frame, presents mirror This allows CPU work to overlap with GPU execution of the previous frame.
void createStartupScene ()
 Creates the initial scene the engine loads before an actual level is loaded.
void initVulkan ()
 Initialisation of all vulkan related resources.
void tryCreateApplicationContext ()
 will try to create a window and if there is no openxr runtime detected it will wait 5 seconds and try to find one again
void calculateFrameTime (double &lastTime)
void fixLoadingAssets () const
 When assets have been requested but are not loaded yet the static mesh data is in a limbo where it has no asset yet but a path. This function fixes this issue by checking each frame if the asset is loaded already and if it is it sets it.
void processResourceLoadingPipelines ()
 Collects and processes the pipelines which have finished and dispatches the new steps. Asset loading.
void update (double &gameTime)
void captureRenderdocFrame ()
 Captures a frame for render doc if the define RENDERDOC_ENABLED is set.
int isMirrorViewMinimized ()
void mainLoop ()
 Main engine loop where the rendering and game steps happen.
void cleanup ()
 Cleanup of pointers for vulkan and subsystems.
void initializePlogDebugger ()
void initStartupScene ()
void createAssetManager ()
void initAssets ()
void createPhysicsWorld ()
 PHYSICS.
void destroyPhysicsWorld ()

Static Private Member Functions

static VkBool32 debugCallback (VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageType, const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData, void *pUserData)

Private Attributes

double gameTime = 0.0f
double deltaTimeSeconds
std::unique_ptr< AssetManagerassetManager
std::shared_ptr< InputHandler > inputHandler
std::unique_ptr< GameModulemodule
VkDebugUtilsMessengerEXT debugMessenger = nullptr
Input::XrInputHandlerxrInputHandler = nullptr
uint64_t frameCounter = 0
bool descriptorDataIsDirty = false
std::vector< VkCommandBuffer > commandBuffers
uint32_t currentFrame = 0
uint32_t textureCount = 0
uint32_t meshCount = 0
bool isXrSessionRunning = false
PFN_vkDestroyDebugUtilsMessengerEXT vkDestroyDebugUtilsMessengerEXT = nullptr
ApplicationContextapplicationContext = nullptr
MirrorViewmirrorView = nullptr
Headsetheadset = nullptr
Rendererrenderer = nullptr
std::future< void > frameCompletionFuture_
std::atomic< bool > previousFrameXrComplete_ {true}
std::unique_ptr< NamedThreadPoolxrFrameThreadPool_
MeshComponentrightHand = nullptr
MeshComponentleftHand = nullptr
std::unique_ptr< SceneManagersceneManager
PhysicsEnginephysicsEngine = nullptr

Detailed Description

Definition at line 36 of file Engine.h.

Constructor & Destructor Documentation

◆ Engine()

EngineCore::Engine::Engine ( )
default

References module.

◆ ~Engine()

EngineCore::Engine::~Engine ( )

Definition at line 59 of file Engine.cpp.

Member Function Documentation

◆ calculateFrameTime()

void EngineCore::Engine::calculateFrameTime ( double & lastTime)
private

Definition at line 380 of file Engine.cpp.

References deltaTimeSeconds, and TRACY_ZONE_SCOPED_NAMED.

Referenced by mainLoop().

Here is the caller graph for this function:

◆ captureRenderdocFrame()

void EngineCore::Engine::captureRenderdocFrame ( )
private

Captures a frame for render doc if the define RENDERDOC_ENABLED is set.

Definition at line 508 of file Engine.cpp.

References applicationContext, RenderDoc::get(), and TRACY_ZONE_SCOPED_NAMED.

Referenced by mainLoop().

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

◆ checkValidationLayerSupport()

bool EngineCore::Engine::checkValidationLayerSupport ( )
private

Definition at line 262 of file Engine.cpp.

References validationLayers.

◆ cleanup()

void EngineCore::Engine::cleanup ( )
private

Cleanup of pointers for vulkan and subsystems.

Definition at line 987 of file Engine.cpp.

References applicationContext, ARE_VALIDATION_LAYERS_ENABLED, assetManager, debugMessenger, frameCompletionFuture_, VulkanHelper::getFunctions(), headset, mirrorView, module, EngineCore::PIPELINE_STAGE_COUNT, renderer, sceneManager, and VulkanFunctions::vkDestroyDebugUtilsMessengerEXT.

Referenced by run().

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

◆ completeFrameAsync()

void EngineCore::Engine::completeFrameAsync ( VkFence graphicsFence,
bool presentMirror )
private

Runs on background thread: waits for GPU fence, ends XR frame, presents mirror This allows CPU work to overlap with GPU execution of the previous frame.

Parameters
graphicsFenceThe fence to wait on (from the frame that was just submitted)
presentMirrorWhether to present the mirror view after xrEndFrame

Definition at line 532 of file Engine.cpp.

References applicationContext, headset, mirrorView, previousFrameXrComplete_, and TRACY_ZONE_SCOPED_NAMED.

Referenced by mainLoop().

Here is the caller graph for this function:

◆ createAssetManager()

void EngineCore::Engine::createAssetManager ( )
private

Definition at line 1116 of file Engine.cpp.

References applicationContext, and assetManager.

Referenced by initVulkan().

Here is the caller graph for this function:

◆ createInputManager()

void EngineCore::Engine::createInputManager ( )
private

Definition at line 117 of file Engine.cpp.

References applicationContext, headset, and xrInputHandler.

Referenced by initVulkan().

Here is the caller graph for this function:

◆ createPhysicsWorld()

void EngineCore::Engine::createPhysicsWorld ( )
private

PHYSICS.

Definition at line 1124 of file Engine.cpp.

References physicsEngine.

Referenced by run().

Here is the caller graph for this function:

◆ createStartupScene()

void EngineCore::Engine::createStartupScene ( )
private

Creates the initial scene the engine loads before an actual level is loaded.

Definition at line 287 of file Engine.cpp.

References module, and sceneManager.

Referenced by initVulkan().

Here is the caller graph for this function:

◆ createVulkanDebugMessenger()

void EngineCore::Engine::createVulkanDebugMessenger ( )
private

Definition at line 146 of file Engine.cpp.

References applicationContext, debugMessenger, and VulkanHelper::getFunctions().

Referenced by initVulkan().

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

◆ debugCallback()

VkBool32 EngineCore::Engine::debugCallback ( VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
VkDebugUtilsMessageTypeFlagsEXT messageType,
const VkDebugUtilsMessengerCallbackDataEXT * pCallbackData,
void * pUserData )
staticprivate

Definition at line 233 of file Engine.cpp.

References GPU_PRINTF, and USE_GPU_PRINTF.

Referenced by populateDebugMessengerCreateInfo().

Here is the caller graph for this function:

◆ destroyPhysicsWorld()

void EngineCore::Engine::destroyPhysicsWorld ( )
private

Definition at line 1129 of file Engine.cpp.

References physicsEngine.

Referenced by run().

Here is the caller graph for this function:

◆ fixLoadingAssets()

void EngineCore::Engine::fixLoadingAssets ( ) const
private

When assets have been requested but are not loaded yet the static mesh data is in a limbo where it has no asset yet but a path. This function fixes this issue by checking each frame if the asset is loaded already and if it is it sets it.

Definition at line 388 of file Engine.cpp.

References assetManager, Ecs::RegistryManager::get(), TRACY_ZONE_SCOPED_NAMED, and TRACY_ZONE_SCOPED_NAMED_ASSET.

Referenced by mainLoop().

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

◆ getAssetManager()

const std::unique_ptr< AssetManager > & EngineCore::Engine::getAssetManager ( ) const

Definition at line 103 of file Engine.cpp.

References assetManager.

◆ getContext()

ApplicationContext * EngineCore::Engine::getContext ( ) const
inlinenodiscard

Gets the application context which stores the vulkan instance the device and queues.

Returns
the context object

Definition at line 90 of file Engine.h.

References applicationContext.

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

Here is the caller graph for this function:

◆ getDeltaTimeSeconds()

double EngineCore::Engine::getDeltaTimeSeconds ( )

gets the time between frames

Returns
time in seconds

Definition at line 107 of file Engine.cpp.

References deltaTimeSeconds.

◆ getGlobalTimeSeconds()

double EngineCore::Engine::getGlobalTimeSeconds ( )

Gets the time since the beginning of the simulation (sum of all delta times)

Returns
time since the beginning of simulation

Definition at line 112 of file Engine.cpp.

References gameTime.

◆ getHeadset()

Headset * EngineCore::Engine::getHeadset ( ) const
inlinenodiscard

Getter for the VR headset.

Returns
pointer to the headset

Definition at line 133 of file Engine.h.

References headset.

◆ getInputHandler()

std::shared_ptr< InputHandler > EngineCore::Engine::getInputHandler ( )

Gets a shared handle to the input handler. This is used for any type of input.

Returns
Shared ptr to the input handler.
Author
Konstantin Passig
Date
10.12.2025

Definition at line 96 of file Engine.cpp.

References inputHandler.

◆ getPhysicsEngine()

PhysicsEngine * EngineCore::Engine::getPhysicsEngine ( ) const

Getter for the pointer to the physics engine.

Returns
pointer to the physics engine

Definition at line 1111 of file Engine.cpp.

References physicsEngine.

Referenced by EngineCore::PhysicsBodyComponent::getPhysicsEngine(), and update().

Here is the caller graph for this function:

◆ getRenderableSceneObjectCount()

uint32_t EngineCore::Engine::getRenderableSceneObjectCount ( ) const
nodiscard

Counts the amount of entities which have renderable components.

Returns
amount of entities which fit the description of a renderable object
Author
Konstantin Passig
Date
10.12.2025

Definition at line 122 of file Engine.cpp.

References Ecs::RegistryManager::get().

Here is the call graph for this function:

◆ getRenderer()

Renderer * EngineCore::Engine::getRenderer ( ) const
nodiscard

Getter for the renderer.

Returns
pointer to the renderer

Definition at line 126 of file Engine.cpp.

References renderer.

Referenced by EngineCore::MeshComponent::beginPlay().

Here is the caller graph for this function:

◆ getSceneManager()

const std::unique_ptr< SceneManager > & EngineCore::Engine::getSceneManager ( ) const
inline

Definition at line 217 of file Engine.h.

References sceneManager.

◆ getXrInputHandler()

Input::XrInputHandler * EngineCore::Engine::getXrInputHandler ( ) const
inlinenodiscard

Getter for the XR input handler.

Returns
pointer to the XR input handler

Definition at line 127 of file Engine.h.

References xrInputHandler.

◆ initAssets()

void EngineCore::Engine::initAssets ( )
private

Definition at line 1120 of file Engine.cpp.

References assetManager.

◆ initializePlogDebugger()

void EngineCore::Engine::initializePlogDebugger ( )
private

Definition at line 1091 of file Engine.cpp.

Referenced by initVulkan().

Here is the caller graph for this function:

◆ initRenderDoc()

void EngineCore::Engine::initRenderDoc ( )

Initialization point for software driven captures.

Author
Konstantin Passig
Date
10.12.2025

Definition at line 62 of file Engine.cpp.

References RenderDoc::get().

Referenced by run().

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

◆ initStartupScene()

void EngineCore::Engine::initStartupScene ( )
private

Definition at line 1104 of file Engine.cpp.

References sceneManager.

Referenced by initVulkan().

Here is the caller graph for this function:

◆ initVulkan()

void EngineCore::Engine::initVulkan ( )
private

Initialisation of all vulkan related resources.

Definition at line 292 of file Engine.cpp.

References applicationContext, assetManager, createAssetManager(), createInputManager(), createStartupScene(), createVulkanDebugMessenger(), headset, VulkanHelper::initializeFunctions(), initializePlogDebugger(), initStartupScene(), mirrorView, renderer, sceneManager, TRACY_ZONE_SCOPED_FUNCTION, and tryCreateApplicationContext().

Referenced by run().

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

◆ initWindow()

void EngineCore::Engine::initWindow ( )
private

Definition at line 131 of file Engine.cpp.

References TRACY_ZONE_SCOPED_FUNCTION.

Referenced by run().

Here is the caller graph for this function:

◆ isMirrorViewMinimized()

int EngineCore::Engine::isMirrorViewMinimized ( )
private

Definition at line 527 of file Engine.cpp.

References mirrorView.

Referenced by mainLoop().

Here is the caller graph for this function:

◆ loadScene()

template<typename T>
void EngineCore::Engine::loadScene ( )
inline

Triggers the load of a new scene. Will be executed once the current frame has finished processing.

Template Parameters
TType of the scene to load. Has to be child of EngineCore::Scene
Author
Konstantin Passig
Date
10.12.2025

Definition at line 266 of file Engine.h.

References sceneManager.

◆ mainLoop()

void EngineCore::Engine::mainLoop ( )
private

Main engine loop where the rendering and game steps happen.

Definition at line 567 of file Engine.cpp.

References applicationContext, assetManager, calculateFrameTime(), captureRenderdocFrame(), completeFrameAsync(), EngineCore::Headset::ComputeOnly, EngineCore::Headset::Error, fixLoadingAssets(), frameCompletionFuture_, frameCounter, gameTime, VulkanHelper::getFunctions(), EngineCore::RenderProcess::getGraphicsCompleteFence(), EngineCore::RenderProcess::getGraphicsFenceSubmitted(), EngineCore::RenderProcess::getTransferCompleteFence(), EngineCore::RenderProcess::getTransferFenceSubmitted(), headset, isMirrorViewMinimized(), mirrorView, previousFrameXrComplete_, processMirrorWindowEvents(), processResourceLoadingPipelines(), renderer, EngineCore::Headset::RenderFully, EngineCore::Headset::WaitFrameResult::result, sceneManager, EngineCore::RenderProcess::setGraphicsFenceSubmitted(), EngineCore::RenderProcess::setTransferFenceSubmitted(), EngineCore::Headset::WaitFrameResult::shouldCallBeginFrame, EngineCore::Headset::SkipFully, EngineCore::Headset::SkipRender, TRACY_FRAME_MARK, TRACY_ZONE_SCOPED_NAMED, update(), EngineCore::MirrorView::RenderResult::Visible, xrFrameThreadPool_, and xrInputHandler.

Referenced by run().

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

◆ populateDebugMessengerCreateInfo()

void EngineCore::Engine::populateDebugMessengerCreateInfo ( VkDebugUtilsMessengerCreateInfoEXT & createInfo)
private

Definition at line 219 of file Engine.cpp.

References debugCallback().

Here is the call graph for this function:

◆ processMirrorWindowEvents()

void EngineCore::Engine::processMirrorWindowEvents ( )

processes glfw window events like key presses or window events

Author
Konstantin Passig
Date
10.12.2025

Definition at line 374 of file Engine.cpp.

References TRACY_ZONE_SCOPED_NAMED.

Referenced by mainLoop().

Here is the caller graph for this function:

◆ processResourceLoadingPipelines()

void EngineCore::Engine::processResourceLoadingPipelines ( )
private

Collects and processes the pipelines which have finished and dispatches the new steps. Asset loading.

Definition at line 404 of file Engine.cpp.

References assetManager, and TRACY_ZONE_SCOPED_NAMED.

Referenced by mainLoop().

Here is the caller graph for this function:

◆ run()

void EngineCore::Engine::run ( std::unique_ptr< GameModule > module)

Runs the engine. Is the entry point for this module.

Author
Konstantin Passig
Date
10.12.2025

Definition at line 73 of file Engine.cpp.

References cleanup(), createPhysicsWorld(), destroyPhysicsWorld(), initRenderDoc(), initVulkan(), initWindow(), mainLoop(), module, and xrFrameThreadPool_.

Referenced by main().

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

◆ tryCreateApplicationContext()

void EngineCore::Engine::tryCreateApplicationContext ( )
private

will try to create a window and if there is no openxr runtime detected it will wait 5 seconds and try to find one again

Definition at line 353 of file Engine.cpp.

References applicationContext, and tryCreateApplicationContext().

Referenced by initVulkan(), and tryCreateApplicationContext().

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

◆ update()

void EngineCore::Engine::update ( double & gameTime)
private

Definition at line 412 of file Engine.cpp.

References deltaTimeSeconds, gameTime, Ecs::RegistryManager::get(), getPhysicsEngine(), module, TRACY_ZONE_SCOPED_NAMED, and EngineCore::PhysicsEngine::update().

Referenced by mainLoop().

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

Member Data Documentation

◆ applicationContext

◆ assetManager

std::unique_ptr<AssetManager> EngineCore::Engine::assetManager
private

◆ commandBuffers

std::vector<VkCommandBuffer> EngineCore::Engine::commandBuffers
private

Definition at line 140 of file Engine.h.

◆ currentFrame

uint32_t EngineCore::Engine::currentFrame = 0
private

Definition at line 143 of file Engine.h.

◆ debugMessenger

VkDebugUtilsMessengerEXT EngineCore::Engine::debugMessenger = nullptr
private

Definition at line 102 of file Engine.h.

Referenced by cleanup(), and createVulkanDebugMessenger().

◆ deltaTimeSeconds

double EngineCore::Engine::deltaTimeSeconds
private

Definition at line 93 of file Engine.h.

Referenced by calculateFrameTime(), getDeltaTimeSeconds(), and update().

◆ descriptorDataIsDirty

bool EngineCore::Engine::descriptorDataIsDirty = false
private

Definition at line 136 of file Engine.h.

◆ frameCompletionFuture_

std::future<void> EngineCore::Engine::frameCompletionFuture_
private

Definition at line 172 of file Engine.h.

Referenced by cleanup(), and mainLoop().

◆ frameCounter

uint64_t EngineCore::Engine::frameCounter = 0
private

Definition at line 105 of file Engine.h.

Referenced by mainLoop().

◆ gameTime

double EngineCore::Engine::gameTime = 0.0f
private

Definition at line 69 of file Engine.h.

Referenced by getGlobalTimeSeconds(), mainLoop(), and update().

◆ headset

Headset* EngineCore::Engine::headset = nullptr
private

◆ inputHandler

std::shared_ptr<InputHandler> EngineCore::Engine::inputHandler
private

Definition at line 96 of file Engine.h.

Referenced by getInputHandler().

◆ isXrSessionRunning

bool EngineCore::Engine::isXrSessionRunning = false
private

Definition at line 149 of file Engine.h.

◆ leftHand

MeshComponent* EngineCore::Engine::leftHand = nullptr
private

Definition at line 253 of file Engine.h.

◆ meshCount

uint32_t EngineCore::Engine::meshCount = 0
private

Definition at line 146 of file Engine.h.

◆ mirrorView

MirrorView* EngineCore::Engine::mirrorView = nullptr
private

Definition at line 166 of file Engine.h.

Referenced by cleanup(), completeFrameAsync(), initVulkan(), isMirrorViewMinimized(), and mainLoop().

◆ module

std::unique_ptr<GameModule> EngineCore::Engine::module
private

Definition at line 99 of file Engine.h.

Referenced by cleanup(), createStartupScene(), Engine(), run(), and update().

◆ physicsEngine

PhysicsEngine* EngineCore::Engine::physicsEngine = nullptr
private

Definition at line 286 of file Engine.h.

Referenced by createPhysicsWorld(), destroyPhysicsWorld(), and getPhysicsEngine().

◆ previousFrameXrComplete_

std::atomic<bool> EngineCore::Engine::previousFrameXrComplete_ {true}
private

Definition at line 173 of file Engine.h.

Referenced by completeFrameAsync(), and mainLoop().

◆ renderer

Renderer* EngineCore::Engine::renderer = nullptr
private

Definition at line 168 of file Engine.h.

Referenced by cleanup(), getRenderer(), initVulkan(), and mainLoop().

◆ rightHand

MeshComponent* EngineCore::Engine::rightHand = nullptr
private

Definition at line 252 of file Engine.h.

◆ sceneManager

std::unique_ptr<SceneManager> EngineCore::Engine::sceneManager
private

◆ textureCount

uint32_t EngineCore::Engine::textureCount = 0
private

Definition at line 145 of file Engine.h.

◆ vkDestroyDebugUtilsMessengerEXT

PFN_vkDestroyDebugUtilsMessengerEXT EngineCore::Engine::vkDestroyDebugUtilsMessengerEXT = nullptr
private

Definition at line 154 of file Engine.h.

◆ xrFrameThreadPool_

std::unique_ptr<NamedThreadPool> EngineCore::Engine::xrFrameThreadPool_
private

Definition at line 176 of file Engine.h.

Referenced by mainLoop(), and run().

◆ xrInputHandler

Input::XrInputHandler* EngineCore::Engine::xrInputHandler = nullptr
private

Definition at line 104 of file Engine.h.

Referenced by createInputManager(), getXrInputHandler(), and mainLoop().


The documentation for this class was generated from the following files:
  • /home/magerbeton/Documents/gl3-vulkan/Engine/include/Engine/Core/Engine.h
  • /home/magerbeton/Documents/gl3-vulkan/Engine/src/Engine/Core/Engine.cpp