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

The renderer is the main class for rendering. It owns all data which is used any time in any frame. For per frame data take a look at. More...

#include <Renderer.h>

Collaboration diagram for Engine::Rendering::Renderer:

Classes

struct  MeshConstants
 A texture index push constant. More...
struct  TaskConstants
 Used to tell the pipeline which objects are shaded with which shader. More...
struct  TonemapPushConstants

Public Member Functions

 Renderer (Core::ApplicationContext *context=nullptr, Headset *headset=nullptr, const EngineKern *engine=nullptr)
 Constructor.
 ~Renderer ()
 cleans up the object
void allocateDescriptors ()
 allocates the first batch of mesh data to the shaders
void initializeGpuBuffers () const
void prepareTransferSubmission (uint32_t frameIndex) const
void updateViewMatrix () const
 Requests an update of the current render processes view matrix. The matrix is pulled from the headset.
void createVertexShaderPathResources ()
void updateCpuRenderResources (float time)
 Creates the complete pipeline for the meshlet unpacker. This should only be called after the buffer has been created which it will be dispatching to, such as the meshlet unpacking resources.
void restartRenderCommandBuffers () const
 Resets the command buffers of the active frame and begins a new write.
void recordTonemapToSwapchain (uint32_t swapChainImageIndex) const
void recordRenderPass (size_t swapChainImageIndex)
 Records the main render pass using dynamic rendering.
const std::unique_ptr< Core::RenderingDataManager > & getRenderingDataManager () const
 Getter for the rendering data manager.
const std::unique_ptr< BufferManager > & getBufferManager () const
 Getter for the buffer manager of the renderer.
const std::unique_ptr< ComputePassManager > & getComputePassManager () const
bool ensureOutputBufferSizes (uint32_t primitive_count) const
 Calculates buffer sizes based on primitive count.
const Vulkan::BuffergetObjectCullingDataBuffer () const
const Vulkan::BuffergetObjectMeshletDataBuffer () const
const Vulkan::BuffergetObjectIDsBuffer () const
const Vulkan::BuffergetCounterBuffer () const
const Vulkan::BuffergetDispatchBuffer () const
const Vulkan::BuffergetMeshUnpackingDataBuffer () const
const Vulkan::BuffergetPlaceholderBuffer () const
const Vulkan::BuffergetPlaceholderUniformBuffer () const
VkDependencyInfo getObjectCullingToMeshletUnpackingDispatchBarriers (Vulkan::BarrierBundle &bundle) const
VkDependencyInfo getMeshletUnpackingDispatchToMeshletUnpackingBarriers (Vulkan::BarrierBundle &bundle) const
VkDependencyInfo getMeshletUnpackingToMeshletCullingDispatchBarriers (Vulkan::BarrierBundle &bundle) const
VkDependencyInfo getMeshletCullingDispatchToMeshletCullingBarriers () const
VkDependencyInfo getMeshletCullingToPrepareDrawBarriers () const
void resetMeshletUnpackingDispatchBuffers ()
void resetMeshletCullingDispatchBuffers () const
void renderToXr (size_t swapChainImageIndex, float time)
void recordTransfer (float time)
void submitInitialTransfers ()
void uploadFrameData (float time)
void submitTransfer () const
void waitForPreviousFrame () const
 Waits for the previous frame's transfer to complete before writing to GPU buffers. Must be called BEFORE updateIfDirty() to prevent race conditions where the GPU is still reading from buffers while the CPU writes new data.
void submitGraphics (uint32_t swapChainImageIndex, VkSemaphore mirrorAcquireSemaphore=VK_NULL_HANDLE) const
uint64_t getTimelineSemaphoreValue () const
VkCommandBuffer getCurrentTransferCommandBuffer () const
 Gets the current frame in flight and retrieves the transfer command buffer.
VkCommandBuffer getCurrentRenderingCommandBuffer () const
VkSemaphore getCurrentMirrorViewSemaphore () const
VkSemaphore getCurrentPresentableSemaphore (uint32_t swapchainImageIndex) const
std::vector< VkCommandBuffer > getGraphicsCommandBuffers () const
 Gets all graphics command buffers from all owned render processes.
std::vector< VkCommandBuffer > getTransferCommandBuffers () const
const std::vector< RenderProcess * > & getRenderProcesses () const
 Gets all render processes for cleanup/synchronization.
VkCommandPool getGraphicsCommandPool () const
 gets the graphics command pool
VkCommandPool getTransferCommandPool () const
 gets the command pool used for recording data transfer at the beginning of a frame
void cleanup ()
 Cleans up all resources of the renderer.
RenderProcess * getCurrentRenderProcess () const
 Gets the render process of the current frame.
void advanceFrameIndices ()
 advances the frame indices for the next frame in flight
void syncTimelineAfterPause ()
 Synchronizes the frame counter with the timeline semaphore after pausing.
bool shouldSkipMirrorView ()
 Checks if mirror view should be skipped this frame.
void markFrameStart ()
 Marks the start of a new frame for stall detection. Call this at the beginning of each render frame.
void resetFrameTimer ()
 Resets the frame timer to prevent false stall detection. Call after long blocking operations (e.g. vkDeviceWaitIdle during state transitions) so that the next markFrameStart() doesn't see the blocking time as a stall.
int64_t getFrameElapsedMs () const
 Gets the elapsed time since markFrameStart() was called. Used to check if the current frame has taken too long.
bool isInStallRecovery () const
 Checks if we're currently in stall recovery mode. During stall recovery, extra GPU synchronization should be performed.
VkSemaphore getTimelineSemaphore () const
 Getter for the main timeline renderer semaphore.
const std::vector< GraphicsPipeline * > & getGraphicsPipelines () const
 Gets the list of all graphics pipelines.
HeadsetgetHeadset () const
 Gets the headset pointer.
const ImageBasedLightingResourcesgetIBLResources () const
const SunShadowResourcesgetSunShadowResources () const
const SunShadowResourcesgetDynamicSunShadowResources () const
void setFreezeCulling (bool freeze)
 Freezes culling data (frustum planes, view-projection)
bool isFreezeCulling () const
 Checks if culling data is currently frozen.
void setVertexShaderOnlyMode (bool enabled)
bool isVertexShaderOnlyMode () const
void setParallelLodSelection (bool enabled) const
void setVSInstancedDrawing (bool enabled)
void setSkipMeshShaderDraw (bool skip)
void setSkipVertexShaderDraw (bool skip)
void setSunShadowCasterDebugView (bool enabled)
void registerWindTrailEmitter (std::shared_ptr< Entities::SceneNode > node)
void unregisterWindTrailEmitter ()
void setTracyContextManager (Debug::Tracy::TracyVkContextManager *manager)
const TimelineSynchronizer & getTimelineSynchronizer () const
 Gets the timeline synchronizer for managing frame synchronization.
bool getPipelineIndex (GraphicsPipeline *pipeline, uint32_t &pipelineIndex) const
 Gets the index of a pipeline.
bool getPipelineIndex (PipelineNames pipelineName, uint32_t &pipelineIndex) const
 Gets the pipeline index for a given PipelineNames enum.

Static Public Member Functions

static PipelineConfig getPipelineConfig (PipelineNames pipelineName)
 Gets the static configuration for a given pipeline type Returns shader paths and pipeline data for the given PipelineNames enum.

Private Member Functions

void getCurrentTracyVkContext () const
void getCurrentTracyTransferVkContext () const
void initializeFrameIndices ()
void initializeXrSwapchainFormats () const
int findExistingPipeline (const std::string &meshShader, const std::string &fragShader, const PipelineMaterialPayload &pipelineData) const
 Searches for the first existing pipeline which has the same vertex and fragment shader.
void createVertexShaderPipelineResources ()
void recordVertexShaderDraws (size_t swapChainImageIndex) const
void createVSInstancedDrawingResources ()
void recordVSInstancedDrawingPipeline () const
void recordParallelLodSelectionPipeline () const
void resetVisibilityBuffers (VkCommandBuffer commandBuffer) const
void recordVisibilityComputeToGraphicsBarriers (VkCommandBuffer commandBuffer) const
void createImageBasedLightingResources ()
void createSunShadowResources ()
void createSunShadowPipelines ()
void updateSunShadowCascades ()
void recordSunShadowPass ()
void recordSunShadowVisibilityPipeline (uint32_t cascadeIndex) const
void recordSunShadowPipelineDraws (VkCommandBuffer commandBuffer, PipelineNames pipelineName, VkPipeline shadowPipeline, uint32_t cascadeIndex)
void recordSunShadowVertexShaderDraws (VkCommandBuffer commandBuffer, uint32_t cascadeIndex, bool staticCastersOnly, bool dynamicCastersOnly) const
VkPipeline getSunShadowPipelineForCaster (PipelineNames pipelineName) const
VkPipeline getVSSunShadowPipelineForCaster (PipelineNames pipelineName) const
void createDebugLinePipeline ()
void recordDebugLineDraws (VkCommandBuffer commandBuffer) const
void createSkyGradientPipeline ()
void recordSkyGradientDraw (VkCommandBuffer commandBuffer)
void createTonemapResources ()

Private Attributes

std::unique_ptr< Core::RenderingDataManager > renderingDataManager_
std::unique_ptr< BufferManager > bufferManager_
std::unique_ptr< ComputePassManager > computePassManager_
Debug::Tracy::TracyVkContextManager * tracyContextManager_ = nullptr
std::unique_ptr< TimelineSynchronizer > timelineSynchronizer_
uint64_t renderedFrameCounter_ = 0u
int skipMirrorFramesRemaining_ = 0
std::chrono::steady_clock::time_point lastFrameStartTime_ = std::chrono::steady_clock::now()
 Time when the last frame started, for stall detection.
std::vector< Vulkan::StagedBufferSyncObjectssyncCopyObjects_ {}
std::unordered_map< GraphicsPipeline *, uint32_t > pipelineIndices_
std::unordered_map< PipelineNames, GraphicsPipeline * > pipelinesByName_
std::unordered_map< PipelineNames, uint32_t > vsPipelineNameToIndex_
const EngineKernengine_ = nullptr
VkCommandPool vkGraphicsCommandPool_ = VK_NULL_HANDLE
 The graphics and present command pool.
VkCommandPool vkTransferCommandPool_ = VK_NULL_HANDLE
 The transfer command pool for all commands submitted to the transfer queue.
VkDescriptorPool descriptorPool_ = VK_NULL_HANDLE
 The descriptor pool for all descriptors of the renderer.
std::vector< VkPipeline > vsGraphicsPipelines_
VkPipelineLayout vsPipelineLayout_ = VK_NULL_HANDLE
bool useVertexShaderPath_ = true
bool vertexShaderOnlyMode_ = false
bool useVSInstancedDrawing_ = true
ImageBasedLightingResources iblResources_
VkDescriptorPool iblDescriptorPool_ = VK_NULL_HANDLE
VkDescriptorSet brdfLutDescriptorSet_ = VK_NULL_HANDLE
SunShadowResources sunShadowResources_
SunShadowResources dynamicSunShadowResources_
SunShadowCascadeBuffer staticSunShadowCascadeData_ {}
bool staticSunShadowCacheValid_ = false
VkPipeline sunShadowOpaquePipeline_ = VK_NULL_HANDLE
VkPipeline sunShadowMovableAlphaPipeline_ = VK_NULL_HANDLE
VkPipeline sunShadowStaticAlphaPipeline_ = VK_NULL_HANDLE
VkPipeline vsSunShadowOpaquePipeline_ = VK_NULL_HANDLE
VkPipeline vsSunShadowMovableAlphaPipeline_ = VK_NULL_HANDLE
VkPipeline vsSunShadowStaticAlphaPipeline_ = VK_NULL_HANDLE
VkPipeline debugLinePipeline_ = VK_NULL_HANDLE
VkPipeline debugLineOverlayPipeline_ = VK_NULL_HANDLE
VkPipeline skyGradientPipeline_ = VK_NULL_HANDLE
VkPipelineLayout skyGradientPipelineLayout_ = VK_NULL_HANDLE
VkDescriptorSetLayout tonemapDescriptorSetLayout_ = VK_NULL_HANDLE
VkDescriptorSet tonemapDescriptorSet_ = VK_NULL_HANDLE
VkPipelineLayout tonemapPipelineLayout_ = VK_NULL_HANDLE
VkPipeline tonemapPipeline_ = VK_NULL_HANDLE
ParticleSystem * particleSystem_ = nullptr
std::weak_ptr< Entities::SceneNodewindTrailEmitterNode_
float lastRenderTime_ = 0.0f
bool freezeCulling_ = false
 When true, culling data (frustum planes) is frozen for debugging.
