Verified Commit 40ec3566 authored by Tobias Frisch's avatar Tobias Frisch
Browse files

Refactored the compute pipeline config and cleaned up projects


Signed-off-by: Tobias Frisch's avatarTobias Frisch <tfrisch@uni-koblenz.de>
parent 79ab00a1
Pipeline #28203 failed with stages
in 0 seconds
#pragma once
/**
* @authors Mark Mints
* @authors Mark Mints, Tobias Frisch
* @file src/vkcv/ComputePipelineConfig.hpp
* @brief Compute Pipeline Config Struct to hand over required information to Pipeline Creation.
*/
#include <vector>
#include "Handles.hpp"
#include "ShaderProgram.hpp"
namespace vkcv
{
struct ComputePipelineConfig {
ShaderProgram& m_ShaderProgram;
std::vector<vk::DescriptorSetLayout> m_DescriptorSetLayouts;
std::vector<DescriptorSetLayoutHandle> m_DescriptorSetLayouts;
};
}
\ No newline at end of file
......@@ -232,9 +232,9 @@ namespace vkcv::upscaling {
program.addShader(shaderStage, path);
});
m_easuPipeline = m_core.createComputePipeline({ program,
{m_core.getDescriptorSetLayout(m_easuDescriptorSetLayout).vulkanHandle}
});
m_easuPipeline = m_core.createComputePipeline({program,{
m_easuDescriptorSetLayout
}});
DescriptorWrites writes;
......@@ -255,7 +255,7 @@ namespace vkcv::upscaling {
});
m_rcasPipeline = m_core.createComputePipeline({ program, {
m_core.getDescriptorSetLayout(m_rcasDescriptorSetLayout).vulkanHandle
m_rcasDescriptorSetLayout
}});
DescriptorWrites writes;
......
......@@ -260,7 +260,7 @@ bool loadComputePass(vkcv::Core& core, const std::filesystem::path& path, Comput
outComputePass->descriptorSet = core.createDescriptorSet(outComputePass->descriptorSetLayout);
outComputePass->pipeline = core.createComputePipeline({
shaderProgram,
{ core.getDescriptorSetLayout(outComputePass->descriptorSetLayout).vulkanHandle }});
{ outComputePass->descriptorSetLayout }});
if (!outComputePass->pipeline) {
vkcv_log(vkcv::LogLevel::ERROR, "Compute shader pipeline creation failed");
......
......@@ -512,7 +512,7 @@ int main(int argc, const char** argv) {
const vkcv::ComputePipelineConfig computeCullingConfig {
cullingProgram,
{core.getDescriptorSetLayout(cullingSetLayout).vulkanHandle}
{cullingSetLayout}
};
vkcv::ComputePipelineHandle cullingPipelineHandle = core.createComputePipeline(computeCullingConfig);
if (!cullingPipelineHandle) {
......
......@@ -38,7 +38,8 @@ BloomAndFlares::BloomAndFlares(
}
m_DownsamplePipe = p_Core->createComputePipeline({
dsProg, { p_Core->getDescriptorSetLayout(m_DownsampleDescSetLayouts[0]).vulkanHandle }});
dsProg, m_DownsampleDescSetLayouts
});
// UPSAMPLE
vkcv::ShaderProgram usProg;
......@@ -57,7 +58,8 @@ BloomAndFlares::BloomAndFlares(
}
m_UpsamplePipe = p_Core->createComputePipeline({
usProg, { p_Core->getDescriptorSetLayout(m_UpsampleDescSetLayouts[0]).vulkanHandle }});
usProg, m_UpsampleDescSetLayouts
});
// LENS FEATURES
vkcv::ShaderProgram lensProg;
......@@ -71,7 +73,8 @@ BloomAndFlares::BloomAndFlares(
m_LensFlareDescSetLayout = p_Core->createDescriptorSetLayout(lensProg.getReflectedDescriptors().at(0));
m_LensFlareDescSet = p_Core->createDescriptorSet(m_LensFlareDescSetLayout);
m_LensFlarePipe = p_Core->createComputePipeline({
lensProg, { p_Core->getDescriptorSetLayout(m_LensFlareDescSetLayout).vulkanHandle }});
lensProg, { m_LensFlareDescSetLayout }
});
// COMPOSITE
vkcv::ShaderProgram compProg;
......@@ -85,7 +88,8 @@ BloomAndFlares::BloomAndFlares(
m_CompositeDescSetLayout = p_Core->createDescriptorSetLayout(compProg.getReflectedDescriptors().at(0));
m_CompositeDescSet = p_Core->createDescriptorSet(m_CompositeDescSetLayout);
m_CompositePipe = p_Core->createComputePipeline({
compProg, { p_Core->getDescriptorSetLayout(m_CompositeDescSetLayout).vulkanHandle }});
compProg, { m_CompositeDescSetLayout }
});
}
void BloomAndFlares::execDownsamplePipe(const vkcv::CommandStreamHandle &cmdStream,
......
......@@ -133,7 +133,9 @@ int main(int argc, const char **argv) {
vkcv::GraphicsPipelineHandle particlePipeline = core.createGraphicsPipeline(particlePipelineDefinition);
vkcv::ComputePipelineHandle computePipeline = core.createComputePipeline({ computeShaderProgram, {core.getDescriptorSetLayout(computeDescriptorSetLayout).vulkanHandle} });
vkcv::ComputePipelineHandle computePipeline = core.createComputePipeline({
computeShaderProgram, {computeDescriptorSetLayout}
});
vkcv::Buffer<glm::vec4> color = core.createBuffer<glm::vec4>(
vkcv::BufferType::UNIFORM,
......@@ -238,7 +240,8 @@ int main(int argc, const char **argv) {
vkcv::DescriptorSetHandle tonemappingDescriptor = core.createDescriptorSet(tonemappingDescriptorLayout);
vkcv::ComputePipelineHandle tonemappingPipe = core.createComputePipeline({
tonemappingShader,
{ core.getDescriptorSetLayout(tonemappingDescriptorLayout).vulkanHandle }});
{ tonemappingDescriptorLayout }
});
std::uniform_real_distribution<float> rdm = std::uniform_real_distribution<float>(0.95f, 1.05f);
std::default_random_engine rdmEngine;
......
......@@ -103,7 +103,7 @@ int main(int argc, const char** argv) {
vkcv::DescriptorSetHandle imageCombineDescriptorSet = core.createDescriptorSet(imageCombineDescriptorSetLayout);
vkcv::ComputePipelineHandle imageCombinePipeline = core.createComputePipeline({
imageCombineShaderProgram,
{ core.getDescriptorSetLayout(imageCombineDescriptorSetLayout).vulkanHandle }
{ imageCombineDescriptorSetLayout }
});
vkcv::DescriptorWrites imageCombineDescriptorWrites;
......@@ -125,7 +125,7 @@ int main(int argc, const char** argv) {
vkcv::DescriptorSetHandle presentDescriptorSet = core.createDescriptorSet(presentDescriptorSetLayout);
vkcv::ComputePipelineHandle presentPipeline = core.createComputePipeline({
presentShaderProgram,
{ core.getDescriptorSetLayout(presentDescriptorSetLayout).vulkanHandle }
{ presentDescriptorSetLayout }
});
// clear shader
......@@ -140,7 +140,7 @@ int main(int argc, const char** argv) {
vkcv::DescriptorSetHandle imageClearDescriptorSet = core.createDescriptorSet(imageClearDescriptorSetLayout);
vkcv::ComputePipelineHandle imageClearPipeline = core.createComputePipeline({
clearShaderProgram,
{ core.getDescriptorSetLayout(imageClearDescriptorSetLayout).vulkanHandle }
{ imageClearDescriptorSetLayout }
});
vkcv::DescriptorWrites imageClearDescriptorWrites;
......@@ -203,7 +203,7 @@ int main(int argc, const char** argv) {
vkcv::ComputePipelineHandle tracePipeline = core.createComputePipeline({
traceShaderProgram,
{ core.getDescriptorSetLayout(traceDescriptorSetLayout).vulkanHandle }
{ traceDescriptorSetLayout }
});
if (!tracePipeline)
......
......@@ -184,7 +184,7 @@ int main(int argc, const char** argv) {
const vkcv::ComputePipelineConfig computePipelineConfig{
computeShaderProgram,
{core.getDescriptorSetLayout(computeDescriptorSetLayout).vulkanHandle}
{computeDescriptorSetLayout}
};
vkcv::ComputePipelineHandle computePipeline = core.createComputePipeline(computePipelineConfig);
......
......@@ -37,7 +37,8 @@ BloomAndFlares::BloomAndFlares(
p_Core->createDescriptorSet(m_DownsampleDescSetLayouts.back()));
}
m_DownsamplePipe = p_Core->createComputePipeline({
dsProg, { p_Core->getDescriptorSetLayout(m_DownsampleDescSetLayouts[0]).vulkanHandle } });
dsProg, m_DownsampleDescSetLayouts
});
// UPSAMPLE
vkcv::ShaderProgram usProg;
......@@ -55,7 +56,8 @@ BloomAndFlares::BloomAndFlares(
p_Core->createDescriptorSet(m_UpsampleDescSetLayouts.back()));
}
m_UpsamplePipe = p_Core->createComputePipeline({
usProg, { p_Core->getDescriptorSetLayout(m_UpsampleDescSetLayouts[0]).vulkanHandle } });
usProg, m_UpsampleDescSetLayouts
});
// LENS FEATURES
vkcv::ShaderProgram lensProg;
......@@ -68,7 +70,8 @@ BloomAndFlares::BloomAndFlares(
m_LensFlareDescSetLayout = p_Core->createDescriptorSetLayout(lensProg.getReflectedDescriptors().at(0));
m_LensFlareDescSet = p_Core->createDescriptorSet(m_LensFlareDescSetLayout);
m_LensFlarePipe = p_Core->createComputePipeline({
lensProg, { p_Core->getDescriptorSetLayout(m_LensFlareDescSetLayout).vulkanHandle } });
lensProg, { m_LensFlareDescSetLayout }
});
// COMPOSITE
vkcv::ShaderProgram compProg;
......@@ -81,7 +84,8 @@ BloomAndFlares::BloomAndFlares(
m_CompositeDescSetLayout = p_Core->createDescriptorSetLayout(compProg.getReflectedDescriptors().at(0));
m_CompositeDescSet = p_Core->createDescriptorSet(m_CompositeDescSetLayout);
m_CompositePipe = p_Core->createComputePipeline({
compProg, { p_Core->getDescriptorSetLayout(m_CompositeDescSetLayout).vulkanHandle } });
compProg, { m_CompositeDescSetLayout }
});
}
void BloomAndFlares::execDownsamplePipe(const vkcv::CommandStreamHandle &cmdStream,
......
......@@ -21,7 +21,8 @@ vkcv::DescriptorSetHandle PipelineInit::ComputePipelineInit(vkcv::Core *pCore, v
pipeline = pCore->createComputePipeline({
shaderProgram,
{ pCore->getDescriptorSetLayout(descriptorSetLayout).vulkanHandle } });
{ descriptorSetLayout }
});
return descriptorSet;
}
\ No newline at end of file
......@@ -51,7 +51,7 @@ BloomAndFlares::BloomAndFlares(
}
m_DownsamplePipe = p_Core->createComputePipeline({
dsProg, { p_Core->getDescriptorSetLayout(m_DownsampleDescSetLayouts[0]).vulkanHandle }
dsProg, m_DownsampleDescSetLayouts
});
// UPSAMPLE
......@@ -77,7 +77,7 @@ BloomAndFlares::BloomAndFlares(
}
m_UpsamplePipe = p_Core->createComputePipeline({
usProg, { p_Core->getDescriptorSetLayout(m_UpsampleDescSetLayouts[0]).vulkanHandle }
usProg, m_UpsampleDescSetLayouts
});
// LENS FEATURES
......@@ -92,7 +92,8 @@ BloomAndFlares::BloomAndFlares(
m_LensFlareDescSetLayout = p_Core->createDescriptorSetLayout(lensProg.getReflectedDescriptors().at(0));
m_LensFlareDescSet = p_Core->createDescriptorSet(m_LensFlareDescSetLayout);
m_LensFlarePipe = p_Core->createComputePipeline(
{ lensProg, { p_Core->getDescriptorSetLayout(m_LensFlareDescSetLayout).vulkanHandle } });
{ lensProg, { m_LensFlareDescSetLayout }
});
// COMPOSITE
......@@ -107,7 +108,8 @@ BloomAndFlares::BloomAndFlares(
m_CompositeDescSetLayout = p_Core->createDescriptorSetLayout(compProg.getReflectedDescriptors().at(0));
m_CompositeDescSet = p_Core->createDescriptorSet(m_CompositeDescSetLayout);
m_CompositePipe = p_Core->createComputePipeline(
{ compProg, { p_Core->getDescriptorSetLayout(m_CompositeDescSetLayout).vulkanHandle } });
{ compProg, { m_CompositeDescSetLayout }
});
// radial LUT
const auto texture = vkcv::asset::loadTexture("assets/RadialLUT.png");
......
......@@ -192,7 +192,7 @@ ShadowMapping::ShadowMapping(vkcv::Core* corePtr, const vkcv::VertexLayout& vert
m_depthToMomentsDescriptorSetLayout = corePtr->createDescriptorSetLayout(depthToMomentsShader.getReflectedDescriptors().at(0));
m_depthToMomentsDescriptorSet = corePtr->createDescriptorSet(m_depthToMomentsDescriptorSetLayout);
m_depthToMomentsPipe = corePtr->createComputePipeline({ depthToMomentsShader, { corePtr->getDescriptorSetLayout(m_depthToMomentsDescriptorSetLayout).vulkanHandle }});
m_depthToMomentsPipe = corePtr->createComputePipeline({ depthToMomentsShader, { m_depthToMomentsDescriptorSetLayout }});
vkcv::DescriptorWrites depthToMomentDescriptorWrites;
depthToMomentDescriptorWrites.sampledImageWrites = { vkcv::SampledImageDescriptorWrite(0, m_shadowMapDepth.getHandle()) };
......@@ -204,7 +204,7 @@ ShadowMapping::ShadowMapping(vkcv::Core* corePtr, const vkcv::VertexLayout& vert
vkcv::ShaderProgram shadowBlurXShader = loadShadowBlurXShader();
m_shadowBlurXDescriptorSetLayout = corePtr->createDescriptorSetLayout(shadowBlurXShader.getReflectedDescriptors().at(0));
m_shadowBlurXDescriptorSet = corePtr->createDescriptorSet(m_shadowBlurXDescriptorSetLayout);
m_shadowBlurXPipe = corePtr->createComputePipeline({ shadowBlurXShader, { corePtr->getDescriptorSetLayout(m_shadowBlurXDescriptorSetLayout).vulkanHandle }});
m_shadowBlurXPipe = corePtr->createComputePipeline({ shadowBlurXShader, { m_shadowBlurXDescriptorSetLayout }});
vkcv::DescriptorWrites shadowBlurXDescriptorWrites;
shadowBlurXDescriptorWrites.sampledImageWrites = { vkcv::SampledImageDescriptorWrite(0, m_shadowMap.getHandle()) };
......@@ -216,7 +216,7 @@ ShadowMapping::ShadowMapping(vkcv::Core* corePtr, const vkcv::VertexLayout& vert
vkcv::ShaderProgram shadowBlurYShader = loadShadowBlurYShader();
m_shadowBlurYDescriptorSetLayout = corePtr->createDescriptorSetLayout(shadowBlurYShader.getReflectedDescriptors().at(0));
m_shadowBlurYDescriptorSet = corePtr->createDescriptorSet(m_shadowBlurYDescriptorSetLayout);
m_shadowBlurYPipe = corePtr->createComputePipeline({ shadowBlurYShader, { corePtr->getDescriptorSetLayout(m_shadowBlurYDescriptorSetLayout).vulkanHandle }});
m_shadowBlurYPipe = corePtr->createComputePipeline({ shadowBlurYShader, { m_shadowBlurYDescriptorSetLayout }});
vkcv::DescriptorWrites shadowBlurYDescriptorWrites;
shadowBlurYDescriptorWrites.sampledImageWrites = { vkcv::SampledImageDescriptorWrite(0, m_shadowMapIntermediate.getHandle()) };
......
......@@ -176,7 +176,8 @@ Voxelization::Voxelization(
m_voxelResetDescriptorSet = m_corePtr->createDescriptorSet(m_voxelResetDescriptorSetLayout);
m_voxelResetPipe = m_corePtr->createComputePipeline({
resetVoxelShader,
{ m_corePtr->getDescriptorSetLayout(m_voxelResetDescriptorSetLayout).vulkanHandle }});
{ m_voxelResetDescriptorSetLayout }
});
vkcv::DescriptorWrites resetVoxelWrites;
resetVoxelWrites.storageBufferWrites = { vkcv::BufferDescriptorWrite(0, m_voxelBuffer.getHandle()) };
......@@ -189,7 +190,8 @@ Voxelization::Voxelization(
m_bufferToImageDescriptorSet = m_corePtr->createDescriptorSet(m_bufferToImageDescriptorSetLayout);
m_bufferToImagePipe = m_corePtr->createComputePipeline({
bufferToImageShader,
{ m_corePtr->getDescriptorSetLayout(m_bufferToImageDescriptorSetLayout).vulkanHandle }});
{ m_bufferToImageDescriptorSetLayout }
});
vkcv::DescriptorWrites bufferToImageDescriptorWrites;
bufferToImageDescriptorWrites.storageBufferWrites = { vkcv::BufferDescriptorWrite(0, m_voxelBuffer.getHandle()) };
......@@ -203,7 +205,8 @@ Voxelization::Voxelization(
m_secondaryBounceDescriptorSet = m_corePtr->createDescriptorSet(m_secondaryBounceDescriptorSetLayout);
m_secondaryBouncePipe = m_corePtr->createComputePipeline({
secondaryBounceShader,
{ m_corePtr->getDescriptorSetLayout(m_secondaryBounceDescriptorSetLayout).vulkanHandle }});
{ m_secondaryBounceDescriptorSetLayout }
});
vkcv::DescriptorWrites secondaryBounceDescriptorWrites;
secondaryBounceDescriptorWrites.storageBufferWrites = { vkcv::BufferDescriptorWrite(0, m_voxelBuffer.getHandle()) };
......
......@@ -468,7 +468,8 @@ int main(int argc, const char** argv) {
vkcv::DescriptorSetHandle tonemappingDescriptorSet = core.createDescriptorSet(tonemappingDescriptorSetLayout);
vkcv::ComputePipelineHandle tonemappingPipeline = core.createComputePipeline({
tonemappingProgram,
{ core.getDescriptorSetLayout(tonemappingDescriptorSetLayout).vulkanHandle }});
{ tonemappingDescriptorSetLayout }
});
// tonemapping compute shader
vkcv::ShaderProgram postEffectsProgram;
......@@ -482,7 +483,8 @@ int main(int argc, const char** argv) {
vkcv::DescriptorSetHandle postEffectsDescriptorSet = core.createDescriptorSet(postEffectsDescriptorSetLayout);
vkcv::ComputePipelineHandle postEffectsPipeline = core.createComputePipeline({
postEffectsProgram,
{ core.getDescriptorSetLayout(postEffectsDescriptorSetLayout).vulkanHandle }});
{ postEffectsDescriptorSetLayout }
});
// resolve compute shader
vkcv::ShaderProgram resolveProgram;
......@@ -496,7 +498,8 @@ int main(int argc, const char** argv) {
vkcv::DescriptorSetHandle resolveDescriptorSet = core.createDescriptorSet(resolveDescriptorSetLayout);
vkcv::ComputePipelineHandle resolvePipeline = core.createComputePipeline({
resolveProgram,
{ core.getDescriptorSetLayout(resolveDescriptorSetLayout).vulkanHandle }});
{ resolveDescriptorSetLayout }
});
vkcv::SamplerHandle resolveSampler = core.createSampler(
vkcv::SamplerFilterType::NEAREST,
......@@ -1001,7 +1004,8 @@ int main(int argc, const char** argv) {
vkcv::ComputePipelineHandle newPipeline = core.createComputePipeline({
newProgram,
{ core.getDescriptorSetLayout(tonemappingDescriptorSetLayout).vulkanHandle }});
{ tonemappingDescriptorSetLayout }
});
if (newPipeline) {
tonemappingPipeline = newPipeline;
......
......@@ -41,11 +41,12 @@ namespace vkcv
return pipeline.m_layout;
}
ComputePipelineHandle ComputePipelineManager::createComputePipeline(const ComputePipelineConfig& config) {
ComputePipelineHandle ComputePipelineManager::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, config.m_ShaderProgram, ShaderStage::COMPUTE) != vk::Result::eSuccess)
if (createShaderModule(computeModule, shaderProgram, ShaderStage::COMPUTE) != vk::Result::eSuccess)
return ComputePipelineHandle();
vk::PipelineShaderStageCreateInfo pipelineComputeShaderStageInfo(
......@@ -56,9 +57,9 @@ namespace vkcv
nullptr
);
vk::PipelineLayoutCreateInfo pipelineLayoutCreateInfo({}, config.m_DescriptorSetLayouts);
vk::PipelineLayoutCreateInfo pipelineLayoutCreateInfo({}, descriptorSetLayouts);
const size_t pushConstantSize = config.m_ShaderProgram.getPushConstantSize();
const size_t pushConstantSize = shaderProgram.getPushConstantSize();
vk::PushConstantRange pushConstantRange(vk::ShaderStageFlagBits::eCompute, 0, pushConstantSize);
if (pushConstantSize > 0) {
pipelineLayoutCreateInfo.setPushConstantRangeCount(1);
......
#pragma once
/**
* @authors Mark Mints
* @authors Mark Mints, Tobias Frisch
* @file src/vkcv/ComputePipelineManager.hpp
* @brief Creation and handling of Compute Pipelines
*/
......@@ -49,10 +49,12 @@ namespace vkcv
* Creates a Compute Pipeline based on the set shader stages in the Config Struct.
* 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.
* @param shaderProgram Hands over all needed information for pipeline creation.
* @param descriptorSetLayouts Hands over all needed information for pipeline creation.
* @return A Handler to the created Compute Pipeline Object.
*/
ComputePipelineHandle createComputePipeline(const ComputePipelineConfig& config);
ComputePipelineHandle createComputePipeline(const ShaderProgram& shaderProgram,
const std::vector<vk::DescriptorSetLayout>& descriptorSetLayouts);
private:
struct ComputePipeline {
......
......@@ -85,7 +85,14 @@ namespace vkcv
ComputePipelineHandle Core::createComputePipeline(const ComputePipelineConfig &config)
{
return m_ComputePipelineManager->createComputePipeline(config);
std::vector<vk::DescriptorSetLayout> layouts;
layouts.resize(config.m_DescriptorSetLayouts.size());
for (size_t i = 0; i < layouts.size(); i++) {
layouts[i] = getDescriptorSetLayout(config.m_DescriptorSetLayouts[i]).vulkanHandle;
}
return m_ComputePipelineManager->createComputePipeline(config.m_ShaderProgram, layouts);
}
PassHandle Core::createPass(const PassConfig &config)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment