sandbox
Loading...
Searching...
No Matches
upsample_filter.hpp
1// SPDX-License-Identifier: MIT
2#ifndef LIBSBX_POST_FILTERS_UPSAMPLE_FILTER_HPP_
3#define LIBSBX_POST_FILTERS_UPSAMPLE_FILTER_HPP_
4
5#include <filesystem>
6#include <string>
7
8#include <libsbx/core/engine.hpp>
9
10#include <libsbx/graphics/graphics_module.hpp>
11#include <libsbx/graphics/buffers/push_handler.hpp>
12
13#include <libsbx/post/filter.hpp>
14
15namespace sbx::post {
16
17class upsample_filter final : public filter {
18
19 using base = filter;
20
21public:
22
23 upsample_filter(const std::vector<graphics::attachment_description>& attachments, const std::filesystem::path& path, std::string low_attachment, std::string base_attachment, std::float_t intensity = 1.0f)
24 : base{attachments, path, base::default_pipeline_definition},
25 _push_handler{base::pipeline()},
26 _low_attachment{std::move(low_attachment)},
27 _base_attachment{std::move(base_attachment)},
28 _intensity{intensity} { }
29
30 ~upsample_filter() override = default;
31
32 auto render(graphics::command_buffer& command_buffer) -> void override {
33 EASY_BLOCK("upsample_filter::render");
34
35 auto& pipeline = base::pipeline();
36 auto& descriptor_handler = base::descriptor_handler();
37
38 auto& graphics_module = core::engine::get_module<graphics::graphics_module>();
39
40 pipeline.bind(command_buffer);
41
42 _push_handler.push("intensity", _intensity);
43
44 descriptor_handler.push("low_image", graphics_module.attachment(_low_attachment));
45 descriptor_handler.push("base_image", graphics_module.attachment(_base_attachment));
46
47 if (!descriptor_handler.update(pipeline)) {
48 return;
49 }
50
51 descriptor_handler.bind_descriptors(command_buffer);
52 _push_handler.bind(command_buffer);
53
54 command_buffer.draw(3, 1, 0, 0);
55 }
56
57private:
58
59 graphics::push_handler _push_handler;
60 std::string _low_attachment;
61 std::string _base_attachment;
62 std::float_t _intensity;
63
64}; // class upsample_filter
65
66} // namespace sbx::post
67
68#endif // LIBSBX_POST_FILTERS_UPSAMPLE_FILTER_HPP_
Definition: command_buffer.hpp:15
Definition: push_handler.hpp:18
Definition: filter.hpp:19
Definition: upsample_filter.hpp:17