bool skipMeshShaderDraw_ = false
bool skipVertexShaderDraw_ = false
bool sunShadowCasterDebugView_ = false
VkDescriptorSetLayout graphicsDescriptorSetLayout = VK_NULL_HANDLE
std::vector< VkPushConstantRange > pushConstants
VkPipelineLayout computeObjectCullingPipelineLayout = VK_NULL_HANDLE
 The pipeline layout.
VkPipelineLayout computeMeshletCullingPipelineLayout = VK_NULL_HANDLE
VkPipelineLayout prepareDrawsComputePipelineLayout = VK_NULL_HANDLE
VkPipelineLayout graphicsPipelineLayout = VK_NULL_HANDLE
std::vector< RenderProcess * > renderProcesses
 The render processes.
std::vector< GraphicsPipeline * > graphicsPipelines
 The pipelines.
uint32_t currentFrame = 0u
Core::ApplicationContextcontext_ = nullptr
Headsetheadset_ = nullptr
uint64_t frameCounter = 0u
std::vector< VkSemaphore > renderFinishedSemaphores

Static Private Attributes

static constexpr int SKIP_FRAMES_AFTER_STALL = 4
 Number of frames to skip after detecting a stall (covers all swapchain images)
static constexpr std::chrono::milliseconds STALL_THRESHOLD_MS {1000}
 Threshold for considering a frame as "stalled" (1 second)

Detailed Description

The renderer is the main class for rendering. It owns all data which is used any time in any frame. For per frame data take a look at.

Data stored in this class:

RenderProcess.

Definition at line 70 of file Renderer.h.

Constructor & Destructor Documentation

◆ Renderer()

Engine::Rendering::Renderer::Renderer ( Core::ApplicationContext * context = nullptr,
Headset * headset = nullptr,
const EngineKern * engine = nullptr )
explicit

Constructor.

Parameters
contextThe application context.
headsetThe headset.
enginepointer to the engine

◆ ~Renderer()

Engine::Rendering::Renderer::~Renderer ( )

cleans up the object

Member Function Documentation

◆ advanceFrameIndices()

void Engine::Rendering::Renderer::advanceFrameIndices ( )

advances the frame indices for the next frame in flight

◆ allocateDescriptors()

void Engine::Rendering::Renderer::allocateDescriptors ( )

allocates the first batch of mesh data to the shaders

Exceptions
std::runtime_error()Thrown when functions dont resolve

◆ cleanup()

void Engine::Rendering::Renderer::cleanup ( )

Cleans up all resources of the renderer.

◆ createDebugLinePipeline()

void Engine::Rendering::Renderer::createDebugLinePipeline ( )
private

◆ createImageBasedLightingResources()

void Engine::Rendering::Renderer::createImageBasedLightingResources ( )
private

◆ createSkyGradientPipeline()

void Engine::Rendering::Renderer::createSkyGradientPipeline ( )
private

◆ createSunShadowPipelines()

void Engine::Rendering::Renderer::createSunShadowPipelines ( )
private

◆ createSunShadowResources()

void Engine::Rendering::Renderer::createSunShadowResources ( )
private

◆ createTonemapResources()

void Engine::Rendering::Renderer::createTonemapResources ( )
private

◆ createVertexShaderPathResources()

void Engine::Rendering::Renderer::createVertexShaderPathResources ( )

◆ createVertexShaderPipelineResources()

void Engine::Rendering::Renderer::createVertexShaderPipelineResources ( )
private

◆ createVSInstancedDrawingResources()

void Engine::Rendering::Renderer::createVSInstancedDrawingResources ( )
private

◆ ensureOutputBufferSizes()

bool Engine::Rendering::Renderer::ensureOutputBufferSizes ( uint32_t primitive_count) const

Calculates buffer sizes based on primitive count.

Parameters
primitive_countnumber of primitives in the scene

◆ findExistingPipeline()

int Engine::Rendering::Renderer::findExistingPipeline ( const std::string & meshShader,
const std::string & fragShader,
const PipelineMaterialPayload & pipelineData ) const
private

Searches for the first existing pipeline which has the same vertex and fragment shader.

Parameters
meshShaderThe vertex shader.
fragShaderThe fragment shader.
pipelineDataInformation describing the pipeline.
Returns
The found existing pipeline.

◆ getBufferManager()

const std::unique_ptr< BufferManager > & Engine::Rendering::Renderer::getBufferManager ( ) const

Getter for the buffer manager of the renderer.

◆ getComputePassManager()

const std::unique_ptr< ComputePassManager > & Engine::Rendering::Renderer::getComputePassManager ( ) const

◆ getCounterBuffer()

const Vulkan::Buffer & Engine::Rendering::Renderer::getCounterBuffer ( ) const
nodiscard

◆ getCurrentMirrorViewSemaphore()

VkSemaphore Engine::Rendering::Renderer::getCurrentMirrorViewSemaphore ( ) const
nodiscard

◆ getCurrentPresentableSemaphore()

VkSemaphore Engine::Rendering::Renderer::getCurrentPresentableSemaphore ( uint32_t swapchainImageIndex) const
nodiscard

◆ getCurrentRenderingCommandBuffer()

VkCommandBuffer Engine::Rendering::Renderer::getCurrentRenderingCommandBuffer ( ) const
nodiscard

◆ getCurrentRenderProcess()

RenderProcess * Engine::Rendering::Renderer::getCurrentRenderProcess ( ) const

Gets the render process of the current frame.

Returns
the current render process

◆ getCurrentTracyTransferVkContext()

void Engine::Rendering::Renderer::getCurrentTracyTransferVkContext ( ) const
inlineprivate

Definition at line 440 of file Renderer.h.

◆ getCurrentTracyVkContext()

