mirror of
https://github.com/PancakeTAS/lsfg-vk.git
synced 2026-02-09 23:35:52 +00:00
refactor(cleanup): optimize VRAM amount a slight bit
This commit is contained in:
parent
0c5553543f
commit
ea856ce062
6 changed files with 36 additions and 36 deletions
|
|
@ -392,13 +392,13 @@ ContextImpl::ContextImpl(const InstanceImpl& instance,
|
|||
chains::Alpha0(ctx, mipmaps.getImages().at(6))
|
||||
},
|
||||
alpha1{
|
||||
chains::Alpha1(ctx, alpha0.at(0).getImages()),
|
||||
chains::Alpha1(ctx, alpha0.at(1).getImages()),
|
||||
chains::Alpha1(ctx, alpha0.at(2).getImages()),
|
||||
chains::Alpha1(ctx, alpha0.at(3).getImages()),
|
||||
chains::Alpha1(ctx, alpha0.at(4).getImages()),
|
||||
chains::Alpha1(ctx, alpha0.at(5).getImages()),
|
||||
chains::Alpha1(ctx, alpha0.at(6).getImages())
|
||||
chains::Alpha1(ctx, 3, alpha0.at(0).getImages()),
|
||||
chains::Alpha1(ctx, 2, alpha0.at(1).getImages()),
|
||||
chains::Alpha1(ctx, 2, alpha0.at(2).getImages()),
|
||||
chains::Alpha1(ctx, 2, alpha0.at(3).getImages()),
|
||||
chains::Alpha1(ctx, 2, alpha0.at(4).getImages()),
|
||||
chains::Alpha1(ctx, 2, alpha0.at(5).getImages()),
|
||||
chains::Alpha1(ctx, 2, alpha0.at(6).getImages())
|
||||
},
|
||||
beta0(ctx, alpha1.at(0).getImages()),
|
||||
beta1(ctx, beta0.getImages()) {
|
||||
|
|
|
|||
|
|
@ -12,14 +12,14 @@
|
|||
|
||||
using namespace chains;
|
||||
|
||||
Alpha1::Alpha1(const ls::Ctx& ctx,
|
||||
Alpha1::Alpha1(const ls::Ctx& ctx, size_t temporal,
|
||||
const std::vector<vk::Image>& sourceImages) {
|
||||
const size_t m = ctx.perf ? 1 : 2; // multiplier
|
||||
const VkExtent2D quarterExtent = sourceImages.at(0).getExtent();
|
||||
|
||||
// create output images for mod3
|
||||
this->images.reserve(3);
|
||||
for(size_t i = 0; i < 3; i++) {
|
||||
this->images.reserve(temporal);
|
||||
for(size_t i = 0; i < temporal; i++) {
|
||||
auto& vec = this->images.emplace_back();
|
||||
|
||||
vec.reserve(2 * m);
|
||||
|
|
@ -29,8 +29,8 @@ Alpha1::Alpha1(const ls::Ctx& ctx,
|
|||
|
||||
// create descriptor sets
|
||||
const auto& shaders = ctx.perf ? ctx.shaders.get().performance : ctx.shaders.get().quality;
|
||||
this->sets.reserve(3);
|
||||
for (size_t i = 0; i < 3; i++)
|
||||
this->sets.reserve(temporal);
|
||||
for (size_t i = 0; i < temporal; i++)
|
||||
this->sets.emplace_back(ls::ManagedShaderBuilder()
|
||||
.sampleds(sourceImages)
|
||||
.storages(this->images.at(i))
|
||||
|
|
@ -48,6 +48,5 @@ void Alpha1::prepare(std::vector<VkImage>& images) const {
|
|||
}
|
||||
|
||||
void Alpha1::render(const vk::Vulkan& vk, const vk::CommandBuffer& cmd, size_t idx) const {
|
||||
// FIXME: iirc only one of the 7 instances of alpha1 requires 3 temporal images
|
||||
this->sets[idx % 3].dispatch(vk, cmd, dispatchExtent);
|
||||
this->sets[idx % this->sets.size()].dispatch(vk, cmd, dispatchExtent);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,8 +18,9 @@ namespace chains {
|
|||
public:
|
||||
/// create a alpha shaderchain
|
||||
/// @param ctx context
|
||||
/// @param temporal temporal count
|
||||
/// @param sourceImages source images
|
||||
Alpha1(const ls::Ctx& ctx,
|
||||
Alpha1(const ls::Ctx& ctx, size_t temporal,
|
||||
const std::vector<vk::Image>& sourceImages);
|
||||
|
||||
/// prepare the shaderchain initially
|
||||
|
|
|
|||
|
|
@ -24,12 +24,12 @@ Beta0::Beta0(const ls::Ctx& ctx,
|
|||
// create descriptor sets
|
||||
const auto& shader = (ctx.perf ?
|
||||
ctx.shaders.get().performance : ctx.shaders.get().quality).beta.at(0);
|
||||
this->sets.reserve(3);
|
||||
for (size_t i = 0; i < 3; i++)
|
||||
this->sets.reserve(sourceImages.size());
|
||||
for (size_t i = 0; i < sourceImages.size(); i++)
|
||||
this->sets.emplace_back(ls::ManagedShaderBuilder()
|
||||
.sampleds(sourceImages.at((i + 1) % 3))
|
||||
.sampleds(sourceImages.at((i + 2) % 3))
|
||||
.sampleds(sourceImages.at(i % 3))
|
||||
.sampleds(sourceImages.at((i + (sourceImages.size() - 2)) % sourceImages.size()))
|
||||
.sampleds(sourceImages.at((i + (sourceImages.size() - 1)) % sourceImages.size()))
|
||||
.sampleds(sourceImages.at(i % sourceImages.size()))
|
||||
.storages(this->images)
|
||||
.sampler(ctx.bnwSampler)
|
||||
.build(ctx.vk, ctx.pool, shader));
|
||||
|
|
@ -44,5 +44,5 @@ void Beta0::prepare(std::vector<VkImage>& images) const {
|
|||
}
|
||||
|
||||
void Beta0::render(const vk::Vulkan& vk, const vk::CommandBuffer& cmd, size_t idx) const {
|
||||
this->sets[idx % 3].dispatch(vk, cmd, dispatchExtent);
|
||||
this->sets[idx % this->sets.size()].dispatch(vk, cmd, dispatchExtent);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,11 +31,11 @@ Delta0::Delta0(const ls::Ctx& ctx, size_t idx,
|
|||
const auto& shaders = (ctx.perf ?
|
||||
ctx.shaders.get().performance : ctx.shaders.get().quality).delta;
|
||||
|
||||
this->sets0.reserve(3);
|
||||
for (size_t i = 0; i < 3; i++)
|
||||
this->sets0.reserve(sourceImages.size());
|
||||
for (size_t i = 0; i < sourceImages.size(); i++)
|
||||
this->sets0.emplace_back(ls::ManagedShaderBuilder()
|
||||
.sampleds(sourceImages.at((i + 2) % 3))
|
||||
.sampleds(sourceImages.at(i % 3))
|
||||
.sampleds(sourceImages.at((i + (sourceImages.size() - 1)) % sourceImages.size()))
|
||||
.sampleds(sourceImages.at(i % sourceImages.size()))
|
||||
.sampled(additionalInput0)
|
||||
.storages(this->images0)
|
||||
.sampler(ctx.bnwSampler)
|
||||
|
|
@ -43,11 +43,11 @@ Delta0::Delta0(const ls::Ctx& ctx, size_t idx,
|
|||
.buffer(ctx.constantBuffers.at(idx))
|
||||
.build(ctx.vk, ctx.pool, shaders.at(0)));
|
||||
|
||||
this->sets1.reserve(3);
|
||||
for (size_t i = 0; i < 3; i++)
|
||||
this->sets1.reserve(sourceImages.size());
|
||||
for (size_t i = 0; i < sourceImages.size(); i++)
|
||||
this->sets1.emplace_back(ls::ManagedShaderBuilder()
|
||||
.sampleds(sourceImages.at((i + 2) % 3))
|
||||
.sampleds(sourceImages.at(i % 3))
|
||||
.sampleds(sourceImages.at((i + (sourceImages.size() - 1)) % sourceImages.size()))
|
||||
.sampleds(sourceImages.at(i % sourceImages.size()))
|
||||
.sampled(additionalInput1)
|
||||
.sampled(additionalInput0)
|
||||
.storages(this->images1)
|
||||
|
|
@ -68,6 +68,6 @@ void Delta0::prepare(std::vector<VkImage>& images) const {
|
|||
}
|
||||
|
||||
void Delta0::render(const vk::Vulkan& vk, const vk::CommandBuffer& cmd, size_t idx) const {
|
||||
this->sets0[idx % 3].dispatch(vk, cmd, dispatchExtent);
|
||||
this->sets1[idx % 3].dispatch(vk, cmd, dispatchExtent);
|
||||
this->sets0[idx % this->sets0.size()].dispatch(vk, cmd, dispatchExtent);
|
||||
this->sets1[idx % this->sets1.size()].dispatch(vk, cmd, dispatchExtent);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,11 +25,11 @@ Gamma0::Gamma0(const ls::Ctx& ctx, size_t idx,
|
|||
// create descriptor sets
|
||||
const auto& shader = (ctx.perf ?
|
||||
ctx.shaders.get().performance : ctx.shaders.get().quality).gamma.at(0);
|
||||
this->sets.reserve(3);
|
||||
for (size_t i = 0; i < 3; i++)
|
||||
this->sets.reserve(sourceImages.size());
|
||||
for (size_t i = 0; i < sourceImages.size(); i++)
|
||||
this->sets.emplace_back(ls::ManagedShaderBuilder()
|
||||
.sampleds(sourceImages.at((i + 2) % 3))
|
||||
.sampleds(sourceImages.at(i % 3))
|
||||
.sampleds(sourceImages.at((i + (sourceImages.size() - 1)) % sourceImages.size()))
|
||||
.sampleds(sourceImages.at(i % sourceImages.size()))
|
||||
.sampled(additionalInput)
|
||||
.storages(this->images)
|
||||
.sampler(ctx.bnwSampler)
|
||||
|
|
@ -47,5 +47,5 @@ void Gamma0::prepare(std::vector<VkImage>& images) const {
|
|||
}
|
||||
|
||||
void Gamma0::render(const vk::Vulkan& vk, const vk::CommandBuffer& cmd, size_t idx) const {
|
||||
this->sets[idx % 3].dispatch(vk, cmd, dispatchExtent);
|
||||
this->sets[idx % this->sets.size()].dispatch(vk, cmd, dispatchExtent);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue