Rendu
A lightweight rendering engine for experimentations
Loading...
Searching...
No Matches
DebugViewer.hpp
1#pragma once
2#include "graphics/Program.hpp"
3#include "graphics/GPUTypes.hpp"
4
5class Texture;
6class Mesh;
7
14
15public:
16
19 explicit DebugViewer();
20
24 void track(const Texture * tex);
25
29 void track(const Mesh * mesh);
30
34 void trackState(const std::string & name);
35
39 void untrack(const Texture * tex);
40
44 void untrack(const Mesh * mesh);
45
51 void pushMarker(const std::string& category, const std::string& label, const glm::vec4& color);
52
58 void insertMarker(const std::string& category, const std::string& label, const glm::vec4& color);
59
63 void popMarker(const std::string& category);
64
66 void nextFrame();
67
69 void interface();
70
72 ~DebugViewer() = default;
73
75 DebugViewer(const DebugViewer &) = delete;
76
80 DebugViewer & operator=(const DebugViewer &) = delete;
81
84
89
90public:
91
94 static void setDefault(DebugViewer * viewer);
95
99 static void trackDefault(const Texture * tex);
100
104 static void trackDefault(const Mesh * mesh);
105
109 static void trackStateDefault(const std::string & name);
110
114 static void untrackDefault(const Texture * tex);
115
119 static void untrackDefault(const Mesh * mesh);
120
126 static void pushMarkerDefault(const std::string& category, const std::string& label, const glm::vec4& color);
127
133 static void insertMarkerDefault(const std::string& category, const std::string& label, const glm::vec4& color);
134
138 static void popMarkerDefault(const std::string& category);
139
140private:
141
143
144private:
145
148 const Texture * tex = nullptr;
149 std::string name;
150 std::unique_ptr<Texture> display;
151 std::string displayName;
152 glm::vec2 range = glm::vec2(0.0f, 1.0f);
153 glm::bvec4 channels = glm::bvec4(true, true, true, false);
154 int mip = 0;
155 int layer = 0;
156 bool gamma = false;
157 bool visible = false;
158 };
159
161 struct MeshInfos {
162 const Mesh * mesh = nullptr;
163 std::string name;
164 bool visible = false;
165 };
166
168 struct StateInfos {
170 bool visible = false;
171 bool populated = false;
172 };
173
175 struct MarkerInfos {
176 std::string name;
177 glm::vec4 color;
178 uint index;
179 std::vector<MarkerInfos> markers;
180 };
181
184 std::vector<MarkerInfos> markers;
185 int frequency = 1;
186 int offset = 0;
187 uint depth = 0;
188 bool visible = false;
189 bool record = true;
190 };
191
194 void displayMetrics();
195
199 void displayMarker(const MarkerInfos& marker);
200
205 void displayMarkers(const std::string & name, MarkerCategoryInfos& category);
206
211 void displayState(const std::string & name, StateInfos & infos);
212
216 void displayMesh(MeshInfos & mesh);
217
223 void registerTexture(const std::string & name, const Texture * tex, TextureInfos & infos);
224
229 void displayTexture(const std::string & prefix, TextureInfos & tex);
230
234 void updateDisplay(const TextureInfos & tex);
235
236 std::vector<TextureInfos> _textures;
237 std::vector<TextureInfos> _drawables;
238 std::vector<MeshInfos> _meshes;
239 std::unordered_map<std::string, StateInfos> _states;
240 std::unordered_map<std::string, MarkerCategoryInfos> _markers;
241
243 uint64_t _frameCounter = 0;
244 uint _textureId = 0;
245 uint _drawableId = 0;
246 uint _meshId = 0;
247 uint _winId = 0;
248 uint _markerId = 0;
249
250};
Provide helper GUI to display the content of textures and mesh infos. This can be useful to validate ...
Definition: DebugViewer.hpp:13
static void trackStateDefault(const std::string &name)
Definition: DebugViewer.cpp:657
void interface()
Definition: DebugViewer.cpp:259
void insertMarker(const std::string &category, const std::string &label, const glm::vec4 &color)
Definition: DebugViewer.cpp:123
void nextFrame()
Definition: DebugViewer.cpp:244
void displayMetrics()
Definition: DebugViewer.cpp:342
void untrack(const Texture *tex)
Definition: DebugViewer.cpp:229
void updateDisplay(const TextureInfos &tex)
Definition: DebugViewer.cpp:605
static void insertMarkerDefault(const std::string &category, const std::string &label, const glm::vec4 &color)
Definition: DebugViewer.cpp:685
Program * _texDisplay
Texture display shader.
Definition: DebugViewer.hpp:242
static void popMarkerDefault(const std::string &category)
Definition: DebugViewer.cpp:692
static void pushMarkerDefault(const std::string &category, const std::string &label, const glm::vec4 &color)
Definition: DebugViewer.cpp:678
static void trackDefault(const Texture *tex)
Definition: DebugViewer.cpp:643
static void untrackDefault(const Texture *tex)
Definition: DebugViewer.cpp:664
void displayState(const std::string &name, StateInfos &infos)
Definition: DebugViewer.cpp:407
std::unordered_map< std::string, MarkerCategoryInfos > _markers
The registered markers.
Definition: DebugViewer.hpp:240
void trackState(const std::string &name)
Definition: DebugViewer.cpp:152
void registerTexture(const std::string &name, const Texture *tex, TextureInfos &infos)
Definition: DebugViewer.cpp:161
void track(const Texture *tex)
Definition: DebugViewer.cpp:27
void displayMesh(MeshInfos &mesh)
Definition: DebugViewer.cpp:517
DebugViewer(const DebugViewer &)=delete
static DebugViewer * _shared
Optional shared debug viewer.
Definition: DebugViewer.hpp:142
void displayMarker(const MarkerInfos &marker)
Definition: DebugViewer.cpp:365
uint64_t _frameCounter
Frame counter.
Definition: DebugViewer.hpp:243
void displayTexture(const std::string &prefix, TextureInfos &tex)
Definition: DebugViewer.cpp:549
std::unordered_map< std::string, StateInfos > _states
GPU states currently tracked.
Definition: DebugViewer.hpp:239
uint _winId
Internal window counter.
Definition: DebugViewer.hpp:247
~DebugViewer()=default
uint _drawableId
Default drawable name counter.
Definition: DebugViewer.hpp:245
DebugViewer & operator=(DebugViewer &&)=delete
DebugViewer(DebugViewer &&)=delete
static void setDefault(DebugViewer *viewer)
Definition: DebugViewer.cpp:639
void pushMarker(const std::string &category, const std::string &label, const glm::vec4 &color)
Definition: DebugViewer.cpp:102
uint _markerId
Internal marker counter.
Definition: DebugViewer.hpp:248
std::vector< TextureInfos > _textures
The registered textures.
Definition: DebugViewer.hpp:236
uint _textureId
Default texture name counter.
Definition: DebugViewer.hpp:244
DebugViewer & operator=(const DebugViewer &)=delete
std::vector< MeshInfos > _meshes
The registered meshes.
Definition: DebugViewer.hpp:238
std::vector< TextureInfos > _drawables
The registered drawable textures.
Definition: DebugViewer.hpp:237
DebugViewer()
Definition: DebugViewer.cpp:23
void displayMarkers(const std::string &name, MarkerCategoryInfos &category)
Definition: DebugViewer.cpp:382
uint _meshId
Default mesh name counter.
Definition: DebugViewer.hpp:246
void popMarker(const std::string &category)
Definition: DebugViewer.cpp:142
Internal GPU state ; not all API options are exposed, only these that can be toggled in Rendu.
Definition: GPUTypes.hpp:324
Represents a geometric mesh composed of vertices, other attributes and triangles.
Definition: Mesh.hpp:15
Represents a group of shaders used for rendering.
Definition: Program.hpp:31
Represents a texture containing one or more images, stored on the CPU and/or GPU.
Definition: Texture.hpp:12
Definition: DebugViewer.hpp:183
int frequency
Sampling frequency.
Definition: DebugViewer.hpp:185
bool record
Should the category be recorded at this frame.
Definition: DebugViewer.hpp:189
uint depth
Current marker hierarchy depth.
Definition: DebugViewer.hpp:187
bool visible
Are the marker details displayed.
Definition: DebugViewer.hpp:188
std::vector< MarkerInfos > markers
Root markers.
Definition: DebugViewer.hpp:184
int offset
Sampling offset.
Definition: DebugViewer.hpp:186
Definition: DebugViewer.hpp:175
std::string name
Marker label.
Definition: DebugViewer.hpp:176
uint index
Marker index in the frame.
Definition: DebugViewer.hpp:178
glm::vec4 color
Marker color.
Definition: DebugViewer.hpp:177
std::vector< MarkerInfos > markers
Child markers.
Definition: DebugViewer.hpp:179
Definition: DebugViewer.hpp:161
const Mesh * mesh
Mesh to track.
Definition: DebugViewer.hpp:162
std::string name
Mesh display name.
Definition: DebugViewer.hpp:163
bool visible
Are the mesh details displayed.
Definition: DebugViewer.hpp:164
Definition: DebugViewer.hpp:168
bool visible
Is the state window visible.
Definition: DebugViewer.hpp:170
GPUState state
GPU state to track.
Definition: DebugViewer.hpp:169
bool populated
Has the state already been queried.
Definition: DebugViewer.hpp:171
Definition: DebugViewer.hpp:147
std::string displayName
Texture name with extra information about the layout,...
Definition: DebugViewer.hpp:151
int mip
Mipmap level to display.
Definition: DebugViewer.hpp:154
std::string name
Texture name.
Definition: DebugViewer.hpp:149
std::unique_ptr< Texture > display
Texture used for visualization.
Definition: DebugViewer.hpp:150
int layer
Layer to display for arrays and 3D textures.
Definition: DebugViewer.hpp:155
bool visible
Is the texture window visible.
Definition: DebugViewer.hpp:157
glm::bvec4 channels
Channels that should be displayed.
Definition: DebugViewer.hpp:153
bool gamma
Should gamma correction be applied.
Definition: DebugViewer.hpp:156
glm::vec2 range
Range of values to display normalized.
Definition: DebugViewer.hpp:152
const Texture * tex
The texture to display.
Definition: DebugViewer.hpp:148