void Engine::Rendering::Renderer::getCurrentTracyVkContext ( ) const
inlineprivate

Definition at line 439 of file Renderer.h.

◆ getCurrentTransferCommandBuffer()

VkCommandBuffer Engine::Rendering::Renderer::getCurrentTransferCommandBuffer ( ) const
nodiscard

Gets the current frame in flight and retrieves the transfer command buffer.

Returns
the transfer command buffer of the current frame in flight

◆ getDispatchBuffer()

const Vulkan::Buffer & Engine::Rendering::Renderer::getDispatchBuffer ( ) const
nodiscard

◆ getDynamicSunShadowResources()

const SunShadowResources & Engine::Rendering::Renderer::getDynamicSunShadowResources ( ) const
inlinenodiscard

Definition at line 365 of file Renderer.h.

References dynamicSunShadowResources_.

◆ getFrameElapsedMs()

int64_t Engine::Rendering::Renderer::getFrameElapsedMs ( ) const
nodiscard

Gets the elapsed time since markFrameStart() was called. Used to check if the current frame has taken too long.

Returns
Elapsed milliseconds since frame start

◆ getGraphicsCommandBuffers()

std::vector< VkCommandBuffer > Engine::Rendering::Renderer::getGraphicsCommandBuffers ( ) const

Gets all graphics command buffers from all owned render processes.

Returns
a list of all graphics command buffers

◆ getGraphicsCommandPool()

VkCommandPool Engine::Rendering::Renderer::getGraphicsCommandPool ( ) const
nodiscard

gets the graphics command pool

Returns
command pool

◆ getGraphicsPipelines()

const std::vector< GraphicsPipeline * > & Engine::Rendering::Renderer::getGraphicsPipelines ( ) const

Gets the list of all graphics pipelines.

Returns
list of graphics pipelines

◆ getHeadset()

Headset * Engine::Rendering::Renderer::getHeadset ( ) const
inlinenodiscard

Gets the headset pointer.

Returns
Pointer to the headset

Definition at line 361 of file Renderer.h.

References headset_.

◆ getIBLResources()

const ImageBasedLightingResources & Engine::Rendering::Renderer::getIBLResources ( ) const
inlinenodiscard

Definition at line 363 of file Renderer.h.

References iblResources_.

◆ getMeshletCullingDispatchToMeshletCullingBarriers()

VkDependencyInfo Engine::Rendering::Renderer::getMeshletCullingDispatchToMeshletCullingBarriers ( ) const

◆ getMeshletCullingToPrepareDrawBarriers()

VkDependencyInfo Engine::Rendering::Renderer::getMeshletCullingToPrepareDrawBarriers ( ) const

◆ getMeshletUnpackingDispatchToMeshletUnpackingBarriers()

VkDependencyInfo Engine::Rendering::Renderer::getMeshletUnpackingDispatchToMeshletUnpackingBarriers ( Vulkan::BarrierBundle & bundle) const

◆ getMeshletUnpackingToMeshletCullingDispatchBarriers()

VkDependencyInfo Engine::Rendering::Renderer::getMeshletUnpackingToMeshletCullingDispatchBarriers ( Vulkan::BarrierBundle & bundle) const

◆ getMeshUnpackingDataBuffer()

const Vulkan::Buffer & Engine::Rendering::Renderer::getMeshUnpackingDataBuffer ( ) const
nodiscard

◆ getObjectCullingDataBuffer()

const Vulkan::Buffer & Engine::Rendering::Renderer::getObjectCullingDataBuffer ( ) const
nodiscard

◆ getObjectCullingToMeshletUnpackingDispatchBarriers()

VkDependencyInfo Engine::Rendering::Renderer::getObjectCullingToMeshletUnpackingDispatchBarriers ( Vulkan::BarrierBundle & bundle) const

◆ getObjectIDsBuffer()

const Vulkan::Buffer & Engine::Rendering::Renderer::getObjectIDsBuffer ( ) const
nodiscard

◆ getObjectMeshletDataBuffer()

const Vulkan::Buffer & Engine::Rendering::Renderer::getObjectMeshletDataBuffer ( ) const
nodiscard

◆ getPipelineConfig()

PipelineConfig Engine::Rendering::Renderer::getPipelineConfig ( PipelineNames pipelineName)
static

Gets the static configuration for a given pipeline type Returns shader paths and pipeline data for the given PipelineNames enum.

Parameters
pipelineNameThe pipeline type enum
Returns
The static configuration for this pipeline

◆ getPipelineIndex() [1/2]

bool Engine::Rendering::Renderer::getPipelineIndex ( GraphicsPipeline * pipeline,
uint32_t & pipelineIndex ) const

Gets the index of a pipeline.

Parameters
pipelineThe pipeline to get the index from
pipelineIndexthe index or if the pipeline does not exist value stays unchanged!
Returns
Whether the pipeline exists or not

◆ getPipelineIndex() [2/2]

bool Engine::Rendering::Renderer::getPipelineIndex ( PipelineNames pipelineName,
uint32_t & pipelineIndex ) const

Gets the pipeline index for a given PipelineNames enum.

Parameters
pipelineNameThe pipeline type enum
pipelineIndexthe index or if the pipeline does not exist value stays unchanged!
Returns
Whether the pipeline exists or not

◆ getPlaceholderBuffer()

const Vulkan::Buffer & Engine::Rendering::Renderer::getPlaceholderBuffer ( ) const
nodiscard

◆ getPlaceholderUniformBuffer()

const Vulkan::Buffer & Engine::Rendering::Renderer::getPlaceholderUniformBuffer ( ) const
nodiscard

◆ getRenderingDataManager()

const std::unique_ptr< Core::RenderingDataManager > & Engine::Rendering::Renderer::getRenderingDataManager ( ) const

Getter for the rendering data manager.

◆ getRenderProcesses()

const std::vector< RenderProcess * > & Engine::Rendering::Renderer::getRenderProcesses ( ) const
inlinenodiscard

Gets all render processes for cleanup/synchronization.

Definition at line 255 of file Renderer.h.

References renderProcesses.

◆ getSunShadowPipelineForCaster()

VkPipeline Engine::Rendering::Renderer::getSunShadowPipelineForCaster ( PipelineNames pipelineName) const
nodiscardprivate

