mirror of
https://github.com/PancakeTAS/lsfg-vk.git
synced 2026-04-27 21:01:41 +00:00
lsfg-vk-v3.1p: optimizing delta
This commit is contained in:
parent
ec4be495ea
commit
2fde1bbf10
3 changed files with 15 additions and 17 deletions
|
|
@ -30,20 +30,19 @@ namespace LSFG::Shaders {
|
||||||
/// @param inImg2 Second Input image
|
/// @param inImg2 Second Input image
|
||||||
/// @param optImg1 Optional image for non-first passes.
|
/// @param optImg1 Optional image for non-first passes.
|
||||||
/// @param optImg2 Second 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.
|
/// @throws LSFG::vulkan_error if resource creation fails.
|
||||||
///
|
///
|
||||||
Delta(Vulkan& vk, std::array<std::array<Core::Image, 2>, 3> inImgs1,
|
Delta(Vulkan& vk, std::array<std::array<Core::Image, 2>, 3> inImgs1,
|
||||||
Core::Image inImg2,
|
Core::Image inImg2,
|
||||||
std::optional<Core::Image> optImg1,
|
std::optional<Core::Image> optImg1,
|
||||||
std::optional<Core::Image> optImg2,
|
std::optional<Core::Image> optImg2);
|
||||||
std::optional<Core::Image> optImg3);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Dispatch the shaderchain.
|
/// 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
|
/// Get the first output image
|
||||||
[[nodiscard]] const auto& getOutImage1() const { return this->outImg1; }
|
[[nodiscard]] const auto& getOutImage1() const { return this->outImg1; }
|
||||||
|
|
@ -70,7 +69,7 @@ namespace LSFG::Shaders {
|
||||||
|
|
||||||
std::array<std::array<Core::Image, 2>, 3> inImgs1;
|
std::array<std::array<Core::Image, 2>, 3> inImgs1;
|
||||||
Core::Image inImg2;
|
Core::Image inImg2;
|
||||||
std::optional<Core::Image> optImg1, optImg2, optImg3;
|
std::optional<Core::Image> optImg1, optImg2;
|
||||||
std::array<Core::Image, 3> tempImgs1;
|
std::array<Core::Image, 3> tempImgs1;
|
||||||
std::array<Core::Image, 2> tempImgs2;
|
std::array<Core::Image, 2> tempImgs2;
|
||||||
Core::Image outImg1, outImg2;
|
Core::Image outImg1, outImg2;
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,7 @@ Context::Context(Vulkan& vk,
|
||||||
this->alpha.at(6 - i).getOutImages(),
|
this->alpha.at(6 - i).getOutImages(),
|
||||||
this->beta.getOutImages().at(6 - i),
|
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->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->generate = Shaders::Generate(vk,
|
||||||
this->inImg_0, this->inImg_1,
|
this->inImg_0, this->inImg_1,
|
||||||
|
|
@ -105,7 +104,7 @@ void Context::present(Vulkan& vk,
|
||||||
for (size_t i = 0; i < 7; i++) {
|
for (size_t i = 0; i < 7; i++) {
|
||||||
this->gamma.at(i).Dispatch(buf2, this->frameIdx, pass);
|
this->gamma.at(i).Dispatch(buf2, this->frameIdx, pass);
|
||||||
if (i >= 4)
|
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);
|
this->generate.Dispatch(buf2, this->frameIdx, pass);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,11 +16,9 @@ using namespace LSFG::Shaders;
|
||||||
Delta::Delta(Vulkan& vk, std::array<std::array<Core::Image, 2>, 3> inImgs1,
|
Delta::Delta(Vulkan& vk, std::array<std::array<Core::Image, 2>, 3> inImgs1,
|
||||||
Core::Image inImg2,
|
Core::Image inImg2,
|
||||||
std::optional<Core::Image> optImg1,
|
std::optional<Core::Image> optImg1,
|
||||||
std::optional<Core::Image> optImg2,
|
std::optional<Core::Image> optImg2)
|
||||||
std::optional<Core::Image> optImg3)
|
|
||||||
: inImgs1(std::move(inImgs1)), inImg2(std::move(inImg2)),
|
: 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
|
// create resources
|
||||||
this->shaderModules = {{
|
this->shaderModules = {{
|
||||||
vk.shaders.getShader(vk.device, "delta[0]",
|
vk.shaders.getShader(vk.device, "delta[0]",
|
||||||
|
|
@ -115,7 +113,7 @@ Delta::Delta(Vulkan& vk, std::array<std::array<Core::Image, 2>, 3> inImgs1,
|
||||||
.add(VK_DESCRIPTOR_TYPE_SAMPLER, this->samplers.at(2))
|
.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 + 2) % 3))
|
||||||
.add(VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, this->inImgs1.at(i % 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)
|
.add(VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, this->tempImgs1)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
@ -195,13 +193,14 @@ Delta::Delta(Vulkan& vk, std::array<std::array<Core::Image, 2>, 3> inImgs1,
|
||||||
.add(VK_DESCRIPTOR_TYPE_SAMPLER, this->samplers.at(0))
|
.add(VK_DESCRIPTOR_TYPE_SAMPLER, this->samplers.at(0))
|
||||||
.add(VK_DESCRIPTOR_TYPE_SAMPLER, this->samplers.at(2))
|
.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->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)
|
.add(VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, this->outImg2)
|
||||||
.build();
|
.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);
|
auto& pass = this->passes.at(pass_idx);
|
||||||
|
|
||||||
// first shader
|
// 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));
|
pass.sixthDescriptorSet.at(frameCount % 3).bind(buf, this->pipelines.at(5));
|
||||||
buf.dispatch(threadsX, threadsY, 1);
|
buf.dispatch(threadsX, threadsY, 1);
|
||||||
|
|
||||||
|
if (!last)
|
||||||
|
return;
|
||||||
|
|
||||||
// seventh shader
|
// seventh shader
|
||||||
Utils::BarrierBuilder(buf)
|
Utils::BarrierBuilder(buf)
|
||||||
.addW2R(this->tempImgs2)
|
.addW2R(this->tempImgs2)
|
||||||
|
|
@ -299,7 +301,6 @@ void Delta::Dispatch(const Core::CommandBuffer& buf, uint64_t frameCount, uint64
|
||||||
// ninth shader
|
// ninth shader
|
||||||
Utils::BarrierBuilder(buf)
|
Utils::BarrierBuilder(buf)
|
||||||
.addW2R(this->tempImgs2)
|
.addW2R(this->tempImgs2)
|
||||||
.addW2R(this->optImg3)
|
|
||||||
.addR2W(this->tempImgs1.at(0))
|
.addR2W(this->tempImgs1.at(0))
|
||||||
.addR2W(this->tempImgs1.at(1))
|
.addR2W(this->tempImgs1.at(1))
|
||||||
.build();
|
.build();
|
||||||
|
|
@ -312,7 +313,6 @@ void Delta::Dispatch(const Core::CommandBuffer& buf, uint64_t frameCount, uint64
|
||||||
Utils::BarrierBuilder(buf)
|
Utils::BarrierBuilder(buf)
|
||||||
.addW2R(this->tempImgs1.at(0))
|
.addW2R(this->tempImgs1.at(0))
|
||||||
.addW2R(this->tempImgs1.at(1))
|
.addW2R(this->tempImgs1.at(1))
|
||||||
.addW2R(this->optImg3)
|
|
||||||
.addR2W(this->outImg2)
|
.addR2W(this->outImg2)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue