#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 #include 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( static_cast(in1.getExtent().width) / vkd.flow), .height = static_cast( static_cast(in1.getExtent().height) / vkd.flow) }; std::vector 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(std::move(shader)); }