2#ifndef LIBSBX_SCENES_DEBUG_SUBRENDERER_HPP_
3#define LIBSBX_SCENES_DEBUG_SUBRENDERER_HPP_
7#include <libsbx/math/vector4.hpp>
10#include <libsbx/graphics/subrenderer.hpp>
11#include <libsbx/graphics/render_graph.hpp>
12#include <libsbx/graphics/pipeline/graphics_pipeline.hpp>
13#include <libsbx/graphics/buffers/push_handler.hpp>
14#include <libsbx/graphics/buffers/storage_handler.hpp>
15#include <libsbx/graphics/descriptor/descriptor_handler.hpp>
17#include <libsbx/scenes/scenes_module.hpp>
19namespace sbx::scenes {
24 .depth = sbx::graphics::depth::disabled,
25 .uses_transparency =
false,
27 .polygon_mode = sbx::graphics::polygon_mode::fill,
28 .cull_mode = sbx::graphics::cull_mode::none,
29 .front_face = sbx::graphics::front_face::counter_clockwise
31 .primitive_topology = sbx::graphics::primitive_topology::line_list
34 inline static constexpr auto default_shader_path = std::string_view{
"engine://shaders/debug"};
38 debug_subrenderer(
const std::vector<graphics::attachment_description>& attachments,
const std::filesystem::path& path = default_shader_path)
40 _pipeline{path, attachments, pipeline_definition},
41 _push_handler{_pipeline},
42 _descriptor_handler{_pipeline, 0u} {
43 auto& graphics_module = core::engine::get_module<graphics::graphics_module>();
45 _storage_buffer = graphics_module.add_resource<
graphics::storage_buffer>(graphics::storage_buffer::min_size, VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT);
53 EASY_BLOCK(
"debug_subrenderer::render");
55 auto& graphics_module = core::engine::get_module<graphics::graphics_module>();
56 auto&
scenes_module = sbx::core::engine::get_module<sbx::scenes::scenes_module>();
65 auto& environment =
scene.environment();
66 auto& graph =
scene.graph();
68 _pipeline.bind(command_buffer);
72 const auto required_size =
static_cast<std::uint32_t
>(lines.size() *
sizeof(
scenes_module::line));
74 if (storage_buffer.size() < required_size) {
75 storage_buffer.resize(
static_cast<std::size_t
>(
static_cast<std::float_t
>(required_size) * 1.5f));
78 storage_buffer.update(lines.data(), required_size);
80 _push_handler.push(
"vertices", storage_buffer.address());
82 _descriptor_handler.push(
"scene", environment.uniform_handler());
84 if (!_descriptor_handler.update(_pipeline)) {
88 _descriptor_handler.bind_descriptors(command_buffer);
89 _push_handler.bind(command_buffer);
91 command_buffer.draw(
static_cast<std::uint32_t
>(lines.size()), 1u, 0u, 0u);
Definition: command_buffer.hpp:15
Definition: descriptor_handler.hpp:26
Definition: graphics_pipeline.hpp:115
Definition: push_handler.hpp:18
Definition: resource_storage.hpp:18
Definition: storage_buffer.hpp:17
Definition: subrenderer.hpp:14
Definition: debug_subrenderer.hpp:21
Definition: scenes_module.hpp:26
RGBA color representation and utilities.
Definition: graphics_pipeline.hpp:106
Definition: graphics_pipeline.hpp:67
Definition: scenes_module.hpp:32