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"
26
27namespace Vulkan
28{
29class VkVertexLayout;
30class VkShaderProgram;
31class VkPass;
32
34{
36public:
37
47
51 virtual ~VkPipelineDatabase();
52
54 void Setup(const VkDevice dev, const VkPipelineCache cache);
56 void Discard();
57
59 void SetPass(const CoreGraphics::PassId pass);
61 void SetSubpass(uint32_t subpass);
63 void SetShader(const CoreGraphics::ShaderProgramId program, const VkGraphicsPipelineCreateInfo& shaderInfo);
67 VkPipeline GetCompiledPipeline();
69 VkPipeline GetCompiledPipeline(
70 const CoreGraphics::PassId pass
71 , const uint32_t subpass
72 , const CoreGraphics::ShaderProgramId program
73 , const CoreGraphics::InputAssemblyKey inputAssembly
74 , const VkGraphicsPipelineCreateInfo& shaderInfo);
76 VkPipeline CreatePipeline(
77 const CoreGraphics::PassId pass
78 , const uint32_t subpass
79 , const CoreGraphics::ShaderProgramId program
80 , const CoreGraphics::InputAssemblyKey inputAssembly
81 , const VkGraphicsPipelineCreateInfo& shaderInfo
82 );
84 void Reset();
85
87 void Reload(const CoreGraphics::ShaderProgramId id);
89 void RecreatePipelines();
90private:
91
92
93 VkDevice dev;
94 VkPipelineCache cache;
97 CoreGraphics::ShaderProgramId currentShaderProgram;
98 VkGraphicsPipelineCreateInfo currentShaderInfo;
100 const VkPipelineVertexInputStateCreateInfo* currentVertexLayout;
101
102 struct Tier1Node;
103 struct Tier2Node;
104 struct Tier3Node;
105 struct Tier4Node;
106
107 struct BaseNode
108 {
110
111 BaseNode() : initial(true) {}
112 };
113 struct Tier1Node : public BaseNode
114 {
115 // IndexT == subpass id
117 };
126 struct Tier4Node : public BaseNode
127 {
128 VkPipeline pipeline = VK_NULL_HANDLE;
129 };
130
132
134
139 VkPipeline currentPipeline;
140};
141} // 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
Definition vkpipelinedatabase.h:34
void Reload(const CoreGraphics::ShaderProgramId id)
re-creates all pipelines for the given shader program id
Definition vkpipelinedatabase.cc:272
VkPipelineCache cache
Definition vkpipelinedatabase.h:94
void SetShader(const CoreGraphics::ShaderProgramId program, const VkGraphicsPipelineCreateInfo &shaderInfo)
set shader
Definition vkpipelinedatabase.cc:120
void RecreatePipelines()
re-creates all pipelines for all shader programs
Definition vkpipelinedatabase.cc:340
Tier1Node * ct1
Definition vkpipelinedatabase.h:135
VkPipeline GetCompiledPipeline()
gets pipeline if it already exists, or creates if exists
Definition vkpipelinedatabase.cc:160
void SetPass(const CoreGraphics::PassId pass)
set pass
Definition vkpipelinedatabase.cc:80
virtual ~VkPipelineDatabase()
destructor
Definition vkpipelinedatabase.cc:28
VkGraphicsPipelineCreateInfo currentShaderInfo
Definition vkpipelinedatabase.h:98
VkPipelineDatabase()
constructor
Definition vkpipelinedatabase.cc:17
VkPipeline currentPipeline
Definition vkpipelinedatabase.h:139
void SetInputAssembly(const CoreGraphics::InputAssemblyKey key)
Set input assembly.
Definition vkpipelinedatabase.cc:141
void SetSubpass(uint32_t subpass)
set subpass
Definition vkpipelinedatabase.cc:100
CoreGraphics::PassId currentPass
Definition vkpipelinedatabase.h:95
const VkPipelineVertexInputStateCreateInfo * currentVertexLayout
Definition vkpipelinedatabase.h:100
void Discard()
discard database
Definition vkpipelinedatabase.cc:47
uint32_t currentSubpass
Definition vkpipelinedatabase.h:96
CoreGraphics::ShaderProgramId currentShaderProgram
Definition vkpipelinedatabase.h:97
void Reset()
resets all iterators
Definition vkpipelinedatabase.cc:256
Memory::ArenaAllocator< BIG_CHUNK > tierNodeAllocator
Definition vkpipelinedatabase.h:133
__DeclareSingleton(VkPipelineDatabase)
StateLevel
Definition vkpipelinedatabase.h:39
@ ShaderLevel
Definition vkpipelinedatabase.h:42
@ PipelineLevel
Definition vkpipelinedatabase.h:45
@ SubpassLevel
Definition vkpipelinedatabase.h:41
@ VertexLayoutLevel
Definition vkpipelinedatabase.h:43
@ InputAssemblyLevel
Definition vkpipelinedatabase.h:44
@ PassLevel
Definition vkpipelinedatabase.h:40
VkPipeline CreatePipeline(const CoreGraphics::PassId pass, const uint32_t subpass, const CoreGraphics::ShaderProgramId program, const CoreGraphics::InputAssemblyKey inputAssembly, const VkGraphicsPipelineCreateInfo &shaderInfo)
Create pipeline.
Definition vkpipelinedatabase.cc:203
void Setup(const VkDevice dev, const VkPipelineCache cache)
setup database
Definition vkpipelinedatabase.cc:37
CoreGraphics::InputAssemblyKey currentInputAssembly
Definition vkpipelinedatabase.h:99
Tier2Node * ct2
Definition vkpipelinedatabase.h:136
Tier3Node * ct3
Definition vkpipelinedatabase.h:137
Util::Dictionary< CoreGraphics::PassId, Tier1Node * > tier1
Definition vkpipelinedatabase.h:131
VkDevice dev
Definition vkpipelinedatabase.h:93
Tier4Node * ct4
Definition vkpipelinedatabase.h:138
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 vkpipelinedatabase.h:108
bool initial
Definition vkpipelinedatabase.h:109
BaseNode()
Definition vkpipelinedatabase.h:111
Definition vkpipelinedatabase.h:114
Util::Dictionary< IndexT, Tier2Node * > children
Definition vkpipelinedatabase.h:116
Definition vkpipelinedatabase.h:119
Util::Dictionary< CoreGraphics::ShaderProgramId, Tier3Node * > children
Definition vkpipelinedatabase.h:120
Definition vkpipelinedatabase.h:123
Util::Dictionary< CoreGraphics::InputAssemblyKey, Tier4Node * > children
Definition vkpipelinedatabase.h:124
Definition vkpipelinedatabase.h:127
VkPipeline pipeline
Definition vkpipelinedatabase.h:128
Definition config.h:24