sandbox
Loading...
Searching...
No Matches
skinned_mesh_material_subrenderer.hpp
1// SPDX-License-Identifier: MIT
2#ifndef LIBSBX_ANIMATIONS_SKINNED_MESH_MATERIAL_SUBRENDERER_HPP_
3#define LIBSBX_ANIMATIONS_SKINNED_MESH_MATERIAL_SUBRENDERER_HPP_
4
5#include <filesystem>
6#include <unordered_set>
7#include <ranges>
8#include <algorithm>
9#include <iterator>
10
11#include <easy/profiler.h>
12
13#include <range/v3/view/enumerate.hpp>
14
15#include <libsbx/core/engine.hpp>
16
17#include <libsbx/memory/observer_ptr.hpp>
18
19#include <libsbx/graphics/graphics_module.hpp>
20#include <libsbx/graphics/subrenderer.hpp>
21#include <libsbx/graphics/pipeline/pipeline.hpp>
22#include <libsbx/graphics/pipeline/graphics_pipeline.hpp>
23#include <libsbx/graphics/descriptor/descriptor_handler.hpp>
24
25#include <libsbx/assets/assets_module.hpp>
26
27#include <libsbx/scenes/scenes_module.hpp>
28#include <libsbx/scenes/scene.hpp>
29
30#include <libsbx/scenes/components/skinned_mesh.hpp>
31
32#include <libsbx/models/material_draw_list.hpp>
33
34#include <libsbx/animations/mesh.hpp>
35#include <libsbx/animations/animator.hpp>
36
37#include <libsbx/animations/skinned_mesh_material_draw_list.hpp>
38#include <libsbx/animations/skinning_task.hpp>
39
40namespace sbx::animations {
41
43
44 inline static const auto pipeline_definition = graphics::pipeline_definition{
45 .depth = graphics::depth::read_write,
46 .uses_transparency = false,
47 .rasterization_state = graphics::rasterization_state{
48 .polygon_mode = graphics::polygon_mode::fill,
49 .cull_mode = graphics::cull_mode::back,
50 .front_face = graphics::front_face::counter_clockwise
51 }
52 };
53
54 inline static constexpr auto default_pipeline_path = std::string_view{"engine://shaders/deferred_pbr_material"};
55
56public:
57
58 skinned_mesh_material_subrenderer(const std::vector<graphics::attachment_description>& attachments, const skinned_mesh_material_draw_list::bucket bucket, const std::filesystem::path& base_pipeline = default_pipeline_path);
59
61
62 auto render(graphics::command_buffer& command_buffer) -> void override;
63
64private:
65
66 struct pipeline_data {
67
69 graphics::push_handler push_handler;
70
71 pipeline_data(const graphics::graphics_pipeline_handle& handle);
72
73 }; // struct pipeline_data
74
75 struct descriptor_data {
76
77 graphics::descriptor_handler scene_descriptor_handler;
78 graphics::descriptor_handler sampler_descriptor_handler;
79 graphics::descriptor_handler image_descriptor_handler;
80
81 descriptor_data(const graphics::graphics_pipeline_handle& handle);
82
83 }; // struct descriptor_data
84
85 auto _get_or_create_pipeline(const models::material_key& key) -> pipeline_data&;
86
87 auto _get_or_create_descriptor_data(const graphics::graphics_pipeline_handle& handle) -> descriptor_data&;
88
89 inline static const auto _fs_entry = std::array<std::string, 3u>{
90 "opaque_main",
91 "mask_main",
92 "blend_main"
93 };
94
95 std::vector<graphics::attachment_description> _attachments;
96 std::filesystem::path _base_pipeline;
97 skinned_mesh_material_draw_list::bucket _bucket;
98
99 inline static std::unordered_map<models::material_key, pipeline_data, models::material_key_hash> _pipeline_cache{};
100
101 std::unordered_map<graphics::graphics_pipeline_handle, descriptor_data> _descriptor_cache{};
102
103}; // class skinned_mesh_material_subrenderer
104
105} // namespace sbx::animations
106
107#endif // LIBSBX_ANIMATIONS_SKINNED_MESH_MATERIAL_SUBRENDERER_HPP_
Definition: skinned_mesh_material_subrenderer.hpp:42
Definition: command_buffer.hpp:15
Definition: descriptor_handler.hpp:26
Definition: push_handler.hpp:18
Definition: resource_storage.hpp:18
Definition: subrenderer.hpp:14
Definition: graphics_pipeline.hpp:106
Definition: graphics_pipeline.hpp:67
Definition: material.hpp:87