Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
ComputePass.h
Go to the documentation of this file.
1#pragma once
2#include <array>
3#include <optional>
6
7namespace EngineCore {
9}
10
11namespace EngineCore {
12 class ComputePipeline;
13
15 {
16 public:
17 private:
18 };
19
26 class ComputePass : public RenderingPass {
27 public:
28 virtual ~ComputePass() = default;
29
31 const std::string& name
32 );
33
44 void create(
45 VkDevice device,
46 const VkPipelineLayoutCreateInfo * pPipelineLayoutCreateInfo,
47 const VkDescriptorSetLayoutCreateInfo * pDescriptorSetLayoutCreateInfo,
48 std::string shaderName,
49 std::optional<const PipelineSpecializationData *> pSpecializationData
50 );
51
59 [[nodiscard]] uint32_t getThreadCount() const;
60
68 VkPipelineLayout & getPipelineLayout();
69
78
86 VkDescriptorSetLayout & getDescriptorSetLayout();
87
97 VkPushConstantsInfo createPushConstantsInfo(uint32_t size, const void* pValues) const;
98
108 void createDescriptorSet(VkDevice device, uint32_t frameInFlightIndex, VkDescriptorPool descriptorPool);
109
118 DescriptorSetUpdater & updateDescriptorSet(uint32_t frameInFlightIndex);
119
128 [[nodiscard]] VkDescriptorSet getDescriptorSet(uint32_t frameInFlightIndex) const;
129
138 void bindDescriptorSets(VkCommandBuffer commandBuffer, uint32_t frameInFlightIndex);
139
150 void cleanup(VkDevice device);
151
159 void cleanup(ApplicationContext *context);
160
161 protected:
162 virtual void extractSpecializationData( std::optional<const PipelineSpecializationData *> pSpecializationData
163 );
164
165 private:
167
168 std::string name = "Generic Compute";
169 VkPipelineLayout pipelineLayout = VK_NULL_HANDLE;
170 VkDescriptorSetLayout descriptorSetLayout = VK_NULL_HANDLE;
172 bool cleanedUp = false; // Guard to prevent double-cleanup
173
174 std::array<VkDescriptorSet, MAX_FRAMES_IN_FLIGHT> descriptorSet {VK_NULL_HANDLE};
175
176 protected:
177 [[nodiscard]] std::string getName() const { return name; }
178
179 uint32_t threadCount = 32;
180 };
181
183 public:
184 DispatcherComputePass(const std::string &name);
185
186 [[nodiscard]] uint32_t getTargetThreadCount() const;
187
188 protected:
189 void extractSpecializationData( std::optional<const PipelineSpecializationData *> pSpecializationData
190 ) override;
191 uint32_t targetThreadCount = 32;
192
193 };
194}
The application context is the core class which stores the basic openxr and vulkan objects.
std::array< VkDescriptorSet, MAX_FRAMES_IN_FLIGHT > descriptorSet
VkDescriptorSetLayout descriptorSetLayout
void createDescriptorSet(VkDevice device, uint32_t frameInFlightIndex, VkDescriptorPool descriptorPool)
Creates a vulkan descriptor set resource for a frame in flight into a specified descriptor pool.
DescriptorSetUpdater & updateDescriptorSet(uint32_t frameInFlightIndex)
Creates a descriptor set updater which is used to batch update descriptor set resources.
DescriptorSetUpdater descriptorSetBuilder
std::string getName() const
virtual void extractSpecializationData(std::optional< const PipelineSpecializationData * > pSpecializationData)
uint32_t getThreadCount() const
Gets the amount of threads this compute shader is running on on the GPU.
void bindDescriptorSets(VkCommandBuffer commandBuffer, uint32_t frameInFlightIndex)
Binds the descriptor set of a frame in flight.
virtual ~ComputePass()=default
void create(VkDevice device, const VkPipelineLayoutCreateInfo *pPipelineLayoutCreateInfo, const VkDescriptorSetLayoutCreateInfo *pDescriptorSetLayoutCreateInfo, std::string shaderName, std::optional< const PipelineSpecializationData * > pSpecializationData)
Creates a whole compute pass with a layout and everything. This is one of two steps needed to create ...
ComputePass(const std::string &name)
VkPipelineLayout & getPipelineLayout()
Gets the layout of this compute pipeline.
VkPipelineLayout pipelineLayout
VkPushConstantsInfo createPushConstantsInfo(uint32_t size, const void *pValues) const
Used to create preconfigured push constants where you only pass in the size of the push constant and ...
ComputePipeline * computePipeline
void cleanup(VkDevice device)
Cleanup of owned resources using direct VkDevice handle.
VkDescriptorSet getDescriptorSet(uint32_t frameInFlightIndex) const
Getter for the descriptor set of this pipeline.
VkDescriptorSetLayout & getDescriptorSetLayout()
Gets the descriptor set layout associated with this pipeline.
ComputePipeline * getComputePipeline()
Getter for the raw compute pipeline.
A wrapper for vulkan pipeline resources. In this case a typesafe compute pipeline.
The Descriptor set updater is used to create a list of descriptor set writes which are executed with ...
void extractSpecializationData(std::optional< const PipelineSpecializationData * > pSpecializationData) override
DispatcherComputePass(const std::string &name)
Log category system implementation.