mirror of
https://github.com/PancakeTAS/lsfg-vk.git
synced 2025-10-30 07:01:10 +00:00
48 lines
1.5 KiB
C++
48 lines
1.5 KiB
C++
#include "v31n/shaderchain/mipmaps.hpp"
|
|
#include "vk/types/shader.hpp"
|
|
#include "vk/core/sampler.hpp"
|
|
#include "vk/core/buffer.hpp"
|
|
#include "vk/core/image.hpp"
|
|
#include "lsfg.hpp"
|
|
|
|
#include <vulkan/vulkan_core.h>
|
|
|
|
#include <vector>
|
|
|
|
using namespace LSFG::V31N::Shaderchain;
|
|
using namespace VK;
|
|
|
|
Mipmaps::Mipmaps(LSFG::VKD& vkd, const Core::Image& in1, const Core::Image& in2) {
|
|
auto sampler = vkd.apool.getOrCreate(vkd.device,
|
|
VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,
|
|
VK_COMPARE_OP_NEVER, false);
|
|
auto buffer = vkd.bpool.getOrCreate(vkd.device,
|
|
vkd.flow, vkd.hdr, 0.0F, false, false);
|
|
|
|
|
|
// create output images
|
|
const VkExtent2D extent{
|
|
.width = static_cast<uint32_t>(
|
|
static_cast<float>(in1.getExtent().width) / vkd.flow),
|
|
.height = static_cast<uint32_t>(
|
|
static_cast<float>(in1.getExtent().height) / vkd.flow)
|
|
};
|
|
|
|
std::vector<Core::Image> mipmapVector{};
|
|
mipmapVector.reserve(7);
|
|
for (size_t i = 0; i < 7; i++)
|
|
mipmapVector.emplace_back(vkd.device,
|
|
VkExtent2D { extent.width >> i, extent.height >> i },
|
|
VK_FORMAT_R8_UNORM);
|
|
this->mipmaps = VK::Types::Images<7>(mipmapVector);
|
|
|
|
// create shaders
|
|
auto shader = Types::ShaderBuilder(
|
|
vkd.device, vkd.registry, vkd.spool, "mipmaps", 2)
|
|
.withSamplers(sampler)
|
|
.withBuffer(buffer)
|
|
.addTemporalInput({ in1, in2 })
|
|
.addOutputs(this->mipmaps.all())
|
|
.build(vkd.device, vkd.dpool);
|
|
this->shader = std::make_unique<Types::Shader>(std::move(shader));
|
|
}
|