[Bf-blender-cvs] [8ca55e2f9e0] temp-geometry-nodes-timings: Refactored extra info drawing uint64_t -> chrono::duration
Erik
noreply at git.blender.org
Thu Nov 18 08:19:26 CET 2021
Commit: 8ca55e2f9e0bc890f9cd85d2373e0e1a68670ed8
Author: Erik
Date: Thu Nov 18 08:18:53 2021 +0100
Branches: temp-geometry-nodes-timings
https://developer.blender.org/rB8ca55e2f9e0bc890f9cd85d2373e0e1a68670ed8
Refactored extra info drawing
uint64_t -> chrono::duration
===================================================================
M release/datafiles/locale
M release/scripts/addons
M release/scripts/startup/bl_ui/space_node.py
M source/blender/editors/space_node/node_draw.cc
M source/blender/modifiers/intern/MOD_nodes_evaluator.cc
M source/blender/nodes/NOD_geometry_nodes_eval_log.hh
M source/blender/nodes/intern/geometry_nodes_eval_log.cc
M source/blender/nodes/intern/node_geometry_exec.cc
M source/tools
===================================================================
diff --git a/release/datafiles/locale b/release/datafiles/locale
index 6178bad247c..8ee2942570f 160000
--- a/release/datafiles/locale
+++ b/release/datafiles/locale
@@ -1 +1 @@
-Subproject commit 6178bad247c69c9c4e1a98c5f35765752341b3ae
+Subproject commit 8ee2942570f08d10484bb2328d0d1b0aaaa0367c
diff --git a/release/scripts/addons b/release/scripts/addons
index f6107e2fd9a..f2a08d80ccd 160000
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit f6107e2fd9a92b55ac110c7db941e287e2f6604a
+Subproject commit f2a08d80ccd3c13af304525778df3905f95bd44d
diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py
index 32fa2d86150..1f1999faace 100644
--- a/release/scripts/startup/bl_ui/space_node.py
+++ b/release/scripts/startup/bl_ui/space_node.py
@@ -790,7 +790,7 @@ class NodeTreeInterfacePanel:
"node.tree_socket_change_type",
"socket_type",
text=active_socket.bl_label if active_socket.bl_label else active_socket.bl_idname
- )
+ )
props.in_out = in_out
layout.use_property_split = True
@@ -830,7 +830,6 @@ class NODE_PT_node_tree_interface_inputs(NodeTreeInterfacePanel, Panel):
def draw(self, context):
self.draw_socket_list(context, "IN", "inputs", "active_input")
-
class NODE_PT_node_tree_interface_outputs(NodeTreeInterfacePanel, Panel):
bl_space_type = 'NODE_EDITOR'
bl_region_type = 'UI'
diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc
index f0181eb29bd..b2f4d749a9b 100644
--- a/source/blender/editors/space_node/node_draw.cc
+++ b/source/blender/editors/space_node/node_draw.cc
@@ -1579,20 +1579,20 @@ static void node_add_error_message_button(
UI_block_emboss_set(node.block, UI_EMBOSS);
}
-static uint64_t node_get_execution_time(const bNodeTree *ntree,
- const bNode *node,
- const SpaceNode *snode)
+static std::chrono::microseconds node_get_execution_time(const bNodeTree *ntree,
+ const bNode *node,
+ const SpaceNode *snode)
{
- uint64_t exec_time_us = 0;
+ std::chrono::microseconds exec_time = std::chrono::microseconds::zero();
if (node->type == NODE_GROUP_OUTPUT) {
auto *tree_log = geo_log::ModifierLog::find_tree_by_node_editor_context(*snode);
if (tree_log == nullptr) {
- return 0;
+ return exec_time;
}
tree_log->foreach_node_log(
- [&](const geo_log::NodeLog &node_log) { exec_time_us += node_log.execution_time(); });
+ [&](const geo_log::NodeLog &node_log) { exec_time += node_log.execution_time(); });
}
else if (node->type == NODE_FRAME) {
LISTBASE_FOREACH (bNode *, tnode, &ntree->nodes) {
@@ -1601,7 +1601,7 @@ static uint64_t node_get_execution_time(const bNodeTree *ntree,
}
if (tnode->type == NODE_FRAME) {
- exec_time_us += node_get_execution_time(ntree, tnode, snode);
+ exec_time += node_get_execution_time(ntree, tnode, snode);
}
else if (tnode->type == NODE_GROUP) {
auto *root_tree_log = geo_log::ModifierLog::find_tree_by_node_editor_context(*snode);
@@ -1613,12 +1613,12 @@ static uint64_t node_get_execution_time(const bNodeTree *ntree,
continue;
}
tree_log->foreach_node_log(
- [&](const geo_log::NodeLog &node_log) { exec_time_us += node_log.execution_time(); });
+ [&](const geo_log::NodeLog &node_log) { exec_time += node_log.execution_time(); });
}
else {
auto *node_log = geo_log::ModifierLog::find_node_by_node_editor_context(*snode, *tnode);
if (node_log) {
- exec_time_us += node_log->execution_time();
+ exec_time += node_log->execution_time();
}
}
}
@@ -1626,36 +1626,44 @@ static uint64_t node_get_execution_time(const bNodeTree *ntree,
else if (node->type == NODE_GROUP) {
auto *root_tree_log = geo_log::ModifierLog::find_tree_by_node_editor_context(*snode);
if (root_tree_log == nullptr) {
- return 0;
+ return exec_time;
}
auto *tree_log = root_tree_log->lookup_child_log(node->name);
if (tree_log == nullptr) {
- return 0;
+ return exec_time;
}
tree_log->foreach_node_log(
- [&](const geo_log::NodeLog &node_log) { exec_time_us += node_log.execution_time(); });
+ [&](const geo_log::NodeLog &node_log) { exec_time += node_log.execution_time(); });
}
else {
auto *node_log = geo_log::ModifierLog::find_node_by_node_editor_context(*snode, *node);
- exec_time_us = node_log ? node_log->execution_time() : 0;
+ if (node_log) {
+ exec_time = node_log->execution_time();
+ }
}
- return exec_time_us;
+ return exec_time;
}
static std::string node_get_execution_time_label(const SpaceNode *snode, const bNode *node)
{
- uint64_t exec_time_us = node_get_execution_time(snode->nodetree, node, snode);
-
+ std::chrono::microseconds exec_time = node_get_execution_time(snode->nodetree, node, snode);
+ uint64_t exec_time_us = exec_time.count();
std::string timing_str;
/* Don't show time if execution time is 0 microseconds. */
if (exec_time_us == 0) {
timing_str = "-";
}
+ else if (exec_time_us < 100) {
+ timing_str = "< 0.1 ms";
+ }
else {
short precision = 0;
/* Show decimal if value is below 1ms */
if (exec_time_us < 1000) {
+ precision = 2;
+ }
+ else if (exec_time_us < 10000) {
precision = 1;
}
@@ -1666,30 +1674,37 @@ static std::string node_get_execution_time_label(const SpaceNode *snode, const b
return timing_str;
}
-static int node_get_extra_info_count(const SpaceNode *snode, const bNode *node)
+struct NodeExtraInfoRow {
+ std::string text;
+ std::string tooltip;
+ int icon;
+};
+
+static Vector<NodeExtraInfoRow> node_get_extra_info(const SpaceNode *snode, const bNode *node)
{
- int extra_info_count = 0;
+ Vector<NodeExtraInfoRow> rows;
- if (snode->flag & SNODE_SHOW_TIMING &&
+ if (snode->edittree->type == NTREE_GEOMETRY && snode->flag & SNODE_SHOW_TIMING &&
(ELEM(node->typeinfo->nclass, NODE_CLASS_GEOMETRY, NODE_CLASS_GROUP) ||
ELEM(node->type, NODE_FRAME, NODE_GROUP_OUTPUT))) {
- extra_info_count++;
+ NodeExtraInfoRow row;
+ row.text = node_get_execution_time_label(snode, node);
+ row.tooltip = "Latest execution time. Shows total execution time for groups and frames";
+ row.icon = ICON_PREVIEW_RANGE;
+ rows.append(row);
}
-
- return extra_info_count;
+ return rows;
}
static void node_draw_extra_info_row(const bNode *node,
const rctf *rect,
const int row,
- const std::string &text,
- const char *tooltip,
- const int icon)
+ NodeExtraInfoRow extra_info_row)
{
uiBut *but_timing = uiDefBut(node->block,
UI_BTYPE_LABEL,
0,
- text.c_str(),
+ extra_info_row.text.c_str(),
(int)(rect->xmin + 4.0f * U.dpi_fac + NODE_MARGIN_X + 0.4f),
(int)(rect->ymin + row * (20.0f * U.dpi_fac)),
(short)(rect->xmax - rect->xmin),
@@ -1700,14 +1715,11 @@ static void node_draw_extra_info_row(const bNode *node,
0,
0,
"");
- if (node->flag & NODE_MUTED) {
- UI_but_flag_enable(but_timing, UI_BUT_INACTIVE);
- }
UI_block_emboss_set(node->block, UI_EMBOSS_NONE);
uiBut *but_icon = uiDefIconBut(node->block,
UI_BTYPE_BUT,
0,
- icon,
+ extra_info_row.icon,
(int)(rect->xmin + 6.0f * U.dpi_fac),
(int)(rect->ymin + row * (20.0f * U.dpi_fac)),
NODE_HEADER_ICON_SIZE * 0.8f,
@@ -1717,15 +1729,19 @@ static void node_draw_extra_info_row(const bNode *node,
0,
0,
0,
- tooltip);
+ extra_info_row.tooltip.c_str());
UI_block_emboss_set(node->block, UI_EMBOSS);
+ if (node->flag & NODE_MUTED) {
+ UI_but_flag_enable(but_timing, UI_BUT_INACTIVE);
+ UI_but_flag_enable(but_icon, UI_BUT_INACTIVE);
+ }
}
void node_draw_extra_info_panel(const SpaceNode *snode, const bNode *node)
{
- int extra_info_count = node_get_extra_info_count(snode, node);
+ Vector<NodeExtraInfoRow> extra_info_rows = node_get_extra_info(snode, node);
- if (extra_info_count == 0) {
+ if (extra_info_rows.size() == 0) {
return;
}
@@ -1734,20 +1750,25 @@ void node_draw_extra_info_panel(const SpaceNode *snode, const bNode *node)
rctf extra_info_rect;
if (node->type == NODE_FRAME) {
- extra_info_rect.xmin = rct->xmin + 6.0f * U.dpi_fac;
- extra_info_rect.xmax = rct->xmin + 105.0f * U.dpi_fac;
- extra_info_rect.ymin = rct->ymin;
- extra_info_rect.ymax = rct->ymin;
+ extra_info_rect.xmin = rct->xmin;
+ extra_info_rect.xmax = rct->xmin + 95.0f * U.dpi_fac;
+ extra_info_rect.ymin = rct->ymin + 2.0f * U.dpi_fac;
+ extra_info_rect.ymax = rct->ymin + 2.0f * U.dpi_fac;
}
else {
extra_info_rect.xmin = rct->xmin + 3.0f * U.dpi_fac;
- extra_info_rect.xmax = rct->xmin + 105.0f * U.dpi_fac;
+ extra_info_rect.xmax = rct->xmin + 95.0f * U.dpi_fac;
extra_info_rect.ymin = rct->ymax;
- extra_info_rect.ymax = rct->ymax + extra_info_count * (20.0f * U.dpi_fac) + 2.0f * U.dpi_fac;
+ extra_info_rect.ymax = rct->ymax + extra_info_rows.s
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list