15#include <unordered_map>
17#include <vulkan/vulkan_core.h>
20# include <tracy/TracyVulkan.hpp>
25 class TracyVkContextManager;
41 class RenderingDataManager;
46 class ComputePassManager;
50 class TimelineSynchronizer;
229 uint32_t swapChainImageIndex,
230 VkSemaphore mirrorAcquireSemaphore = VK_NULL_HANDLE
486 const std::string & meshShader,
487 const std::string & fragShader,
601 PFN_vkCmdBeginDebugUtilsLabelEXT vkCmdBeginDebugUtilsLabelEXT =
nullptr;
602 PFN_vkCmdEndDebugUtilsLabelEXT vkCmdEndDebugUtilsLabelEXT =
nullptr;
The application context is the core class which stores the basic openxr and vulkan objects.
const Vulkan::Buffer & getPlaceholderUniformBuffer() const
std::unique_ptr< TimelineSynchronizer > timelineSynchronizer_
VkPipelineLayout vsPipelineLayout_
VkDependencyInfo getMeshletUnpackingDispatchToMeshletUnpackingBarriers(Vulkan::BarrierBundle &bundle) const
void resetVisibilityBuffers(VkCommandBuffer commandBuffer) const
void createVertexShaderPathResources()
void createSunShadowResources()
const std::unique_ptr< Core::RenderingDataManager > & getRenderingDataManager() const
Getter for the rendering data manager.
void setTracyContextManager(Debug::Tracy::TracyVkContextManager *manager)
std::vector< GraphicsPipeline * > graphicsPipelines
The pipelines.
VkPipelineLayout skyGradientPipelineLayout_
std::unordered_map< GraphicsPipeline *, uint32_t > pipelineIndices_
const SunShadowResources & getSunShadowResources() const
void uploadFrameData(float time)
RenderProcess * getCurrentRenderProcess() const
Gets the render process of the current frame.
void advanceFrameIndices()
advances the frame indices for the next frame in flight
void recordTonemapToSwapchain(uint32_t swapChainImageIndex) const
std::unique_ptr< BufferManager > bufferManager_
void markFrameStart()
Marks the start of a new frame for stall detection. Call this at the beginning of each render frame.
void allocateDescriptors()
allocates the first batch of mesh data to the shaders
void recordSunShadowVisibilityPipeline(uint32_t cascadeIndex) const
VkDescriptorSetLayout tonemapDescriptorSetLayout_
VkPipeline vsSunShadowOpaquePipeline_
const std::vector< RenderProcess * > & getRenderProcesses() const
Gets all render processes for cleanup/synchronization.
VkPipelineLayout computeObjectCullingPipelineLayout
The pipeline layout.
static constexpr int SKIP_FRAMES_AFTER_STALL
Number of frames to skip after detecting a stall (covers all swapchain images)
void resetFrameTimer()
Resets the frame timer to prevent false stall detection. Call after long blocking operations (e....
void setVSInstancedDrawing(bool enabled)
const Vulkan::Buffer & getMeshUnpackingDataBuffer() const
std::unique_ptr< ComputePassManager > computePassManager_
VkPipeline sunShadowOpaquePipeline_
void setSunShadowCasterDebugView(bool enabled)
const std::unique_ptr< BufferManager > & getBufferManager() const
Getter for the buffer manager of the renderer.
void updateCpuRenderResources(float time)
Creates the complete pipeline for the meshlet unpacker. This should only be called after the buffer h...
const Vulkan::Buffer & getPlaceholderBuffer() 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 recordSunShadowPipelineDraws(VkCommandBuffer commandBuffer, PipelineNames pipelineName, VkPipeline shadowPipeline, uint32_t cascadeIndex)
static PipelineConfig getPipelineConfig(PipelineNames pipelineName)
Gets the static configuration for a given pipeline type Returns shader paths and pipeline data for th...
std::vector< RenderProcess * > renderProcesses
The render processes.
VkDescriptorSetLayout graphicsDescriptorSetLayout
void setVertexShaderOnlyMode(bool enabled)
void updateViewMatrix() const
Requests an update of the current render processes view matrix. The matrix is pulled from the headset...
void resetMeshletCullingDispatchBuffers() const
void getCurrentTracyTransferVkContext() const
void initializeFrameIndices()
VkPipeline vsSunShadowMovableAlphaPipeline_
void renderToXr(size_t swapChainImageIndex, float time)
bool freezeCulling_
When true, culling data (frustum planes) is frozen for debugging.
std::vector< VkCommandBuffer > getGraphicsCommandBuffers() const
Gets all graphics command buffers from all owned render processes.
void recordSunShadowVertexShaderDraws(VkCommandBuffer commandBuffer, uint32_t cascadeIndex, bool staticCastersOnly, bool dynamicCastersOnly) const
VkDependencyInfo getMeshletCullingToPrepareDrawBarriers() const
VkPipelineLayout graphicsPipelineLayout
Core::ApplicationContext * context_
VkSemaphore getCurrentMirrorViewSemaphore() const
VkCommandBuffer getCurrentRenderingCommandBuffer() const
VkPipeline skyGradientPipeline_
VkDependencyInfo getMeshletCullingDispatchToMeshletCullingBarriers() const
void cleanup()
Cleans up all resources of the renderer.
VkPipelineLayout tonemapPipelineLayout_
void submitGraphics(uint32_t swapChainImageIndex, VkSemaphore mirrorAcquireSemaphore=VK_NULL_HANDLE) const
VkPipeline tonemapPipeline_
std::vector< VkSemaphore > renderFinishedSemaphores
void submitTransfer() const
VkPipeline getVSSunShadowPipelineForCaster(PipelineNames pipelineName) const
void registerWindTrailEmitter(std::shared_ptr< Entities::SceneNode > node)
SunShadowCascadeBuffer staticSunShadowCascadeData_
VkDescriptorPool descriptorPool_
The descriptor pool for all descriptors of the renderer.
const Vulkan::Buffer & getDispatchBuffer() const
bool vertexShaderOnlyMode_
uint64_t renderedFrameCounter_
const std::vector< GraphicsPipeline * > & getGraphicsPipelines() const
Gets the list of all graphics pipelines.
void resetMeshletUnpackingDispatchBuffers()
VkCommandPool vkGraphicsCommandPool_
The graphics and present command pool.
const Vulkan::Buffer & getObjectMeshletDataBuffer() const
std::chrono::steady_clock::time_point lastFrameStartTime_
Time when the last frame started, for stall detection.
const Vulkan::Buffer & getCounterBuffer() const
void initializeXrSwapchainFormats() const
bool getPipelineIndex(GraphicsPipeline *pipeline, uint32_t &pipelineIndex) const
Gets the index of a pipeline.
std::unique_ptr< Core::RenderingDataManager > renderingDataManager_
void recordSkyGradientDraw(VkCommandBuffer commandBuffer)
ParticleSystem * particleSystem_
void initializeGpuBuffers() const
VkDependencyInfo getObjectCullingToMeshletUnpackingDispatchBarriers(Vulkan::BarrierBundle &bundle) const
bool shouldSkipMirrorView()
Checks if mirror view should be skipped this frame.
std::vector< VkPushConstantRange > pushConstants
bool skipVertexShaderDraw_
static constexpr std::chrono::milliseconds STALL_THRESHOLD_MS
Threshold for considering a frame as "stalled" (1 second)
void setParallelLodSelection(bool enabled) const
void createImageBasedLightingResources()
void setFreezeCulling(bool freeze)
Freezes culling data (frustum planes, view-projection)
const std::unique_ptr< ComputePassManager > & getComputePassManager() const
VkDependencyInfo getMeshletUnpackingToMeshletCullingDispatchBarriers(Vulkan::BarrierBundle &bundle) const
Headset * getHeadset() const
Gets the headset pointer.
void waitForPreviousFrame() const
Waits for the previous frame's transfer to complete before writing to GPU buffers....
VkPipeline sunShadowMovableAlphaPipeline_
int64_t getFrameElapsedMs() const
Gets the elapsed time since markFrameStart() was called. Used to check if the current frame has taken...
bool getPipelineIndex(PipelineNames pipelineName, uint32_t &pipelineIndex) const
Gets the pipeline index for a given PipelineNames enum.
VkPipeline debugLineOverlayPipeline_
void unregisterWindTrailEmitter()
void restartRenderCommandBuffers() const
Resets the command buffers of the active frame and begins a new write.
void submitInitialTransfers()
void recordVisibilityComputeToGraphicsBarriers(VkCommandBuffer commandBuffer) const
std::unordered_map< PipelineNames, uint32_t > vsPipelineNameToIndex_
ImageBasedLightingResources iblResources_
bool ensureOutputBufferSizes(uint32_t primitive_count) const
Calculates buffer sizes based on primitive count.
bool isVertexShaderOnlyMode() const
VkDescriptorSet tonemapDescriptorSet_
Renderer(Core::ApplicationContext *context=nullptr, Headset *headset=nullptr, const EngineKern *engine=nullptr)
Constructor.
void createVSInstancedDrawingResources()
VkPipelineLayout prepareDrawsComputePipelineLayout
void recordSunShadowPass()
std::vector< VkCommandBuffer > getTransferCommandBuffers() const
std::unordered_map< PipelineNames, GraphicsPipeline * > pipelinesByName_
const SunShadowResources & getDynamicSunShadowResources() const
const TimelineSynchronizer & getTimelineSynchronizer() const
Gets the timeline synchronizer for managing frame synchronization.
VkDescriptorPool iblDescriptorPool_
std::vector< Vulkan::StagedBufferSyncObjects > syncCopyObjects_
VkPipelineLayout computeMeshletCullingPipelineLayout
VkCommandPool vkTransferCommandPool_
The transfer command pool for all commands submitted to the transfer queue.
void recordVSInstancedDrawingPipeline() const
void recordDebugLineDraws(VkCommandBuffer commandBuffer) const
void createTonemapResources()
bool useVertexShaderPath_
VkCommandPool getTransferCommandPool() const
gets the command pool used for recording data transfer at the beginning of a frame
VkCommandBuffer getCurrentTransferCommandBuffer() const
Gets the current frame in flight and retrieves the transfer command buffer.
void getCurrentTracyVkContext() const
const Vulkan::Buffer & getObjectCullingDataBuffer() const
void updateSunShadowCascades()
void createSkyGradientPipeline()
SunShadowResources dynamicSunShadowResources_
void recordTransfer(float time)
void createSunShadowPipelines()
bool isInStallRecovery() const
Checks if we're currently in stall recovery mode. During stall recovery, extra GPU synchronization sh...
const Vulkan::Buffer & getObjectIDsBuffer() const
uint64_t getTimelineSemaphoreValue() const
~Renderer()
cleans up the object
std::vector< VkPipeline > vsGraphicsPipelines_
int skipMirrorFramesRemaining_
bool sunShadowCasterDebugView_
void setSkipMeshShaderDraw(bool skip)
VkPipeline debugLinePipeline_
void syncTimelineAfterPause()
Synchronizes the frame counter with the timeline semaphore after pausing.
bool useVSInstancedDrawing_
SunShadowResources sunShadowResources_
void createDebugLinePipeline()
void setSkipVertexShaderDraw(bool skip)
void createVertexShaderPipelineResources()
VkDescriptorSet brdfLutDescriptorSet_
const EngineKern * engine_
Debug::Tracy::TracyVkContextManager * tracyContextManager_
VkCommandPool getGraphicsCommandPool() const
gets the graphics command pool
VkPipeline vsSunShadowStaticAlphaPipeline_
VkSemaphore getCurrentPresentableSemaphore(uint32_t swapchainImageIndex) const
VkPipeline sunShadowStaticAlphaPipeline_
VkSemaphore getTimelineSemaphore() const
Getter for the main timeline renderer semaphore.
void recordVertexShaderDraws(size_t swapChainImageIndex) const
void recordRenderPass(size_t swapChainImageIndex)
Records the main render pass using dynamic rendering.
VkPipeline getSunShadowPipelineForCaster(PipelineNames pipelineName) const
const ImageBasedLightingResources & getIBLResources() const
void prepareTransferSubmission(uint32_t frameIndex) const
bool staticSunShadowCacheValid_
bool isFreezeCulling() const
Checks if culling data is currently frozen.
std::weak_ptr< Entities::SceneNode > windTrailEmitterNode_
void recordParallelLodSelectionPipeline() const
RAII wrapper for Vulkan buffer and device memory.
Core audio subsystem owning the miniaudio engine and managing playback.
GpuBuffers::SunShadowCascadeBuffer SunShadowCascadeBuffer
Static configuration for a graphics pipeline Defines which shaders to use for a given PipelineNames e...
std::filesystem::path meshShaderPath
PipelineMaterialPayload pipelineData
std::filesystem::path fragmentShaderPath
uint32_t baseVisibleMeshletIndex
MeshConstants(uint32_t baseVisibleMeshletIndex)
TaskConstants(const uint32_t drawCommandOffset, const uint32_t cascadeIndex)
TaskConstants(const uint32_t drawCommandOffset=0)
uint32_t drawCommandOffset
uint32_t manualSrgbEncode