Rendu
A lightweight rendering engine for experimentations
Loading...
Searching...
No Matches
PipelineCache.hpp
1#pragma once
2
3#include "Common.hpp"
4#include "graphics/GPUObjects.hpp"
5
6#include <unordered_map>
7#include <deque>
8
19public:
20
22 void init();
23
28 VkPipeline getGraphicsPipeline(const GPUState & state);
29
34 VkPipeline getComputePipeline(const GPUState & state);
35
38
40 void clean();
41
42private:
43
46 struct Entry {
47 VkPipeline pipeline;
50 };
51
57 VkPipeline createNewPipeline(const GPUState& state, const uint64_t hash);
58
63 VkPipeline buildGraphicsPipeline(const GPUState& state);
64
69 VkPipeline buildComputePipeline(Program& program);
70
71 using ProgramPipelines = std::unordered_multimap<uint64_t, Entry>;
72 using GraphicCache = std::unordered_map<const Program*, ProgramPipelines>;
73 using ComputeCache = std::unordered_map<const Program*, VkPipeline>;
74
77 VkPipelineCache _vulkanCache = VK_NULL_HANDLE;
78
81 VkPipeline pipeline;
82 uint64_t frame = 0;
83 };
84
85 std::deque<PipelineToDelete> _pipelinesToDelete;
86};
Internal GPU state ; not all API options are exposed, only these that can be toggled in Rendu.
Definition: GPUTypes.hpp:324
Create and reuse GPU pipelines based on a given state. This supports both graphics and compute pipeli...
Definition: PipelineCache.hpp:18
VkPipeline buildGraphicsPipeline(const GPUState &state)
Definition: PipelineCache.cpp:175
GraphicCache _graphicPipelines
Graphics pipeline cache.
Definition: PipelineCache.hpp:75
std::unordered_multimap< uint64_t, Entry > ProgramPipelines
Per program pipeline type.
Definition: PipelineCache.hpp:71
std::unordered_map< const Program *, ProgramPipelines > GraphicCache
Complete cache type.
Definition: PipelineCache.hpp:72
std::deque< PipelineToDelete > _pipelinesToDelete
List of pipelines to delete once we are sure they are unused.
Definition: PipelineCache.hpp:85
void clean()
Definition: PipelineCache.cpp:133
VkPipeline createNewPipeline(const GPUState &state, const uint64_t hash)
Definition: PipelineCache.cpp:165
std::unordered_map< const Program *, VkPipeline > ComputeCache
Complete cache type.
Definition: PipelineCache.hpp:73
VkPipeline getGraphicsPipeline(const GPUState &state)
Definition: PipelineCache.cpp:27
VkPipelineCache _vulkanCache
Vulkan pipeline cache.
Definition: PipelineCache.hpp:77
ComputeCache _computePipelines
Compute pipeline cache.
Definition: PipelineCache.hpp:76
void init()
Definition: PipelineCache.cpp:11
void freeOutdatedPipelines()
Destroy pipelines that are referencing outdated state and are not used anymore.
Definition: PipelineCache.cpp:111
VkPipeline getComputePipeline(const GPUState &state)
Definition: PipelineCache.cpp:83
VkPipeline buildComputePipeline(Program &program)
Definition: PipelineCache.cpp:455
Represents a group of shaders used for rendering.
Definition: Program.hpp:31
Internal GPU state for pipeline compatibility.
Definition: GPUObjects.hpp:162
Current rendering pass information.
Definition: GPUTypes.hpp:328
Store a pipeline along with part of the information used to generate it.
Definition: PipelineCache.hpp:46
VkPipeline pipeline
The native handle.
Definition: PipelineCache.hpp:47
GPUState::RenderPass pass
The attachments layout.
Definition: PipelineCache.hpp:49
GPUMesh::State mesh
The mesh layout.
Definition: PipelineCache.hpp:48
Information for buffered pipeline deletion.
Definition: PipelineCache.hpp:80
VkPipeline pipeline
The native handle.
Definition: PipelineCache.hpp:81
uint64_t frame
The frame at which the deletion request was created.
Definition: PipelineCache.hpp:82