sandbox
Loading...
Searching...
No Matches
downsample_filter.hpp
1// SPDX-License-Identifier: MIT
2#ifndef LIBSBX_POST_FILTERS_DOWNSAMPLE_FILTER_HPP_
3#define LIBSBX_POST_FILTERS_DOWNSAMPLE_FILTER_HPP_
4
5#include <libsbx/core/engine.hpp>
6
7#include <libsbx/post/filter.hpp>
8
9namespace sbx::post {
10
11class downsample_filter final : public filter {
12
13 using base = filter;
14
15public:
16
17 downsample_filter(const std::vector<graphics::attachment_description>& attachments, const std::filesystem::path& path, const std::string& source_attachment)
18 : base{attachments, path, base::default_pipeline_definition},
19 _source_attachment{source_attachment} { }
20
21 ~downsample_filter() override = default;
22
23 auto render(graphics::command_buffer& command_buffer) -> void override {
24 EASY_BLOCK("downsample_filter::render");
25
26 auto& pipeline = base::pipeline();
27 auto& descriptor_handler = base::descriptor_handler();
28
29 auto& graphics_module = core::engine::get_module<graphics::graphics_module>();
30
31 pipeline.bind(command_buffer);
32
33 descriptor_handler.push("source_image", graphics_module.attachment(_source_attachment));
34
35 if (!descriptor_handler.update(pipeline)) {
36 return;
37 }
38
39 descriptor_handler.bind_descriptors(command_buffer);
40
41 command_buffer.draw(3, 1, 0, 0);
42 }
43
44private:
45
46 std::string _source_attachment;
47
48}; // class downsample_filter
49
50} // namespace sbx::post
51
52#endif // LIBSBX_POST_FILTERS_DOWNSAMPLE_FILTER_HPP_
Definition: command_buffer.hpp:15
Definition: downsample_filter.hpp:11
Definition: filter.hpp:19