Skip to main content

RenderQueue.ixx File

Container for enqueued render commands and renderables. More...

Included Headers

#include <cassert> #include <format> #include <helios/helios_config.h> #include <memory> #include <span> #include <vector> #include <helios.util.log.LogManager> #include <helios.util.log.Logger> #include <helios.rendering.text.TextRenderCommand> #include <helios.rendering.mesh.MeshRenderCommand>

Namespaces Index

namespacehelios
namespacerendering

Graphics rendering infrastructure. More...

Classes Index

classRenderQueue

Manages collections of render commands for geometry and text. More...

Macro Definitions Index

#defineHELIOS_LOG_SCOPE   "helios::rendering::RenderQueue"

Description

Container for enqueued render commands and renderables.

Macro Definitions

HELIOS_LOG_SCOPE

#define HELIOS_LOG_SCOPE   "helios::rendering::RenderQueue"

Definition at line 22 of file RenderQueue.ixx.

22#define HELIOS_LOG_SCOPE "helios::rendering::RenderQueue"

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file RenderQueue.ixx
3 * @brief Container for enqueued render commands and renderables.
4 */
5module;
6
7#include <cassert>
8#include <format>
9#include <helios/helios_config.h>
10#include <memory>
11#include <span>
12#include <vector>
13
14export module helios.rendering.RenderQueue;
15
16import helios.rendering.mesh.MeshRenderCommand;
17import helios.rendering.text.TextRenderCommand;
18
19import helios.util.log.Logger;
20import helios.util.log.LogManager;
21
22#define HELIOS_LOG_SCOPE "helios::rendering::RenderQueue"
23export namespace helios::rendering {
24
25 /**
26 * @brief Manages collections of render commands for geometry and text.
27 *
28 * `RenderQueue` acts as a container for all render commands in a single rendering pass.
29 * It manages two separate command lists:
30 *
31 * - **RenderCommands:** For geometry rendering (meshes, materials).
32 * - **TextRenderCommands:** For text rendering (glyphs, fonts).
33 *
34 * A `RenderQueue` holds unique ownership of geometry render commands and value ownership
35 * of text render commands. It can be cleared after processing for reuse in subsequent passes.
36 *
37 * ## Design
38 *
39 * - **Non-copyable, non-movable:** Ensures unique queue identity during processing.
40 * - **Separate command lists:** Allows different rendering strategies for geometry and text.
41 *
42 * @see RenderCommand
43 * @see TextRenderCommand
44 * @see RenderPass
45 */
46 class RenderQueue {
47
48 protected:
49 /**
50 * @brief Stores the unique ptrs to the RenderCommand objects of this queue.
51 */
52 std::vector<helios::rendering::mesh::MeshRenderCommand> meshRenderCommands_;
53
54 /**
55 * @brief Stores text render commands for glyph-based text rendering.
56 */
57 std::vector<helios::rendering::text::TextRenderCommand> textRenderCommands_;
58
59 /**
60 * @brief Shared logger instance for all RenderQueue objects.
61 */
63
64 public:
65 ~RenderQueue() = default;
66
67 /**
68 * @brief Delete copy constructor.
69 */
70 RenderQueue(const RenderQueue&) = delete;
71
72 /**
73 * @brief Delete copy assignment operator.
74 */
75 RenderQueue& operator=(const RenderQueue&) = delete;
76
77
78 RenderQueue(RenderQueue&&) noexcept = default;
79
80
81 RenderQueue& operator=(RenderQueue&&) noexcept = default;
82
83 /**
84 * @brief Constructs a new empty RenderQueue.
85 */
87 textRenderCommands_.reserve(RENDERQUEUE_TEXTRENDER_COMMANDS_SIZE);
88 meshRenderCommands_.reserve(RENDERQUEUE_MESHRENDER_COMMANDS_SIZE);
89 };
90
91 /**
92 * @brief Adds a `RenderCommand` to this `RenderQueue`.
93 * Ownership of the `RenderCommand` is transferred to this `RenderQueue`.
94 *
95 * @param renderCommand A unique_ptr to the RenderCommand. This
96 * instance takes ownership of the RenderCommand.
97 *
98 * @todo prevent adding renderables while rendering
99 */
101 meshRenderCommands_.emplace_back(std::move(renderCommand));
102 }
103
104 /**
105 * @brief Adds a `TextRenderCommand` to this `RenderQueue`.
106 *
107 * The command is moved into the queue. Text commands are processed
108 * separately from geometry commands during rendering.
109 *
110 * @param renderCommand The text render command to add (moved).
111 */
113 textRenderCommands_.emplace_back(std::move(renderCommand));
114 }
115
116 /**
117 * @brief Returns a const ref to the internal vector of `RenderCommand`.
118 *
119 * @return A const ref to the list of `RenderCommand`s of this queue.
120 */
121 [[nodiscard]] std::span<const helios::rendering::mesh::MeshRenderCommand> meshRenderCommands() const noexcept {
123 }
124
125 /**
126 * @brief Returns a const ref to the internal vector of `TextRenderCommand`.
127 *
128 * @return A const ref to the list of text render commands in this queue.
129 */
130 [[nodiscard]] std::span<const helios::rendering::text::TextRenderCommand> textRenderCommands() const noexcept {
132 }
133
134 /**
135 * @brief Clears all `RenderCommand` objects from the queue.
136 *
137 * This prepares this queue to be reused in a new rendering pass.
138 */
139 void clear() {
140 meshRenderCommands_.clear();
141 textRenderCommands_.clear();
142
143 /**
144 * @todo strategy to decide whether shrink_to_fit should only be applied
145 * if expected numbers RenderCommands for the subsequent render passes is
146 * less than current size?
147 */
148 //renderCommands_.shrink_to_fit();
149 }
150
151 /**
152 * @brief Returns the number of `RenderCommand`s this queue contains.
153 *
154 * @return The number of RenderCommands in this queue.
155 */
156 [[nodiscard]] size_t meshRenderCommandsSize() const noexcept {
157 return meshRenderCommands_.size();
158 }
159
160 /**
161 * @brief Returns the number of `TextRenderCommand`s this queue contains.
162 *
163 * @return The number of text render commands in this queue.
164 */
165 [[nodiscard]] size_t textRenderCommandsSize() const noexcept {
166 return textRenderCommands_.size();
167 }
168 };
169
170} // namespace helios::rendering

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.