From 61be74fe1839f664646b23f7860b217462dce0c4 Mon Sep 17 00:00:00 2001 From: PancakeTAS Date: Tue, 29 Jul 2025 16:33:16 +0200 Subject: [PATCH] fix: bind correct resources in performance mode --- framegen/v3.1_src/shaders/delta.cpp | 1 - framegen/v3.1p_include/v3_1p/shaders/delta.hpp | 9 +++++---- framegen/v3.1p_src/context.cpp | 5 +++-- framegen/v3.1p_src/shaders/delta.cpp | 17 ++++++++--------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/framegen/v3.1_src/shaders/delta.cpp b/framegen/v3.1_src/shaders/delta.cpp index bcafbf7..fbd2624 100644 --- a/framegen/v3.1_src/shaders/delta.cpp +++ b/framegen/v3.1_src/shaders/delta.cpp @@ -318,7 +318,6 @@ void Delta::Dispatch(const Core::CommandBuffer& buf, uint64_t frameCount, uint64 Utils::BarrierBuilder(buf) .addW2R(this->tempImgs2.at(0)) .addW2R(this->tempImgs2.at(1)) - .addW2R(this->optImg3) .addR2W(this->tempImgs1.at(0)) .addR2W(this->tempImgs1.at(1)) .build(); diff --git a/framegen/v3.1p_include/v3_1p/shaders/delta.hpp b/framegen/v3.1p_include/v3_1p/shaders/delta.hpp index fdbf3d1..983227d 100644 --- a/framegen/v3.1p_include/v3_1p/shaders/delta.hpp +++ b/framegen/v3.1p_include/v3_1p/shaders/delta.hpp @@ -32,19 +32,20 @@ namespace LSFG_3_1P::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 optImg2, + std::optional optImg3); /// /// Dispatch the shaderchain. /// - void Dispatch(const Core::CommandBuffer& buf, uint64_t frameCount, uint64_t pass_idx, - bool last); + void Dispatch(const Core::CommandBuffer& buf, uint64_t frameCount, uint64_t pass_idx); /// Get the first output image [[nodiscard]] const auto& getOutImage1() const { return this->outImg1; } @@ -71,7 +72,7 @@ namespace LSFG_3_1P::Shaders { std::array, 3> inImgs1; Core::Image inImg2; - std::optional optImg1, optImg2; + std::optional optImg1, optImg2, optImg3; std::array tempImgs1; std::array tempImgs2; Core::Image outImg1, outImg2; diff --git a/framegen/v3.1p_src/context.cpp b/framegen/v3.1p_src/context.cpp index 6702b5b..e4d94c5 100644 --- a/framegen/v3.1p_src/context.cpp +++ b/framegen/v3.1p_src/context.cpp @@ -50,7 +50,8 @@ 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).getOutImage1()), + (i == 4) ? std::nullopt : std::make_optional(this->delta.at(i - 5).getOutImage2())); } this->generate = Shaders::Generate(vk, this->inImg_0, this->inImg_1, @@ -106,7 +107,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, i == 6); + this->delta.at(i - 4).Dispatch(buf2, this->frameIdx, pass); } this->generate.Dispatch(buf2, this->frameIdx, pass); diff --git a/framegen/v3.1p_src/shaders/delta.cpp b/framegen/v3.1p_src/shaders/delta.cpp index df06d38..f65190e 100644 --- a/framegen/v3.1p_src/shaders/delta.cpp +++ b/framegen/v3.1p_src/shaders/delta.cpp @@ -17,9 +17,11 @@ using namespace LSFG_3_1P::Shaders; Delta::Delta(Vulkan& vk, std::array, 3> inImgs1, Core::Image inImg2, std::optional optImg1, - std::optional optImg2) + std::optional optImg2, + std::optional optImg3) : inImgs1(std::move(inImgs1)), inImg2(std::move(inImg2)), - optImg1(std::move(optImg1)), optImg2(std::move(optImg2)) { + optImg1(std::move(optImg1)), optImg2(std::move(optImg2)), + optImg3(std::move(optImg3)) { // create resources this->shaderModules = {{ vk.shaders.getShader(vk.device, "p_delta[0]", @@ -114,7 +116,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) + .add(VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, this->optImg1) .add(VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, this->tempImgs1) .build(); } @@ -194,14 +196,13 @@ 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) + .add(VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, this->optImg3) .add(VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, this->outImg2) .build(); } } -void Delta::Dispatch(const Core::CommandBuffer& buf, uint64_t frameCount, uint64_t pass_idx, - bool last) { +void Delta::Dispatch(const Core::CommandBuffer& buf, uint64_t frameCount, uint64_t pass_idx) { auto& pass = this->passes.at(pass_idx); // first shader @@ -275,9 +276,6 @@ 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) @@ -314,6 +312,7 @@ 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();