mirror of
https://github.com/PancakeTAS/lsfg-vk.git
synced 2025-10-30 07:01:10 +00:00
shaderchain draft headers
This commit is contained in:
parent
c3e1d0ded9
commit
33e11eef3e
10 changed files with 634 additions and 15 deletions
|
|
@ -14,7 +14,7 @@ namespace Vulkan::Shaderchains {
|
|||
///
|
||||
/// Shader chain alpha.
|
||||
///
|
||||
/// Takes an 8-bit R texture creates four quarter-sized 8-bit RGBA textures.
|
||||
/// Takes an 8-bit R image creates four quarter-sized 8-bit RGBA images.
|
||||
///
|
||||
class Alpha {
|
||||
public:
|
||||
|
|
@ -23,12 +23,12 @@ namespace Vulkan::Shaderchains {
|
|||
///
|
||||
/// @param device The Vulkan device to create the resources on.
|
||||
/// @param pool The descriptor pool to allocate in.
|
||||
/// @param inImage The input texture to process
|
||||
/// @param inImg The input image to process
|
||||
///
|
||||
/// @throws ls::vulkan_error if resource creation fails.
|
||||
///
|
||||
Alpha(const Device& device, const Core::DescriptorPool& pool,
|
||||
const Core::Image& inImage);
|
||||
const Core::Image& inImg);
|
||||
|
||||
///
|
||||
/// Dispatch the shaderchain.
|
||||
|
|
@ -40,7 +40,7 @@ namespace Vulkan::Shaderchains {
|
|||
void Dispatch(const Core::CommandBuffer& buf);
|
||||
|
||||
/// Get the output images.
|
||||
[[nodiscard]] const auto& getOutImages() const { return this->outImages; }
|
||||
[[nodiscard]] const auto& getOutImages() const { return this->outImgs; }
|
||||
|
||||
/// Trivially copyable, moveable and destructible
|
||||
Alpha(const Alpha&) noexcept = default;
|
||||
|
|
@ -53,13 +53,13 @@ namespace Vulkan::Shaderchains {
|
|||
std::vector<Core::Pipeline> pipelines{4};
|
||||
std::vector<Core::DescriptorSet> descriptorSets{4};
|
||||
|
||||
Core::Image inImage;
|
||||
Core::Image inImg;
|
||||
|
||||
std::vector<Core::Image> tempTex1{2}; // half-size
|
||||
std::vector<Core::Image> tempTex2{2}; // half-size
|
||||
std::vector<Core::Image> tempTex3{4}; // quarter-size
|
||||
std::vector<Core::Image> tempImgs1{2}; // half-size
|
||||
std::vector<Core::Image> tempImgs2{2}; // half-size
|
||||
std::vector<Core::Image> tempImgs3{4}; // quarter-size
|
||||
|
||||
std::vector<Core::Image> outImages{4}; // quarter-size
|
||||
std::vector<Core::Image> outImgs{4}; // quarter-size
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
72
include/shaderchains/beta.hpp
Normal file
72
include/shaderchains/beta.hpp
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
#ifndef BETA_HPP
|
||||
#define BETA_HPP
|
||||
|
||||
#include "core/buffer.hpp"
|
||||
#include "core/commandbuffer.hpp"
|
||||
#include "core/descriptorpool.hpp"
|
||||
#include "core/descriptorset.hpp"
|
||||
#include "core/image.hpp"
|
||||
#include "core/pipeline.hpp"
|
||||
#include "core/shadermodule.hpp"
|
||||
#include "device.hpp"
|
||||
|
||||
namespace Vulkan::Shaderchains {
|
||||
|
||||
///
|
||||
/// Shader chain beta.
|
||||
///
|
||||
/// Takes eight temporal 8-bit RGBA images, as well as the four output images from alpha,
|
||||
/// and creates six 8-bit R images, halving in resolution each step.
|
||||
///
|
||||
class Beta {
|
||||
public:
|
||||
///
|
||||
/// Initialize the shaderchain.
|
||||
///
|
||||
/// @param device The Vulkan device to create the resources on.
|
||||
/// @param pool The descriptor pool to allocate in.
|
||||
/// @param temporalImgs The temporal images to use for processing.
|
||||
/// @param inImgs The input images to process
|
||||
///
|
||||
/// @throws ls::vulkan_error if resource creation fails.
|
||||
///
|
||||
Beta(const Device& device, const Core::DescriptorPool& pool,
|
||||
const std::vector<Core::Image>& temporalImgs,
|
||||
const std::vector<Core::Image>& inImgs);
|
||||
|
||||
///
|
||||
/// Dispatch the shaderchain.
|
||||
///
|
||||
/// @param buf The command buffer to use for dispatching.
|
||||
///
|
||||
/// @throws std::logic_error if the command buffer is not recording.
|
||||
///
|
||||
void Dispatch(const Core::CommandBuffer& buf);
|
||||
|
||||
/// Get the output images.
|
||||
[[nodiscard]] const auto& getOutImages() const { return this->outImgs; }
|
||||
|
||||
/// Trivially copyable, moveable and destructible
|
||||
Beta(const Beta&) noexcept = default;
|
||||
Beta& operator=(const Beta&) noexcept = default;
|
||||
Beta(Beta&&) noexcept = default;
|
||||
Beta& operator=(Beta&&) noexcept = default;
|
||||
~Beta() = default;
|
||||
private:
|
||||
std::vector<Core::ShaderModule> shaderModules{5};
|
||||
std::vector<Core::Pipeline> pipelines{5};
|
||||
std::vector<Core::DescriptorSet> descriptorSets{5};
|
||||
Core::Buffer buffer;
|
||||
|
||||
std::vector<Core::Image> temporalImgs{8};
|
||||
std::vector<Core::Image> inImgs{4};
|
||||
|
||||
std::vector<Core::Image> tempImgs1{2};
|
||||
std::vector<Core::Image> tempImgs2{2};
|
||||
|
||||
std::vector<Core::Image> outImgs{6};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // BETA_HPP
|
||||
72
include/shaderchains/delta.hpp
Normal file
72
include/shaderchains/delta.hpp
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
#ifndef DELTA_HPP
|
||||
#define DELTA_HPP
|
||||
|
||||
#include "core/buffer.hpp"
|
||||
#include "core/commandbuffer.hpp"
|
||||
#include "core/descriptorpool.hpp"
|
||||
#include "core/descriptorset.hpp"
|
||||
#include "core/image.hpp"
|
||||
#include "core/pipeline.hpp"
|
||||
#include "core/shadermodule.hpp"
|
||||
#include "device.hpp"
|
||||
|
||||
namespace Vulkan::Shaderchains {
|
||||
|
||||
///
|
||||
/// Shader chain delta.
|
||||
///
|
||||
/// Takes two 8-bit RGBA images and an optional third 16-bit half-res RGBA image,
|
||||
/// producing a full-res 16-bit RGBA image.
|
||||
///
|
||||
class Delta {
|
||||
public:
|
||||
///
|
||||
/// Initialize the shaderchain.
|
||||
///
|
||||
/// @param device The Vulkan device to create the resources on.
|
||||
/// @param pool The descriptor pool to allocate in.
|
||||
/// @param inImgs The input images to process.
|
||||
/// @param optImg An optional additional input from the previous pass.
|
||||
///
|
||||
/// @throws ls::vulkan_error if resource creation fails.
|
||||
///
|
||||
Delta(const Device& device, const Core::DescriptorPool& pool,
|
||||
const std::vector<Core::Image>& inImgs,
|
||||
const std::optional<Core::Image>& optImg);
|
||||
|
||||
///
|
||||
/// Dispatch the shaderchain.
|
||||
///
|
||||
/// @param buf The command buffer to use for dispatching.
|
||||
///
|
||||
/// @throws std::logic_error if the command buffer is not recording.
|
||||
///
|
||||
void Dispatch(const Core::CommandBuffer& buf);
|
||||
|
||||
/// Get the output image.
|
||||
[[nodiscard]] const auto& getOutImage() const { return this->outImg; }
|
||||
|
||||
/// Trivially copyable, moveable and destructible
|
||||
Delta(const Delta&) noexcept = default;
|
||||
Delta& operator=(const Delta&) noexcept = default;
|
||||
Delta(Delta&&) noexcept = default;
|
||||
Delta& operator=(Delta&&) noexcept = default;
|
||||
~Delta() = default;
|
||||
private:
|
||||
std::vector<Core::ShaderModule> shaderModules{4};
|
||||
std::vector<Core::Pipeline> pipelines{4};
|
||||
std::vector<Core::DescriptorSet> descriptorSets{4};
|
||||
Core::Buffer buffer;
|
||||
|
||||
std::vector<Core::Image> inImg{2};
|
||||
std::optional<Core::Image> optImg;
|
||||
|
||||
std::vector<Core::Image> tempImgs1{2};
|
||||
std::vector<Core::Image> tempImgs2{2};
|
||||
|
||||
Core::Image outImg;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // DELTA_HPP
|
||||
|
|
@ -15,7 +15,7 @@ namespace Vulkan::Shaderchains {
|
|||
///
|
||||
/// Downsample shader.
|
||||
///
|
||||
/// Takes an 8-bit RGBA texture and downsamples it into 7x 8-bit R textures.
|
||||
/// Takes an 8-bit RGBA image and downsamples it into 7x 8-bit R images.
|
||||
///
|
||||
class Downsample {
|
||||
public:
|
||||
|
|
@ -24,12 +24,12 @@ namespace Vulkan::Shaderchains {
|
|||
///
|
||||
/// @param device The Vulkan device to create the resources on.
|
||||
/// @param pool The descriptor pool to allocate in.
|
||||
/// @param inImage The input image to downsample.
|
||||
/// @param inImg The input image to downsample.
|
||||
///
|
||||
/// @throws ls::vulkan_error if resource creation fails.
|
||||
///
|
||||
Downsample(const Device& device, const Core::DescriptorPool& pool,
|
||||
const Core::Image& inImage);
|
||||
const Core::Image& inImg);
|
||||
|
||||
///
|
||||
/// Dispatch the shaderchain.
|
||||
|
|
@ -41,7 +41,7 @@ namespace Vulkan::Shaderchains {
|
|||
void Dispatch(const Core::CommandBuffer& buf);
|
||||
|
||||
/// Get the output images.
|
||||
[[nodiscard]] const auto& getOutImages() const { return this->outImages; }
|
||||
[[nodiscard]] const auto& getOutImages() const { return this->outImgs; }
|
||||
|
||||
/// Trivially copyable, moveable and destructible
|
||||
Downsample(const Downsample&) noexcept = default;
|
||||
|
|
@ -55,9 +55,9 @@ namespace Vulkan::Shaderchains {
|
|||
Core::DescriptorSet descriptorSet;
|
||||
Core::Buffer buffer;
|
||||
|
||||
Core::Image inImage;
|
||||
Core::Image inImg;
|
||||
|
||||
std::vector<Core::Image> outImages{7};
|
||||
std::vector<Core::Image> outImgs{7};
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
75
include/shaderchains/epsilon.hpp
Normal file
75
include/shaderchains/epsilon.hpp
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
#ifndef EPSILON_HPP
|
||||
#define EPSILON_HPP
|
||||
|
||||
#include "core/buffer.hpp"
|
||||
#include "core/commandbuffer.hpp"
|
||||
#include "core/descriptorpool.hpp"
|
||||
#include "core/descriptorset.hpp"
|
||||
#include "core/image.hpp"
|
||||
#include "core/pipeline.hpp"
|
||||
#include "core/shadermodule.hpp"
|
||||
#include "device.hpp"
|
||||
|
||||
namespace Vulkan::Shaderchains {
|
||||
|
||||
///
|
||||
/// Shader chain epsilon.
|
||||
///
|
||||
/// Takes three 8-bit RGBA textures, a fourth 8-bit R texture, an optional fifth
|
||||
/// half-res 16-bit RGBA texture and produces a full-res 16-bit RGBA texture.
|
||||
///
|
||||
class Epsilon {
|
||||
public:
|
||||
///
|
||||
/// Initialize the shaderchain.
|
||||
///
|
||||
/// @param device The Vulkan device to create the resources on.
|
||||
/// @param pool The descriptor pool to use for descriptor sets.
|
||||
/// @param inImgs1 The first set of input images to process.
|
||||
/// @param inImg2 The second type image to process.
|
||||
/// @param optImg An optional additional input from the previous pass.
|
||||
///
|
||||
/// @throws ls::vulkan_error if resource creation fails.
|
||||
///
|
||||
Epsilon(const Device& device, const Core::DescriptorPool& pool,
|
||||
const std::vector<Core::Image>& inImgs1,
|
||||
const Core::Image& inImg2,
|
||||
const std::optional<Core::Image>& optImg);
|
||||
|
||||
///
|
||||
/// Dispatch the shaderchain.
|
||||
///
|
||||
/// @param buf The command buffer to use for dispatching.
|
||||
///
|
||||
/// @throws std::logic_error if the command buffer is not recording.
|
||||
///
|
||||
void Dispatch(const Core::CommandBuffer& buf);
|
||||
|
||||
/// Get the output image.
|
||||
[[nodiscard]] const auto& getOutImage() const { return this->outImg; }
|
||||
|
||||
/// Trivially copyable, moveable and destructible
|
||||
Epsilon(const Epsilon&) noexcept = default;
|
||||
Epsilon& operator=(const Epsilon&) noexcept = default;
|
||||
Epsilon(Epsilon&&) noexcept = default;
|
||||
Epsilon& operator=(Epsilon&&) noexcept = default;
|
||||
~Epsilon() = default;
|
||||
private:
|
||||
std::vector<Core::ShaderModule> shaderModules{4};
|
||||
std::vector<Core::Pipeline> pipelines{4};
|
||||
std::vector<Core::DescriptorSet> descriptorSets{4};
|
||||
Core::Buffer buffer;
|
||||
|
||||
std::vector<Core::Image> inImgs1{3};
|
||||
Core::Image inImg2;
|
||||
std::optional<Core::Image> optImg;
|
||||
|
||||
std::vector<Core::Image> tempImgs1{4};
|
||||
std::vector<Core::Image> tempImgs2{4};
|
||||
|
||||
Core::Image outImg;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // EPSILON_HPP
|
||||
74
include/shaderchains/extract.hpp
Normal file
74
include/shaderchains/extract.hpp
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
#ifndef EXTRACT_HPP
|
||||
#define EXTRACT_HPP
|
||||
|
||||
#include "core/buffer.hpp"
|
||||
#include "core/commandbuffer.hpp"
|
||||
#include "core/descriptorpool.hpp"
|
||||
#include "core/descriptorset.hpp"
|
||||
#include "core/image.hpp"
|
||||
#include "core/pipeline.hpp"
|
||||
#include "core/shadermodule.hpp"
|
||||
#include "device.hpp"
|
||||
#include <vulkan/vulkan_core.h>
|
||||
|
||||
namespace Vulkan::Shaderchains {
|
||||
|
||||
///
|
||||
/// Shader chain extract.
|
||||
///
|
||||
/// Takes two half-res 16-bit RGBA textures, producing
|
||||
/// an full-res 8-bit RGBA texture.
|
||||
///
|
||||
class Extract {
|
||||
public:
|
||||
///
|
||||
/// Initialize the shaderchain.
|
||||
///
|
||||
/// @param device The Vulkan device to create the resources on.
|
||||
/// @param pool The descriptor pool to use for descriptor sets.
|
||||
/// @param inImg1 The first set of input images to process.
|
||||
/// @param inImg2 The second type image to process.
|
||||
/// @param outExtent The extent of the output image.
|
||||
///
|
||||
/// @throws ls::vulkan_error if resource creation fails.
|
||||
///
|
||||
Extract(const Device& device, const Core::DescriptorPool& pool,
|
||||
const Core::Image& inImg1,
|
||||
const Core::Image& inImg2,
|
||||
VkExtent2D outExtent);
|
||||
|
||||
///
|
||||
/// Dispatch the shaderchain.
|
||||
///
|
||||
/// @param buf The command buffer to use for dispatching.
|
||||
///
|
||||
/// @throws std::logic_error if the command buffer is not recording.
|
||||
///
|
||||
void Dispatch(const Core::CommandBuffer& buf);
|
||||
|
||||
/// Get the output image.
|
||||
[[nodiscard]] const auto& getOutImage() const { return this->outImg; }
|
||||
|
||||
/// Trivially copyable, moveable and destructible
|
||||
Extract(const Extract&) noexcept = default;
|
||||
Extract& operator=(const Extract&) noexcept = default;
|
||||
Extract(Extract&&) noexcept = default;
|
||||
Extract& operator=(Extract&&) noexcept = default;
|
||||
~Extract() = default;
|
||||
private:
|
||||
Core::ShaderModule shaderModule;
|
||||
Core::Pipeline pipeline;
|
||||
Core::DescriptorSet descriptorSet;
|
||||
Core::Buffer buffer;
|
||||
|
||||
Core::Image inImg1;
|
||||
Core::Image inImg2;
|
||||
|
||||
Core::Image whiteImg;
|
||||
|
||||
Core::Image outImg;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // EXTRACT_HPP
|
||||
89
include/shaderchains/gamma.hpp
Normal file
89
include/shaderchains/gamma.hpp
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
#ifndef GAMMA_HPP
|
||||
#define GAMMA_HPP
|
||||
|
||||
#include "core/buffer.hpp"
|
||||
#include "core/commandbuffer.hpp"
|
||||
#include "core/descriptorpool.hpp"
|
||||
#include "core/descriptorset.hpp"
|
||||
#include "core/image.hpp"
|
||||
#include "core/pipeline.hpp"
|
||||
#include "core/shadermodule.hpp"
|
||||
#include "device.hpp"
|
||||
|
||||
namespace Vulkan::Shaderchains {
|
||||
|
||||
///
|
||||
/// Shader chain gamma.
|
||||
///
|
||||
/// Takes four temporal 8-bit RGBA images, as well as four output images from a given alpha stage.
|
||||
/// Also takes the corresponding (smallest if oob) output image from the beta pass.
|
||||
/// On non-first passes optionally takes 2 output images from previous gamma pass.
|
||||
/// Creates two images, one at twice the resolution of input images and the other with R16G16B16A16_FLOAT.
|
||||
///
|
||||
class Gamma {
|
||||
public:
|
||||
///
|
||||
/// Initialize the shaderchain.
|
||||
///
|
||||
/// @param device The Vulkan device to create the resources on.
|
||||
/// @param pool The descriptor pool to allocate in.
|
||||
/// @param temporalImgs The temporal images to use for processing.
|
||||
/// @param inImgs1 The input images to process.
|
||||
/// @param inImg2 The second input image to process, next step up the resolution.
|
||||
/// @param optImg1 An optional additional input from the previous pass.
|
||||
/// @param optImg2 An optional additional input image for processing non-first passes.
|
||||
/// @param outExtent The extent of the output image.
|
||||
///
|
||||
/// @throws ls::vulkan_error if resource creation fails.
|
||||
///
|
||||
Gamma(const Device& device, const Core::DescriptorPool& pool,
|
||||
const std::vector<Core::Image>& temporalImgs,
|
||||
const std::vector<Core::Image>& inImgs1,
|
||||
const Core::Image& inImg2,
|
||||
const std::optional<Core::Image>& optImg1,
|
||||
const std::optional<Core::Image>& optImg2,
|
||||
VkExtent2D outExtent);
|
||||
|
||||
///
|
||||
/// Dispatch the shaderchain.
|
||||
///
|
||||
/// @param buf The command buffer to use for dispatching.
|
||||
///
|
||||
/// @throws std::logic_error if the command buffer is not recording.
|
||||
///
|
||||
void Dispatch(const Core::CommandBuffer& buf);
|
||||
|
||||
/// Get the first output image.
|
||||
[[nodiscard]] const auto& getOutImage1() const { return this->outImg1; }
|
||||
/// Get the second output image.
|
||||
[[nodiscard]] const auto& getOutImage2() const { return this->outImg2; }
|
||||
|
||||
/// Trivially copyable, moveable and destructible
|
||||
Gamma(const Gamma&) noexcept = default;
|
||||
Gamma& operator=(const Gamma&) noexcept = default;
|
||||
Gamma(Gamma&&) noexcept = default;
|
||||
Gamma& operator=(Gamma&&) noexcept = default;
|
||||
~Gamma() = default;
|
||||
private:
|
||||
std::vector<Core::ShaderModule> shaderModules{6};
|
||||
std::vector<Core::Pipeline> pipelines{6};
|
||||
std::vector<Core::DescriptorSet> descriptorSets{6};
|
||||
Core::Buffer buffer;
|
||||
|
||||
std::vector<Core::Image> temporalImgs{4};
|
||||
std::vector<Core::Image> inImgs1{4};
|
||||
Core::Image inImg2;
|
||||
Core::Image optImg1; // specified or created black
|
||||
std::optional<Core::Image> optImg2;
|
||||
|
||||
std::vector<Core::Image> tempImgs1{4};
|
||||
std::vector<Core::Image> tempImgs2{4};
|
||||
Core::Image whiteImg;
|
||||
|
||||
Core::Image outImg1;
|
||||
Core::Image outImg2;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // GAMMA_HPP
|
||||
84
include/shaderchains/magic.hpp
Normal file
84
include/shaderchains/magic.hpp
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
#ifndef MAGIC_HPP
|
||||
#define MAGIC_HPP
|
||||
|
||||
#include "core/buffer.hpp"
|
||||
#include "core/commandbuffer.hpp"
|
||||
#include "core/descriptorpool.hpp"
|
||||
#include "core/descriptorset.hpp"
|
||||
#include "core/image.hpp"
|
||||
#include "core/pipeline.hpp"
|
||||
#include "core/shadermodule.hpp"
|
||||
#include "device.hpp"
|
||||
|
||||
namespace Vulkan::Shaderchains {
|
||||
|
||||
///
|
||||
/// Shader chain magic.
|
||||
///
|
||||
/// Takes textures similar to gamma shader chain, produces intermediary
|
||||
/// results in groups of 3, 2, 2.
|
||||
///
|
||||
class Magic {
|
||||
public:
|
||||
///
|
||||
/// Initialize the shaderchain.
|
||||
///
|
||||
/// @param device The Vulkan device to create the resources on.
|
||||
/// @param pool The descriptor pool to use for descriptor sets.
|
||||
/// @param temporalImgs The temporal images to use for processing.
|
||||
/// @param inImgs1 The first set of input images to process.
|
||||
/// @param inImg2 The second input image to process.
|
||||
/// @param inImg3 The third input image to process, next step up the resolution.
|
||||
/// @param optImg An optional additional input from the previous pass.
|
||||
///
|
||||
/// @throws ls::vulkan_error if resource creation fails.
|
||||
///
|
||||
Magic(const Device& device, const Core::DescriptorPool& pool,
|
||||
const std::array<Core::Image, 4>& temporalImgs,
|
||||
const std::array<Core::Image, 4>& inImgs1,
|
||||
const Core::Image& inImg2,
|
||||
const Core::Image& inImg3,
|
||||
const std::optional<Core::Image>& optImg);
|
||||
|
||||
///
|
||||
/// Dispatch the shaderchain.
|
||||
///
|
||||
/// @param buf The command buffer to use for dispatching.
|
||||
///
|
||||
/// @throws std::logic_error if the command buffer is not recording.
|
||||
///
|
||||
void Dispatch(const Core::CommandBuffer& buf);
|
||||
|
||||
/// Get the first set of output images
|
||||
[[nodiscard]] const auto& getOutImages1() const { return this->outImgs1; }
|
||||
/// Get the second set of output images
|
||||
[[nodiscard]] const auto& getOutImages2() const { return this->outImgs2; }
|
||||
/// Get the third set of output images
|
||||
[[nodiscard]] const auto& getOutImages3() const { return this->outImgs3; }
|
||||
|
||||
/// Trivially copyable, moveable and destructible
|
||||
Magic(const Magic&) noexcept = default;
|
||||
Magic& operator=(const Magic&) noexcept = default;
|
||||
Magic(Magic&&) noexcept = default;
|
||||
Magic& operator=(Magic&&) noexcept = default;
|
||||
~Magic() = default;
|
||||
private:
|
||||
Core::ShaderModule shaderModule;
|
||||
Core::Pipeline pipeline;
|
||||
Core::DescriptorSet descriptorSet;
|
||||
Core::Buffer buffer;
|
||||
|
||||
std::vector<Core::Image> temporalImgs{4};
|
||||
std::vector<Core::Image> inImgs1{4};
|
||||
Core::Image inImg2;
|
||||
Core::Image inImg3;
|
||||
std::optional<Core::Image> optImg;
|
||||
|
||||
std::vector<Core::Image> outImgs1{3};
|
||||
std::vector<Core::Image> outImgs2{3};
|
||||
std::vector<Core::Image> outImgs3{3};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // MAGIC_HPP
|
||||
78
include/shaderchains/merge.hpp
Normal file
78
include/shaderchains/merge.hpp
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
#ifndef MERGE_HPP
|
||||
#define MERGE_HPP
|
||||
|
||||
#include "core/buffer.hpp"
|
||||
#include "core/commandbuffer.hpp"
|
||||
#include "core/descriptorpool.hpp"
|
||||
#include "core/descriptorset.hpp"
|
||||
#include "core/image.hpp"
|
||||
#include "core/pipeline.hpp"
|
||||
#include "core/shadermodule.hpp"
|
||||
#include "device.hpp"
|
||||
|
||||
namespace Vulkan::Shaderchains {
|
||||
|
||||
///
|
||||
/// Shader chain merge.
|
||||
///
|
||||
/// Takes the two previous frames as well as related resources
|
||||
/// and merges them into a new frame.
|
||||
///
|
||||
class Merge {
|
||||
public:
|
||||
///
|
||||
/// Initialize the shaderchain.
|
||||
///
|
||||
/// @param device The Vulkan device to create the resources on.
|
||||
/// @param pool The descriptor pool to use for descriptor sets.
|
||||
/// @param inImg1 The first frame texture
|
||||
/// @param inImg2 The second frame texture
|
||||
/// @param inImg3 The first related input texture
|
||||
/// @param inImg4 The second related input texture
|
||||
/// @param inImg5 The third related input texture
|
||||
///
|
||||
/// @throws ls::vulkan_error if resource creation fails.
|
||||
///
|
||||
Merge(const Device& device, const Core::DescriptorPool& pool,
|
||||
const Core::Image& inImg1,
|
||||
const Core::Image& inImg2,
|
||||
const Core::Image& inImg3,
|
||||
const Core::Image& inImg4,
|
||||
const Core::Image& inImg5);
|
||||
|
||||
///
|
||||
/// Dispatch the shaderchain.
|
||||
///
|
||||
/// @param buf The command buffer to use for dispatching.
|
||||
///
|
||||
/// @throws std::logic_error if the command buffer is not recording.
|
||||
///
|
||||
void Dispatch(const Core::CommandBuffer& buf);
|
||||
|
||||
/// Get the output image
|
||||
[[nodiscard]] const auto& getOutImage() const { return this->outImg; }
|
||||
|
||||
/// Trivially copyable, moveable and destructible
|
||||
Merge(const Merge&) noexcept = default;
|
||||
Merge& operator=(const Merge&) noexcept = default;
|
||||
Merge(Merge&&) noexcept = default;
|
||||
Merge& operator=(Merge&&) noexcept = default;
|
||||
~Merge() = default;
|
||||
private:
|
||||
Core::ShaderModule shaderModule;
|
||||
Core::Pipeline pipeline;
|
||||
Core::DescriptorSet descriptorSet;
|
||||
Core::Buffer buffer;
|
||||
|
||||
Core::Image inImg1;
|
||||
Core::Image inImg2;
|
||||
Core::Image inImg3;
|
||||
Core::Image inImg4;
|
||||
Core::Image inImg5;
|
||||
|
||||
Core::Image outImg;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // MERGE_HPP
|
||||
75
include/shaderchains/zeta.hpp
Normal file
75
include/shaderchains/zeta.hpp
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
#ifndef ZETA_HPP
|
||||
#define ZETA_HPP
|
||||
|
||||
#include "core/buffer.hpp"
|
||||
#include "core/commandbuffer.hpp"
|
||||
#include "core/descriptorpool.hpp"
|
||||
#include "core/descriptorset.hpp"
|
||||
#include "core/image.hpp"
|
||||
#include "core/pipeline.hpp"
|
||||
#include "core/shadermodule.hpp"
|
||||
#include "device.hpp"
|
||||
|
||||
namespace Vulkan::Shaderchains {
|
||||
|
||||
///
|
||||
/// Shader chain zeta.
|
||||
///
|
||||
/// Takes three 8-bit RGBA textures, a fourth 8-bit R texture, a fifth
|
||||
/// half-res 16-bit RGBA texture and produces a full-res 16-bit RGBA texture.
|
||||
///
|
||||
class Zeta {
|
||||
public:
|
||||
///
|
||||
/// Initialize the shaderchain.
|
||||
///
|
||||
/// @param device The Vulkan device to create the resources on.
|
||||
/// @param pool The descriptor pool to use for descriptor sets.
|
||||
/// @param inImgs1 The first set of input images to process.
|
||||
/// @param inImg2 The second type image to process.
|
||||
/// @param inImg3 The third type image to process.
|
||||
///
|
||||
/// @throws ls::vulkan_error if resource creation fails.
|
||||
///
|
||||
Zeta(const Device& device, const Core::DescriptorPool& pool,
|
||||
const std::vector<Core::Image>& inImgs1,
|
||||
const Core::Image& inImg2,
|
||||
const Core::Image& inImg3);
|
||||
|
||||
///
|
||||
/// Dispatch the shaderchain.
|
||||
///
|
||||
/// @param buf The command buffer to use for dispatching.
|
||||
///
|
||||
/// @throws std::logic_error if the command buffer is not recording.
|
||||
///
|
||||
void Dispatch(const Core::CommandBuffer& buf);
|
||||
|
||||
/// Get the output image.
|
||||
[[nodiscard]] const auto& getOutImage() const { return this->outImg; }
|
||||
|
||||
/// Trivially copyable, moveable and destructible
|
||||
Zeta(const Zeta&) noexcept = default;
|
||||
Zeta& operator=(const Zeta&) noexcept = default;
|
||||
Zeta(Zeta&&) noexcept = default;
|
||||
Zeta& operator=(Zeta&&) noexcept = default;
|
||||
~Zeta() = default;
|
||||
private:
|
||||
std::vector<Core::ShaderModule> shaderModules{4};
|
||||
std::vector<Core::Pipeline> pipelines{4};
|
||||
std::vector<Core::DescriptorSet> descriptorSets{4};
|
||||
Core::Buffer buffer;
|
||||
|
||||
std::vector<Core::Image> inImgs1{3};
|
||||
Core::Image inImg2;
|
||||
Core::Image inImg3;
|
||||
|
||||
std::vector<Core::Image> tempImgs1{4};
|
||||
std::vector<Core::Image> tempImgs2{4};
|
||||
|
||||
Core::Image outImg;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // ZETA_HPP
|
||||
Loading…
Add table
Reference in a new issue