◆ getSunShadowResources()

const SunShadowResources & Engine::Rendering::Renderer::getSunShadowResources ( ) const
inlinenodiscard

Definition at line 364 of file Renderer.h.

References sunShadowResources_.

◆ getTimelineSemaphore()

VkSemaphore Engine::Rendering::Renderer::getTimelineSemaphore ( ) const

Getter for the main timeline renderer semaphore.

Returns
The main timeline semaphore of the renderer

◆ getTimelineSemaphoreValue()

uint64_t Engine::Rendering::Renderer::getTimelineSemaphoreValue ( ) const

◆ getTimelineSynchronizer()

const TimelineSynchronizer & Engine::Rendering::Renderer::getTimelineSynchronizer ( ) const
nodiscard

Gets the timeline synchronizer for managing frame synchronization.

Returns
The timeline synchronizer

◆ getTransferCommandBuffers()

std::vector< VkCommandBuffer > Engine::Rendering::Renderer::getTransferCommandBuffers ( ) const

◆ getTransferCommandPool()

VkCommandPool Engine::Rendering::Renderer::getTransferCommandPool ( ) const
nodiscard

gets the command pool used for recording data transfer at the beginning of a frame

Returns
transfer command pool

◆ getVSSunShadowPipelineForCaster()

VkPipeline Engine::Rendering::Renderer::getVSSunShadowPipelineForCaster ( PipelineNames pipelineName) const
nodiscardprivate

◆ initializeFrameIndices()

void Engine::Rendering::Renderer::initializeFrameIndices ( )
private

◆ initializeGpuBuffers()

void Engine::Rendering::Renderer::initializeGpuBuffers ( ) const

◆ initializeXrSwapchainFormats()

void Engine::Rendering::Renderer::initializeXrSwapchainFormats ( ) const
private

◆ isFreezeCulling()

bool Engine::Rendering::Renderer::isFreezeCulling ( ) const
inlinenodiscard

Checks if culling data is currently frozen.

Returns
true if culling data is frozen

Definition at line 384 of file Renderer.h.

References freezeCulling_.

◆ isInStallRecovery()

bool Engine::Rendering::Renderer::isInStallRecovery ( ) const
nodiscard

Checks if we're currently in stall recovery mode. During stall recovery, extra GPU synchronization should be performed.

Returns
True if in stall recovery mode

◆ isVertexShaderOnlyMode()

bool Engine::Rendering::Renderer::isVertexShaderOnlyMode ( ) const
inlinenodiscard

Definition at line 387 of file Renderer.h.

References vertexShaderOnlyMode_.

◆ markFrameStart()

void Engine::Rendering::Renderer::markFrameStart ( )

Marks the start of a new frame for stall detection. Call this at the beginning of each render frame.

◆ prepareTransferSubmission()

void Engine::Rendering::Renderer::prepareTransferSubmission ( uint32_t frameIndex) const

◆ recordDebugLineDraws()

void Engine::Rendering::Renderer::recordDebugLineDraws ( VkCommandBuffer commandBuffer) const
private

◆ recordParallelLodSelectionPipeline()

void Engine::Rendering::Renderer::recordParallelLodSelectionPipeline ( ) const
private

◆ recordRenderPass()

void Engine::Rendering::Renderer::recordRenderPass ( size_t swapChainImageIndex)

Records the main render pass using dynamic rendering.

Parameters
swapChainImageIndexIndex of the swapchain image for rendering

◆ recordSkyGradientDraw()

void Engine::Rendering::Renderer::recordSkyGradientDraw ( VkCommandBuffer commandBuffer)
private

◆ recordSunShadowPass()

void Engine::Rendering::Renderer::recordSunShadowPass ( )
private

◆ recordSunShadowPipelineDraws()

void Engine::Rendering::Renderer::recordSunShadowPipelineDraws ( VkCommandBuffer commandBuffer,
PipelineNames pipelineName,
VkPipeline shadowPipeline,
uint32_t cascadeIndex )
private

◆ recordSunShadowVertexShaderDraws()

void Engine::Rendering::Renderer::recordSunShadowVertexShaderDraws ( VkCommandBuffer commandBuffer,
uint32_t cascadeIndex,
bool staticCastersOnly,
bool dynamicCastersOnly ) const
private

◆ recordSunShadowVisibilityPipeline()

void Engine::Rendering::Renderer::recordSunShadowVisibilityPipeline ( uint32_t cascadeIndex) const
private

◆ recordTonemapToSwapchain()

void Engine::Rendering::Renderer::recordTonemapToSwapchain ( uint32_t swapChainImageIndex) const

◆ recordTransfer()

void Engine::Rendering::Renderer::recordTransfer ( float time)

◆ recordVertexShaderDraws()

void Engine::Rendering::Renderer::recordVertexShaderDraws ( size_t swapChainImageIndex) const
private

◆ recordVisibilityComputeToGraphicsBarriers()

void Engine::Rendering::Renderer::recordVisibilityComputeToGraphicsBarriers ( VkCommandBuffer commandBuffer) const
private

◆ recordVSInstancedDrawingPipeline()

void Engine::Rendering::Renderer::recordVSInstancedDrawingPipeline ( ) const
private

◆ registerWindTrailEmitter()

void Engine::Rendering::Renderer::registerWindTrailEmitter ( std::shared_ptr< Entities::SceneNode > node)
inline

Definition at line 396 of file Renderer.h.

References windTrailEmitterNode_.

◆ renderToXr()

void Engine::Rendering::Renderer::renderToXr ( size_t swapChainImageIndex,
float time )

◆ resetFrameTimer()

void Engine::Rendering::Renderer::resetFrameTimer ( )

Resets the frame timer to prevent false stall detection. Call after long blocking operations (e.g. vkDeviceWaitIdle during state transitions) so that the next markFrameStart() doesn't see the blocking time as a stall.

◆ resetMeshletCullingDispatchBuffers()

void Engine::Rendering::Renderer::resetMeshletCullingDispatchBuffers ( ) const

◆ resetMeshletUnpackingDispatchBuffers()

void Engine::Rendering::Renderer::resetMeshletUnpackingDispatchBuffers ( )

◆ resetVisibilityBuffers()

