diff --git a/lsfg-vk-v3.1p/include/shaders/delta.hpp b/lsfg-vk-v3.1p/include/shaders/delta.hpp index c04375c..72d9262 100644 --- a/lsfg-vk-v3.1p/include/shaders/delta.hpp +++ b/lsfg-vk-v3.1p/include/shaders/delta.hpp @@ -30,20 +30,19 @@ namespace LSFG::Shaders { /// @param inImg2 Second Input image /// @param optImg1 Optional image for non-first passes. /// @param optImg2 Second optional image for non-first passes. - /// @param optImg3 Third optional image for non-first passes. /// /// @throws LSFG::vulkan_error if resource creation fails. /// Delta(Vulkan& vk, std::array, 3> inImgs1, Core::Image inImg2, std::optional optImg1, - std::optional optImg2, - std::optional optImg3); + std::optional optImg2); /// /// Dispatch the shaderchain. /// - void Dispatch(const Core::CommandBuffer& buf, uint64_t frameCount, uint64_t pass_idx); + void Dispatch(const Core::CommandBuffer& buf, uint64_t frameCount, uint64_t pass_idx, + bool last); /// Get the first output image [[nodiscard]] const auto& getOutImage1() const { return this->outImg1; } @@ -70,7 +69,7 @@ namespace LSFG::Shaders { std::array, 3> inImgs1; Core::Image inImg2; - std::optional optImg1, optImg2, optImg3; + std::optional optImg1, optImg2; std::array tempImgs1; std::array tempImgs2; Core::Image outImg1, outImg2; diff --git a/lsfg-vk-v3.1p/src/context.cpp b/lsfg-vk-v3.1p/src/context.cpp index 0e45687..327c4a7 100644 --- a/lsfg-vk-v3.1p/src/context.cpp +++ b/lsfg-vk-v3.1p/src/context.cpp @@ -48,8 +48,7 @@ Context::Context(Vulkan& vk, this->alpha.at(6 - i).getOutImages(), this->beta.getOutImages().at(6 - i), (i == 4) ? std::nullopt : std::make_optional(this->gamma.at(i - 1).getOutImage()), - (i == 4) ? std::nullopt : std::make_optional(this->delta.at(i - 5).getOutImage1()), - (i == 4) ? std::nullopt : std::make_optional(this->delta.at(i - 5).getOutImage2())); + (i == 4) ? std::nullopt : std::make_optional(this->delta.at(i - 5).getOutImage1())); } this->generate = Shaders::Generate(vk, this->inImg_0, this->inImg_1, @@ -105,7 +104,7 @@ void Context::present(Vulkan& vk, for (size_t i = 0; i < 7; i++) { this->gamma.at(i).Dispatch(buf2, this->frameIdx, pass); if (i >= 4) - this->delta.at(i - 4).Dispatch(buf2, this->frameIdx, pass); + this->delta.at(i - 4).Dispatch(buf2, this->frameIdx, pass, i == 6); } this->generate.Dispatch(buf2, this->frameIdx, pass); diff --git a/lsfg-vk-v3.1p/src/shaders/delta.cpp b/lsfg-vk-v3.1p/src/shaders/delta.cpp index ce87e39..2c77c00 100644 --- a/lsfg-vk-v3.1p/src/shaders/delta.cpp +++ b/lsfg-vk-v3.1p/src/shaders/delta.cpp @@ -16,11 +16,9 @@ using namespace LSFG::Shaders; Delta::Delta(Vulkan& vk, std::array, 3> inImgs1, Core::Image inImg2, std::optional optImg1, - std::optional optImg2, - std::optional optImg3) + std::optional optImg2) : inImgs1(std::move(inImgs1)), inImg2(std::move(inImg2)), - optImg1(std::move(optImg1)), optImg2(std::move(optImg2)), - optImg3(std::move(optImg3)) { + optImg1(std::move(optImg1)), optImg2(std::move(optImg2)) { // create resources this->shaderModules = {{ vk.shaders.getShader(vk.device, "delta[0]", @@ -115,7 +113,7 @@ Delta::Delta(Vulkan& vk, std::array, 3> inImgs1, .add(VK_DESCRIPTOR_TYPE_SAMPLER, this->samplers.at(2)) .add(VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, this->inImgs1.at((i + 2) % 3)) .add(VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, this->inImgs1.at(i % 3)) - .add(VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, this->optImg1) + .add(VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) .add(VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, this->tempImgs1) .build(); } @@ -195,13 +193,14 @@ Delta::Delta(Vulkan& vk, std::array, 3> inImgs1, .add(VK_DESCRIPTOR_TYPE_SAMPLER, this->samplers.at(0)) .add(VK_DESCRIPTOR_TYPE_SAMPLER, this->samplers.at(2)) .add(VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, this->tempImgs1.at(0)) - .add(VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, this->optImg3) + .add(VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) .add(VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, this->outImg2) .build(); } } -void Delta::Dispatch(const Core::CommandBuffer& buf, uint64_t frameCount, uint64_t pass_idx) { +void Delta::Dispatch(const Core::CommandBuffer& buf, uint64_t frameCount, uint64_t pass_idx, + bool last) { auto& pass = this->passes.at(pass_idx); // first shader @@ -275,6 +274,9 @@ void Delta::Dispatch(const Core::CommandBuffer& buf, uint64_t frameCount, uint64 pass.sixthDescriptorSet.at(frameCount % 3).bind(buf, this->pipelines.at(5)); buf.dispatch(threadsX, threadsY, 1); + if (!last) + return; + // seventh shader Utils::BarrierBuilder(buf) .addW2R(this->tempImgs2) @@ -299,7 +301,6 @@ void Delta::Dispatch(const Core::CommandBuffer& buf, uint64_t frameCount, uint64 // ninth shader Utils::BarrierBuilder(buf) .addW2R(this->tempImgs2) - .addW2R(this->optImg3) .addR2W(this->tempImgs1.at(0)) .addR2W(this->tempImgs1.at(1)) .build(); @@ -312,7 +313,6 @@ void Delta::Dispatch(const Core::CommandBuffer& buf, uint64_t frameCount, uint64 Utils::BarrierBuilder(buf) .addW2R(this->tempImgs1.at(0)) .addW2R(this->tempImgs1.at(1)) - .addW2R(this->optImg3) .addR2W(this->outImg2) .build();