Nebula
Loading...
Searching...
No Matches
vkpipelinedatabase.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
21//------------------------------------------------------------------------------
22#include "core/singleton.h"
23#include "coregraphics/shader.h"
24#include "coregraphics/pass.h"
27
28namespace Vulkan
29{
30class VkVertexLayout;
31class VkShaderProgram;
32class VkPass;
33
35{
37public:
38
48
52 virtual ~VkPipelineDatabase();
53
55 void Setup(const VkDevice dev, const VkPipelineCache cache);
57 void Discard();
58
60 void SetPass(const CoreGraphics::PassId pass);
62 void SetSubpass(uint32_t subpass);
64 void SetShader(const CoreGraphics::ShaderProgramId program, const VkGraphicsPipelineCreateInfo& shaderInfo);
69 const CoreGraphics::PassId pass
70 , const uint32_t subpass
71 , const CoreGraphics::ShaderProgramId program
72 , const CoreGraphics::InputAssemblyKey inputAssembly
73 , const VkGraphicsPipelineCreateInfo& shaderInfo);
75 void CachePipeline(
76 const CoreGraphics::PassId pass
77 , const uint32_t subpass
78 , const CoreGraphics::ShaderProgramId program
79 , const CoreGraphics::InputAssemblyKey inputAssembly
80 , const VkGraphicsPipelineCreateInfo& shaderInfo
81 , CoreGraphics::PipelineId pipeline);
85 VkPipeline GetCompiledPipeline();
87 VkPipeline GetCompiledPipeline(
88 const CoreGraphics::PassId pass
89 , const uint32_t subpass
90 , const CoreGraphics::ShaderProgramId program
91 , const CoreGraphics::InputAssemblyKey inputAssembly
92 , const VkGraphicsPipelineCreateInfo& shaderInfo);
94 void Reset();
95
97 void Reload(const CoreGraphics::ShaderProgramId id);
99 void RecreatePipelines();
100private:
101
102
103 VkDevice dev;
104 VkPipelineCache cache;
107 CoreGraphics::ShaderProgramId currentShaderProgram;
108 VkGraphicsPipelineCreateInfo currentShaderInfo;
110 const VkPipelineVertexInputStateCreateInfo* currentVertexLayout;
111
112 struct Tier1Node;
113 struct Tier2Node;
114 struct Tier3Node;
115 struct Tier4Node;
116
117 struct BaseNode
118 {
120
121 BaseNode() : initial(true) {}
122 };
123 struct Tier1Node : public BaseNode
124 {
125 // IndexT == subpass id
127 };
136 struct Tier4Node : public BaseNode
137 {
138 CoreGraphics::PipelineId pipeline = CoreGraphics::InvalidPipelineId;
139 };
140
142
144
149 VkPipeline currentPipeline;
150};
151} // namespace Vulkan
Allocates memory in chunks.
Definition arenaallocator.h:36
A collection of key/value pairs with quick value retrieval by key at roughly O(log n).
Definition dictionary.h:34
void Reload(const CoreGraphics::ShaderProgramId id)
re-creates all pipelines for the given shader program id
Definition vkpipelinedatabase.cc:288
VkPipelineCache cache
Definition vkpipelinedatabase.h:104
void SetShader(const CoreGraphics::ShaderProgramId program, const VkGraphicsPipelineCreateInfo &shaderInfo)
set shader
Definition vkpipelinedatabase.cc:124
void RecreatePipelines()
re-creates all pipelines for all shader programs
Definition vkpipelinedatabase.cc:356
Tier1Node * ct1
Definition vkpipelinedatabase.h:145
VkPipeline GetCompiledPipeline()
gets pipeline if it already exists, or creates if exists
Definition vkpipelinedatabase.cc:216
void SetPass(const CoreGraphics::PassId pass)
set pass
Definition vkpipelinedatabase.cc:84
virtual ~VkPipelineDatabase()
destructor
Definition vkpipelinedatabase.cc:29
VkGraphicsPipelineCreateInfo currentShaderInfo
Definition vkpipelinedatabase.h:108
VkPipelineDatabase()
constructor
Definition vkpipelinedatabase.cc:18
VkPipeline currentPipeline
Definition vkpipelinedatabase.h:149
void SetInputAssembly(const CoreGraphics::InputAssemblyKey key)
Set input assembly.
Definition vkpipelinedatabase.cc:145
void SetSubpass(uint32_t subpass)
set subpass
Definition vkpipelinedatabase.cc:104
CoreGraphics::PassId currentPass
Definition vkpipelinedatabase.h:105
const VkPipelineVertexInputStateCreateInfo * currentVertexLayout
Definition vkpipelinedatabase.h:110
void InvalidatePipeline(const CoreGraphics::PipelineId pipeline)
Invalidate a pipeline.
Definition vkpipelinedatabase.cc:207
void Discard()
discard database
Definition vkpipelinedatabase.cc:48
CoreGraphics::PipelineId GetPipeline(const CoreGraphics::PassId pass, const uint32_t subpass, const CoreGraphics::ShaderProgramId program, const CoreGraphics::InputAssemblyKey inputAssembly, const VkGraphicsPipelineCreateInfo &shaderInfo)
Get if there is a pipeline associated with the current state.
Definition vkpipelinedatabase.cc:164
uint32_t currentSubpass
Definition vkpipelinedatabase.h:106
void CachePipeline(const CoreGraphics::PassId pass, const uint32_t subpass, const CoreGraphics::ShaderProgramId program, const CoreGraphics::InputAssemblyKey inputAssembly, const VkGraphicsPipelineCreateInfo &shaderInfo, CoreGraphics::PipelineId pipeline)
Inject pipeline, used for pipelines created outside of the database.
Definition vkpipelinedatabase.cc:186
CoreGraphics::ShaderProgramId currentShaderProgram
Definition vkpipelinedatabase.h:107
void Reset()
resets all iterators
Definition vkpipelinedatabase.cc:272
Memory::ArenaAllocator< BIG_CHUNK > tierNodeAllocator
Definition vkpipelinedatabase.h:143
__DeclareSingleton(VkPipelineDatabase)
StateLevel
Definition vkpipelinedatabase.h:40
@ ShaderLevel
Definition vkpipelinedatabase.h:43
@ PipelineLevel
Definition vkpipelinedatabase.h:46
@ SubpassLevel
Definition vkpipelinedatabase.h:42
@ VertexLayoutLevel
Definition vkpipelinedatabase.h:44
@ InputAssemblyLevel
Definition vkpipelinedatabase.h:45
@ PassLevel
Definition vkpipelinedatabase.h:41
void Setup(const VkDevice dev, const VkPipelineCache cache)
setup database
Definition vkpipelinedatabase.cc:38
CoreGraphics::InputAssemblyKey currentInputAssembly
Definition vkpipelinedatabase.h:109
Tier2Node * ct2
Definition vkpipelinedatabase.h:146
Tier3Node * ct3
Definition vkpipelinedatabase.h:147
Util::Dictionary< CoreGraphics::PassId, Tier1Node * > tier1
Definition vkpipelinedatabase.h:141
VkDevice dev
Definition vkpipelinedatabase.h:103
Tier4Node * ct4
Definition vkpipelinedatabase.h:148
Vulkan implementation of GPU acceleration structure.
Definition vkaccelerationstructure.cc:15
A shader represents an entire shader resource, containing several stages and programs.
Definition pass.h:28
Definition pipeline.h:16
bool initial
Definition vkpipelinedatabase.h:119
BaseNode()
Definition vkpipelinedatabase.h:121
Definition vkpipelinedatabase.h:124
Util::Dictionary< IndexT, Tier2Node * > children
Definition vkpipelinedatabase.h:126
Definition vkpipelinedatabase.h:129
Util::Dictionary< CoreGraphics::ShaderProgramId, Tier3Node * > children
Definition vkpipelinedatabase.h:130
Definition vkpipelinedatabase.h:133
Util::Dictionary< CoreGraphics::InputAssemblyKey, Tier4Node * > children
Definition vkpipelinedatabase.h:134
Definition vkpipelinedatabase.h:137
CoreGraphics::PipelineId pipeline
Definition vkpipelinedatabase.h:138
Definition config.h:24