void Engine::Rendering::Renderer::resetVisibilityBuffers ( VkCommandBuffer commandBuffer) const
private

◆ restartRenderCommandBuffers()

void Engine::Rendering::Renderer::restartRenderCommandBuffers ( ) const

Resets the command buffers of the active frame and begins a new write.

◆ setFreezeCulling()

void Engine::Rendering::Renderer::setFreezeCulling ( bool freeze)

Freezes culling data (frustum planes, view-projection)

When frozen, the culling system continues to use the frustum matrices from the moment freeze was enabled. This allows viewing the scene from a debug camera while seeing what's being culled from the original viewpoint.

Parameters
freezetrue to freeze culling data, false to resume updates

◆ setParallelLodSelection()

void Engine::Rendering::Renderer::setParallelLodSelection ( bool enabled) const

◆ setSkipMeshShaderDraw()

void Engine::Rendering::Renderer::setSkipMeshShaderDraw ( bool skip)
inline

Definition at line 392 of file Renderer.h.

References skipMeshShaderDraw_.

◆ setSkipVertexShaderDraw()

void Engine::Rendering::Renderer::setSkipVertexShaderDraw ( bool skip)
inline

Definition at line 393 of file Renderer.h.

References skipVertexShaderDraw_.

◆ setSunShadowCasterDebugView()

void Engine::Rendering::Renderer::setSunShadowCasterDebugView ( bool enabled)
inline

Definition at line 394 of file Renderer.h.

References sunShadowCasterDebugView_.

◆ setTracyContextManager()

void Engine::Rendering::Renderer::setTracyContextManager ( Debug::Tracy::TracyVkContextManager * manager)
inline

Definition at line 399 of file Renderer.h.

References tracyContextManager_.

◆ setVertexShaderOnlyMode()

void Engine::Rendering::Renderer::setVertexShaderOnlyMode ( bool enabled)
inline

Definition at line 386 of file Renderer.h.

References vertexShaderOnlyMode_.

◆ setVSInstancedDrawing()

void Engine::Rendering::Renderer::setVSInstancedDrawing ( bool enabled)
inline

Definition at line 391 of file Renderer.h.

References useVSInstancedDrawing_.

◆ shouldSkipMirrorView()

bool Engine::Rendering::Renderer::shouldSkipMirrorView ( )
nodiscard

Checks if mirror view should be skipped this frame.

Returns true if:

  • A timeline sync just happened (mirror swapchain may be in PRESENT state)
  • More than 1 second elapsed since last frame (long stall recovery)

When true due to stall, also performs vkDeviceWaitIdle to ensure clean GPU state.

Returns
true if mirror view should be skipped, false otherwise

◆ submitGraphics()

void Engine::Rendering::Renderer::submitGraphics ( uint32_t swapChainImageIndex,
VkSemaphore mirrorAcquireSemaphore = VK_NULL_HANDLE ) const

◆ submitInitialTransfers()

void Engine::Rendering::Renderer::submitInitialTransfers ( )

◆ submitTransfer()

void Engine::Rendering::Renderer::submitTransfer ( ) const

◆ syncTimelineAfterPause()

void Engine::Rendering::Renderer::syncTimelineAfterPause ( )

Synchronizes the frame counter with the timeline semaphore after pausing.

Call this when transitioning from non-rendering (SkipRender) back to rendering. This ensures the frame counter is advanced enough that timeline semaphore signals will have increasing values (required by Vulkan spec).

Without this, resuming after SkipRender frames would try to signal the same timeline values that were already signaled before pausing, causing a validation error and potential hang.

◆ unregisterWindTrailEmitter()

void Engine::Rendering::Renderer::unregisterWindTrailEmitter ( )
inline

Definition at line 397 of file Renderer.h.

References windTrailEmitterNode_.

◆ updateCpuRenderResources()

void Engine::Rendering::Renderer::updateCpuRenderResources ( float time)

Creates the complete pipeline for the meshlet unpacker. This should only be called after the buffer has been created which it will be dispatching to, such as the meshlet unpacking resources.

Creates the compute pipeline for the meshlet culling stage. This should only be called after the meshlet culling shader has been created.

Updates all data for gpu frame buffers

Parameters
timetime for time based fragment shaders

◆ updateSunShadowCascades()

void Engine::Rendering::Renderer::updateSunShadowCascades ( )
private

◆ updateViewMatrix()

void Engine::Rendering::Renderer::updateViewMatrix ( ) const

Requests an update of the current render processes view matrix. The matrix is pulled from the headset.

◆ uploadFrameData()

void Engine::Rendering::Renderer::uploadFrameData ( float time)

◆ waitForPreviousFrame()

void Engine::Rendering::Renderer::waitForPreviousFrame ( ) const

Waits for the previous frame's transfer to complete before writing to GPU buffers. Must be called BEFORE updateIfDirty() to prevent race conditions where the GPU is still reading from buffers while the CPU writes new data.

Member Data Documentation

◆ brdfLutDescriptorSet_

VkDescriptorSet Engine::Rendering::Renderer::brdfLutDescriptorSet_ = VK_NULL_HANDLE
private

Definition at line 530 of file Renderer.h.

◆ bufferManager_

std::unique_ptr<BufferManager> Engine::Rendering::Renderer::bufferManager_
private

Definition at line 191 of file Renderer.h.

◆ computeMeshletCullingPipelineLayout

VkPipelineLayout Engine::Rendering::Renderer::computeMeshletCullingPipelineLayout = VK_NULL_HANDLE
private

Definition at line 629 of file Renderer.h.

◆ computeObjectCullingPipelineLayout

VkPipelineLayout Engine::Rendering::Renderer::computeObjectCullingPipelineLayout = VK_NULL_HANDLE
private

The pipeline layout.

Definition at line 628 of file Renderer.h.

◆ computePassManager_

std::unique_ptr<ComputePassManager> Engine::Rendering::Renderer::computePassManager_
private

Definition at line 192 of file Renderer.h.

◆ context_

Core::ApplicationContext* Engine::Rendering::Renderer::context_ = nullptr
private

Definition at line 649 of file Renderer.h.

◆ currentFrame

uint32_t Engine::Rendering::Renderer::currentFrame = 0u
private

