mirror of
https://github.com/PancakeTAS/lsfg-vk.git
synced 2025-10-30 07:01:10 +00:00
bugfixes again
This commit is contained in:
parent
b66568f0b7
commit
0bdbc4b25c
7 changed files with 106 additions and 247 deletions
31
src/lsfg.cpp
31
src/lsfg.cpp
|
|
@ -1,12 +1,26 @@
|
|||
#include "lsfg.hpp"
|
||||
#include "core/commandbuffer.hpp"
|
||||
#include "core/fence.hpp"
|
||||
#include "core/image.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <format>
|
||||
|
||||
using namespace LSFG;
|
||||
|
||||
Generator::Generator(const Context& context) {
|
||||
// TODO: temporal frames
|
||||
// TEST: create temporal images
|
||||
this->inImg_0 = Core::Image(context.device,
|
||||
{ 2560, 1411 }, VK_FORMAT_R8G8B8A8_UNORM,
|
||||
VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT
|
||||
);
|
||||
this->inImg_1 = Core::Image(context.device,
|
||||
{ 2560, 1411 }, VK_FORMAT_R8G8B8A8_UNORM,
|
||||
VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT
|
||||
);
|
||||
// TEST END
|
||||
|
||||
// create shader chains
|
||||
this->downsampleChain = Shaderchains::Downsample(context.device, context.descPool,
|
||||
|
|
@ -64,13 +78,13 @@ Generator::Generator(const Context& context) {
|
|||
this->extractChains.at(i - 4) = Shaderchains::Extract(context.device, context.descPool,
|
||||
this->zetaChains.at(i - 4).getOutImage(),
|
||||
this->epsilonChains.at(i - 4).getOutImage(),
|
||||
this->extractChains.at(i - 5).getOutImage().getExtent()
|
||||
this->alphaChains.at(6 - i - 1).getOutImages0().at(0).getExtent()
|
||||
);
|
||||
}
|
||||
}
|
||||
this->mergeChain = Shaderchains::Merge(context.device, context.descPool,
|
||||
this->inImg_0,
|
||||
this->inImg_1,
|
||||
this->inImg_0,
|
||||
this->zetaChains.at(2).getOutImage(),
|
||||
this->epsilonChains.at(2).getOutImage(),
|
||||
this->deltaChains.at(2).getOutImage()
|
||||
|
|
@ -78,6 +92,10 @@ Generator::Generator(const Context& context) {
|
|||
}
|
||||
|
||||
void Generator::present(const Context& context) {
|
||||
// TEST: upload input images
|
||||
// TODO: implement test, lol
|
||||
// TEST END
|
||||
|
||||
Core::CommandBuffer cmdBuffer(context.device, context.cmdPool);
|
||||
cmdBuffer.begin();
|
||||
|
||||
|
|
@ -99,7 +117,12 @@ void Generator::present(const Context& context) {
|
|||
|
||||
cmdBuffer.end();
|
||||
|
||||
// TODO: submit logic
|
||||
// TEST: temporary fence submit logic
|
||||
Core::Fence fence(context.device);
|
||||
cmdBuffer.submit(context.device.getComputeQueue(), fence);
|
||||
assert(fence.wait(context.device));
|
||||
// TEST END
|
||||
|
||||
fc++;
|
||||
}
|
||||
|
||||
|
|
|
|||
195
src/main.cpp
195
src/main.cpp
|
|
@ -1,29 +1,10 @@
|
|||
#include "core/commandbuffer.hpp"
|
||||
#include "core/commandpool.hpp"
|
||||
#include "core/descriptorpool.hpp"
|
||||
#include "core/fence.hpp"
|
||||
#include "core/image.hpp"
|
||||
#include "device.hpp"
|
||||
#include "instance.hpp"
|
||||
#include "shaderchains/alpha.hpp"
|
||||
#include "shaderchains/beta.hpp"
|
||||
#include "shaderchains/delta.hpp"
|
||||
#include "shaderchains/downsample.hpp"
|
||||
#include "shaderchains/epsilon.hpp"
|
||||
#include "shaderchains/extract.hpp"
|
||||
#include "shaderchains/gamma.hpp"
|
||||
#include "shaderchains/magic.hpp"
|
||||
#include "shaderchains/merge.hpp"
|
||||
#include "shaderchains/zeta.hpp"
|
||||
#include "utils.hpp"
|
||||
#include "lsfg.hpp"
|
||||
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
|
||||
#include <renderdoc_app.h>
|
||||
#include <dlfcn.h>
|
||||
#include <unistd.h>
|
||||
#include <vector>
|
||||
|
||||
using namespace LSFG;
|
||||
|
||||
|
|
@ -42,172 +23,24 @@ int main() {
|
|||
usleep(1000 * 100); // give renderdoc time to load
|
||||
}
|
||||
|
||||
// initialize application
|
||||
// const Instance instance;
|
||||
// const Device device(instance);
|
||||
// const Core::DescriptorPool descriptorPool(device);
|
||||
// const Core::CommandPool commandPool(device);
|
||||
// initialize test application
|
||||
LSFG::Context context;
|
||||
auto gen = LSFG::Generator(context);
|
||||
|
||||
// Globals::initializeGlobals(device);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (rdoc)
|
||||
rdoc->StartFrameCapture(nullptr, nullptr);
|
||||
|
||||
// create downsample shader chain
|
||||
// Core::Image inputImage(
|
||||
// device, { 2560, 1411 }, VK_FORMAT_R8G8B8A8_UNORM,
|
||||
// VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT,
|
||||
// VK_IMAGE_ASPECT_COLOR_BIT
|
||||
// );
|
||||
// Utils::uploadImage(device, commandPool, inputImage, "rsc/images/source.dds");
|
||||
gen.present(context);
|
||||
|
||||
// Shaderchains::Downsample downsample(device, descriptorPool, inputImage);
|
||||
if (rdoc)
|
||||
rdoc->EndFrameCapture(nullptr, nullptr);
|
||||
|
||||
// create alpha shader chains
|
||||
// std::vector<Shaderchains::Alpha> alphas;
|
||||
// alphas.reserve(7);
|
||||
// for (size_t i = 0; i < 7; ++i)
|
||||
// alphas.emplace_back(device, descriptorPool, downsample.getOutImages().at(i));
|
||||
// sleep 8 ms
|
||||
usleep(8000);
|
||||
}
|
||||
|
||||
// // create beta shader chain
|
||||
// std::array<Core::Image, 8> betaTemporalImages;
|
||||
// auto betaInExtent = alphas.at(0).getOutImages().at(0).getExtent();
|
||||
// for (size_t i = 0; i < 8; ++i) {
|
||||
// betaTemporalImages.at(i) = Core::Image(
|
||||
// device, betaInExtent, VK_FORMAT_R8G8B8A8_UNORM,
|
||||
// VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT |
|
||||
// VK_IMAGE_USAGE_TRANSFER_DST_BIT,
|
||||
// VK_IMAGE_ASPECT_COLOR_BIT
|
||||
// );
|
||||
// Utils::uploadImage(device, commandPool, betaTemporalImages.at(i),
|
||||
// std::format("rsc/images/temporal_beta/{}.dds", i));
|
||||
// }
|
||||
|
||||
// Shaderchains::Beta beta(device, descriptorPool,
|
||||
// betaTemporalImages,
|
||||
// alphas.at(0).getOutImages()
|
||||
// );
|
||||
|
||||
// create gamma to zeta shader chains
|
||||
// std::vector<Shaderchains::Gamma> gammas;
|
||||
// std::vector<Shaderchains::Magic> magics;
|
||||
// std::vector<Shaderchains::Delta> deltas;
|
||||
// std::vector<Shaderchains::Epsilon> epsilons;
|
||||
// std::vector<Shaderchains::Zeta> zetas;
|
||||
// std::vector<Shaderchains::Extract> extracts;
|
||||
// std::array<std::array<Core::Image, 4>, 7> otherTemporalImages;
|
||||
// for (size_t i = 0; i < 7; i++) {
|
||||
// auto otherInExtent = alphas.at(6 - i).getOutImages().at(0).getExtent();
|
||||
// for (size_t j = 0; j < 4; j++) {
|
||||
// otherTemporalImages.at(i).at(j) = Core::Image(
|
||||
// device, otherInExtent, VK_FORMAT_R8G8B8A8_UNORM,
|
||||
// VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT |
|
||||
// VK_IMAGE_USAGE_TRANSFER_DST_BIT,
|
||||
// VK_IMAGE_ASPECT_COLOR_BIT
|
||||
// );
|
||||
// Utils::uploadImage(device, commandPool, otherTemporalImages.at(i).at(j),
|
||||
// std::format("rsc/images/temporal_other/{}.{}.dds", i, j));
|
||||
// }
|
||||
// if (i < 4) {
|
||||
// auto gammaOutExtent = alphas.at(6 - i - 1).getOutImages().at(0).getExtent();
|
||||
// gammas.emplace_back(device, descriptorPool,
|
||||
// otherTemporalImages.at(i),
|
||||
// alphas.at(6 - i).getOutImages(),
|
||||
// beta.getOutImages().at(std::min(static_cast<size_t>(5), 6 - i)), // smallest twice
|
||||
// i == 0 ? std::nullopt : std::optional{gammas.at(i - 1).getOutImage2()},
|
||||
// i == 0 ? std::nullopt : std::optional{gammas.at(i - 1).getOutImage1()},
|
||||
// gammaOutExtent);
|
||||
// } else {
|
||||
// magics.emplace_back(device, descriptorPool,
|
||||
// otherTemporalImages.at(i),
|
||||
// alphas.at(6 - i).getOutImages(),
|
||||
// i == 4 ? gammas.at(i - 1).getOutImage2() : extracts.at(i - 5).getOutImage(),
|
||||
// i == 4 ? gammas.at(i - 1).getOutImage1() : zetas.at(i - 5).getOutImage(),
|
||||
// i == 4 ? std::nullopt : std::optional{epsilons.at(i - 5).getOutImage()}
|
||||
// );
|
||||
// deltas.emplace_back(device, descriptorPool,
|
||||
// magics.at(i - 4).getOutImages1(),
|
||||
// i == 4 ? std::nullopt : std::optional{deltas.at(i - 5).getOutImage()}
|
||||
// );
|
||||
// epsilons.emplace_back(device, descriptorPool,
|
||||
// magics.at(i - 4).getOutImages2(),
|
||||
// beta.getOutImages().at(6 - i),
|
||||
// i == 4 ? std::nullopt : std::optional{epsilons.at(i - 5).getOutImage()}
|
||||
// );
|
||||
// zetas.emplace_back(device, descriptorPool,
|
||||
// magics.at(i - 4).getOutImages3(),
|
||||
// i == 4 ? gammas.at(i - 1).getOutImage1() : zetas.at(i - 5).getOutImage(),
|
||||
// beta.getOutImages().at(6 - i)
|
||||
// );
|
||||
// if (i < 6) {
|
||||
// auto extractOutExtent = alphas.at(6 - i - 1).getOutImages().at(0).getExtent();
|
||||
// extracts.emplace_back(device, descriptorPool,
|
||||
// zetas.at(i - 4).getOutImage(),
|
||||
// epsilons.at(i - 4).getOutImage(),
|
||||
// extractOutExtent);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// // create merge shader chain
|
||||
// Core::Image inputImagePrev(
|
||||
// device, { 2560, 1411 }, VK_FORMAT_R8G8B8A8_UNORM,
|
||||
// VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT,
|
||||
// VK_IMAGE_ASPECT_COLOR_BIT
|
||||
// );
|
||||
// Utils::uploadImage(device, commandPool, inputImagePrev, "rsc/images/source_prev.dds");
|
||||
// Shaderchains::Merge merge(device, descriptorPool,
|
||||
// inputImagePrev,
|
||||
// inputImage,
|
||||
// zetas.at(2).getOutImage(),
|
||||
// epsilons.at(2).getOutImage(),
|
||||
// deltas.at(2).getOutImage()
|
||||
// );
|
||||
|
||||
// for (int i = 0; i < 1000; i++) {
|
||||
// const Core::Fence fence(device);
|
||||
|
||||
// // start the rendering pipeline
|
||||
// if (rdoc)
|
||||
// rdoc->StartFrameCapture(nullptr, nullptr);
|
||||
|
||||
// Core::CommandBuffer commandBuffer(device, commandPool);
|
||||
// commandBuffer.begin();
|
||||
|
||||
// downsample.Dispatch(commandBuffer);
|
||||
// for (size_t i = 0; i < 7; i++)
|
||||
// alphas.at(6 - i).Dispatch(commandBuffer);
|
||||
// beta.Dispatch(commandBuffer);
|
||||
// for (size_t i = 0; i < 4; i++)
|
||||
// gammas.at(i).Dispatch(commandBuffer);
|
||||
// for (size_t i = 0; i < 3; i++) {
|
||||
// magics.at(i).Dispatch(commandBuffer);
|
||||
// deltas.at(i).Dispatch(commandBuffer);
|
||||
// epsilons.at(i).Dispatch(commandBuffer);
|
||||
// zetas.at(i).Dispatch(commandBuffer);
|
||||
// if (i < 2)
|
||||
// extracts.at(i).Dispatch(commandBuffer);
|
||||
// }
|
||||
// merge.Dispatch(commandBuffer);
|
||||
|
||||
// // finish the rendering pipeline
|
||||
// commandBuffer.end();
|
||||
|
||||
// commandBuffer.submit(device.getComputeQueue(), fence);
|
||||
// if (!fence.wait(device)) {
|
||||
// Globals::uninitializeGlobals();
|
||||
|
||||
// std::cerr << "Application failed due to timeout" << '\n';
|
||||
// return 1;
|
||||
// }
|
||||
|
||||
// if (rdoc)
|
||||
// rdoc->EndFrameCapture(nullptr, nullptr);
|
||||
|
||||
// // sleep 8 ms
|
||||
// usleep(8000);
|
||||
// }
|
||||
|
||||
// usleep(1000 * 100); // give renderdoc time to capture
|
||||
|
||||
// Globals::uninitializeGlobals();
|
||||
usleep(1000 * 100);
|
||||
|
||||
std::cerr << "Application finished" << '\n';
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -67,17 +67,20 @@ Alpha::Alpha(const Device& device, const Core::DescriptorPool& pool,
|
|||
this->outImgs_0.at(i) = Core::Image(device,
|
||||
quarterExtent,
|
||||
VK_FORMAT_R8G8B8A8_UNORM,
|
||||
VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_SAMPLED_BIT,
|
||||
VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_SAMPLED_BIT
|
||||
| VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT);
|
||||
this->outImgs_1.at(i) = Core::Image(device,
|
||||
quarterExtent,
|
||||
VK_FORMAT_R8G8B8A8_UNORM,
|
||||
VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_SAMPLED_BIT,
|
||||
VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_SAMPLED_BIT
|
||||
| VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT);
|
||||
this->outImgs_2.at(i) = Core::Image(device,
|
||||
quarterExtent,
|
||||
VK_FORMAT_R8G8B8A8_UNORM,
|
||||
VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_SAMPLED_BIT,
|
||||
VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_SAMPLED_BIT
|
||||
| VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT);
|
||||
}
|
||||
|
||||
|
|
@ -97,13 +100,13 @@ Alpha::Alpha(const Device& device, const Core::DescriptorPool& pool,
|
|||
.add(VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, this->tempImgs3)
|
||||
.build();
|
||||
for (size_t fc = 0; fc < 3; fc++) {
|
||||
auto& outImgs = this->outImgs_0;
|
||||
if (fc == 1) outImgs = this->outImgs_1;
|
||||
else if (fc == 2) outImgs = this->outImgs_2;
|
||||
auto* outImgs = &this->outImgs_0;
|
||||
if (fc == 1) outImgs = &this->outImgs_1;
|
||||
else if (fc == 2) outImgs = &this->outImgs_2;
|
||||
this->specialDescriptorSets.at(fc).update(device)
|
||||
.add(VK_DESCRIPTOR_TYPE_SAMPLER, Globals::samplerClampBorder)
|
||||
.add(VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, this->tempImgs3)
|
||||
.add(VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, outImgs)
|
||||
.add(VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, *outImgs)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
@ -156,12 +159,12 @@ void Alpha::Dispatch(const Core::CommandBuffer& buf, uint64_t fc) {
|
|||
buf.dispatch(threadsX, threadsY, 1);
|
||||
|
||||
// fourth pass
|
||||
auto& outImgs = this->outImgs_0;
|
||||
if ((fc % 3) == 1) outImgs = this->outImgs_1;
|
||||
else if ((fc % 3) == 2) outImgs = this->outImgs_2;
|
||||
auto* outImgs = &this->outImgs_0;
|
||||
if ((fc % 3) == 1) outImgs = &this->outImgs_1;
|
||||
else if ((fc % 3) == 2) outImgs = &this->outImgs_2;
|
||||
Utils::BarrierBuilder(buf)
|
||||
.addW2R(this->tempImgs3)
|
||||
.addR2W(outImgs)
|
||||
.addR2W(*outImgs)
|
||||
.build();
|
||||
|
||||
this->pipelines.at(3).bind(buf);
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ Beta::Beta(const Device& device, const Core::DescriptorPool& pool,
|
|||
}
|
||||
for (size_t i = 0; i < 3; i++)
|
||||
this->specialDescriptorSets.at(i) = Core::DescriptorSet(device, pool,
|
||||
this->shaderModules.at(4));
|
||||
this->shaderModules.at(0));
|
||||
this->buffer = Core::Buffer(device, Globals::fgBuffer, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT);
|
||||
|
||||
const auto extent = this->inImgs_0.at(0).getExtent();
|
||||
|
|
@ -69,23 +69,23 @@ Beta::Beta(const Device& device, const Core::DescriptorPool& pool,
|
|||
}
|
||||
|
||||
for (size_t fc = 0; fc < 3; fc++) {
|
||||
auto& nextImgs = this->inImgs_0;
|
||||
auto& prevImgs = this->inImgs_2;
|
||||
auto& pprevImgs = this->inImgs_1;
|
||||
auto* nextImgs = &this->inImgs_0;
|
||||
auto* prevImgs = &this->inImgs_2;
|
||||
auto* pprevImgs = &this->inImgs_1;
|
||||
if (fc == 1) {
|
||||
nextImgs = this->inImgs_1;
|
||||
prevImgs = this->inImgs_0;
|
||||
pprevImgs = this->inImgs_2;
|
||||
nextImgs = &this->inImgs_1;
|
||||
prevImgs = &this->inImgs_0;
|
||||
pprevImgs = &this->inImgs_2;
|
||||
} else if (fc == 2) {
|
||||
nextImgs = this->inImgs_2;
|
||||
prevImgs = this->inImgs_1;
|
||||
pprevImgs = this->inImgs_0;
|
||||
nextImgs = &this->inImgs_2;
|
||||
prevImgs = &this->inImgs_1;
|
||||
pprevImgs = &this->inImgs_0;
|
||||
}
|
||||
this->specialDescriptorSets.at(fc).update(device)
|
||||
.add(VK_DESCRIPTOR_TYPE_SAMPLER, Globals::samplerClampBorder)
|
||||
.add(VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, pprevImgs)
|
||||
.add(VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, prevImgs)
|
||||
.add(VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, nextImgs)
|
||||
.add(VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, *pprevImgs)
|
||||
.add(VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, *prevImgs)
|
||||
.add(VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, *nextImgs)
|
||||
.add(VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, this->tempImgs1)
|
||||
.build();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,20 +98,20 @@ Gamma::Gamma(const Device& device, const Core::DescriptorPool& pool,
|
|||
VK_IMAGE_ASPECT_COLOR_BIT);
|
||||
|
||||
for (size_t fc = 0; fc < 3; fc++) {
|
||||
auto& nextImgs1 = this->inImgs1_0;
|
||||
auto& prevImgs1 = this->inImgs1_2;
|
||||
auto* nextImgs1 = &this->inImgs1_0;
|
||||
auto* prevImgs1 = &this->inImgs1_2;
|
||||
if (fc == 1) {
|
||||
nextImgs1 = this->inImgs1_1;
|
||||
prevImgs1 = this->inImgs1_0;
|
||||
nextImgs1 = &this->inImgs1_1;
|
||||
prevImgs1 = &this->inImgs1_0;
|
||||
} else if (fc == 2) {
|
||||
nextImgs1 = this->inImgs1_2;
|
||||
prevImgs1 = this->inImgs1_1;
|
||||
nextImgs1 = &this->inImgs1_2;
|
||||
prevImgs1 = &this->inImgs1_1;
|
||||
}
|
||||
this->specialDescriptorSets.at(fc).update(device)
|
||||
.add(VK_DESCRIPTOR_TYPE_SAMPLER, Globals::samplerClampBorder)
|
||||
.add(VK_DESCRIPTOR_TYPE_SAMPLER, Globals::samplerClampEdge)
|
||||
.add(VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, prevImgs1)
|
||||
.add(VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, nextImgs1)
|
||||
.add(VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, *prevImgs1)
|
||||
.add(VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, *nextImgs1)
|
||||
.add(VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, this->optImg1)
|
||||
.add(VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, this->optImg2)
|
||||
.add(VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, this->tempImgs1.at(0))
|
||||
|
|
@ -168,18 +168,18 @@ void Gamma::Dispatch(const Core::CommandBuffer& buf, uint64_t fc) {
|
|||
uint32_t threadsX = (extent.width + 7) >> 3;
|
||||
uint32_t threadsY = (extent.height + 7) >> 3;
|
||||
|
||||
auto& nextImgs1 = this->inImgs1_0;
|
||||
auto& prevImgs1 = this->inImgs1_2;
|
||||
auto* nextImgs1 = &this->inImgs1_0;
|
||||
auto* prevImgs1 = &this->inImgs1_2;
|
||||
if ((fc % 3) == 1) {
|
||||
nextImgs1 = this->inImgs1_1;
|
||||
prevImgs1 = this->inImgs1_0;
|
||||
nextImgs1 = &this->inImgs1_1;
|
||||
prevImgs1 = &this->inImgs1_0;
|
||||
} else if ((fc % 3) == 2) {
|
||||
nextImgs1 = this->inImgs1_2;
|
||||
prevImgs1 = this->inImgs1_1;
|
||||
nextImgs1 = &this->inImgs1_2;
|
||||
prevImgs1 = &this->inImgs1_1;
|
||||
}
|
||||
Utils::BarrierBuilder(buf)
|
||||
.addW2R(prevImgs1)
|
||||
.addW2R(nextImgs1)
|
||||
.addW2R(*prevImgs1)
|
||||
.addW2R(*nextImgs1)
|
||||
.addW2R(this->optImg1)
|
||||
.addW2R(this->optImg2)
|
||||
.addR2W(this->tempImgs1.at(0))
|
||||
|
|
@ -200,7 +200,7 @@ void Gamma::Dispatch(const Core::CommandBuffer& buf, uint64_t fc) {
|
|||
.build();
|
||||
|
||||
this->pipelines.at(1).bind(buf);
|
||||
this->descriptorSets.at(1).bind(buf, this->pipelines.at(1));
|
||||
this->descriptorSets.at(0).bind(buf, this->pipelines.at(1));
|
||||
buf.dispatch(threadsX, threadsY, 1);
|
||||
|
||||
// third pass
|
||||
|
|
@ -210,7 +210,7 @@ void Gamma::Dispatch(const Core::CommandBuffer& buf, uint64_t fc) {
|
|||
.build();
|
||||
|
||||
this->pipelines.at(2).bind(buf);
|
||||
this->descriptorSets.at(2).bind(buf, this->pipelines.at(2));
|
||||
this->descriptorSets.at(1).bind(buf, this->pipelines.at(2));
|
||||
buf.dispatch(threadsX, threadsY, 1);
|
||||
|
||||
// fourth pass
|
||||
|
|
@ -220,7 +220,7 @@ void Gamma::Dispatch(const Core::CommandBuffer& buf, uint64_t fc) {
|
|||
.build();
|
||||
|
||||
this->pipelines.at(3).bind(buf);
|
||||
this->descriptorSets.at(3).bind(buf, this->pipelines.at(3));
|
||||
this->descriptorSets.at(2).bind(buf, this->pipelines.at(3));
|
||||
buf.dispatch(threadsX, threadsY, 1);
|
||||
|
||||
// fifth pass
|
||||
|
|
@ -232,7 +232,7 @@ void Gamma::Dispatch(const Core::CommandBuffer& buf, uint64_t fc) {
|
|||
.build();
|
||||
|
||||
this->pipelines.at(4).bind(buf);
|
||||
this->descriptorSets.at(4).bind(buf, this->pipelines.at(4));
|
||||
this->descriptorSets.at(3).bind(buf, this->pipelines.at(4));
|
||||
buf.dispatch(threadsX, threadsY, 1);
|
||||
|
||||
// sixth pass
|
||||
|
|
@ -246,6 +246,6 @@ void Gamma::Dispatch(const Core::CommandBuffer& buf, uint64_t fc) {
|
|||
.build();
|
||||
|
||||
this->pipelines.at(5).bind(buf);
|
||||
this->descriptorSets.at(5).bind(buf, this->pipelines.at(5));
|
||||
this->descriptorSets.at(4).bind(buf, this->pipelines.at(5));
|
||||
buf.dispatch(threadsX, threadsY, 1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,20 +50,20 @@ Magic::Magic(const Device& device, const Core::DescriptorPool& pool,
|
|||
VK_IMAGE_ASPECT_COLOR_BIT);
|
||||
|
||||
for (size_t fc = 0; fc < 3; fc++) {
|
||||
auto& nextImgs1 = this->inImgs1_0;
|
||||
auto& prevImgs1 = this->inImgs1_2;
|
||||
auto* nextImgs1 = &this->inImgs1_0;
|
||||
auto* prevImgs1 = &this->inImgs1_2;
|
||||
if (fc == 1) {
|
||||
nextImgs1 = this->inImgs1_1;
|
||||
prevImgs1 = this->inImgs1_0;
|
||||
nextImgs1 = &this->inImgs1_1;
|
||||
prevImgs1 = &this->inImgs1_0;
|
||||
} else if (fc == 2) {
|
||||
nextImgs1 = this->inImgs1_2;
|
||||
prevImgs1 = this->inImgs1_1;
|
||||
nextImgs1 = &this->inImgs1_2;
|
||||
prevImgs1 = &this->inImgs1_1;
|
||||
}
|
||||
this->descriptorSets.at(fc).update(device)
|
||||
.add(VK_DESCRIPTOR_TYPE_SAMPLER, Globals::samplerClampBorder)
|
||||
.add(VK_DESCRIPTOR_TYPE_SAMPLER, Globals::samplerClampEdge)
|
||||
.add(VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, prevImgs1)
|
||||
.add(VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, nextImgs1)
|
||||
.add(VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, *prevImgs1)
|
||||
.add(VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, *nextImgs1)
|
||||
.add(VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, this->inImg2)
|
||||
.add(VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, this->inImg3)
|
||||
.add(VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, this->optImg)
|
||||
|
|
@ -82,18 +82,18 @@ void Magic::Dispatch(const Core::CommandBuffer& buf, uint64_t fc) {
|
|||
const uint32_t threadsX = (extent.width + 7) >> 3;
|
||||
const uint32_t threadsY = (extent.height + 7) >> 3;
|
||||
|
||||
auto& nextImgs1 = this->inImgs1_0;
|
||||
auto& prevImgs1 = this->inImgs1_2;
|
||||
auto* nextImgs1 = &this->inImgs1_0;
|
||||
auto* prevImgs1 = &this->inImgs1_2;
|
||||
if ((fc % 3) == 1) {
|
||||
nextImgs1 = this->inImgs1_1;
|
||||
prevImgs1 = this->inImgs1_0;
|
||||
nextImgs1 = &this->inImgs1_1;
|
||||
prevImgs1 = &this->inImgs1_0;
|
||||
} else if ((fc % 3) == 2) {
|
||||
nextImgs1 = this->inImgs1_2;
|
||||
prevImgs1 = this->inImgs1_1;
|
||||
nextImgs1 = &this->inImgs1_2;
|
||||
prevImgs1 = &this->inImgs1_1;
|
||||
}
|
||||
Utils::BarrierBuilder(buf)
|
||||
.addW2R(prevImgs1)
|
||||
.addW2R(nextImgs1)
|
||||
.addW2R(*prevImgs1)
|
||||
.addW2R(*nextImgs1)
|
||||
.addW2R(this->inImg2)
|
||||
.addW2R(this->inImg3)
|
||||
.addW2R(this->optImg)
|
||||
|
|
|
|||
|
|
@ -64,6 +64,6 @@ void Merge::Dispatch(const Core::CommandBuffer& buf, uint64_t fc) {
|
|||
.build();
|
||||
|
||||
this->pipeline.bind(buf);
|
||||
this->descriptorSets.at(fc).bind(buf, this->pipeline);
|
||||
this->descriptorSets.at(fc % 2).bind(buf, this->pipeline);
|
||||
buf.dispatch(threadsX, threadsY, 1);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue