49 lines
1.4 KiB
C++
49 lines
1.4 KiB
C++
#ifndef COMPUTEPIPELINE_H
|
|
#define COMPUTEPIPELINE_H
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include <destrum/Graphics/GfxDevice.h>
|
|
|
|
struct ComputePipelineConfigInfo {
|
|
std::string name;
|
|
|
|
// Optional specialization constants (can be nullptr if unused)
|
|
VkSpecializationInfo* specializationInfo{nullptr};
|
|
|
|
VkPipelineLayout pipelineLayout{VK_NULL_HANDLE};
|
|
};
|
|
|
|
class ComputePipeline {
|
|
public:
|
|
ComputePipeline(GfxDevice& device,
|
|
const std::string& compPath,
|
|
const ComputePipelineConfigInfo& configInfo);
|
|
~ComputePipeline();
|
|
|
|
ComputePipeline(const ComputePipeline& other) = delete;
|
|
ComputePipeline(ComputePipeline&& other) noexcept = delete;
|
|
ComputePipeline& operator=(const ComputePipeline& other) = delete;
|
|
ComputePipeline& operator=(ComputePipeline&& other) noexcept = delete;
|
|
|
|
void bind(VkCommandBuffer buffer) const;
|
|
|
|
static void DefaultPipelineConfigInfo(ComputePipelineConfigInfo& configInfo);
|
|
|
|
private:
|
|
static std::vector<char> readFile(const std::string& filename);
|
|
|
|
void CreateComputePipeline(const std::string& compPath,
|
|
const ComputePipelineConfigInfo& configInfo);
|
|
|
|
void CreateShaderModule(const std::vector<char>& code, VkShaderModule* shaderModule) const;
|
|
|
|
GfxDevice& m_device;
|
|
|
|
VkPipeline m_computePipeline{VK_NULL_HANDLE};
|
|
VkShaderModule m_compShaderModule{VK_NULL_HANDLE};
|
|
};
|
|
|
|
#endif //COMPUTEPIPELINE_H
|