Skip to content
Snippets Groups Projects
Commit ff56e184 authored by Mark Oliver Mints's avatar Mark Oliver Mints
Browse files

[#71] introduce compute pipeline config struct

parent a3f22be8
No related branches found
No related tags found
1 merge request!83Resolve "Refactor Pipeline Config and Manager"
Pipeline #27060 failed
...@@ -52,6 +52,7 @@ set(vkcv_sources ...@@ -52,6 +52,7 @@ set(vkcv_sources
${vkcv_source}/vkcv/ShaderProgram.cpp ${vkcv_source}/vkcv/ShaderProgram.cpp
${vkcv_include}/vkcv/PipelineConfig.hpp ${vkcv_include}/vkcv/PipelineConfig.hpp
${vkcv_include}/vkcv/ComputePipelineConfig.hpp
${vkcv_source}/vkcv/ComputePipelineManager.hpp ${vkcv_source}/vkcv/ComputePipelineManager.hpp
${vkcv_source}/vkcv/ComputePipelineManager.cpp ${vkcv_source}/vkcv/ComputePipelineManager.cpp
......
#pragma once
/**
* @authors Mark Mints
* @file src/vkcv/ComputePipelineConfig.hpp
* @brief Compute Pipeline Config Struct to hand over required information to Pipeline Creation.
*/
#include <vector>
#include "ShaderProgram.hpp"
namespace vkcv
{
struct ComputePipelineConfig {
ShaderProgram& m_ShaderProgram;
std::vector<vk::DescriptorSetLayout> m_DescriptorSetLayouts;
};
}
\ No newline at end of file
...@@ -41,13 +41,11 @@ namespace vkcv ...@@ -41,13 +41,11 @@ namespace vkcv
return pipeline.m_layout; return pipeline.m_layout;
} }
ComputePipelineHandle ComputePipelineManager::createComputePipeline( ComputePipelineHandle ComputePipelineManager::createComputePipeline(const ComputePipelineConfig& config) {
const ShaderProgram &shaderProgram,
const std::vector <vk::DescriptorSetLayout> &descriptorSetLayouts) {
// Temporally handing over the Shader Program instead of a pipeline config // Temporally handing over the Shader Program instead of a pipeline config
vk::ShaderModule computeModule{}; vk::ShaderModule computeModule{};
if (createShaderModule(computeModule, shaderProgram, ShaderStage::COMPUTE) != vk::Result::eSuccess) if (createShaderModule(computeModule, config.m_ShaderProgram, ShaderStage::COMPUTE) != vk::Result::eSuccess)
return ComputePipelineHandle(); return ComputePipelineHandle();
vk::PipelineShaderStageCreateInfo pipelineComputeShaderStageInfo( vk::PipelineShaderStageCreateInfo pipelineComputeShaderStageInfo(
...@@ -58,9 +56,9 @@ namespace vkcv ...@@ -58,9 +56,9 @@ namespace vkcv
nullptr nullptr
); );
vk::PipelineLayoutCreateInfo pipelineLayoutCreateInfo({}, descriptorSetLayouts); vk::PipelineLayoutCreateInfo pipelineLayoutCreateInfo({}, config.m_DescriptorSetLayouts);
const size_t pushConstantSize = shaderProgram.getPushConstantSize(); const size_t pushConstantSize = config.m_ShaderProgram.getPushConstantSize();
vk::PushConstantRange pushConstantRange(vk::ShaderStageFlagBits::eCompute, 0, pushConstantSize); vk::PushConstantRange pushConstantRange(vk::ShaderStageFlagBits::eCompute, 0, pushConstantSize);
if (pushConstantSize > 0) { if (pushConstantSize > 0) {
pipelineLayoutCreateInfo.setPushConstantRangeCount(1); pipelineLayoutCreateInfo.setPushConstantRangeCount(1);
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "vkcv/Handles.hpp" #include "vkcv/Handles.hpp"
#include "vkcv/ShaderProgram.hpp" #include "vkcv/ShaderProgram.hpp"
#include "vkcv/ComputePipelineConfig.hpp"
namespace vkcv namespace vkcv
{ {
...@@ -44,9 +45,14 @@ namespace vkcv ...@@ -44,9 +45,14 @@ namespace vkcv
[[nodiscard]] [[nodiscard]]
vk::PipelineLayout getVkPipelineLayout(const ComputePipelineHandle &handle) const; vk::PipelineLayout getVkPipelineLayout(const ComputePipelineHandle &handle) const;
ComputePipelineHandle createComputePipeline( /**
const ShaderProgram& shaderProgram, * Creates a Compute Pipeline based on the set shader stages in the Config Struct.
const std::vector<vk::DescriptorSetLayout>& descriptorSetLayouts); * This function is wrapped in /src/vkcv/Core.cpp by Core::createComputePipeline(const ComputePipelineConfig &config).
* On application level it is necessary first to fill a ComputePipelineConfig Struct.
* @param config Hands over all needed information for pipeline creation.
* @return A Handler to the created Compute Pipeline Object.
*/
ComputePipelineHandle createComputePipeline(const ComputePipelineConfig& config);
private: private:
struct ComputePipeline { struct ComputePipeline {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment