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