策略抽离
This commit is contained in:
@@ -3,35 +3,35 @@
|
||||
#include <utility>
|
||||
|
||||
namespace renderive {
|
||||
void Frame_Lifecycle_Record::record_renderable_render(const std::string& object_name, const std::string& parent_object_name, int tree_depth, Renderable_Cache_Mode cache_mode, std::uint64_t render_time_ns) {
|
||||
Renderable_Frame_Stat& stat = renderable_stat(object_name, parent_object_name, tree_depth);
|
||||
void Frame_Lifecycle_Record::record_renderable_render(std::uint64_t node_id, std::uint64_t parent_node_id, std::string_view object_name, std::string_view parent_object_name, int tree_depth, Renderable_Cache_Mode cache_mode, std::uint64_t render_time_ns) {
|
||||
Renderable_Frame_Stat& stat = renderable_stat(node_id, parent_node_id, object_name, parent_object_name, tree_depth);
|
||||
stat.cache_enabled = cache_mode == Renderable_Cache_Mode::Local_Pixel;
|
||||
++stat.render_count;
|
||||
stat.total_render_time_ns += render_time_ns;
|
||||
stat.last_total_render_time_ns = render_time_ns;
|
||||
}
|
||||
|
||||
void Frame_Lifecycle_Record::record_renderable_self_draw(const std::string& object_name, const std::string& parent_object_name, int tree_depth, Renderable_Cache_Mode cache_mode, std::uint64_t draw_time_ns) {
|
||||
Renderable_Frame_Stat& stat = renderable_stat(object_name, parent_object_name, tree_depth);
|
||||
void Frame_Lifecycle_Record::record_renderable_self_draw(std::uint64_t node_id, std::uint64_t parent_node_id, std::string_view object_name, std::string_view parent_object_name, int tree_depth, Renderable_Cache_Mode cache_mode, std::uint64_t draw_time_ns) {
|
||||
Renderable_Frame_Stat& stat = renderable_stat(node_id, parent_node_id, object_name, parent_object_name, tree_depth);
|
||||
stat.cache_enabled = cache_mode == Renderable_Cache_Mode::Local_Pixel;
|
||||
++stat.self_draw_count;
|
||||
stat.self_draw_time_ns += draw_time_ns;
|
||||
stat.last_self_draw_time_ns = draw_time_ns;
|
||||
}
|
||||
|
||||
void Frame_Lifecycle_Record::record_renderable_cache_hit(const std::string& object_name, const std::string& parent_object_name, int tree_depth) {
|
||||
void Frame_Lifecycle_Record::record_renderable_cache_hit(std::uint64_t node_id, std::uint64_t parent_node_id, std::string_view object_name, std::string_view parent_object_name, int tree_depth) {
|
||||
++renderable_cache_hit_count;
|
||||
++cache_stat(object_name, parent_object_name, tree_depth).hit_count;
|
||||
++cache_stat(node_id, parent_node_id, object_name, parent_object_name, tree_depth).hit_count;
|
||||
}
|
||||
|
||||
void Frame_Lifecycle_Record::record_renderable_cache_miss(const std::string& object_name, const std::string& parent_object_name, int tree_depth) {
|
||||
void Frame_Lifecycle_Record::record_renderable_cache_miss(std::uint64_t node_id, std::uint64_t parent_node_id, std::string_view object_name, std::string_view parent_object_name, int tree_depth) {
|
||||
++renderable_cache_miss_count;
|
||||
++cache_stat(object_name, parent_object_name, tree_depth).miss_count;
|
||||
++cache_stat(node_id, parent_node_id, object_name, parent_object_name, tree_depth).miss_count;
|
||||
}
|
||||
|
||||
void Frame_Lifecycle_Record::record_renderable_cache_rebuild(const std::string& object_name, const std::string& parent_object_name, int tree_depth, std::uint64_t rebuild_time_ns, std::uint64_t image_bytes, std::uint64_t image_area, std::uint64_t edit_version, std::uint64_t ready_version) {
|
||||
void Frame_Lifecycle_Record::record_renderable_cache_rebuild(std::uint64_t node_id, std::uint64_t parent_node_id, std::string_view object_name, std::string_view parent_object_name, int tree_depth, std::uint64_t rebuild_time_ns, std::uint64_t image_bytes, std::uint64_t image_area, std::uint64_t edit_version, std::uint64_t ready_version) {
|
||||
++renderable_cache_rebuild_count;
|
||||
Renderable_Cache_Frame_Stats& stat = cache_stat(object_name, parent_object_name, tree_depth);
|
||||
Renderable_Cache_Frame_Stats& stat = cache_stat(node_id, parent_node_id, object_name, parent_object_name, tree_depth);
|
||||
renderable_cache_rebuild_time_ns += rebuild_time_ns;
|
||||
renderable_cache_image_bytes += image_bytes;
|
||||
renderable_cache_image_area += image_area;
|
||||
@@ -44,9 +44,9 @@ void Frame_Lifecycle_Record::record_renderable_cache_rebuild(const std::string&
|
||||
stat.last_ready_version = ready_version;
|
||||
}
|
||||
|
||||
void Frame_Lifecycle_Record::record_renderable_cache_compose(const std::string& object_name, const std::string& parent_object_name, int tree_depth, std::uint64_t compose_time_ns, std::uint64_t image_bytes, std::uint64_t image_area, std::uint64_t edit_version, std::uint64_t ready_version) {
|
||||
void Frame_Lifecycle_Record::record_renderable_cache_compose(std::uint64_t node_id, std::uint64_t parent_node_id, std::string_view object_name, std::string_view parent_object_name, int tree_depth, std::uint64_t compose_time_ns, std::uint64_t image_bytes, std::uint64_t image_area, std::uint64_t edit_version, std::uint64_t ready_version) {
|
||||
renderable_cache_compose_time_ns += compose_time_ns;
|
||||
Renderable_Cache_Frame_Stats& stat = cache_stat(object_name, parent_object_name, tree_depth);
|
||||
Renderable_Cache_Frame_Stats& stat = cache_stat(node_id, parent_node_id, object_name, parent_object_name, tree_depth);
|
||||
stat.compose_time_ns += compose_time_ns;
|
||||
stat.last_compose_time_ns = compose_time_ns;
|
||||
stat.last_image_bytes = image_bytes;
|
||||
@@ -55,27 +55,31 @@ void Frame_Lifecycle_Record::record_renderable_cache_compose(const std::string&
|
||||
stat.last_ready_version = ready_version;
|
||||
}
|
||||
|
||||
Renderable_Frame_Stat& Frame_Lifecycle_Record::renderable_stat(const std::string& object_name, const std::string& parent_object_name, int tree_depth) {
|
||||
Renderable_Frame_Stat& Frame_Lifecycle_Record::renderable_stat(std::uint64_t node_id, std::uint64_t parent_node_id, std::string_view object_name, std::string_view parent_object_name, int tree_depth) {
|
||||
for (auto& stat : renderable_stats) {
|
||||
if (stat.object_name == object_name && stat.parent_object_name == parent_object_name && stat.tree_depth == tree_depth)
|
||||
if (stat.node_id == node_id && stat.parent_node_id == parent_node_id && stat.tree_depth == tree_depth)
|
||||
return stat;
|
||||
}
|
||||
Renderable_Frame_Stat stat;
|
||||
stat.object_name = object_name;
|
||||
stat.parent_object_name = parent_object_name;
|
||||
stat.node_id = node_id;
|
||||
stat.parent_node_id = parent_node_id;
|
||||
stat.object_name = std::string(object_name);
|
||||
stat.parent_object_name = std::string(parent_object_name);
|
||||
stat.tree_depth = tree_depth;
|
||||
renderable_stats.push_back(std::move(stat));
|
||||
return renderable_stats.back();
|
||||
}
|
||||
|
||||
Renderable_Cache_Frame_Stats& Frame_Lifecycle_Record::cache_stat(const std::string& object_name, const std::string& parent_object_name, int tree_depth) {
|
||||
Renderable_Cache_Frame_Stats& Frame_Lifecycle_Record::cache_stat(std::uint64_t node_id, std::uint64_t parent_node_id, std::string_view object_name, std::string_view parent_object_name, int tree_depth) {
|
||||
for (auto& stat : renderable_cache_stats) {
|
||||
if (stat.object_name == object_name && stat.parent_object_name == parent_object_name && stat.tree_depth == tree_depth)
|
||||
if (stat.node_id == node_id && stat.parent_node_id == parent_node_id && stat.tree_depth == tree_depth)
|
||||
return stat;
|
||||
}
|
||||
Renderable_Cache_Frame_Stats stat;
|
||||
stat.object_name = object_name;
|
||||
stat.parent_object_name = parent_object_name;
|
||||
stat.node_id = node_id;
|
||||
stat.parent_node_id = parent_node_id;
|
||||
stat.object_name = std::string(object_name);
|
||||
stat.parent_object_name = std::string(parent_object_name);
|
||||
stat.tree_depth = tree_depth;
|
||||
renderable_cache_stats.push_back(std::move(stat));
|
||||
return renderable_cache_stats.back();
|
||||
|
||||
Reference in New Issue
Block a user