Use Time singleton
parent
b96b27084c
commit
4d2fe30661
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <core/core_string_names.h>
|
||||
#include <core/object/undo_redo.h>
|
||||
#include <core/os/os.h>
|
||||
#include <core/os/time.h>
|
||||
#include <editor/editor_scale.h>
|
||||
#include <scene/gui/check_box.h>
|
||||
#include <scene/gui/dialogs.h>
|
||||
|
@ -706,7 +706,7 @@ void VoxelGraphEditor::update_previews() {
|
|||
clear_range_analysis_tooltips();
|
||||
reset_modulates(*_graph_edit);
|
||||
|
||||
uint64_t time_before = OS::get_singleton()->get_ticks_usec();
|
||||
uint64_t time_before = Time::get_singleton()->get_ticks_usec();
|
||||
|
||||
const VoxelGraphRuntime::CompilationResult result = _graph->compile();
|
||||
if (!result.success) {
|
||||
|
@ -741,7 +741,7 @@ void VoxelGraphEditor::update_previews() {
|
|||
update_range_analysis_previews();
|
||||
}
|
||||
|
||||
uint64_t time_taken = OS::get_singleton()->get_ticks_usec() - time_before;
|
||||
uint64_t time_taken = Time::get_singleton()->get_ticks_usec() - time_before;
|
||||
PRINT_VERBOSE(String("Previews generated in {0} us").format(varray(time_taken)));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
#include "voxel_library.h"
|
||||
#include "../../util/macros.h"
|
||||
|
||||
#include <core/math/geometry_2d.h>
|
||||
#include <core/os/time.h>
|
||||
|
||||
#include <bitset>
|
||||
|
||||
VoxelLibrary::VoxelLibrary() {}
|
||||
|
@ -156,7 +159,7 @@ template <typename F> static void rasterize_triangle_barycentric(Vector2 a, Vect
|
|||
void VoxelLibrary::bake() {
|
||||
RWLockWrite lock(_baked_data_rw_lock);
|
||||
|
||||
const uint64_t time_before = OS::get_singleton()->get_ticks_usec();
|
||||
const uint64_t time_before = Time::get_singleton()->get_ticks_usec();
|
||||
|
||||
// This is the only place we modify the data.
|
||||
|
||||
|
@ -172,7 +175,7 @@ void VoxelLibrary::bake() {
|
|||
|
||||
generate_side_culling_matrix();
|
||||
|
||||
uint64_t time_spent = OS::get_singleton()->get_ticks_usec() - time_before;
|
||||
uint64_t time_spent = Time::get_singleton()->get_ticks_usec() - time_before;
|
||||
PRINT_VERBOSE(String("Took {0} us to bake VoxelLibrary").format(varray(time_spent)));
|
||||
}
|
||||
|
||||
|
|
|
@ -117,8 +117,8 @@ static void generate_blocky_mesh(
|
|||
corner_neighbor_lut[Cube::CORNER_TOP_FRONT_LEFT] = side_neighbor_lut[Cube::SIDE_TOP] +
|
||||
side_neighbor_lut[Cube::SIDE_FRONT] + side_neighbor_lut[Cube::SIDE_LEFT];
|
||||
|
||||
//uint64_t time_prep = OS::get_singleton()->get_ticks_usec() - time_before;
|
||||
//time_before = OS::get_singleton()->get_ticks_usec();
|
||||
//uint64_t time_prep = Time::get_singleton()->get_ticks_usec() - time_before;
|
||||
//time_before = Time::get_singleton()->get_ticks_usec();
|
||||
|
||||
for (unsigned int z = min.z; z < (unsigned int)max.z; ++z) {
|
||||
for (unsigned int x = min.x; x < (unsigned int)max.x; ++x) {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include "../../constants/octree_tables.h"
|
||||
#include "marching_cubes_tables.h"
|
||||
#include "mesh_builder.h"
|
||||
#include <core/os/os.h>
|
||||
#include <core/os/time.h>
|
||||
|
||||
// Dual marching cubes
|
||||
// Algorithm taken from https://www.volume-gfx.com/volume-rendering/dual-marching-cubes/
|
||||
|
@ -1430,7 +1430,7 @@ void VoxelMesherDMC::build(VoxelMesher::Output &output, const VoxelMesher::Input
|
|||
dmc::VoxelAccess voxels_access(voxels, Vector3iUtil::create(PADDING));
|
||||
|
||||
Stats stats;
|
||||
real_t time_before = OS::get_singleton()->get_ticks_usec();
|
||||
real_t time_before = Time::get_singleton()->get_ticks_usec();
|
||||
|
||||
Cache &cache = _cache;
|
||||
|
||||
|
@ -1461,7 +1461,7 @@ void VoxelMesherDMC::build(VoxelMesher::Output &output, const VoxelMesher::Input
|
|||
root = octree_builder.build(Vector3i(), chunk_size);
|
||||
}
|
||||
|
||||
stats.octree_build_time = OS::get_singleton()->get_ticks_usec() - time_before;
|
||||
stats.octree_build_time = Time::get_singleton()->get_ticks_usec() - time_before;
|
||||
|
||||
Array surface;
|
||||
|
||||
|
@ -1470,21 +1470,21 @@ void VoxelMesherDMC::build(VoxelMesher::Output &output, const VoxelMesher::Input
|
|||
surface = dmc::generate_debug_octree_mesh(root, 1 << input.lod);
|
||||
|
||||
} else {
|
||||
time_before = OS::get_singleton()->get_ticks_usec();
|
||||
time_before = Time::get_singleton()->get_ticks_usec();
|
||||
|
||||
dmc::DualGridGenerator dual_grid_generator(cache.dual_grid, root->size);
|
||||
dual_grid_generator.node_proc(root);
|
||||
// TODO Handle non-subdivided octree
|
||||
|
||||
stats.dualgrid_derivation_time = OS::get_singleton()->get_ticks_usec() - time_before;
|
||||
stats.dualgrid_derivation_time = Time::get_singleton()->get_ticks_usec() - time_before;
|
||||
|
||||
if (params.mesh_mode == MESH_DEBUG_DUAL_GRID) {
|
||||
surface = dmc::generate_debug_dual_grid_mesh(cache.dual_grid, 1 << input.lod);
|
||||
|
||||
} else {
|
||||
time_before = OS::get_singleton()->get_ticks_usec();
|
||||
time_before = Time::get_singleton()->get_ticks_usec();
|
||||
dmc::polygonize_dual_grid(cache.dual_grid, voxels_access, cache.mesh_builder, skirts_enabled);
|
||||
stats.meshing_time = OS::get_singleton()->get_ticks_usec() - time_before;
|
||||
stats.meshing_time = Time::get_singleton()->get_ticks_usec() - time_before;
|
||||
}
|
||||
|
||||
cache.dual_grid.cells.clear();
|
||||
|
@ -1495,19 +1495,19 @@ void VoxelMesherDMC::build(VoxelMesher::Output &output, const VoxelMesher::Input
|
|||
} else if (params.simplify_mode == SIMPLIFY_NONE) {
|
||||
// We throw away adaptivity for meshing speed.
|
||||
// This is essentially regular marching cubes.
|
||||
time_before = OS::get_singleton()->get_ticks_usec();
|
||||
time_before = Time::get_singleton()->get_ticks_usec();
|
||||
dmc::polygonize_volume_directly(voxels, Vector3iUtil::create(PADDING), Vector3iUtil::create(chunk_size),
|
||||
cache.mesh_builder, skirts_enabled);
|
||||
stats.meshing_time = OS::get_singleton()->get_ticks_usec() - time_before;
|
||||
stats.meshing_time = Time::get_singleton()->get_ticks_usec() - time_before;
|
||||
}
|
||||
|
||||
if (surface.is_empty()) {
|
||||
time_before = OS::get_singleton()->get_ticks_usec();
|
||||
time_before = Time::get_singleton()->get_ticks_usec();
|
||||
if (input.lod > 0) {
|
||||
cache.mesh_builder.scale(1 << input.lod);
|
||||
}
|
||||
surface = cache.mesh_builder.commit(params.mesh_mode == MESH_WIREFRAME);
|
||||
stats.commit_time = OS::get_singleton()->get_ticks_usec() - time_before;
|
||||
stats.commit_time = Time::get_singleton()->get_ticks_usec() - time_before;
|
||||
}
|
||||
|
||||
// surfaces[material][array_type], for now single material
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "../util/profiling.h"
|
||||
|
||||
#include <core/os/os.h>
|
||||
#include <core/os/time.h>
|
||||
|
||||
// template <typename T>
|
||||
// static bool contains(const std::vector<T> vec, T v) {
|
||||
|
@ -137,7 +138,7 @@ void VoxelThreadPool::thread_func(ThreadData &data) {
|
|||
VOXEL_PROFILE_SCOPE();
|
||||
|
||||
data.debug_state = STATE_PICKING;
|
||||
const uint32_t now = OS::get_singleton()->get_ticks_msec();
|
||||
const uint32_t now = Time::get_singleton()->get_ticks_msec();
|
||||
|
||||
MutexLock lock(_tasks_mutex);
|
||||
|
||||
|
@ -232,7 +233,7 @@ void VoxelThreadPool::thread_func(ThreadData &data) {
|
|||
void VoxelThreadPool::wait_for_all_tasks() {
|
||||
const uint32_t suspicious_delay_msec = 10000;
|
||||
|
||||
uint32_t before = OS::get_singleton()->get_ticks_msec();
|
||||
uint32_t before = Time::get_singleton()->get_ticks_msec();
|
||||
bool error1_reported = false;
|
||||
|
||||
// Wait until all tasks have been taken
|
||||
|
@ -246,13 +247,13 @@ void VoxelThreadPool::wait_for_all_tasks() {
|
|||
|
||||
OS::get_singleton()->delay_usec(2000);
|
||||
|
||||
if (!error1_reported && OS::get_singleton()->get_ticks_msec() - before > suspicious_delay_msec) {
|
||||
if (!error1_reported && Time::get_singleton()->get_ticks_msec() - before > suspicious_delay_msec) {
|
||||
WARN_PRINT("Waiting for all tasks to be picked is taking a long time");
|
||||
error1_reported = true;
|
||||
}
|
||||
}
|
||||
|
||||
before = OS::get_singleton()->get_ticks_msec();
|
||||
before = Time::get_singleton()->get_ticks_msec();
|
||||
bool error2_reported = false;
|
||||
|
||||
// Wait until all threads have done all their tasks
|
||||
|
@ -269,7 +270,7 @@ void VoxelThreadPool::wait_for_all_tasks() {
|
|||
|
||||
OS::get_singleton()->delay_usec(2000);
|
||||
|
||||
if (!error2_reported && OS::get_singleton()->get_ticks_msec() - before > suspicious_delay_msec) {
|
||||
if (!error2_reported && Time::get_singleton()->get_ticks_msec() - before > suspicious_delay_msec) {
|
||||
WARN_PRINT("Waiting for all tasks to be completed is taking a long time");
|
||||
error2_reported = true;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "../../util/profiling.h"
|
||||
|
||||
#include <core/io/json.h>
|
||||
#include <core/os/os.h>
|
||||
#include <core/os/time.h>
|
||||
#include <algorithm>
|
||||
|
||||
namespace {
|
||||
|
@ -510,7 +510,7 @@ VoxelStreamRegionFiles::CachedRegion *VoxelStreamRegionFiles::open_region(
|
|||
_region_cache.push_back(cached_region);
|
||||
|
||||
cached_region->file_exists = true;
|
||||
cached_region->last_opened = OS::get_singleton()->get_ticks_usec();
|
||||
cached_region->last_opened = Time::get_singleton()->get_ticks_usec();
|
||||
|
||||
return cached_region;
|
||||
}
|
||||
|
@ -529,7 +529,7 @@ void VoxelStreamRegionFiles::close_oldest_region() {
|
|||
|
||||
int oldest_index = -1;
|
||||
uint64_t oldest_time = 0;
|
||||
const uint64_t now = OS::get_singleton()->get_ticks_usec();
|
||||
const uint64_t now = Time::get_singleton()->get_ticks_usec();
|
||||
|
||||
for (unsigned int i = 0; i < _region_cache.size(); ++i) {
|
||||
const CachedRegion *r = _region_cache[i];
|
||||
|
|
|
@ -138,7 +138,7 @@ struct ScheduleSaveAction {
|
|||
};
|
||||
|
||||
static inline uint64_t get_ticks_msec() {
|
||||
return OS::get_singleton()->get_ticks_msec();
|
||||
return Time::get_singleton()->get_ticks_msec();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef PROFILING_CLOCK_H
|
||||
#define PROFILING_CLOCK_H
|
||||
|
||||
#include <core/os/os.h>
|
||||
#include <core/os/time.h>
|
||||
|
||||
struct ProfilingClock {
|
||||
uint64_t time_before = 0;
|
||||
|
@ -11,9 +11,9 @@ struct ProfilingClock {
|
|||
}
|
||||
|
||||
uint64_t restart() {
|
||||
uint64_t now = OS::get_singleton()->get_ticks_usec();
|
||||
uint64_t time_spent = now - time_before;
|
||||
time_before = OS::get_singleton()->get_ticks_usec();
|
||||
const uint64_t now = Time::get_singleton()->get_ticks_usec();
|
||||
const uint64_t time_spent = now - time_before;
|
||||
time_before = Time::get_singleton()->get_ticks_usec();
|
||||
return time_spent;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue