[Bf-blender-cvs] [48cb23545ca] sybren-usd: USD: removed the temporary code for timing code execution
Sybren A. Stüvel
noreply at git.blender.org
Thu Oct 3 10:19:46 CEST 2019
Commit: 48cb23545cafbc7e8a37ae0f122f5dd067c0c27c
Author: Sybren A. Stüvel
Date: Wed Oct 2 17:11:34 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rB48cb23545cafbc7e8a37ae0f122f5dd067c0c27c
USD: removed the temporary code for timing code execution
===================================================================
D source/blender/usd/intern/debug_timer.h
M source/blender/usd/intern/usd_capi.cc
===================================================================
diff --git a/source/blender/usd/intern/debug_timer.h b/source/blender/usd/intern/debug_timer.h
deleted file mode 100644
index 0eb6bfd6c2e..00000000000
--- a/source/blender/usd/intern/debug_timer.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-/** \file
- * \ingroup USD
- */
-
-#ifndef __USD__DEBUG_TIMER_H__
-#define __USD__DEBUG_TIMER_H__
-
-// Temporary class for timing stuff.
-#include <stdio.h>
-#include <string>
-#include <time.h>
-
-class Timer {
- timespec ts_begin;
- std::string label;
-
- public:
- explicit Timer(std::string label) : label(label)
- {
- clock_gettime(CLOCK_MONOTONIC, &ts_begin);
- }
- ~Timer()
- {
- timespec ts_end;
- clock_gettime(CLOCK_MONOTONIC, &ts_end);
- double duration = double(ts_end.tv_sec - ts_begin.tv_sec) +
- double(ts_end.tv_nsec - ts_begin.tv_nsec) / 1e9;
- printf("%s took %.3f sec wallclock time\n", label.c_str(), duration);
- }
-};
-
-#endif /* __USD__DEBUG_TIMER_H__ */
diff --git a/source/blender/usd/intern/usd_capi.cc b/source/blender/usd/intern/usd_capi.cc
index d8b15efad24..3d286eb797a 100644
--- a/source/blender/usd/intern/usd_capi.cc
+++ b/source/blender/usd/intern/usd_capi.cc
@@ -19,7 +19,6 @@
*/
#include "../usd.h"
-#include "debug_timer.h"
#include "usd_hierarchy_iterator.h"
#include <pxr/usd/usd/stage.h>
@@ -65,7 +64,6 @@ struct ExportJobData {
static void export_startjob(void *customdata, short *stop, short *do_update, float *progress)
{
- Timer timer_("Export to USD");
ExportJobData *data = static_cast<ExportJobData *>(customdata);
data->stop = stop;
@@ -79,12 +77,9 @@ static void export_startjob(void *customdata, short *stop, short *do_update, flo
// Construct the depsgraph for exporting.
Scene *scene = DEG_get_input_scene(data->depsgraph);
- {
- Timer deg_build_timer_("Building depsgraph for USD export");
- ViewLayer *view_layer = DEG_get_input_view_layer(data->depsgraph);
- DEG_graph_build_from_view_layer(data->depsgraph, data->bmain, scene, view_layer);
- BKE_scene_graph_update_tagged(data->depsgraph, data->bmain);
- }
+ ViewLayer *view_layer = DEG_get_input_view_layer(data->depsgraph);
+ DEG_graph_build_from_view_layer(data->depsgraph, data->bmain, scene, view_layer);
+ BKE_scene_graph_update_tagged(data->depsgraph, data->bmain);
// Constructing & evaluating the depsgraph counts as 10% of the work.
*progress = 0.1f;
@@ -93,59 +88,56 @@ static void export_startjob(void *customdata, short *stop, short *do_update, flo
// For restoring the current frame after exporting animation is done.
const int orig_frame = CFRA;
- {
- Timer usd_write_timer_("Writing to USD");
-
- // Create a stage and set up the metadata.
- pxr::UsdStageRefPtr usd_stage = pxr::UsdStage::CreateNew(data->filename);
- usd_stage->SetMetadata(pxr::UsdGeomTokens->upAxis, pxr::VtValue(pxr::UsdGeomTokens->z));
- usd_stage->SetMetadata(pxr::UsdGeomTokens->metersPerUnit,
- pxr::VtValue(scene->unit.scale_length));
- usd_stage->GetRootLayer()->SetDocumentation(std::string("Blender ") + versionstr);
-
- // Set up the stage for animated data.
- if (data->params.export_animation) {
- usd_stage->SetTimeCodesPerSecond(FPS);
- usd_stage->SetStartTimeCode(scene->r.sfra);
- usd_stage->SetEndTimeCode(scene->r.efra);
- }
-
- USDHierarchyIterator iter(data->depsgraph, usd_stage, data->params);
+ // Create a stage and set up the metadata.
+ pxr::UsdStageRefPtr usd_stage = pxr::UsdStage::CreateNew(data->filename);
+ usd_stage->SetMetadata(pxr::UsdGeomTokens->upAxis, pxr::VtValue(pxr::UsdGeomTokens->z));
+ usd_stage->SetMetadata(pxr::UsdGeomTokens->metersPerUnit,
+ pxr::VtValue(scene->unit.scale_length));
+ usd_stage->GetRootLayer()->SetDocumentation(std::string("Blender ") + versionstr);
+
+ // Set up the stage for animated data.
+ if (data->params.export_animation) {
+ usd_stage->SetTimeCodesPerSecond(FPS);
+ usd_stage->SetStartTimeCode(scene->r.sfra);
+ usd_stage->SetEndTimeCode(scene->r.efra);
+ }
- if (data->params.export_animation) {
- // Writing the animated frames is 80% of the work.
- float progress_per_frame = 0.8f / std::max(1, (scene->r.efra - scene->r.sfra + 1));
+ USDHierarchyIterator iter(data->depsgraph, usd_stage, data->params);
- for (float frame = scene->r.sfra; frame <= scene->r.efra; frame++) {
- if (G.is_break) {
- break;
- }
+ if (data->params.export_animation) {
+ // Writing the animated frames is 80% of the work.
+ float progress_per_frame = 0.8f / std::max(1, (scene->r.efra - scene->r.sfra + 1));
- // Update the scene for the next frame to render.
- scene->r.cfra = static_cast<int>(frame);
- scene->r.subframe = frame - scene->r.cfra;
- BKE_scene_graph_update_for_newframe(data->depsgraph, data->bmain);
+ for (float frame = scene->r.sfra; frame <= scene->r.efra; frame++) {
+ if (G.is_break) {
+ break;
+ }
- iter.set_export_frame(frame);
- iter.iterate();
+ // Update the scene for the next frame to render.
+ scene->r.cfra = static_cast<int>(frame);
+ scene->r.subframe = frame - scene->r.cfra;
+ BKE_scene_graph_update_for_newframe(data->depsgraph, data->bmain);
- *progress += progress_per_frame;
- *do_update = true;
- }
- }
- else {
- // If we're not animating, a single iteration over all objects is enough.
+ iter.set_export_frame(frame);
iter.iterate();
+
+ *progress += progress_per_frame;
+ *do_update = true;
}
+ }
+ else {
+ // If we're not animating, a single iteration over all objects is enough.
+ iter.iterate();
+ }
- iter.release_writers();
+ iter.release_writers();
- // Writing the final file is the other 10% of the work.
- *progress = 0.9f;
- *do_update = true;
- usd_stage->GetRootLayer()->Save();
- }
+ // Writing the final file is the other 10% of the work.
+ *progress = 0.9f;
+ *do_update = true;
+ usd_stage->GetRootLayer()->Save();
+ // Finish up by going back to the keyframe that was current before we started.
*progress = 0.99f;
*do_update = true;
More information about the Bf-blender-cvs
mailing list