2018-07-27 13:46:13 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2011-2018 Blender Foundation
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __RENDER_STATS_H__
|
|
|
|
#define __RENDER_STATS_H__
|
|
|
|
|
2021-10-24 12:19:19 +00:00
|
|
|
#include "scene/scene.h"
|
2018-11-29 01:06:30 +00:00
|
|
|
|
2021-10-24 12:19:19 +00:00
|
|
|
#include "util/stats.h"
|
|
|
|
#include "util/string.h"
|
|
|
|
#include "util/vector.h"
|
2018-07-27 13:46:13 +00:00
|
|
|
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
/* Named statistics entry, which corresponds to a size. There is no real
|
|
|
|
* semantic around the units of size, it just should be the same for all
|
|
|
|
* entries.
|
|
|
|
*
|
2019-08-16 14:54:22 +00:00
|
|
|
* This is a generic entry for all size-related statistics, which helps
|
2018-07-27 13:46:13 +00:00
|
|
|
* avoiding duplicating code for things like sorting.
|
|
|
|
*/
|
|
|
|
class NamedSizeEntry {
|
|
|
|
public:
|
|
|
|
NamedSizeEntry();
|
|
|
|
NamedSizeEntry(const string &name, size_t size);
|
|
|
|
|
|
|
|
string name;
|
|
|
|
size_t size;
|
|
|
|
};
|
|
|
|
|
2020-10-01 21:16:01 +00:00
|
|
|
class NamedTimeEntry {
|
|
|
|
public:
|
|
|
|
NamedTimeEntry();
|
|
|
|
NamedTimeEntry(const string &name, double time);
|
|
|
|
|
|
|
|
string name;
|
|
|
|
double time;
|
|
|
|
};
|
|
|
|
|
2018-07-27 13:46:13 +00:00
|
|
|
/* Container of named size entries. Used, for example, to store per-mesh memory
|
|
|
|
* usage statistics. But also keeps track of overall memory usage of the
|
|
|
|
* container.
|
|
|
|
*/
|
|
|
|
class NamedSizeStats {
|
|
|
|
public:
|
|
|
|
NamedSizeStats();
|
|
|
|
|
|
|
|
/* Add entry to the statistics. */
|
|
|
|
void add_entry(const NamedSizeEntry &entry);
|
|
|
|
|
|
|
|
/* Generate full human-readable report. */
|
|
|
|
string full_report(int indent_level = 0);
|
|
|
|
|
|
|
|
/* Total size of all entries. */
|
|
|
|
size_t total_size;
|
|
|
|
|
|
|
|
/* NOTE: Is fine to read directly, but for adding use add_entry(), which
|
|
|
|
* makes sure all accumulating values are properly updated.
|
|
|
|
*/
|
|
|
|
vector<NamedSizeEntry> entries;
|
|
|
|
};
|
|
|
|
|
2020-10-01 21:16:01 +00:00
|
|
|
class NamedTimeStats {
|
|
|
|
public:
|
|
|
|
NamedTimeStats();
|
|
|
|
|
|
|
|
/* Add entry to the statistics. */
|
|
|
|
void add_entry(const NamedTimeEntry &entry)
|
|
|
|
{
|
|
|
|
total_time += entry.time;
|
|
|
|
entries.push_back(entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Generate full human-readable report. */
|
|
|
|
string full_report(int indent_level = 0);
|
|
|
|
|
|
|
|
/* Total time of all entries. */
|
|
|
|
double total_time;
|
|
|
|
|
|
|
|
/* NOTE: Is fine to read directly, but for adding use add_entry(), which
|
|
|
|
* makes sure all accumulating values are properly updated.
|
|
|
|
*/
|
|
|
|
vector<NamedTimeEntry> entries;
|
2020-10-08 04:41:33 +00:00
|
|
|
|
|
|
|
void clear()
|
|
|
|
{
|
|
|
|
total_time = 0.0;
|
|
|
|
entries.clear();
|
|
|
|
}
|
2020-10-01 21:16:01 +00:00
|
|
|
};
|
|
|
|
|
2018-11-29 01:06:30 +00:00
|
|
|
class NamedNestedSampleStats {
|
|
|
|
public:
|
|
|
|
NamedNestedSampleStats();
|
|
|
|
NamedNestedSampleStats(const string &name, uint64_t samples);
|
|
|
|
|
|
|
|
NamedNestedSampleStats &add_entry(const string &name, uint64_t samples);
|
|
|
|
|
|
|
|
/* Updates sum_samples recursively. */
|
|
|
|
void update_sum();
|
|
|
|
|
|
|
|
string full_report(int indent_level = 0, uint64_t total_samples = 0);
|
|
|
|
|
|
|
|
string name;
|
|
|
|
|
|
|
|
/* self_samples contains only the samples that this specific event got,
|
|
|
|
* while sum_samples also includes the samples of all sub-entries. */
|
|
|
|
uint64_t self_samples, sum_samples;
|
|
|
|
|
|
|
|
vector<NamedNestedSampleStats> entries;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Named entry containing both a time-sample count for objects of a type and a
|
|
|
|
* total count of processed items.
|
|
|
|
* This allows to estimate the time spent per item. */
|
|
|
|
class NamedSampleCountPair {
|
|
|
|
public:
|
|
|
|
NamedSampleCountPair(const ustring &name, uint64_t samples, uint64_t hits);
|
|
|
|
|
|
|
|
ustring name;
|
|
|
|
uint64_t samples;
|
|
|
|
uint64_t hits;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Contains statistics about pairs of samples and counts as described above. */
|
|
|
|
class NamedSampleCountStats {
|
|
|
|
public:
|
|
|
|
NamedSampleCountStats();
|
|
|
|
|
|
|
|
string full_report(int indent_level = 0);
|
|
|
|
void add(const ustring &name, uint64_t samples, uint64_t hits);
|
|
|
|
|
|
|
|
typedef unordered_map<ustring, NamedSampleCountPair, ustringHash> entry_map;
|
|
|
|
entry_map entries;
|
|
|
|
};
|
|
|
|
|
2018-07-27 13:46:13 +00:00
|
|
|
/* Statistics about mesh in the render database. */
|
|
|
|
class MeshStats {
|
|
|
|
public:
|
|
|
|
MeshStats();
|
|
|
|
|
|
|
|
/* Generate full human-readable report. */
|
|
|
|
string full_report(int indent_level = 0);
|
|
|
|
|
|
|
|
/* Input geometry statistics, this is what is coming as an input to render
|
|
|
|
* from. say, Blender. This does not include runtime or engine specific
|
|
|
|
* memory like BVH.
|
|
|
|
*/
|
|
|
|
NamedSizeStats geometry;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Statistics about images held in memory. */
|
|
|
|
class ImageStats {
|
|
|
|
public:
|
|
|
|
ImageStats();
|
|
|
|
|
|
|
|
/* Generate full human-readable report. */
|
|
|
|
string full_report(int indent_level = 0);
|
|
|
|
|
|
|
|
NamedSizeStats textures;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Render process statistics. */
|
|
|
|
class RenderStats {
|
|
|
|
public:
|
|
|
|
RenderStats();
|
|
|
|
|
|
|
|
/* Return full report as string. */
|
|
|
|
string full_report();
|
|
|
|
|
2018-11-29 01:06:30 +00:00
|
|
|
/* Collect kernel sampling information from Stats. */
|
2018-11-29 22:30:17 +00:00
|
|
|
void collect_profiling(Scene *scene, Profiler &prof);
|
2018-11-29 01:06:30 +00:00
|
|
|
|
|
|
|
bool has_profiling;
|
|
|
|
|
2018-07-27 13:46:13 +00:00
|
|
|
MeshStats mesh;
|
|
|
|
ImageStats image;
|
2018-11-29 01:06:30 +00:00
|
|
|
NamedNestedSampleStats kernel;
|
|
|
|
NamedSampleCountStats shaders;
|
|
|
|
NamedSampleCountStats objects;
|
2018-07-27 13:46:13 +00:00
|
|
|
};
|
|
|
|
|
2020-10-01 21:16:01 +00:00
|
|
|
class UpdateTimeStats {
|
|
|
|
public:
|
|
|
|
/* Generate full human-readable report. */
|
|
|
|
string full_report(int indent_level = 0);
|
|
|
|
|
|
|
|
NamedTimeStats times;
|
|
|
|
};
|
|
|
|
|
|
|
|
class SceneUpdateStats {
|
|
|
|
public:
|
|
|
|
SceneUpdateStats();
|
|
|
|
|
|
|
|
UpdateTimeStats geometry;
|
|
|
|
UpdateTimeStats image;
|
|
|
|
UpdateTimeStats light;
|
|
|
|
UpdateTimeStats object;
|
|
|
|
UpdateTimeStats background;
|
|
|
|
UpdateTimeStats bake;
|
|
|
|
UpdateTimeStats camera;
|
|
|
|
UpdateTimeStats film;
|
|
|
|
UpdateTimeStats integrator;
|
|
|
|
UpdateTimeStats osl;
|
|
|
|
UpdateTimeStats particles;
|
|
|
|
UpdateTimeStats scene;
|
|
|
|
UpdateTimeStats svm;
|
|
|
|
UpdateTimeStats tables;
|
2021-01-25 13:56:57 +00:00
|
|
|
UpdateTimeStats procedurals;
|
2020-10-01 21:16:01 +00:00
|
|
|
|
|
|
|
string full_report();
|
|
|
|
|
|
|
|
void clear();
|
|
|
|
};
|
|
|
|
|
2018-07-27 13:46:13 +00:00
|
|
|
CCL_NAMESPACE_END
|
|
|
|
|
|
|
|
#endif /* __RENDER_STATS_H__ */
|