Definition at line 647 of file Renderer.h.

◆ debugLineOverlayPipeline_

VkPipeline Engine::Rendering::Renderer::debugLineOverlayPipeline_ = VK_NULL_HANDLE
private

Definition at line 558 of file Renderer.h.

◆ debugLinePipeline_

VkPipeline Engine::Rendering::Renderer::debugLinePipeline_ = VK_NULL_HANDLE
private

Definition at line 557 of file Renderer.h.

◆ descriptorPool_

VkDescriptorPool Engine::Rendering::Renderer::descriptorPool_ = VK_NULL_HANDLE
private

The descriptor pool for all descriptors of the renderer.

Definition at line 504 of file Renderer.h.

◆ dynamicSunShadowResources_

SunShadowResources Engine::Rendering::Renderer::dynamicSunShadowResources_
private

Definition at line 536 of file Renderer.h.

Referenced by getDynamicSunShadowResources().

◆ engine_

const EngineKern* Engine::Rendering::Renderer::engine_ = nullptr
private

Definition at line 474 of file Renderer.h.

◆ frameCounter

uint64_t Engine::Rendering::Renderer::frameCounter = 0u
private

Definition at line 652 of file Renderer.h.

◆ freezeCulling_

bool Engine::Rendering::Renderer::freezeCulling_ = false
private

When true, culling data (frustum planes) is frozen for debugging.

Definition at line 592 of file Renderer.h.

Referenced by isFreezeCulling().

◆ graphicsDescriptorSetLayout

VkDescriptorSetLayout Engine::Rendering::Renderer::graphicsDescriptorSetLayout = VK_NULL_HANDLE
private

Definition at line 598 of file Renderer.h.

◆ graphicsPipelineLayout

VkPipelineLayout Engine::Rendering::Renderer::graphicsPipelineLayout = VK_NULL_HANDLE
private

Definition at line 631 of file Renderer.h.

◆ graphicsPipelines

std::vector<GraphicsPipeline *> Engine::Rendering::Renderer::graphicsPipelines
private

The pipelines.

Definition at line 645 of file Renderer.h.

◆ headset_

Headset* Engine::Rendering::Renderer::headset_ = nullptr
private

Definition at line 650 of file Renderer.h.

Referenced by getHeadset().

◆ iblDescriptorPool_

VkDescriptorPool Engine::Rendering::Renderer::iblDescriptorPool_ = VK_NULL_HANDLE
private

Definition at line 529 of file Renderer.h.

◆ iblResources_

ImageBasedLightingResources Engine::Rendering::Renderer::iblResources_
private

Definition at line 528 of file Renderer.h.

Referenced by getIBLResources().

◆ lastFrameStartTime_

std::chrono::steady_clock::time_point Engine::Rendering::Renderer::lastFrameStartTime_ = std::chrono::steady_clock::now()
private

Time when the last frame started, for stall detection.

Definition at line 458 of file Renderer.h.

◆ lastRenderTime_

float Engine::Rendering::Renderer::lastRenderTime_ = 0.0f
private

Definition at line 589 of file Renderer.h.

◆ particleSystem_

ParticleSystem* Engine::Rendering::Renderer::particleSystem_ = nullptr
private

Definition at line 587 of file Renderer.h.

◆ pipelineIndices_

std::unordered_map<GraphicsPipeline *, uint32_t> Engine::Rendering::Renderer::pipelineIndices_
private

Definition at line 466 of file Renderer.h.

◆ pipelinesByName_

std::unordered_map<PipelineNames, GraphicsPipeline *> Engine::Rendering::Renderer::pipelinesByName_
private

Definition at line 469 of file Renderer.h.

◆ prepareDrawsComputePipelineLayout

VkPipelineLayout Engine::Rendering::Renderer::prepareDrawsComputePipelineLayout = VK_NULL_HANDLE
private

Definition at line 630 of file Renderer.h.

◆ pushConstants

std::vector<VkPushConstantRange> Engine::Rendering::Renderer::pushConstants
private

Definition at line 623 of file Renderer.h.

◆ renderedFrameCounter_

uint64_t Engine::Rendering::Renderer::renderedFrameCounter_ = 0u
private

Definition at line 448 of file Renderer.h.

◆ renderFinishedSemaphores

std::vector<VkSemaphore> Engine::Rendering::Renderer::renderFinishedSemaphores
private

Definition at line 654 of file Renderer.h.

◆ renderingDataManager_

std::unique_ptr<Core::RenderingDataManager> Engine::Rendering::Renderer::renderingDataManager_
private

Definition at line 190 of file Renderer.h.

◆ renderProcesses

std::vector<RenderProcess *> Engine::Rendering::Renderer::renderProcesses
private

The render processes.

Definition at line 636 of file Renderer.h.

Referenced by getRenderProcesses().

◆ SKIP_FRAMES_AFTER_STALL

int Engine::Rendering::Renderer::SKIP_FRAMES_AFTER_STALL = 4
staticconstexprprivate

Number of frames to skip after detecting a stall (covers all swapchain images)

Definition at line 455 of file Renderer.h.

◆ skipMeshShaderDraw_

bool Engine::Rendering::Renderer::skipMeshShaderDraw_ = false
private

Definition at line 594 of file Renderer.h.

Referenced by setSkipMeshShaderDraw().

◆ skipMirrorFramesRemaining_

int Engine::Rendering::Renderer::skipMirrorFramesRemaining_ = 0
private

Number of frames remaining to skip mirror view after stall recovery We skip multiple frames to cycle through all swapchain images (typically 3)

Definition at line 452 of file Renderer.h.

◆ skipVertexShaderDraw_

bool Engine::Rendering::Renderer::skipVertexShaderDraw_ = false
private

Definition at line 595 of file Renderer.h.

Referenced by setSkipVertexShaderDraw().

◆ skyGradientPipeline_

VkPipeline Engine::Rendering::Renderer::skyGradientPipeline_ = VK_NULL_HANDLE
private

Definition at line 564 of file Renderer.h.

◆ skyGradientPipelineLayout_

VkPipelineLayout Engine::Rendering::Renderer::skyGradientPipelineLayout_ = VK_NULL_HANDLE
private

