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

[#71] remove compute pipeline stuff from pipeline manager

parent b6b892eb
No related branches found
No related tags found
1 merge request!83Resolve "Refactor Pipeline Config and Manager"
Pipeline #27057 passed
...@@ -678,66 +678,4 @@ namespace vkcv ...@@ -678,66 +678,4 @@ namespace vkcv
return m_Pipelines[id].m_config; return m_Pipelines[id].m_config;
} }
PipelineHandle PipelineManager::createComputePipeline(
const ShaderProgram &shaderProgram,
const std::vector<vk::DescriptorSetLayout> &descriptorSetLayouts) {
// Temporally handing over the Shader Program instead of a pipeline config
vk::ShaderModule computeModule{};
if (createShaderModule(computeModule, shaderProgram, ShaderStage::COMPUTE) != vk::Result::eSuccess)
return PipelineHandle();
vk::PipelineShaderStageCreateInfo pipelineComputeShaderStageInfo(
{},
vk::ShaderStageFlagBits::eCompute,
computeModule,
"main",
nullptr
);
vk::PipelineLayoutCreateInfo pipelineLayoutCreateInfo({}, descriptorSetLayouts);
const size_t pushConstantSize = shaderProgram.getPushConstantSize();
vk::PushConstantRange pushConstantRange(vk::ShaderStageFlagBits::eCompute, 0, pushConstantSize);
if (pushConstantSize > 0) {
pipelineLayoutCreateInfo.setPushConstantRangeCount(1);
pipelineLayoutCreateInfo.setPPushConstantRanges(&pushConstantRange);
}
vk::PipelineLayout vkPipelineLayout{};
if (m_Device.createPipelineLayout(&pipelineLayoutCreateInfo, nullptr, &vkPipelineLayout) != vk::Result::eSuccess)
{
m_Device.destroy(computeModule);
return PipelineHandle();
}
vk::ComputePipelineCreateInfo computePipelineCreateInfo{};
computePipelineCreateInfo.stage = pipelineComputeShaderStageInfo;
computePipelineCreateInfo.layout = vkPipelineLayout;
vk::Pipeline vkPipeline;
if (m_Device.createComputePipelines(nullptr, 1, &computePipelineCreateInfo, nullptr, &vkPipeline)!= vk::Result::eSuccess)
{
m_Device.destroy(computeModule);
return PipelineHandle();
}
m_Device.destroy(computeModule);
const uint64_t id = m_Pipelines.size();
m_Pipelines.push_back({ vkPipeline, vkPipelineLayout, PipelineConfig() });
return PipelineHandle(id, [&](uint64_t id) { destroyPipelineById(id); });
}
// There is an issue for refactoring the Pipeline Manager.
// While including Compute Pipeline Creation, some private helper functions where introduced:
vk::Result PipelineManager::createShaderModule(vk::ShaderModule &module, const ShaderProgram &shaderProgram, const ShaderStage stage)
{
std::vector<char> code = shaderProgram.getShader(stage).shaderCode;
vk::ShaderModuleCreateInfo moduleInfo({}, code.size(), reinterpret_cast<uint32_t*>(code.data()));
return m_Device.createShaderModule(&moduleInfo, nullptr, &module);
}
} }
...@@ -40,11 +40,6 @@ namespace vkcv ...@@ -40,11 +40,6 @@ namespace vkcv
*/ */
PipelineHandle createPipeline(const PipelineConfig &config, PassManager& passManager); PipelineHandle createPipeline(const PipelineConfig &config, PassManager& passManager);
// TODO: Move to ComputePipelineManager
PipelineHandle createComputePipeline(
const ShaderProgram& shaderProgram,
const std::vector<vk::DescriptorSetLayout>& descriptorSetLayouts);
/** /**
* Returns a vk::Pipeline object by handle. * Returns a vk::Pipeline object by handle.
* @param handle Directing to the requested pipeline. * @param handle Directing to the requested pipeline.
...@@ -81,8 +76,5 @@ namespace vkcv ...@@ -81,8 +76,5 @@ namespace vkcv
void destroyPipelineById(uint64_t id); void destroyPipelineById(uint64_t id);
// TODO: Move to ComputePipelineManager
vk::Result createShaderModule(vk::ShaderModule &module, const ShaderProgram &shaderProgram, ShaderStage stage);
}; };
} }
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