Blender V5.3
scene/stats.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#pragma once
6
7#include "scene/scene.h"
8
9#include "util/string.h"
10#include "util/vector.h"
11
13
14/* Named statistics entry, which corresponds to a size. There is no real
15 * semantic around the units of size, it just should be the same for all
16 * entries.
17 *
18 * This is a generic entry for all size-related statistics, which helps
19 * avoiding duplicating code for things like sorting.
20 */
22 public:
24 NamedSizeEntry(const string &name, const size_t size);
25
26 string name;
27 size_t size;
28};
29
31 public:
33 NamedTimeEntry(const string &name, const double time);
34
35 string name;
36 double time;
37};
38
39/* Container of named size entries. Used, for example, to store per-mesh memory
40 * usage statistics. But also keeps track of overall memory usage of the
41 * container.
42 */
44 public:
46
47 /* Add entry to the statistics. */
48 void add_entry(const NamedSizeEntry &entry);
49
50 /* Generate full human-readable report. */
51 string full_report(const int indent_level = 0);
52
53 /* Total size of all entries. */
54 size_t total_size;
55
56 /* NOTE: Is fine to read directly, but for adding use add_entry(), which
57 * makes sure all accumulating values are properly updated.
58 */
60};
61
63 public:
65
66 /* Add entry to the statistics. */
67 void add_entry(const NamedTimeEntry &entry)
68 {
69 total_time += entry.time;
70 entries.push_back(entry);
71 }
72
73 /* Generate full human-readable report. */
74 string full_report(const int indent_level = 0);
75
76 /* Total time of all entries. */
77 double total_time;
78
79 /* NOTE: Is fine to read directly, but for adding use add_entry(), which
80 * makes sure all accumulating values are properly updated.
81 */
83
84 void clear()
85 {
86 total_time = 0.0;
87 entries.clear();
88 }
89};
90
92 public:
94 NamedNestedSampleStats(const string &name, const uint64_t samples);
95
96 NamedNestedSampleStats &add_entry(const string &name, const uint64_t samples);
97
98 /* Updates sum_samples recursively. */
99 void update_sum();
100
101 string full_report(const int indent_level = 0, const uint64_t total_samples = 0);
102
103 string name;
104
105 /* self_samples contains only the samples that this specific event got,
106 * while sum_samples also includes the samples of all sub-entries. */
108
110};
111
112/* Named entry containing both a time-sample count for objects of a type and a
113 * total count of processed items.
114 * This allows to estimate the time spent per item. */
116 public:
117 NamedSampleCountPair(const ustring &name, const uint64_t samples, const uint64_t hits);
118
119 ustring name;
122};
123
124/* Contains statistics about pairs of samples and counts as described above. */
126 public:
128
129 string full_report(const int indent_level = 0);
130 void add(const ustring &name, const uint64_t samples, const uint64_t hits);
131
132 using entry_map = unordered_map<ustring, NamedSampleCountPair>;
134};
135
136/* Statistics about mesh in the render database. */
138 public:
140
141 /* Generate full human-readable report. */
142 string full_report(const int indent_level = 0);
143
144 /* Input geometry statistics, this is what is coming as an input to render
145 * from. say, Blender. This does not include runtime or engine specific
146 * memory like BVH.
147 */
149};
150
151/* Cumulative eviction counters for texture cache. */
153 int64_t tiles_loaded = 0; /* Total tiles loaded (including reloads). */
154 int64_t tiles_evicted = 0; /* Total tiles evicted. */
155 int64_t tiles_reloaded = 0; /* Tiles loaded that had been previously evicted. */
156 int64_t peak_loaded = 0; /* High-water mark of simultaneously loaded tiles. */
157};
158
159/* Per-mip-level tile statistics for tiled images. */
161 int width = 0;
162 int height = 0;
164 int tiles_total = 0;
165};
166
167/* Per-image tile statistics for texture cache. */
173
174/* Statistics about images held in memory. */
176 public:
178
179 /* Generate full human-readable report. */
180 string full_report(const int indent_level = 0);
181
182 /* Full image statistics. */
184
185 /* Tiled image statistics. */
187 size_t tiled_images_size = 0; /* Total size of currently loaded tiles. */
188 size_t tiled_images_peak_size = 0; /* Peak loaded tiles size. */
189 size_t overhead_size = 0; /* Non-pixel memory overhead. */
190
191 /* Tile eviction statistics. */
193};
194
195/* Render process statistics. */
197 public:
198 RenderStats();
199
200 /* Return full report as string. */
201 string full_report();
202
203 /* Collect kernel sampling information from Stats. */
204 void collect_profiling(Scene *scene, Profiler &prof);
205
207
213};
214
216 public:
217 /* Generate full human-readable report. */
218 string full_report(const int indent_level = 0);
219
221};
222
247
long long int int64_t
unsigned long long int uint64_t
vector< ImageTileStats > tiled_images
size_t tiled_images_peak_size
ImageEvictionStats eviction
size_t tiled_images_size
string full_report(const int indent_level=0)
Definition stats.cpp:222
NamedSizeStats full_images
size_t overhead_size
string full_report(const int indent_level=0)
Definition stats.cpp:210
NamedSizeStats geometry
vector< NamedNestedSampleStats > entries
NamedNestedSampleStats & add_entry(const string &name, const uint64_t samples)
Definition stats.cpp:107
string full_report(const int indent_level=0, const uint64_t total_samples=0)
Definition stats.cpp:122
NamedSampleCountPair(const ustring &name, const uint64_t samples, const uint64_t hits)
Definition stats.cpp:153
string full_report(const int indent_level=0)
Definition stats.cpp:173
unordered_map< ustring, NamedSampleCountPair > entry_map
void add(const ustring &name, const uint64_t samples, const uint64_t hits)
Definition stats.cpp:162
void add_entry(const NamedSizeEntry &entry)
Definition stats.cpp:58
string full_report(const int indent_level=0)
Definition stats.cpp:64
size_t total_size
Definition scene/stats.h:54
vector< NamedSizeEntry > entries
Definition scene/stats.h:59
double total_time
Definition scene/stats.h:77
void add_entry(const NamedTimeEntry &entry)
Definition scene/stats.h:67
string full_report(const int indent_level=0)
Definition stats.cpp:84
vector< NamedTimeEntry > entries
Definition scene/stats.h:82
void collect_profiling(Scene *scene, Profiler &prof)
Definition stats.cpp:339
bool has_profiling
string full_report()
Definition stats.cpp:394
NamedSampleCountStats shaders
NamedNestedSampleStats kernel
MeshStats mesh
ImageStats image
NamedSampleCountStats objects
UpdateTimeStats tables
UpdateTimeStats image
UpdateTimeStats background
UpdateTimeStats light
UpdateTimeStats bake
UpdateTimeStats film
UpdateTimeStats camera
UpdateTimeStats geometry
string full_report()
Definition stats.cpp:419
UpdateTimeStats particles
UpdateTimeStats procedurals
UpdateTimeStats integrator
UpdateTimeStats osl
UpdateTimeStats object
UpdateTimeStats scene
UpdateTimeStats svm
Definition scene.h:133
string full_report(const int indent_level=0)
Definition stats.cpp:412
NamedTimeStats times
#define CCL_NAMESPACE_END
vector< ImageMipLevelStats > mip_levels