Processes a buffer by coordinating child buffer operations.
21{
22 auto root_buf = std::dynamic_pointer_cast<RootGraphicsBuffer>(
buffer);
25 "GraphicsBatchProcessor can only process its associated RootGraphicsBuffer");
26 return;
27 }
28
29 root_buf->clear_renderable_buffers();
30 root_buf->cleanup_marked_buffers();
31
32 for (const auto& child : root_buf->get_child_buffers()) {
33 if (!child)
34 continue;
35 child->clear_pipeline_commands();
36
37 try {
38 if (!child->needs_removal() && child->has_data_for_cycle()) {
39 if (child->needs_default_processing() && child->get_default_processor())
40 child->process_default();
41
42 if (
auto chain = child->get_processing_chain()) {
43 if (child->has_data_for_cycle())
44 chain->process_complete(child);
45 }
46
47 if (!child->needs_removal()) {
48 for (
const auto& [
id,
window] : child->get_render_pipelines()) {
49 const auto command = child->get_pipeline_command(id);
51 continue;
52
53 RootGraphicsBuffer::RenderableBufferInfo info;
54 info.buffer = child;
55 info.target_window =
window;
56 info.pipeline_id = id;
57 info.command_buffer_id = command;
58 info.needs_depth = child->needs_depth_attachment();
59 root_buf->add_renderable_buffer(info);
60 }
61 }
62 }
63 } catch (const std::exception& e) {
65 "Error processing graphics buffer: {}", e.what());
66 }
67
68 if (child->needs_removal()) {
69 for (
const auto& [
id,
window] : child->get_render_pipelines())
70 root_buf->request_presentation_refresh(
window);
71 }
72 for (
const auto&
window : child->take_presentation_refreshes())
73 root_buf->request_presentation_refresh(
window);
74 }
75
76 const auto& refreshes = root_buf->get_pending_presentation_refreshes();
77 if (!refreshes.empty()) {
78 std::erase_if(root_buf->m_renderable_buffers, [&refreshes](const auto& info) {
79 return refreshes.contains(info.target_window);
80 });
81
82 for (const auto& child : root_buf->get_child_buffers()) {
83 if (!child || child->needs_removal())
84 continue;
85
86 for (
const auto& [
id,
window] : child->get_render_pipelines()) {
88 continue;
89
90 auto render = child->get_render_processor(id);
91 if (!render || !render->is_visible(child))
92 continue;
93
94 try {
95 auto command = child->get_pipeline_command(id);
97 render->record_draw(child);
98 command = child->get_pipeline_command(id);
99 }
101 continue;
102
103 RootGraphicsBuffer::RenderableBufferInfo info;
104 info.buffer = child;
105 info.target_window =
window;
106 info.pipeline_id = id;
107 info.command_buffer_id = command;
108 info.needs_depth = child->needs_depth_attachment();
109 root_buf->add_renderable_buffer(info);
110 } catch (const std::exception& e) {
112 "Error recording retained graphics buffer: {}", e.what());
113 }
114 }
115 }
116 }
117
118 root_buf->sort_renderable_buffers();
119}
#define MF_RT_ERROR(comp, ctx,...)
std::shared_ptr< NetworkGeometryBuffer > buffer
BufferProcessingChain * chain
std::weak_ptr< Core::Window > window
std::weak_ptr< RootGraphicsBuffer > m_root_buffer
Root buffer this processor manages.
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains)
@ Core
Core engine, backend, subsystems.
constexpr CommandBufferID INVALID_COMMAND_BUFFER