sandbox
Loading...
Searching...
No Matches
static_mesh_shadow_subrenderer.hpp
1// SPDX-License-Identifier: MIT
2#ifndef LIBSBX_MODELS_STATIC_MESH_SHADOW_SUBRENDERER_HPP_
3#define LIBSBX_MODELS_STATIC_MESH_SHADOW_SUBRENDERER_HPP_
4
5#include <filesystem>
6#include <unordered_map>
7#include <array>
8
9#include <vulkan/vulkan.h>
10
11#include <libsbx/memory/tracking_allocator.hpp>
12
13#include <libsbx/core/engine.hpp>
14
15#include <libsbx/graphics/subrenderer.hpp>
16#include <libsbx/graphics/graphics_module.hpp>
17#include <libsbx/graphics/pipeline/graphics_pipeline.hpp>
18#include <libsbx/graphics/buffers/push_handler.hpp>
19#include <libsbx/graphics/descriptor/descriptor_handler.hpp>
20
21#include <libsbx/assets/assets_module.hpp>
22#include <libsbx/scenes/scenes_module.hpp>
23
24#include <libsbx/models/models.hpp>
25#include <libsbx/models/material_draw_list.hpp>
26#include <libsbx/models/static_mesh_material_draw_list.hpp>
27
28namespace sbx::models {
29
31
32 inline static const auto pipeline_definition = graphics::pipeline_definition{
33 .depth = graphics::depth::read_write,
34 .uses_transparency = false,
35 .rasterization_state = graphics::rasterization_state{
36 .polygon_mode = graphics::polygon_mode::fill,
37 .cull_mode = graphics::cull_mode::none,
38 .front_face = graphics::front_face::counter_clockwise
39 }
40 };
41
42public:
43
44 static_mesh_shadow_subrenderer(const std::vector<graphics::attachment_description>& attachments, const std::filesystem::path& base_pipeline, const std::uint32_t cascade);
45
47
48 auto render(graphics::command_buffer& command_buffer) -> void override;
49
50private:
51
52 struct pipeline_data {
53
55 graphics::push_handler push_handler;
56
57 pipeline_data(const graphics::graphics_pipeline_handle& handle);
58
59 }; // struct pipeline_data
60
61 struct descriptor_data {
62
63 graphics::descriptor_handler scene_descriptor_handler;
64
65 descriptor_data(const graphics::graphics_pipeline_handle& handle);
66
67 }; // struct descriptor_data
68
69 auto _get_or_create_pipeline(const models::material_key& key) -> pipeline_data&;
70
71 auto _get_or_create_descriptor_data(const graphics::graphics_pipeline_handle& handle) -> descriptor_data&;
72
73 std::vector<graphics::attachment_description> _attachments;
74 std::filesystem::path _base_pipeline;
75 std::uint32_t _cascade;
76
77 inline static std::unordered_map<models::material_key, pipeline_data, models::material_key_hash> _pipeline_cache{};
78
79 std::unordered_map<graphics::graphics_pipeline_handle, descriptor_data> _descriptor_cache{};
80
81}; // class shadow_subrenderer
82
83} // namespace sbx::shadows
84
85#endif // LIBSBX_MODELS_STATIC_MESH_SHADOW_SUBRENDERER_HPP_
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: static_mesh_shadow_subrenderer.hpp:30
Definition: graphics_pipeline.hpp:104
Definition: graphics_pipeline.hpp:65
Definition: material.hpp:85