|
Vulkan Schnee 0.0.1
High-performance rendering engine
|
#include <Engine.h>
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) | |
| ApplicationContext * | getContext () 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. | |
| Renderer * | getRenderer () const |
| Getter for the renderer. | |
| Input::XrInputHandler * | getXrInputHandler () const |
| Getter for the XR input handler. | |
| Headset * | getHeadset () 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. | |
| PhysicsEngine * | getPhysicsEngine () 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< AssetManager > | assetManager |
| std::shared_ptr< InputHandler > | inputHandler |
| std::unique_ptr< GameModule > | module |
| VkDebugUtilsMessengerEXT | debugMessenger = nullptr |
| Input::XrInputHandler * | xrInputHandler = 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 |
| ApplicationContext * | applicationContext = nullptr |
| MirrorView * | mirrorView = nullptr |
| Headset * | headset = nullptr |
| Renderer * | renderer = nullptr |
| std::future< void > | frameCompletionFuture_ |
| std::atomic< bool > | previousFrameXrComplete_ {true} |
| std::unique_ptr< NamedThreadPool > | xrFrameThreadPool_ |
| MeshComponent * | rightHand = nullptr |
| MeshComponent * | leftHand = nullptr |
| std::unique_ptr< SceneManager > | sceneManager |
| PhysicsEngine * | physicsEngine = nullptr |
|
default |
References module.
| EngineCore::Engine::~Engine | ( | ) |
Definition at line 59 of file Engine.cpp.
|
private |
Definition at line 380 of file Engine.cpp.
References deltaTimeSeconds, and TRACY_ZONE_SCOPED_NAMED.
Referenced by mainLoop().
|
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().
|
private |
Definition at line 262 of file Engine.cpp.
References validationLayers.
|
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().
|
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.
| graphicsFence | The fence to wait on (from the frame that was just submitted) |
| presentMirror | Whether 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().
|
private |
Definition at line 1116 of file Engine.cpp.
References applicationContext, and assetManager.
Referenced by initVulkan().
|
private |
Definition at line 117 of file Engine.cpp.
References applicationContext, headset, and xrInputHandler.
Referenced by initVulkan().
|
private |
PHYSICS.
Definition at line 1124 of file Engine.cpp.
References physicsEngine.
Referenced by run().
|
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().
|
private |
Definition at line 146 of file Engine.cpp.
References applicationContext, debugMessenger, and VulkanHelper::getFunctions().
Referenced by initVulkan().
|
staticprivate |
Definition at line 233 of file Engine.cpp.
References GPU_PRINTF, and USE_GPU_PRINTF.
Referenced by populateDebugMessengerCreateInfo().
|
private |
Definition at line 1129 of file Engine.cpp.
References physicsEngine.
Referenced by run().
|
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().
| const std::unique_ptr< AssetManager > & EngineCore::Engine::getAssetManager | ( | ) | const |
Definition at line 103 of file Engine.cpp.
References assetManager.
|
inlinenodiscard |
Gets the application context which stores the vulkan instance the device and queues.
Definition at line 90 of file Engine.h.
References applicationContext.
Referenced by EngineCore::VulkanBuffer::VulkanBuffer().
| double EngineCore::Engine::getDeltaTimeSeconds | ( | ) |
gets the time between frames
Definition at line 107 of file Engine.cpp.
References deltaTimeSeconds.
| double EngineCore::Engine::getGlobalTimeSeconds | ( | ) |
Gets the time since the beginning of the simulation (sum of all delta times)
Definition at line 112 of file Engine.cpp.
References gameTime.
|
inlinenodiscard |
| std::shared_ptr< InputHandler > EngineCore::Engine::getInputHandler | ( | ) |
Gets a shared handle to the input handler. This is used for any type of input.
Definition at line 96 of file Engine.cpp.
References inputHandler.
| PhysicsEngine * EngineCore::Engine::getPhysicsEngine | ( | ) | const |
Getter for the pointer to the physics engine.
Definition at line 1111 of file Engine.cpp.
References physicsEngine.
Referenced by EngineCore::PhysicsBodyComponent::getPhysicsEngine(), and update().
|
nodiscard |
Counts the amount of entities which have renderable components.
Definition at line 122 of file Engine.cpp.
References Ecs::RegistryManager::get().
|
nodiscard |
Getter for the renderer.
Definition at line 126 of file Engine.cpp.
References renderer.
Referenced by EngineCore::MeshComponent::beginPlay().
|
inline |
Definition at line 217 of file Engine.h.
References sceneManager.
|
inlinenodiscard |
Getter for the XR input handler.
Definition at line 127 of file Engine.h.
References xrInputHandler.
|
private |
Definition at line 1120 of file Engine.cpp.
References assetManager.
|
private |
Definition at line 1091 of file Engine.cpp.
Referenced by initVulkan().
| void EngineCore::Engine::initRenderDoc | ( | ) |
Initialization point for software driven captures.
Definition at line 62 of file Engine.cpp.
References RenderDoc::get().
Referenced by run().
|
private |
Definition at line 1104 of file Engine.cpp.
References sceneManager.
Referenced by 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().
|
private |
Definition at line 131 of file Engine.cpp.
References TRACY_ZONE_SCOPED_FUNCTION.
Referenced by run().
|
private |
Definition at line 527 of file Engine.cpp.
References mirrorView.
Referenced by mainLoop().
|
inline |
Triggers the load of a new scene. Will be executed once the current frame has finished processing.
| T | Type of the scene to load. Has to be child of EngineCore::Scene |
Definition at line 266 of file Engine.h.
References sceneManager.
|
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().
|
private |
Definition at line 219 of file Engine.cpp.
References debugCallback().
| void EngineCore::Engine::processMirrorWindowEvents | ( | ) |
processes glfw window events like key presses or window events
Definition at line 374 of file Engine.cpp.
References TRACY_ZONE_SCOPED_NAMED.
Referenced by mainLoop().
|
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().
| void EngineCore::Engine::run | ( | std::unique_ptr< GameModule > | module | ) |
Runs the engine. Is the entry point for this module.
Definition at line 73 of file Engine.cpp.
References cleanup(), createPhysicsWorld(), destroyPhysicsWorld(), initRenderDoc(), initVulkan(), initWindow(), mainLoop(), module, and xrFrameThreadPool_.
Referenced by main().
|
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().
|
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().
|
private |
Definition at line 165 of file Engine.h.
Referenced by captureRenderdocFrame(), cleanup(), completeFrameAsync(), createAssetManager(), createInputManager(), createVulkanDebugMessenger(), getContext(), initVulkan(), mainLoop(), and tryCreateApplicationContext().
|
private |
Definition at line 95 of file Engine.h.
Referenced by cleanup(), createAssetManager(), fixLoadingAssets(), getAssetManager(), initAssets(), initVulkan(), mainLoop(), and processResourceLoadingPipelines().
|
private |
|
private |
Definition at line 102 of file Engine.h.
Referenced by cleanup(), and createVulkanDebugMessenger().
|
private |
Definition at line 93 of file Engine.h.
Referenced by calculateFrameTime(), getDeltaTimeSeconds(), and update().
|
private |
|
private |
Definition at line 172 of file Engine.h.
Referenced by cleanup(), and mainLoop().
|
private |
Definition at line 105 of file Engine.h.
Referenced by mainLoop().
|
private |
Definition at line 69 of file Engine.h.
Referenced by getGlobalTimeSeconds(), mainLoop(), and update().
|
private |
Definition at line 167 of file Engine.h.
Referenced by cleanup(), completeFrameAsync(), createInputManager(), getHeadset(), initVulkan(), and mainLoop().
|
private |
Definition at line 96 of file Engine.h.
Referenced by getInputHandler().
|
private |
|
private |
|
private |
Definition at line 166 of file Engine.h.
Referenced by cleanup(), completeFrameAsync(), initVulkan(), isMirrorViewMinimized(), and mainLoop().
|
private |
|
private |
Definition at line 286 of file Engine.h.
Referenced by createPhysicsWorld(), destroyPhysicsWorld(), and getPhysicsEngine().
|
private |
Definition at line 173 of file Engine.h.
Referenced by completeFrameAsync(), and mainLoop().
|
private |
Definition at line 168 of file Engine.h.
Referenced by cleanup(), getRenderer(), initVulkan(), and mainLoop().
|
private |
|
private |
Definition at line 277 of file Engine.h.
Referenced by cleanup(), createStartupScene(), getSceneManager(), initStartupScene(), initVulkan(), loadScene(), and mainLoop().
|
private |
|
private |
Definition at line 176 of file Engine.h.
Referenced by mainLoop(), and run().
|
private |
Definition at line 104 of file Engine.h.
Referenced by createInputManager(), getXrInputHandler(), and mainLoop().