Definition at line 565 of file Renderer.h.

◆ STALL_THRESHOLD_MS

std::chrono::milliseconds Engine::Rendering::Renderer::STALL_THRESHOLD_MS {1000}
staticconstexprprivate

Threshold for considering a frame as "stalled" (1 second)

Definition at line 461 of file Renderer.h.

◆ staticSunShadowCacheValid_

bool Engine::Rendering::Renderer::staticSunShadowCacheValid_ = false
private

Definition at line 538 of file Renderer.h.

◆ staticSunShadowCascadeData_

SunShadowCascadeBuffer Engine::Rendering::Renderer::staticSunShadowCascadeData_ {}
private

Definition at line 537 of file Renderer.h.

◆ sunShadowCasterDebugView_

bool Engine::Rendering::Renderer::sunShadowCasterDebugView_ = false
private

Definition at line 596 of file Renderer.h.

Referenced by setSunShadowCasterDebugView().

◆ sunShadowMovableAlphaPipeline_

VkPipeline Engine::Rendering::Renderer::sunShadowMovableAlphaPipeline_ = VK_NULL_HANDLE
private

Definition at line 540 of file Renderer.h.

◆ sunShadowOpaquePipeline_

VkPipeline Engine::Rendering::Renderer::sunShadowOpaquePipeline_ = VK_NULL_HANDLE
private

Definition at line 539 of file Renderer.h.

◆ sunShadowResources_

SunShadowResources Engine::Rendering::Renderer::sunShadowResources_
private

Definition at line 535 of file Renderer.h.

Referenced by getSunShadowResources().

◆ sunShadowStaticAlphaPipeline_

VkPipeline Engine::Rendering::Renderer::sunShadowStaticAlphaPipeline_ = VK_NULL_HANDLE
private

Definition at line 541 of file Renderer.h.

◆ syncCopyObjects_

std::vector<Vulkan::StagedBufferSyncObjects> Engine::Rendering::Renderer::syncCopyObjects_ {}
private

Definition at line 463 of file Renderer.h.

◆ timelineSynchronizer_

std::unique_ptr<TimelineSynchronizer> Engine::Rendering::Renderer::timelineSynchronizer_
private

Definition at line 443 of file Renderer.h.

◆ tonemapDescriptorSet_

VkDescriptorSet Engine::Rendering::Renderer::tonemapDescriptorSet_ = VK_NULL_HANDLE
private

Definition at line 580 of file Renderer.h.

◆ tonemapDescriptorSetLayout_

VkDescriptorSetLayout Engine::Rendering::Renderer::tonemapDescriptorSetLayout_ = VK_NULL_HANDLE
private

Definition at line 579 of file Renderer.h.

◆ tonemapPipeline_

VkPipeline Engine::Rendering::Renderer::tonemapPipeline_ = VK_NULL_HANDLE
private

Definition at line 582 of file Renderer.h.

◆ tonemapPipelineLayout_

VkPipelineLayout Engine::Rendering::Renderer::tonemapPipelineLayout_ = VK_NULL_HANDLE
private

Definition at line 581 of file Renderer.h.

◆ tracyContextManager_

Debug::Tracy::TracyVkContextManager* Engine::Rendering::Renderer::tracyContextManager_ = nullptr
private

Definition at line 433 of file Renderer.h.

Referenced by setTracyContextManager().

◆ useVertexShaderPath_

bool Engine::Rendering::Renderer::useVertexShaderPath_ = true
private

Definition at line 511 of file Renderer.h.

◆ useVSInstancedDrawing_

bool Engine::Rendering::Renderer::useVSInstancedDrawing_ = true
private

Definition at line 517 of file Renderer.h.

Referenced by setVSInstancedDrawing().

◆ vertexShaderOnlyMode_

bool Engine::Rendering::Renderer::vertexShaderOnlyMode_ = false
private

Definition at line 512 of file Renderer.h.

Referenced by isVertexShaderOnlyMode(), and setVertexShaderOnlyMode().

◆ vkGraphicsCommandPool_

VkCommandPool Engine::Rendering::Renderer::vkGraphicsCommandPool_ = VK_NULL_HANDLE
private

The graphics and present command pool.

Definition at line 494 of file Renderer.h.

◆ vkTransferCommandPool_

VkCommandPool Engine::Rendering::Renderer::vkTransferCommandPool_ = VK_NULL_HANDLE
private

The transfer command pool for all commands submitted to the transfer queue.

Definition at line 499 of file Renderer.h.

◆ vsGraphicsPipelines_

std::vector<VkPipeline> Engine::Rendering::Renderer::vsGraphicsPipelines_
private

Definition at line 509 of file Renderer.h.

◆ vsPipelineLayout_

VkPipelineLayout Engine::Rendering::Renderer::vsPipelineLayout_ = VK_NULL_HANDLE
private

Definition at line 510 of file Renderer.h.

◆ vsPipelineNameToIndex_

std::unordered_map<PipelineNames, uint32_t> Engine::Rendering::Renderer::vsPipelineNameToIndex_
private

Definition at line 472 of file Renderer.h.

◆ vsSunShadowMovableAlphaPipeline_

VkPipeline Engine::Rendering::Renderer::vsSunShadowMovableAlphaPipeline_ = VK_NULL_HANDLE
private

Definition at line 543 of file Renderer.h.

◆ vsSunShadowOpaquePipeline_

VkPipeline Engine::Rendering::Renderer::vsSunShadowOpaquePipeline_ = VK_NULL_HANDLE
private

Definition at line 542 of file Renderer.h.

◆ vsSunShadowStaticAlphaPipeline_

VkPipeline Engine::Rendering::Renderer::vsSunShadowStaticAlphaPipeline_ = VK_NULL_HANDLE
private

Definition at line 544 of file Renderer.h.

◆ windTrailEmitterNode_

std::weak_ptr<Entities::SceneNode> Engine::Rendering::Renderer::windTrailEmitterNode_
private

Definition at line 588 of file Renderer.h.

Referenced by registerWindTrailEmitter(), and unregisterWindTrailEmitter().


The documentation for this class was generated from the following file:
  • /home/magerbeton/Documents/gl3-vulkan/Engine/include/Engine/Renderer/Renderer.h