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
54public:
55
56 skinned_mesh_material_subrenderer(const std::vector<graphics::attachment_description>& attachments, const std::filesystem::path& base_pipeline, const skinned_mesh_material_draw_list::bucket bucket, memory::observer_ptr<const skinning_task> skinning_task);
57
59
60 auto render(graphics::command_buffer& command_buffer) -> void override;
61
62private:
63
64 struct pipeline_data {
65
67 graphics::push_handler push_handler;
68
69 pipeline_data(const graphics::graphics_pipeline_handle& handle);
70
71 }; // struct pipeline_data
72
73 struct descriptor_data {
74
75 graphics::descriptor_handler scene_descriptor_handler;
76 graphics::descriptor_handler sampler_descriptor_handler;
77 graphics::descriptor_handler image_descriptor_handler;
78
79 descriptor_data(const graphics::graphics_pipeline_handle& handle);
80
81 }; // struct descriptor_data
82
83 auto _get_or_create_pipeline(const models::material_key& key) -> pipeline_data&;
84
85 auto _get_or_create_descriptor_data(const graphics::graphics_pipeline_handle& handle) -> descriptor_data&;
86
87 inline static const auto _fs_entry = std::array<std::string, 3u>{
88 "opaque_main",
89 "mask_main",
90 "blend_main"
91 };
92
93 std::vector<graphics::attachment_description> _attachments;
94 std::filesystem::path _base_pipeline;
95 skinned_mesh_material_draw_list::bucket _bucket;
96
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: skinning_task.hpp:27
Definition: command_buffer.hpp:15
Definition: descriptor_handler.hpp:26
Definition: push_handler.hpp:18
Definition: resource_storage.hpp:18
Definition: subrenderer.hpp:14
A non-owning pointer that can be used to observe the value of a pointer.
Definition: observer_ptr.hpp:28
Definition: graphics_pipeline.hpp:104
Definition: graphics_pipeline.hpp:65
Definition: material.hpp:85