Changed prefix of profiling macros
This commit is contained in:
parent
adb2cd2fe9
commit
219c7bfda3
@ -260,7 +260,7 @@ You need to include `utility/profiling.h` to access the macros.
|
||||
To profile a whole function:
|
||||
```cpp
|
||||
void some_function() {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
//...
|
||||
}
|
||||
```
|
||||
@ -272,7 +272,7 @@ void some_function() {
|
||||
|
||||
// Could be an `if`, `for`, `while`, or a simple block as here
|
||||
{
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
// Profiled code...
|
||||
}
|
||||
|
||||
@ -280,7 +280,7 @@ void some_function() {
|
||||
}
|
||||
```
|
||||
|
||||
By default scopes take the name of the function, or file and a line number, but you can give a name explicitely using `VOXEL_PROFILE_SCOPE_NAMED("Hello")`. Only compile-time strings are supported, don't use `String` or `std::string`.
|
||||
By default scopes take the name of the function, or file and a line number, but you can give a name explicitely using `ZN_PROFILE_SCOPE_NAMED("Hello")`. Only compile-time strings are supported, don't use `String` or `std::string`.
|
||||
|
||||
It is also possible to plot numeric values so they are displayed in the timeline too:
|
||||
|
||||
@ -288,7 +288,7 @@ It is also possible to plot numeric values so they are displayed in the timeline
|
||||
void process_every_frame() {
|
||||
// Some code...
|
||||
|
||||
VOXEL_PROFILE_PLOT("Bunnies", bunnies.size());
|
||||
ZN_PROFILE_PLOT("Bunnies", bunnies.size());
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -179,7 +179,7 @@ inline float sdf_blend(float src_value, float dst_value, VoxelTool::Mode mode) {
|
||||
} // namespace
|
||||
|
||||
void VoxelTool::do_sphere(Vector3 center, float radius) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
const Box3i box(Vector3iUtil::from_floored(center) - Vector3iUtil::create(Math::floor(radius)),
|
||||
Vector3iUtil::create(Math::ceil(radius) * 2));
|
||||
@ -211,7 +211,7 @@ void VoxelTool::do_sphere(Vector3 center, float radius) {
|
||||
|
||||
// Erases matter in every voxel where the provided buffer has matter.
|
||||
void VoxelTool::sdf_stamp_erase(Ref<gd::VoxelBuffer> stamp, Vector3i pos) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
ERR_FAIL_COND_MSG(
|
||||
get_channel() != VoxelBufferInternal::CHANNEL_SDF, "This function only works when channel is set to SDF");
|
||||
|
||||
@ -234,7 +234,7 @@ void VoxelTool::sdf_stamp_erase(Ref<gd::VoxelBuffer> stamp, Vector3i pos) {
|
||||
}
|
||||
|
||||
void VoxelTool::do_box(Vector3i begin, Vector3i end) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
Vector3iUtil::sort_min_max(begin, end);
|
||||
Box3i box = Box3i::from_min_max(begin, end + Vector3i(1, 1, 1));
|
||||
|
||||
|
@ -24,7 +24,7 @@ void VoxelToolBuffer::do_sphere(Vector3 center, float radius) {
|
||||
return;
|
||||
}
|
||||
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
Box3i box(Vector3iUtil::from_floored(center) - Vector3iUtil::create(Math::floor(radius)),
|
||||
Vector3iUtil::create(Math::ceil(radius) * 2));
|
||||
|
@ -177,7 +177,7 @@ struct DoSphere {
|
||||
TextureParams texture_params;
|
||||
|
||||
void operator()() {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
switch (mode) {
|
||||
case VoxelTool::MODE_ADD: {
|
||||
@ -220,7 +220,7 @@ struct DoSphere {
|
||||
} //namespace ops
|
||||
|
||||
void VoxelToolLodTerrain::do_sphere(Vector3 center, float radius) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
ERR_FAIL_COND(_terrain == nullptr);
|
||||
|
||||
const Box3i box = Box3i(Vector3iUtil::from_floored(center) - Vector3iUtil::create(Math::floor(radius)),
|
||||
@ -264,7 +264,7 @@ public:
|
||||
}
|
||||
|
||||
void run(ThreadedTaskContext ctx) override {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
CRASH_COND(_data == nullptr);
|
||||
VoxelDataLodMap::Lod &data_lod = _data->lods[0];
|
||||
{
|
||||
@ -391,7 +391,7 @@ void VoxelToolLodTerrain::set_raycast_binary_search_iterations(int iterations) {
|
||||
// so there are probably other approaches that could be explored in the future, if they have better performance
|
||||
Array separate_floating_chunks(VoxelTool &voxel_tool, Box3i world_box, Node *parent_node, Transform3D transform,
|
||||
Ref<VoxelMesher> mesher, Array materials) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
// Checks
|
||||
ERR_FAIL_COND_V(mesher.is_null(), Array());
|
||||
@ -406,7 +406,7 @@ Array separate_floating_chunks(VoxelTool &voxel_tool, Box3i world_box, Node *par
|
||||
// TODO We should be able to use `VoxelBufferInternal`, just needs some things exposed
|
||||
Ref<gd::VoxelBuffer> source_copy_buffer_ref;
|
||||
{
|
||||
VOXEL_PROFILE_SCOPE_NAMED("Copy");
|
||||
ZN_PROFILE_SCOPE_NAMED("Copy");
|
||||
source_copy_buffer_ref.instantiate();
|
||||
source_copy_buffer_ref->create(world_box.size.x, world_box.size.y, world_box.size.z);
|
||||
voxel_tool.copy(world_box.pos, source_copy_buffer_ref, channels_mask);
|
||||
@ -422,7 +422,7 @@ Array separate_floating_chunks(VoxelTool &voxel_tool, Box3i world_box, Node *par
|
||||
|
||||
{
|
||||
// TODO Allow to run the algorithm at a different LOD, to trade precision for speed
|
||||
VOXEL_PROFILE_SCOPE_NAMED("CCL scan");
|
||||
ZN_PROFILE_SCOPE_NAMED("CCL scan");
|
||||
IslandFinder island_finder;
|
||||
island_finder.scan_3d(
|
||||
Box3i(Vector3i(), world_box.size),
|
||||
@ -443,7 +443,7 @@ Array separate_floating_chunks(VoxelTool &voxel_tool, Box3i world_box, Node *par
|
||||
|
||||
std::vector<Bounds> bounds_per_label;
|
||||
{
|
||||
VOXEL_PROFILE_SCOPE_NAMED("Bounds calculation");
|
||||
ZN_PROFILE_SCOPE_NAMED("Bounds calculation");
|
||||
|
||||
// Adding 1 because label 0 is the index for "no label"
|
||||
bounds_per_label.resize(label_count + 1);
|
||||
@ -522,7 +522,7 @@ Array separate_floating_chunks(VoxelTool &voxel_tool, Box3i world_box, Node *par
|
||||
const int max_padding = 2; //mesher->get_maximum_padding();
|
||||
|
||||
{
|
||||
VOXEL_PROFILE_SCOPE_NAMED("Extraction");
|
||||
ZN_PROFILE_SCOPE_NAMED("Extraction");
|
||||
|
||||
for (unsigned int label = 1; label < bounds_per_label.size(); ++label) {
|
||||
CRASH_COND(label >= bounds_per_label.size());
|
||||
@ -578,7 +578,7 @@ Array separate_floating_chunks(VoxelTool &voxel_tool, Box3i world_box, Node *par
|
||||
// Must be done after we copied voxels from it.
|
||||
|
||||
{
|
||||
VOXEL_PROFILE_SCOPE_NAMED("Erasing");
|
||||
ZN_PROFILE_SCOPE_NAMED("Erasing");
|
||||
|
||||
voxel_tool.set_channel(main_channel);
|
||||
|
||||
@ -596,7 +596,7 @@ Array separate_floating_chunks(VoxelTool &voxel_tool, Box3i world_box, Node *par
|
||||
Array nodes;
|
||||
|
||||
{
|
||||
VOXEL_PROFILE_SCOPE_NAMED("Remeshing and instancing");
|
||||
ZN_PROFILE_SCOPE_NAMED("Remeshing and instancing");
|
||||
|
||||
for (unsigned int instance_index = 0; instance_index < instances_info.size(); ++instance_index) {
|
||||
CRASH_COND(instance_index >= instances_info.size());
|
||||
|
@ -164,7 +164,7 @@ void VoxelToolTerrain::do_sphere(Vector3 center, float radius) {
|
||||
return;
|
||||
}
|
||||
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
const Box3i box(Vector3iUtil::from_floored(center) - Vector3iUtil::create(Math::floor(radius)),
|
||||
Vector3iUtil::create(Math::ceil(radius) * 2));
|
||||
@ -322,7 +322,7 @@ void VoxelToolTerrain::run_blocky_random_tick_static(VoxelDataMap &map, Box3i vo
|
||||
// slow "natural" cellular automata behavior, as can be seen in Minecraft.
|
||||
void VoxelToolTerrain::run_blocky_random_tick(
|
||||
AABB voxel_area, int voxel_count, const Callable &callback, int batch_count) const {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
ERR_FAIL_COND(_terrain == nullptr);
|
||||
ERR_FAIL_COND_MSG(
|
||||
|
@ -353,7 +353,7 @@ Error VoxelVoxMeshImporter::import(const String &p_source_file, const String &p_
|
||||
|
||||
// Save mesh
|
||||
{
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
String mesh_save_path = String("{0}.mesh").format(varray(p_save_path));
|
||||
const Error mesh_save_err = ResourceSaver::save(mesh_save_path, mesh);
|
||||
ERR_FAIL_COND_V_MSG(
|
||||
|
@ -239,7 +239,7 @@ static Error process_scene_node_recursively(const Data &data, int node_id, Node3
|
||||
Error VoxelVoxSceneImporter::import(const String &p_source_file, const String &p_save_path,
|
||||
const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files,
|
||||
Variant *r_metadata) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
const bool p_store_colors_in_textures = p_options[VoxelStringNames::get_singleton().store_colors_in_texture];
|
||||
const float p_scale = p_options[VoxelStringNames::get_singleton().scale];
|
||||
@ -370,7 +370,7 @@ Error VoxelVoxSceneImporter::import(const String &p_source_file, const String &p
|
||||
|
||||
// Save meshes
|
||||
for (unsigned int model_index = 0; model_index < meshes.size(); ++model_index) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
Ref<Mesh> mesh = meshes[model_index].mesh;
|
||||
String res_save_path = String("{0}.model{1}.mesh").format(varray(p_save_path, model_index));
|
||||
// `FLAG_CHANGE_PATH` did not do what I thought it did.
|
||||
@ -384,7 +384,7 @@ Error VoxelVoxSceneImporter::import(const String &p_source_file, const String &p
|
||||
|
||||
// Save scene
|
||||
{
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
Ref<PackedScene> scene;
|
||||
scene.instantiate();
|
||||
scene->pack(root_node);
|
||||
|
@ -375,7 +375,7 @@ bool VoxelGeneratorGraph::is_using_xz_caching() const {
|
||||
void VoxelGeneratorGraph::gather_indices_and_weights(Span<const WeightOutput> weight_outputs,
|
||||
const VoxelGraphRuntime::State &state, Vector3i rmin, Vector3i rmax, int ry,
|
||||
VoxelBufferInternal &out_voxel_buffer, FixedArray<uint8_t, 4> spare_indices) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
// TODO Optimization: exclude up-front outputs that are known to be zero?
|
||||
// So we choose the cases below based on non-zero outputs instead of total output count
|
||||
@ -491,7 +491,7 @@ void VoxelGeneratorGraph::gather_indices_and_weights(Span<const WeightOutput> we
|
||||
void gather_indices_and_weights_from_single_texture(unsigned int output_buffer_index,
|
||||
const VoxelGraphRuntime::State &state, Vector3i rmin, Vector3i rmax, int ry,
|
||||
VoxelBufferInternal &out_voxel_buffer) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
const VoxelGraphRuntime::Buffer &buffer = state.get_buffer(output_buffer_index);
|
||||
Span<const float> buffer_data = Span<const float>(buffer.data, buffer.size);
|
||||
@ -531,7 +531,7 @@ void fill_zx_sdf_slice(Span<Data_T> channel_data, float sdf_scale, Vector3i rmin
|
||||
static void fill_zx_sdf_slice(const VoxelGraphRuntime::Buffer &sdf_buffer, VoxelBufferInternal &out_buffer,
|
||||
unsigned int channel, VoxelBufferInternal::Depth channel_depth, float sdf_scale, Vector3i rmin, Vector3i rmax,
|
||||
int ry) {
|
||||
VOXEL_PROFILE_SCOPE_NAMED("Copy SDF to block");
|
||||
ZN_PROFILE_SCOPE_NAMED("Copy SDF to block");
|
||||
|
||||
if (out_buffer.get_channel_compression(channel) != VoxelBufferInternal::COMPRESSION_NONE) {
|
||||
out_buffer.decompress_channel(channel);
|
||||
@ -585,7 +585,7 @@ void fill_zx_integer_slice(Span<Data_T> channel_data, Vector3i rmin, Vector3i rm
|
||||
|
||||
static void fill_zx_integer_slice(const VoxelGraphRuntime::Buffer &src_buffer, VoxelBufferInternal &out_buffer,
|
||||
unsigned int channel, VoxelBufferInternal::Depth channel_depth, Vector3i rmin, Vector3i rmax, int ry) {
|
||||
VOXEL_PROFILE_SCOPE_NAMED("Copy integer data to block");
|
||||
ZN_PROFILE_SCOPE_NAMED("Copy integer data to block");
|
||||
|
||||
if (out_buffer.get_channel_compression(channel) != VoxelBufferInternal::COMPRESSION_NONE) {
|
||||
out_buffer.decompress_channel(channel);
|
||||
@ -697,7 +697,7 @@ VoxelGenerator::Result VoxelGeneratorGraph::generate_block(VoxelGenerator::Voxel
|
||||
for (int sz = 0; sz < bs.z; sz += section_size.z) {
|
||||
for (int sy = 0; sy < bs.y; sy += section_size.y) {
|
||||
for (int sx = 0; sx < bs.x; sx += section_size.x) {
|
||||
VOXEL_PROFILE_SCOPE_NAMED("Section");
|
||||
ZN_PROFILE_SCOPE_NAMED("Section");
|
||||
|
||||
const Vector3i rmin(sx, sy, sz);
|
||||
const Vector3i rmax = rmin + Vector3i(section_size);
|
||||
@ -791,7 +791,7 @@ VoxelGenerator::Result VoxelGeneratorGraph::generate_block(VoxelGenerator::Voxel
|
||||
}
|
||||
|
||||
for (int ry = rmin.y, gy = gmin.y; ry < rmax.y; ++ry, gy += stride) {
|
||||
VOXEL_PROFILE_SCOPE_NAMED("Full slice");
|
||||
ZN_PROFILE_SCOPE_NAMED("Full slice");
|
||||
|
||||
y_cache.fill(gy);
|
||||
|
||||
@ -1134,7 +1134,7 @@ void VoxelGeneratorGraph::bake_sphere_bumpmap(Ref<Image> im, float ref_radius, f
|
||||
sdf_max(p_sdf_max) {}
|
||||
|
||||
void operator()(int x0, int y0, int width, int height) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
const unsigned int area = width * height;
|
||||
x_coords.resize(area);
|
||||
@ -1191,7 +1191,7 @@ void VoxelGeneratorGraph::bake_sphere_bumpmap(Ref<Image> im, float ref_radius, f
|
||||
// then this function can be used to bake a map of the surface.
|
||||
// Such maps can be used by shaders to sharpen the details of the planet when seen from far away.
|
||||
void VoxelGeneratorGraph::bake_sphere_normalmap(Ref<Image> im, float ref_radius, float strength) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
ERR_FAIL_COND(im.is_null());
|
||||
|
||||
std::shared_ptr<const Runtime> runtime_ptr;
|
||||
@ -1229,7 +1229,7 @@ void VoxelGeneratorGraph::bake_sphere_normalmap(Ref<Image> im, float ref_radius,
|
||||
ref_radius(p_ref_radius) {}
|
||||
|
||||
void operator()(int x0, int y0, int width, int height) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
const unsigned int area = width * height;
|
||||
x_coords.resize(area);
|
||||
|
@ -918,7 +918,7 @@ VoxelGraphNodeDB::VoxelGraphNodeDB() {
|
||||
ctx.add_memdelete_cleanup(curve_range_data);
|
||||
};
|
||||
t.process_buffer_func = [](ProcessBufferContext &ctx) {
|
||||
VOXEL_PROFILE_SCOPE_NAMED("NODE_CURVE");
|
||||
ZN_PROFILE_SCOPE_NAMED("NODE_CURVE");
|
||||
const VoxelGraphRuntime::Buffer &a = ctx.get_input(0);
|
||||
VoxelGraphRuntime::Buffer &out = ctx.get_output(0);
|
||||
const Params p = ctx.get_params<Params>();
|
||||
@ -965,7 +965,7 @@ VoxelGraphNodeDB::VoxelGraphNodeDB() {
|
||||
};
|
||||
|
||||
t.process_buffer_func = [](ProcessBufferContext &ctx) {
|
||||
VOXEL_PROFILE_SCOPE_NAMED("NODE_NOISE_2D");
|
||||
ZN_PROFILE_SCOPE_NAMED("NODE_NOISE_2D");
|
||||
const VoxelGraphRuntime::Buffer &x = ctx.get_input(0);
|
||||
const VoxelGraphRuntime::Buffer &y = ctx.get_input(1);
|
||||
VoxelGraphRuntime::Buffer &out = ctx.get_output(0);
|
||||
@ -1011,7 +1011,7 @@ VoxelGraphNodeDB::VoxelGraphNodeDB() {
|
||||
};
|
||||
|
||||
t.process_buffer_func = [](ProcessBufferContext &ctx) {
|
||||
VOXEL_PROFILE_SCOPE_NAMED("NODE_NOISE_3D");
|
||||
ZN_PROFILE_SCOPE_NAMED("NODE_NOISE_3D");
|
||||
const VoxelGraphRuntime::Buffer &x = ctx.get_input(0);
|
||||
const VoxelGraphRuntime::Buffer &y = ctx.get_input(1);
|
||||
const VoxelGraphRuntime::Buffer &z = ctx.get_input(2);
|
||||
@ -1063,7 +1063,7 @@ VoxelGraphNodeDB::VoxelGraphNodeDB() {
|
||||
ctx.add_memdelete_cleanup(im_range);
|
||||
};
|
||||
t.process_buffer_func = [](ProcessBufferContext &ctx) {
|
||||
VOXEL_PROFILE_SCOPE_NAMED("NODE_IMAGE_2D");
|
||||
ZN_PROFILE_SCOPE_NAMED("NODE_IMAGE_2D");
|
||||
const VoxelGraphRuntime::Buffer &x = ctx.get_input(0);
|
||||
const VoxelGraphRuntime::Buffer &y = ctx.get_input(1);
|
||||
VoxelGraphRuntime::Buffer &out = ctx.get_output(0);
|
||||
@ -1205,7 +1205,7 @@ VoxelGraphNodeDB::VoxelGraphNodeDB() {
|
||||
ctx.set_params(p);
|
||||
};
|
||||
t.process_buffer_func = [](ProcessBufferContext &ctx) {
|
||||
VOXEL_PROFILE_SCOPE_NAMED("NODE_SDF_SMOOTH_UNION");
|
||||
ZN_PROFILE_SCOPE_NAMED("NODE_SDF_SMOOTH_UNION");
|
||||
bool a_ignored;
|
||||
bool b_ignored;
|
||||
const VoxelGraphRuntime::Buffer &a = ctx.try_get_input(0, a_ignored);
|
||||
@ -1290,7 +1290,7 @@ VoxelGraphNodeDB::VoxelGraphNodeDB() {
|
||||
ctx.set_params(p);
|
||||
};
|
||||
t.process_buffer_func = [](ProcessBufferContext &ctx) {
|
||||
VOXEL_PROFILE_SCOPE_NAMED("NODE_SDF_SMOOTH_SUBTRACT");
|
||||
ZN_PROFILE_SCOPE_NAMED("NODE_SDF_SMOOTH_SUBTRACT");
|
||||
bool a_ignored;
|
||||
bool b_ignored;
|
||||
const VoxelGraphRuntime::Buffer &a = ctx.try_get_input(0, a_ignored);
|
||||
@ -1493,7 +1493,7 @@ VoxelGraphNodeDB::VoxelGraphNodeDB() {
|
||||
};
|
||||
|
||||
t.process_buffer_func = [](ProcessBufferContext &ctx) {
|
||||
VOXEL_PROFILE_SCOPE_NAMED("NODE_SDF_SPHERE_HEIGHTMAP");
|
||||
ZN_PROFILE_SCOPE_NAMED("NODE_SDF_SPHERE_HEIGHTMAP");
|
||||
const VoxelGraphRuntime::Buffer &x = ctx.get_input(0);
|
||||
const VoxelGraphRuntime::Buffer &y = ctx.get_input(1);
|
||||
const VoxelGraphRuntime::Buffer &z = ctx.get_input(2);
|
||||
@ -1529,7 +1529,7 @@ VoxelGraphNodeDB::VoxelGraphNodeDB() {
|
||||
t.outputs.push_back(Port("len"));
|
||||
|
||||
t.process_buffer_func = [](ProcessBufferContext &ctx) {
|
||||
VOXEL_PROFILE_SCOPE_NAMED("NODE_NORMALIZE_3D");
|
||||
ZN_PROFILE_SCOPE_NAMED("NODE_NORMALIZE_3D");
|
||||
const VoxelGraphRuntime::Buffer &xb = ctx.get_input(0);
|
||||
const VoxelGraphRuntime::Buffer &yb = ctx.get_input(1);
|
||||
const VoxelGraphRuntime::Buffer &zb = ctx.get_input(2);
|
||||
@ -1590,7 +1590,7 @@ VoxelGraphNodeDB::VoxelGraphNodeDB() {
|
||||
};
|
||||
|
||||
t.process_buffer_func = [](ProcessBufferContext &ctx) {
|
||||
VOXEL_PROFILE_SCOPE_NAMED("NODE_FAST_NOISE_2D");
|
||||
ZN_PROFILE_SCOPE_NAMED("NODE_FAST_NOISE_2D");
|
||||
const VoxelGraphRuntime::Buffer &x = ctx.get_input(0);
|
||||
const VoxelGraphRuntime::Buffer &y = ctx.get_input(1);
|
||||
VoxelGraphRuntime::Buffer &out = ctx.get_output(0);
|
||||
@ -1635,7 +1635,7 @@ VoxelGraphNodeDB::VoxelGraphNodeDB() {
|
||||
};
|
||||
|
||||
t.process_buffer_func = [](ProcessBufferContext &ctx) {
|
||||
VOXEL_PROFILE_SCOPE_NAMED("NODE_FAST_NOISE_3D");
|
||||
ZN_PROFILE_SCOPE_NAMED("NODE_FAST_NOISE_3D");
|
||||
const VoxelGraphRuntime::Buffer &x = ctx.get_input(0);
|
||||
const VoxelGraphRuntime::Buffer &y = ctx.get_input(1);
|
||||
const VoxelGraphRuntime::Buffer &z = ctx.get_input(2);
|
||||
@ -1682,7 +1682,7 @@ VoxelGraphNodeDB::VoxelGraphNodeDB() {
|
||||
};
|
||||
|
||||
t.process_buffer_func = [](ProcessBufferContext &ctx) {
|
||||
VOXEL_PROFILE_SCOPE_NAMED("NODE_FAST_NOISE_GRADIENT_2D");
|
||||
ZN_PROFILE_SCOPE_NAMED("NODE_FAST_NOISE_GRADIENT_2D");
|
||||
const VoxelGraphRuntime::Buffer &xb = ctx.get_input(0);
|
||||
const VoxelGraphRuntime::Buffer &yb = ctx.get_input(1);
|
||||
VoxelGraphRuntime::Buffer &out_x = ctx.get_output(0);
|
||||
@ -1736,7 +1736,7 @@ VoxelGraphNodeDB::VoxelGraphNodeDB() {
|
||||
};
|
||||
|
||||
t.process_buffer_func = [](ProcessBufferContext &ctx) {
|
||||
VOXEL_PROFILE_SCOPE_NAMED("NODE_FAST_NOISE_GRADIENT_3D");
|
||||
ZN_PROFILE_SCOPE_NAMED("NODE_FAST_NOISE_GRADIENT_3D");
|
||||
const VoxelGraphRuntime::Buffer &xb = ctx.get_input(0);
|
||||
const VoxelGraphRuntime::Buffer &yb = ctx.get_input(1);
|
||||
const VoxelGraphRuntime::Buffer &zb = ctx.get_input(2);
|
||||
@ -1798,7 +1798,7 @@ VoxelGraphNodeDB::VoxelGraphNodeDB() {
|
||||
};
|
||||
|
||||
t.process_buffer_func = [](ProcessBufferContext &ctx) {
|
||||
VOXEL_PROFILE_SCOPE_NAMED("NODE_FAST_NOISE_2_2D");
|
||||
ZN_PROFILE_SCOPE_NAMED("NODE_FAST_NOISE_2_2D");
|
||||
const VoxelGraphRuntime::Buffer &x = ctx.get_input(0);
|
||||
const VoxelGraphRuntime::Buffer &y = ctx.get_input(1);
|
||||
VoxelGraphRuntime::Buffer &out = ctx.get_output(0);
|
||||
@ -1846,7 +1846,7 @@ VoxelGraphNodeDB::VoxelGraphNodeDB() {
|
||||
};
|
||||
|
||||
t.process_buffer_func = [](ProcessBufferContext &ctx) {
|
||||
VOXEL_PROFILE_SCOPE_NAMED("NODE_FAST_NOISE_2_3D");
|
||||
ZN_PROFILE_SCOPE_NAMED("NODE_FAST_NOISE_2_3D");
|
||||
const VoxelGraphRuntime::Buffer &x = ctx.get_input(0);
|
||||
const VoxelGraphRuntime::Buffer &y = ctx.get_input(1);
|
||||
const VoxelGraphRuntime::Buffer &z = ctx.get_input(2);
|
||||
|
@ -192,7 +192,7 @@ static uint32_t expand_node(ProgramGraph &graph, const ExpressionParser::Node &e
|
||||
|
||||
static VoxelGraphRuntime::CompilationResult expand_expression_node(ProgramGraph &graph, uint32_t original_node_id,
|
||||
ProgramGraph::PortLocation &expanded_output_port, std::vector<uint32_t> &expanded_nodes) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
const ProgramGraph::Node &original_node = graph.get_node(original_node_id);
|
||||
CRASH_COND(original_node.params.size() == 0);
|
||||
const String code = original_node.params[0];
|
||||
@ -273,7 +273,7 @@ struct ExpandedNodeRemap {
|
||||
|
||||
static VoxelGraphRuntime::CompilationResult expand_expression_nodes(ProgramGraph &graph,
|
||||
std::vector<PortRemap> &user_to_expanded_ports, std::vector<ExpandedNodeRemap> &expanded_to_user_node_ids) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
// Gather expression node IDs first, as expansion could invalidate the iterator
|
||||
std::vector<uint32_t> expression_node_ids;
|
||||
graph.for_each_node([&expression_node_ids](ProgramGraph::Node &node) {
|
||||
@ -305,7 +305,7 @@ static VoxelGraphRuntime::CompilationResult expand_expression_nodes(ProgramGraph
|
||||
}
|
||||
|
||||
VoxelGraphRuntime::CompilationResult VoxelGraphRuntime::compile(const ProgramGraph &p_graph, bool debug) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
ProgramGraph graph;
|
||||
graph.copy_from(p_graph, false);
|
||||
@ -334,7 +334,7 @@ VoxelGraphRuntime::CompilationResult VoxelGraphRuntime::compile(const ProgramGra
|
||||
}
|
||||
|
||||
VoxelGraphRuntime::CompilationResult VoxelGraphRuntime::_compile(const ProgramGraph &graph, bool debug) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
clear();
|
||||
|
||||
std::vector<uint32_t> order;
|
||||
@ -732,7 +732,7 @@ void VoxelGraphRuntime::generate_optimized_execution_map(
|
||||
// It can be useful for biomes, where some branches become constant when not used in the final blending.
|
||||
void VoxelGraphRuntime::generate_optimized_execution_map(
|
||||
const State &state, ExecutionMap &execution_map, Span<const unsigned int> required_outputs, bool debug) const {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
// Range analysis results must have been computed
|
||||
ERR_FAIL_COND(state.ranges.size() == 0);
|
||||
@ -1033,7 +1033,7 @@ void VoxelGraphRuntime::generate_set(State &state, Span<float> in_x, Span<float>
|
||||
}
|
||||
};
|
||||
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
// Each array must have the same size
|
||||
@ -1120,7 +1120,7 @@ void VoxelGraphRuntime::generate_set(State &state, Span<float> in_x, Span<float>
|
||||
|
||||
// TODO Accept float bounds
|
||||
void VoxelGraphRuntime::analyze_range(State &state, Vector3i min_pos, Vector3i max_pos) const {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
ERR_FAIL_COND(state.ranges.size() != _program.buffer_count);
|
||||
|
@ -390,7 +390,7 @@ void build_voxel_mesh_as_greedy_cubes_atlased(
|
||||
VoxelMesherCubes::GreedyAtlasData &out_greedy_atlas_data, const Span<Voxel_T> voxel_buffer,
|
||||
const Vector3i block_size, std::vector<uint8_t> &mask_memory_pool, Color_F color_func) {
|
||||
//
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
ERR_FAIL_COND(block_size.x < static_cast<int>(2 * VoxelMesherCubes::PADDING) ||
|
||||
block_size.y < static_cast<int>(2 * VoxelMesherCubes::PADDING) ||
|
||||
block_size.z < static_cast<int>(2 * VoxelMesherCubes::PADDING));
|
||||
@ -618,13 +618,13 @@ Ref<Image> make_greedy_atlas(
|
||||
const VoxelMesherCubes::GreedyAtlasData &atlas_data, Span<VoxelMesherCubes::Arrays> surfaces) {
|
||||
//
|
||||
ERR_FAIL_COND_V(atlas_data.images.size() == 0, Ref<Image>());
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
// Pack rectangles
|
||||
Vector<Vector2i> result_points;
|
||||
Vector2i result_size;
|
||||
{
|
||||
VOXEL_PROFILE_SCOPE_NAMED("Packing");
|
||||
ZN_PROFILE_SCOPE_NAMED("Packing");
|
||||
Vector<Vector2i> sizes;
|
||||
sizes.resize(atlas_data.images.size());
|
||||
for (unsigned int i = 0; i < atlas_data.images.size(); ++i) {
|
||||
@ -709,7 +709,7 @@ VoxelMesherCubes::VoxelMesherCubes() {
|
||||
VoxelMesherCubes::~VoxelMesherCubes() {}
|
||||
|
||||
void VoxelMesherCubes::build(VoxelMesher::Output &output, const VoxelMesher::Input &input) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
const int channel = VoxelBufferInternal::CHANNEL_COLOR;
|
||||
Cache &cache = _cache;
|
||||
|
||||
|
@ -184,7 +184,7 @@ CellTextureDatas<NVoxels> select_textures_4_per_voxel(const FixedArray<unsigned
|
||||
indexed_weight_sums[i] = IndexAndWeight{ i, 0 };
|
||||
}
|
||||
for (unsigned int ci = 0; ci < voxel_indices.size(); ++ci) {
|
||||
//VOXEL_PROFILE_SCOPE();
|
||||
//ZN_PROFILE_SCOPE();
|
||||
|
||||
const unsigned int data_index = voxel_indices[ci];
|
||||
const FixedArray<uint8_t, 4> indices = decode_indices_from_packed_u16(indices_data[data_index]);
|
||||
@ -223,7 +223,7 @@ CellTextureDatas<NVoxels> select_textures_4_per_voxel(const FixedArray<unsigned
|
||||
|
||||
// Remap weights to follow the indices we selected
|
||||
for (unsigned int ci = 0; ci < cell_texture_weights_temp.size(); ++ci) {
|
||||
//VOXEL_PROFILE_SCOPE();
|
||||
//ZN_PROFILE_SCOPE();
|
||||
const FixedArray<uint8_t, MAX_TEXTURES> &src_weights = cell_texture_weights_temp[ci];
|
||||
FixedArray<uint8_t, 4> &dst_weights = cell_textures.weights[ci];
|
||||
|
||||
@ -305,7 +305,7 @@ template <typename Sdf_T, typename WeightSampler_T>
|
||||
void build_regular_mesh(Span<const Sdf_T> sdf_data, TextureIndicesData texture_indices_data,
|
||||
const WeightSampler_T &weights_sampler, const Vector3i block_size_with_padding, uint32_t lod_index,
|
||||
TexturingMode texturing_mode, Cache &cache, MeshArrays &output, const IDeepSDFSampler *deep_sdf_sampler) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
// This function has some comments as quotes from the Transvoxel paper.
|
||||
|
||||
@ -365,7 +365,7 @@ void build_regular_mesh(Span<const Sdf_T> sdf_data, TextureIndicesData texture_i
|
||||
}
|
||||
}
|
||||
|
||||
//VOXEL_PROFILE_SCOPE();
|
||||
//ZN_PROFILE_SCOPE();
|
||||
|
||||
// 6-------7
|
||||
// /| /|
|
||||
@ -1247,7 +1247,7 @@ thread_local std::vector<uint16_t> s_weights_backing_buffer_u16;
|
||||
//
|
||||
/*template <typename Sdf_T>
|
||||
Span<const Sdf_T> apply_zero_sdf_fix(Span<const Sdf_T> p_sdf_data) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
static thread_local std::vector<Sdf_T> s_sdf_backing_buffer;
|
||||
std::vector<Sdf_T> &sdf_data = s_sdf_backing_buffer;
|
||||
@ -1267,7 +1267,7 @@ Span<const Sdf_T> apply_zero_sdf_fix(Span<const Sdf_T> p_sdf_data) {
|
||||
DefaultTextureIndicesData build_regular_mesh(const VoxelBufferInternal &voxels, unsigned int sdf_channel,
|
||||
uint32_t lod_index, TexturingMode texturing_mode, Cache &cache, MeshArrays &output,
|
||||
const IDeepSDFSampler *deep_sdf_sampler) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
// From this point, we expect the buffer to contain allocated data in the relevant channels.
|
||||
|
||||
Span<uint8_t> sdf_data_raw;
|
||||
@ -1348,7 +1348,7 @@ DefaultTextureIndicesData build_regular_mesh(const VoxelBufferInternal &voxels,
|
||||
void build_transition_mesh(const VoxelBufferInternal &voxels, unsigned int sdf_channel, int direction,
|
||||
uint32_t lod_index, TexturingMode texturing_mode, Cache &cache, MeshArrays &output,
|
||||
DefaultTextureIndicesData default_texture_indices_data) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
// From this point, we expect the buffer to contain allocated data in the relevant channels.
|
||||
|
||||
Span<uint8_t> sdf_data_raw;
|
||||
|
@ -73,7 +73,7 @@ static void remap_vertex_array(const std::vector<T> &src_data, std::vector<T> &d
|
||||
|
||||
static void simplify(const transvoxel::MeshArrays &src_mesh, transvoxel::MeshArrays &dst_mesh, float p_target_ratio,
|
||||
float p_error_threshold) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
// Gather and check input
|
||||
|
||||
@ -92,7 +92,7 @@ static void simplify(const transvoxel::MeshArrays &src_mesh, transvoxel::MeshArr
|
||||
|
||||
// Simplify
|
||||
{
|
||||
VOXEL_PROFILE_SCOPE_NAMED("meshopt_simplify");
|
||||
ZN_PROFILE_SCOPE_NAMED("meshopt_simplify");
|
||||
|
||||
// TODO See build script about the `zylannmeshopt::` namespace
|
||||
const unsigned int lod_index_count = zylannmeshopt::meshopt_simplify(&lod_indices[0],
|
||||
@ -161,7 +161,7 @@ struct DeepSampler : transvoxel::IDeepSDFSampler {
|
||||
};
|
||||
|
||||
void VoxelMesherTransvoxel::build(VoxelMesher::Output &output, const VoxelMesher::Input &input) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
static thread_local transvoxel::Cache s_cache;
|
||||
static thread_local transvoxel::MeshArrays s_mesh_arrays;
|
||||
@ -221,7 +221,7 @@ void VoxelMesherTransvoxel::build(VoxelMesher::Output &output, const VoxelMesher
|
||||
output.surfaces.push_back(regular_arrays);
|
||||
|
||||
for (int dir = 0; dir < Cube::SIDE_COUNT; ++dir) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
s_mesh_arrays.clear();
|
||||
|
||||
transvoxel::build_transition_mesh(voxels, sdf_channel, dir, input.lod,
|
||||
|
@ -25,7 +25,7 @@ int GenerateBlockTask::debug_get_running_count() {
|
||||
}
|
||||
|
||||
void GenerateBlockTask::run(zylann::ThreadedTaskContext ctx) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
CRASH_COND(stream_dependency == nullptr);
|
||||
Ref<VoxelGenerator> generator = stream_dependency->generator;
|
||||
|
@ -6,7 +6,7 @@
|
||||
namespace zylann::voxel {
|
||||
|
||||
void LoadAllBlocksDataTask::run(zylann::ThreadedTaskContext ctx) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
CRASH_COND(stream_dependency == nullptr);
|
||||
Ref<VoxelStream> stream = stream_dependency->stream;
|
||||
|
@ -36,7 +36,7 @@ int LoadBlockDataTask::debug_get_running_count() {
|
||||
}
|
||||
|
||||
void LoadBlockDataTask::run(zylann::ThreadedTaskContext ctx) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
CRASH_COND(_stream_dependency == nullptr);
|
||||
Ref<VoxelStream> stream = _stream_dependency->stream;
|
||||
|
@ -11,7 +11,7 @@ namespace zylann::voxel {
|
||||
static void copy_block_and_neighbors(Span<std::shared_ptr<VoxelBufferInternal>> blocks, VoxelBufferInternal &dst,
|
||||
int min_padding, int max_padding, int channels_mask, Ref<VoxelGenerator> generator, int data_block_size,
|
||||
uint8_t lod_index, Vector3i mesh_block_pos) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
// Extract wanted channels in a list
|
||||
unsigned int channels_count = 0;
|
||||
@ -100,7 +100,7 @@ static void copy_block_and_neighbors(Span<std::shared_ptr<VoxelBufferInternal>>
|
||||
// Subtract edited box from the area to generate
|
||||
// TODO This approach allows to batch boxes if necessary,
|
||||
// but is it just better to do it anyways for every clipped box?
|
||||
VOXEL_PROFILE_SCOPE_NAMED("Box subtract");
|
||||
ZN_PROFILE_SCOPE_NAMED("Box subtract");
|
||||
const unsigned int count = boxes_to_generate.size();
|
||||
const Box3i block_box = Box3i(offset, Vector3iUtil::create(data_block_size)).clipped(mesh_data_box);
|
||||
|
||||
@ -120,7 +120,7 @@ static void copy_block_and_neighbors(Span<std::shared_ptr<VoxelBufferInternal>>
|
||||
|
||||
if (generator.is_valid()) {
|
||||
// Complete data with generated voxels
|
||||
VOXEL_PROFILE_SCOPE_NAMED("Generate");
|
||||
ZN_PROFILE_SCOPE_NAMED("Generate");
|
||||
VoxelBufferInternal generated_voxels;
|
||||
|
||||
const Vector3i origin_in_voxels = mesh_block_pos * (mesh_block_size_factor * data_block_size << lod_index);
|
||||
@ -161,7 +161,7 @@ int MeshBlockTask::debug_get_running_count() {
|
||||
}
|
||||
|
||||
void MeshBlockTask::run(zylann::ThreadedTaskContext ctx) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
CRASH_COND(meshing_dependency == nullptr);
|
||||
|
||||
Ref<VoxelMesher> mesher = meshing_dependency->mesher;
|
||||
|
@ -49,7 +49,7 @@ int SaveBlockDataTask::debug_get_running_count() {
|
||||
}
|
||||
|
||||
void SaveBlockDataTask::run(zylann::ThreadedTaskContext ctx) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
CRASH_COND(_stream_dependency == nullptr);
|
||||
Ref<VoxelStream> stream = _stream_dependency->stream;
|
||||
|
@ -503,10 +503,10 @@ void VoxelServer::push_async_io_tasks(Span<zylann::IThreadedTask *> tasks) {
|
||||
}
|
||||
|
||||
void VoxelServer::process() {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
VOXEL_PROFILE_PLOT("Static memory usage", int64_t(OS::get_singleton()->get_static_memory_usage()));
|
||||
VOXEL_PROFILE_PLOT("TimeSpread tasks", int64_t(_time_spread_task_runner.get_pending_count()));
|
||||
VOXEL_PROFILE_PLOT("Progressive tasks", int64_t(_progressive_task_runner.get_pending_count()));
|
||||
ZN_PROFILE_SCOPE();
|
||||
ZN_PROFILE_PLOT("Static memory usage", int64_t(OS::get_singleton()->get_static_memory_usage()));
|
||||
ZN_PROFILE_PLOT("TimeSpread tasks", int64_t(_time_spread_task_runner.get_pending_count()));
|
||||
ZN_PROFILE_PLOT("Progressive tasks", int64_t(_progressive_task_runner.get_pending_count()));
|
||||
|
||||
// Receive data updates
|
||||
_streaming_thread_pool.dequeue_completed_tasks([](zylann::IThreadedTask *task) {
|
||||
|
@ -24,7 +24,7 @@ void VoxelServer::destroy_singleton() {
|
||||
}
|
||||
|
||||
VoxelServer::VoxelServer() {
|
||||
#ifdef VOXEL_PROFILER_ENABLED
|
||||
#ifdef ZN_PROFILER_ENABLED
|
||||
CRASH_COND(RenderingServer::get_singleton() == nullptr);
|
||||
RenderingServer::get_singleton()->connect(
|
||||
SNAME("frame_post_draw"), callable_mp(this, &VoxelServer::_on_rendering_server_frame_post_draw));
|
||||
@ -42,8 +42,8 @@ void VoxelServer::schedule_task(Ref<ZN_ThreadedTask> task) {
|
||||
}
|
||||
|
||||
void VoxelServer::_on_rendering_server_frame_post_draw() {
|
||||
#ifdef VOXEL_PROFILER_ENABLED
|
||||
VOXEL_PROFILE_MARK_FRAME();
|
||||
#ifdef ZN_PROFILER_ENABLED
|
||||
ZN_PROFILE_MARK_FRAME();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,7 @@ VoxelDataBlock *VoxelDataMap::set_block_buffer(
|
||||
} else if (overwrite) {
|
||||
block->set_voxels(buffer);
|
||||
} else {
|
||||
VOXEL_PROFILE_MESSAGE("Redundant data block");
|
||||
ZN_PROFILE_MESSAGE("Redundant data block");
|
||||
ZN_PRINT_VERBOSE(format(
|
||||
"Discarded block {} lod {}, there was already data and overwriting is not enabled", bpos, _lod_index));
|
||||
}
|
||||
@ -355,7 +355,7 @@ bool VoxelDataMap::is_area_fully_loaded(const Box3i voxels_box) const {
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void preload_box(VoxelDataLodMap &data, Box3i voxel_box, VoxelGenerator *generator) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
//ERR_FAIL_COND_MSG(_full_load_mode == false, nullptr, "This function can only be used in full load mode");
|
||||
|
||||
struct Task {
|
||||
|
@ -144,7 +144,7 @@ public:
|
||||
block_box.for_each_cell_zxy([this, action, voxel_box, channel, block_size, gen_func](Vector3i block_pos) {
|
||||
VoxelDataBlock *block = get_block(block_pos);
|
||||
if (block == nullptr) {
|
||||
VOXEL_PROFILE_SCOPE_NAMED("Generate");
|
||||
ZN_PROFILE_SCOPE_NAMED("Generate");
|
||||
block = create_default_block(block_pos);
|
||||
gen_func(block->get_voxels(), block_pos << get_block_size_pow2());
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ VoxelMemoryPool::~VoxelMemoryPool() {
|
||||
}
|
||||
|
||||
uint8_t *VoxelMemoryPool::allocate(size_t size) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
CRASH_COND(size == 0);
|
||||
uint8_t *block = nullptr;
|
||||
// Not calculating `pot` immediately because the function we use to calculate it uses 32 bits,
|
||||
@ -64,7 +64,7 @@ uint8_t *VoxelMemoryPool::allocate(size_t size) {
|
||||
pool.mutex.unlock();
|
||||
} else {
|
||||
pool.mutex.unlock();
|
||||
VOXEL_PROFILE_SCOPE_NAMED("new alloc");
|
||||
ZN_PROFILE_SCOPE_NAMED("new alloc");
|
||||
// All allocations done in this pool have the same size,
|
||||
// which must be greater or equal to `size`
|
||||
const size_t capacity = get_size_from_pool_index(pot);
|
||||
|
@ -28,7 +28,7 @@ bool decompress_lz4(MemoryReader &f, Span<const uint8_t> src, std::vector<uint8_
|
||||
}
|
||||
|
||||
bool decompress(Span<const uint8_t> src, std::vector<uint8_t> &dst) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
MemoryReader f(src, ENDIANESS_LITTLE_ENDIAN);
|
||||
|
||||
@ -81,7 +81,7 @@ bool compress_lz4(MemoryWriter &f, Span<const uint8_t> src, std::vector<uint8_t>
|
||||
}
|
||||
|
||||
bool compress(Span<const uint8_t> src, std::vector<uint8_t> &dst, Compression comp) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
switch (comp) {
|
||||
case COMPRESSION_NONE: {
|
||||
|
@ -268,7 +268,7 @@ Error RegionFile::open(const String &fpath, bool create_if_not_found) {
|
||||
}
|
||||
|
||||
Error RegionFile::close() {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
Error err = OK;
|
||||
if (_file_access != nullptr) {
|
||||
if (_header_modified) {
|
||||
@ -476,7 +476,7 @@ void RegionFile::pad_to_sector_size(FileAccess *f) {
|
||||
}
|
||||
|
||||
void RegionFile::remove_sectors_from_block(Vector3i block_pos, unsigned int p_sector_count) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
// Removes sectors from a block, starting from the last ones.
|
||||
// So if a block has 5 sectors and we remove 2, the first 3 will be preserved.
|
||||
|
@ -68,7 +68,7 @@ void VoxelStreamRegionFiles::save_voxel_block(VoxelStream::VoxelQueryData &query
|
||||
}
|
||||
|
||||
void VoxelStreamRegionFiles::load_voxel_blocks(Span<VoxelStream::VoxelQueryData> p_blocks) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
// In order to minimize opening/closing files, requests are grouped according to their region.
|
||||
|
||||
@ -100,7 +100,7 @@ void VoxelStreamRegionFiles::load_voxel_blocks(Span<VoxelStream::VoxelQueryData>
|
||||
}
|
||||
|
||||
void VoxelStreamRegionFiles::save_voxel_blocks(Span<VoxelStream::VoxelQueryData> p_blocks) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
// Had to copy input to sort it, as some areas in the module break if they get responses in different order
|
||||
std::vector<unsigned int> sorted_block_indices;
|
||||
@ -122,7 +122,7 @@ int VoxelStreamRegionFiles::get_used_channels_mask() const {
|
||||
|
||||
VoxelStreamRegionFiles::EmergeResult VoxelStreamRegionFiles::_load_block(
|
||||
VoxelBufferInternal &out_buffer, Vector3i origin_in_voxels, int lod) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
MutexLock lock(_mutex);
|
||||
|
||||
@ -175,7 +175,7 @@ VoxelStreamRegionFiles::EmergeResult VoxelStreamRegionFiles::_load_block(
|
||||
}
|
||||
|
||||
void VoxelStreamRegionFiles::_save_block(VoxelBufferInternal &voxel_buffer, Vector3i origin_in_voxels, int lod) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
MutexLock lock(_mutex);
|
||||
|
||||
@ -436,7 +436,7 @@ VoxelStreamRegionFiles::CachedRegion *VoxelStreamRegionFiles::get_region_from_ca
|
||||
|
||||
VoxelStreamRegionFiles::CachedRegion *VoxelStreamRegionFiles::open_region(
|
||||
const Vector3i region_pos, unsigned int lod, bool create_if_not_found) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
ERR_FAIL_COND_V(!_meta_loaded, nullptr);
|
||||
ERR_FAIL_COND_V(lod < 0, nullptr);
|
||||
|
||||
|
@ -147,7 +147,7 @@ VoxelStreamSQLiteInternal::~VoxelStreamSQLiteInternal() {
|
||||
}
|
||||
|
||||
bool VoxelStreamSQLiteInternal::open(const char *fpath) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
close();
|
||||
|
||||
int rc = sqlite3_open_v2(fpath, &_db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, nullptr);
|
||||
@ -290,7 +290,7 @@ bool VoxelStreamSQLiteInternal::end_transaction() {
|
||||
}
|
||||
|
||||
bool VoxelStreamSQLiteInternal::save_block(BlockLocation loc, const std::vector<uint8_t> &block_data, BlockType type) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
sqlite3 *db = _db;
|
||||
|
||||
@ -401,7 +401,7 @@ VoxelStream::ResultCode VoxelStreamSQLiteInternal::load_block(
|
||||
bool VoxelStreamSQLiteInternal::load_all_blocks(void *callback_data,
|
||||
void (*process_block_func)(void *callback_data, BlockLocation location, Span<const uint8_t> voxel_data,
|
||||
Span<const uint8_t> instances_data)) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
CRASH_COND(process_block_func == nullptr);
|
||||
|
||||
sqlite3 *db = _db;
|
||||
@ -419,7 +419,7 @@ bool VoxelStreamSQLiteInternal::load_all_blocks(void *callback_data,
|
||||
rc = sqlite3_step(load_all_blocks_statement);
|
||||
|
||||
if (rc == SQLITE_ROW) {
|
||||
VOXEL_PROFILE_SCOPE_NAMED("Row");
|
||||
ZN_PROFILE_SCOPE_NAMED("Row");
|
||||
|
||||
const uint64_t eloc = sqlite3_column_int64(load_all_blocks_statement, 0);
|
||||
const BlockLocation loc = BlockLocation::decode(eloc);
|
||||
@ -635,7 +635,7 @@ void VoxelStreamSQLite::save_voxel_block(VoxelStream::VoxelQueryData &q) {
|
||||
}
|
||||
|
||||
void VoxelStreamSQLite::load_voxel_blocks(Span<VoxelStream::VoxelQueryData> p_blocks) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
// TODO Get block size from database
|
||||
const int bs_po2 = constants::DEFAULT_BLOCK_SIZE_PO2;
|
||||
@ -720,7 +720,7 @@ bool VoxelStreamSQLite::supports_instance_blocks() const {
|
||||
}
|
||||
|
||||
void VoxelStreamSQLite::load_instance_blocks(Span<VoxelStream::InstancesQueryData> out_blocks) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
// TODO Get block size from database
|
||||
//const int bs_po2 = constants::DEFAULT_BLOCK_SIZE_PO2;
|
||||
@ -801,7 +801,7 @@ void VoxelStreamSQLite::save_instance_blocks(Span<VoxelStream::InstancesQueryDat
|
||||
}
|
||||
|
||||
void VoxelStreamSQLite::load_all_blocks(FullLoadingResult &result) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
VoxelStreamSQLiteInternal *con = get_connection();
|
||||
ERR_FAIL_COND(con == nullptr);
|
||||
@ -873,7 +873,7 @@ void VoxelStreamSQLite::flush_cache() {
|
||||
|
||||
// This function does not lock any mutex for internal use.
|
||||
void VoxelStreamSQLite::flush_cache(VoxelStreamSQLiteInternal *con) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
ZN_PRINT_VERBOSE(format("VoxelStreamSQLite: Flushing cache ({} elements)", _cache.get_indicative_block_count()));
|
||||
|
||||
ERR_FAIL_COND(con == nullptr);
|
||||
|
@ -196,7 +196,7 @@ Error Data::load_from_file(String fpath) {
|
||||
}
|
||||
|
||||
Error Data::_load_from_file(String fpath) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
// https://github.com/ephtracy/voxel-model/blob/master/MagicaVoxel-file-format-vox.txt
|
||||
// https://github.com/ephtracy/voxel-model/blob/master/MagicaVoxel-file-format-vox-extension.txt
|
||||
|
||||
|
@ -212,7 +212,7 @@ size_t get_size_in_bytes(const VoxelBufferInternal &buffer, size_t &metadata_siz
|
||||
|
||||
SerializeResult serialize(const VoxelBufferInternal &voxel_buffer) {
|
||||
//
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
std::vector<uint8_t> &dst_data = tls_data;
|
||||
std::vector<uint8_t> &metadata_tmp = tls_metadata_tmp;
|
||||
@ -388,7 +388,7 @@ bool migrate_v2_to_v3(Span<const uint8_t> p_data, std::vector<uint8_t> &dst) {
|
||||
}
|
||||
|
||||
bool deserialize(Span<const uint8_t> p_data, VoxelBufferInternal &out_voxel_buffer) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
std::vector<uint8_t> &metadata_tmp = tls_metadata_tmp;
|
||||
|
||||
@ -487,7 +487,7 @@ bool deserialize(Span<const uint8_t> p_data, VoxelBufferInternal &out_voxel_buff
|
||||
}
|
||||
|
||||
SerializeResult serialize_and_compress(const VoxelBufferInternal &voxel_buffer) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
std::vector<uint8_t> &compressed_data = tls_compressed_data;
|
||||
|
||||
@ -503,7 +503,7 @@ SerializeResult serialize_and_compress(const VoxelBufferInternal &voxel_buffer)
|
||||
}
|
||||
|
||||
bool decompress_and_deserialize(Span<const uint8_t> p_data, VoxelBufferInternal &out_voxel_buffer) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
std::vector<uint8_t> &data = tls_data;
|
||||
|
||||
@ -514,7 +514,7 @@ bool decompress_and_deserialize(Span<const uint8_t> p_data, VoxelBufferInternal
|
||||
}
|
||||
|
||||
bool decompress_and_deserialize(FileAccess *f, unsigned int size_to_read, VoxelBufferInternal &out_voxel_buffer) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
ERR_FAIL_COND_V(f == nullptr, false);
|
||||
|
||||
#if defined(TOOLS_ENABLED) || defined(DEBUG_ENABLED)
|
||||
|
@ -881,7 +881,7 @@ void VoxelTerrain::_notification(int p_what) {
|
||||
}
|
||||
|
||||
void VoxelTerrain::send_block_data_requests() {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
// Blocks to load
|
||||
for (size_t i = 0; i < _blocks_pending_load.size(); ++i) {
|
||||
@ -958,7 +958,7 @@ void VoxelTerrain::notify_data_block_enter(VoxelDataBlock &block, uint32_t viewe
|
||||
}
|
||||
|
||||
void VoxelTerrain::_process() {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
process_viewers();
|
||||
//process_received_data_blocks();
|
||||
process_meshing();
|
||||
@ -1073,7 +1073,7 @@ void VoxelTerrain::process_viewers() {
|
||||
|
||||
// Find out which blocks need to appear and which need to be unloaded
|
||||
{
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
for (size_t i = 0; i < _paired_viewers.size(); ++i) {
|
||||
const PairedViewer &viewer = _paired_viewers[i];
|
||||
@ -1083,7 +1083,7 @@ void VoxelTerrain::process_viewers() {
|
||||
const Box3i &prev_data_box = viewer.prev_state.data_box;
|
||||
|
||||
if (prev_data_box != new_data_box) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
const bool require_notifications = _block_enter_notification_enabled &&
|
||||
VoxelServer::get_singleton().is_viewer_requiring_data_block_notifications(viewer.id);
|
||||
@ -1113,7 +1113,7 @@ void VoxelTerrain::process_viewers() {
|
||||
const Box3i &prev_mesh_box = viewer.prev_state.mesh_box;
|
||||
|
||||
if (prev_mesh_box != new_mesh_box) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
// Unview blocks that just fell out of range
|
||||
prev_mesh_box.difference(new_mesh_box, [this, &viewer](Box3i out_of_range_box) {
|
||||
@ -1186,7 +1186,7 @@ void VoxelTerrain::process_viewers() {
|
||||
}
|
||||
|
||||
void VoxelTerrain::apply_data_block_response(VoxelServer::BlockDataOutput &ob) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
//print_line(String("Receiving {0} blocks").format(varray(output.emerged_blocks.size())));
|
||||
|
||||
@ -1266,7 +1266,7 @@ void VoxelTerrain::apply_data_block_response(VoxelServer::BlockDataOutput &ob) {
|
||||
|
||||
// The block itself might not be suitable for meshing yet, but blocks surrounding it might be now
|
||||
{
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
try_schedule_mesh_update_from_data(
|
||||
Box3i(_data_map.block_to_voxel(block_pos), Vector3iUtil::create(get_data_block_size())));
|
||||
}
|
||||
@ -1281,7 +1281,7 @@ void VoxelTerrain::apply_data_block_response(VoxelServer::BlockDataOutput &ob) {
|
||||
// If the given block coordinates are not inside any viewer's area, this function won't do anything and return false.
|
||||
// If a block is already loading or generating at this position, it will be cancelled.
|
||||
bool VoxelTerrain::try_set_block_data(Vector3i position, std::shared_ptr<VoxelBufferInternal> &voxel_data) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
ERR_FAIL_COND_V(voxel_data == nullptr, false);
|
||||
|
||||
const Vector3i expected_block_size = Vector3iUtil::create(_data_map.get_block_size());
|
||||
@ -1333,7 +1333,7 @@ void VoxelTerrain::process_meshing() {
|
||||
|
||||
// Send mesh updates
|
||||
{
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
//const int used_channels_mask = get_used_channels_mask();
|
||||
const int mesh_to_data_factor = get_mesh_block_size() / get_data_block_size();
|
||||
@ -1403,7 +1403,7 @@ void VoxelTerrain::process_meshing() {
|
||||
}
|
||||
|
||||
void VoxelTerrain::apply_mesh_update(const VoxelServer::BlockMeshOutput &ob) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
//print_line(String("DDD receive {0}").format(varray(ob.position.to_vec3())));
|
||||
|
||||
VoxelMeshBlockVT *block = _mesh_map.get_block(ob.position);
|
||||
|
@ -36,7 +36,7 @@ inline float get_triangle_area(Vector3 p0, Vector3 p1, Vector3 p2) {
|
||||
void VoxelInstanceGenerator::generate_transforms(std::vector<Transform3D> &out_transforms, Vector3i grid_position,
|
||||
int lod_index, int layer_id, Array surface_arrays, const Transform3D &block_local_transform, UpMode up_mode,
|
||||
uint8_t octant_mask, float block_size) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
if (surface_arrays.size() < ArrayMesh::ARRAY_VERTEX && surface_arrays.size() < ArrayMesh::ARRAY_NORMAL &&
|
||||
surface_arrays.size() < ArrayMesh::ARRAY_INDEX) {
|
||||
@ -86,7 +86,7 @@ void VoxelInstanceGenerator::generate_transforms(std::vector<Transform3D> &out_t
|
||||
|
||||
// Pick random points
|
||||
{
|
||||
VOXEL_PROFILE_SCOPE_NAMED("mesh to points");
|
||||
ZN_PROFILE_SCOPE_NAMED("mesh to points");
|
||||
|
||||
// PackedVector3Array::Read vertices_r = vertices.read();
|
||||
// PackedVector3Array::Read normals_r = normals.read();
|
||||
@ -222,7 +222,7 @@ void VoxelInstanceGenerator::generate_transforms(std::vector<Transform3D> &out_t
|
||||
// This is done so some octants can be filled with user-edited data instead,
|
||||
// because mesh size may not necessarily match data block size
|
||||
if ((octant_mask & 0xff) != 0xff) {
|
||||
VOXEL_PROFILE_SCOPE_NAMED("octant filter");
|
||||
ZN_PROFILE_SCOPE_NAMED("octant filter");
|
||||
const float h = block_size / 2.f;
|
||||
for (unsigned int i = 0; i < vertex_cache.size(); ++i) {
|
||||
const Vector3 &pos = vertex_cache[i];
|
||||
@ -239,7 +239,7 @@ void VoxelInstanceGenerator::generate_transforms(std::vector<Transform3D> &out_t
|
||||
|
||||
// Filter out by noise
|
||||
if (_noise.is_valid()) {
|
||||
VOXEL_PROFILE_SCOPE_NAMED("noise filter");
|
||||
ZN_PROFILE_SCOPE_NAMED("noise filter");
|
||||
|
||||
noise_cache.clear();
|
||||
|
||||
|
@ -36,7 +36,7 @@ VoxelInstancer::~VoxelInstancer() {
|
||||
}
|
||||
|
||||
void VoxelInstancer::clear_blocks() {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
// Destroy blocks, keep configured layers
|
||||
for (auto it = _blocks.begin(); it != _blocks.end(); ++it) {
|
||||
Block *block = *it;
|
||||
@ -121,7 +121,7 @@ void VoxelInstancer::_notification(int p_what) {
|
||||
break;
|
||||
|
||||
case NOTIFICATION_TRANSFORM_CHANGED: {
|
||||
VOXEL_PROFILE_SCOPE_NAMED("VoxelInstancer::NOTIFICATION_TRANSFORM_CHANGED");
|
||||
ZN_PROFILE_SCOPE_NAMED("VoxelInstancer::NOTIFICATION_TRANSFORM_CHANGED");
|
||||
|
||||
if (!is_inside_tree() || _parent == nullptr) {
|
||||
// The transform and other properties can be set by the scene loader,
|
||||
@ -233,7 +233,7 @@ const VoxelInstancer::Layer *VoxelInstancer::get_layer_const(int id) const {
|
||||
}
|
||||
|
||||
void VoxelInstancer::process_mesh_lods() {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
ERR_FAIL_COND(_library.is_null());
|
||||
|
||||
// Get viewer position
|
||||
@ -397,7 +397,7 @@ Ref<VoxelInstanceLibrary> VoxelInstancer::get_library() const {
|
||||
}
|
||||
|
||||
void VoxelInstancer::regenerate_layer(uint16_t layer_id, bool regenerate_blocks) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
ERR_FAIL_COND(_parent == nullptr);
|
||||
|
||||
Ref<World3D> world_ref = get_world_3d();
|
||||
@ -723,7 +723,7 @@ void VoxelInstancer::on_mesh_block_exit(Vector3i render_grid_position, unsigned
|
||||
return;
|
||||
}
|
||||
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
Lod &lod = _lods[lod_index];
|
||||
|
||||
@ -817,7 +817,7 @@ int VoxelInstancer::create_block(Layer *layer, uint16_t layer_id, Vector3i grid_
|
||||
void VoxelInstancer::update_block_from_transforms(int block_index, Span<const Transform3D> transforms,
|
||||
Vector3i grid_position, Layer *layer, const VoxelInstanceLibraryItem *item_base, uint16_t layer_id,
|
||||
World3D *world, const Transform3D &block_transform) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
CRASH_COND(layer == nullptr);
|
||||
CRASH_COND(item_base == nullptr);
|
||||
@ -876,7 +876,7 @@ void VoxelInstancer::update_block_from_transforms(int block_index, Span<const Tr
|
||||
Span<const VoxelInstanceLibraryMultiMeshItem::CollisionShapeInfo> collision_shapes =
|
||||
item->get_collision_shapes();
|
||||
if (collision_shapes.size() > 0) {
|
||||
VOXEL_PROFILE_SCOPE_NAMED("Update multimesh bodies");
|
||||
ZN_PROFILE_SCOPE_NAMED("Update multimesh bodies");
|
||||
|
||||
const int data_block_size_po2 = _parent->get_data_block_size_pow2();
|
||||
|
||||
@ -927,7 +927,7 @@ void VoxelInstancer::update_block_from_transforms(int block_index, Span<const Tr
|
||||
// Update scene instances
|
||||
const VoxelInstanceLibrarySceneItem *scene_item = Object::cast_to<VoxelInstanceLibrarySceneItem>(item_base);
|
||||
if (scene_item != nullptr) {
|
||||
VOXEL_PROFILE_SCOPE_NAMED("Update scene instances");
|
||||
ZN_PROFILE_SCOPE_NAMED("Update scene instances");
|
||||
ERR_FAIL_COND(scene_item->get_scene().is_null());
|
||||
|
||||
const int data_block_size_po2 = _parent->get_data_block_size_pow2();
|
||||
@ -978,7 +978,7 @@ static const InstanceBlockData::LayerData *find_layer_data(const InstanceBlockDa
|
||||
}
|
||||
|
||||
void VoxelInstancer::create_render_blocks(Vector3i render_grid_position, int lod_index, Array surface_arrays) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
ERR_FAIL_COND(_library.is_null());
|
||||
|
||||
// TODO Query one or multiple data blocks if any
|
||||
@ -1060,7 +1060,7 @@ void VoxelInstancer::create_render_blocks(Vector3i render_grid_position, int lod
|
||||
PackedVector3Array normals = surface_arrays[ArrayMesh::ARRAY_NORMAL];
|
||||
ERR_FAIL_COND(normals.size() == 0);
|
||||
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
static thread_local std::vector<Transform3D> s_generated_transforms;
|
||||
s_generated_transforms.clear();
|
||||
@ -1081,7 +1081,7 @@ void VoxelInstancer::create_render_blocks(Vector3i render_grid_position, int lod
|
||||
}
|
||||
|
||||
void VoxelInstancer::save_block(Vector3i data_grid_pos, int lod_index) const {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
ERR_FAIL_COND(_library.is_null());
|
||||
|
||||
ZN_PRINT_VERBOSE(format("Requesting save of instance block {} lod {}", data_grid_pos, lod_index));
|
||||
@ -1148,7 +1148,7 @@ void VoxelInstancer::save_block(Vector3i data_grid_pos, int lod_index) const {
|
||||
Ref<MultiMesh> multimesh = render_block->multimesh_instance.get_multimesh();
|
||||
CRASH_COND(multimesh.is_null());
|
||||
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
const int instance_count = get_visible_instance_count(**multimesh);
|
||||
|
||||
@ -1178,7 +1178,7 @@ void VoxelInstancer::save_block(Vector3i data_grid_pos, int lod_index) const {
|
||||
} else if (render_block->scene_instances.size() > 0) {
|
||||
// Scenes
|
||||
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
const unsigned int instance_count = render_block->scene_instances.size();
|
||||
|
||||
if (render_to_data_factor == 1) {
|
||||
@ -1361,7 +1361,7 @@ void VoxelInstancer::remove_floating_scene_instances(Block &block, const Transfo
|
||||
}
|
||||
|
||||
void VoxelInstancer::on_area_edited(Box3i p_voxel_box) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
ERR_FAIL_COND(_parent == nullptr);
|
||||
const int render_block_size = _parent->get_mesh_block_size();
|
||||
const int data_block_size = _parent->get_data_block_size();
|
||||
|
@ -24,7 +24,7 @@ namespace {
|
||||
|
||||
Ref<ArrayMesh> build_mesh(
|
||||
Span<const Array> surfaces, Mesh::PrimitiveType primitive, int flags, Ref<Material> material) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
Ref<ArrayMesh> mesh;
|
||||
|
||||
unsigned int surface_index = 0;
|
||||
@ -77,7 +77,7 @@ struct BeforeUnloadMeshAction {
|
||||
std::vector<Ref<ShaderMaterial>> &shader_material_pool;
|
||||
|
||||
void operator()(VoxelMeshBlockVLT &block) {
|
||||
VOXEL_PROFILE_SCOPE_NAMED("Recycle material");
|
||||
ZN_PROFILE_SCOPE_NAMED("Recycle material");
|
||||
// Recycle material
|
||||
Ref<ShaderMaterial> sm = block.get_shader_material();
|
||||
if (sm.is_valid()) {
|
||||
@ -622,7 +622,7 @@ void VoxelLodTerrain::copy(Vector3i p_origin_voxels, VoxelBufferInternal &dst_bu
|
||||
// Marks intersecting blocks in the area as modified, updates LODs and schedules remeshing.
|
||||
// The provided box must be at LOD0 coordinates.
|
||||
void VoxelLodTerrain::post_edit_area(Box3i p_box) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
// TODO Better decoupling is needed here.
|
||||
// In the past this padding was necessary for mesh blocks because visuals depend on neighbor voxels.
|
||||
// So when editing voxels at the boundary of two mesh blocks, both must update.
|
||||
@ -1034,7 +1034,7 @@ void VoxelLodTerrain::_notification(int p_what) {
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_TRANSFORM_CHANGED: {
|
||||
VOXEL_PROFILE_SCOPE_NAMED("VoxelLodTerrain::NOTIFICATION_TRANSFORM_CHANGED");
|
||||
ZN_PROFILE_SCOPE_NAMED("VoxelLodTerrain::NOTIFICATION_TRANSFORM_CHANGED");
|
||||
|
||||
const Transform3D transform = get_global_transform();
|
||||
VoxelServer::get_singleton().set_volume_transform(_volume_id, transform);
|
||||
@ -1089,7 +1089,7 @@ inline bool check_block_sizes(int data_block_size, int mesh_block_size) {
|
||||
// }
|
||||
|
||||
void VoxelLodTerrain::_process(float delta) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
_stats.dropped_block_loads = 0;
|
||||
_stats.dropped_block_meshs = 0;
|
||||
@ -1116,7 +1116,7 @@ void VoxelLodTerrain::_process(float delta) {
|
||||
#endif
|
||||
|
||||
if (_update_data->task_is_complete) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
apply_main_thread_update_tasks();
|
||||
|
||||
@ -1144,7 +1144,7 @@ void VoxelLodTerrain::_process(float delta) {
|
||||
}
|
||||
|
||||
void VoxelLodTerrain::apply_main_thread_update_tasks() {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
// Dequeue outputs of the threadable part of the update for actions taking place on the main thread
|
||||
|
||||
CRASH_COND(_update_data->task_is_complete == false);
|
||||
@ -1260,7 +1260,7 @@ bool thread_safe_contains(const std::unordered_set<T> &set, T v, BinaryMutex &mu
|
||||
}
|
||||
|
||||
void VoxelLodTerrain::apply_data_block_response(VoxelServer::BlockDataOutput &ob) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
if (ob.type == VoxelServer::BlockDataOutput::TYPE_SAVED) {
|
||||
// That's a save confirmation event.
|
||||
@ -1335,7 +1335,7 @@ void VoxelLodTerrain::apply_mesh_update(const VoxelServer::BlockMeshOutput &ob)
|
||||
// The following is done on the main thread because Godot doesn't really support multithreaded Mesh allocation.
|
||||
// This also proved to be very slow compared to the meshing process itself...
|
||||
// hopefully Vulkan will allow us to upload graphical resources without stalling rendering as they upload?
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
ERR_FAIL_COND(!is_inside_tree());
|
||||
|
||||
@ -1431,7 +1431,7 @@ void VoxelLodTerrain::apply_mesh_update(const VoxelServer::BlockMeshOutput &ob)
|
||||
|
||||
Ref<ShaderMaterial> shader_material = _material;
|
||||
if (shader_material.is_valid() && block->get_shader_material().is_null()) {
|
||||
VOXEL_PROFILE_SCOPE_NAMED("Add ShaderMaterial");
|
||||
ZN_PROFILE_SCOPE_NAMED("Add ShaderMaterial");
|
||||
|
||||
// Pooling shader materials is necessary for now, to avoid stuttering in the editor.
|
||||
// Due to a signal used to keep the inspector up to date, even though these
|
||||
@ -1457,7 +1457,7 @@ void VoxelLodTerrain::apply_mesh_update(const VoxelServer::BlockMeshOutput &ob)
|
||||
|
||||
block->set_mesh(mesh, DirectMeshInstance::GIMode(get_gi_mode()));
|
||||
{
|
||||
VOXEL_PROFILE_SCOPE_NAMED("Transition meshes");
|
||||
ZN_PROFILE_SCOPE_NAMED("Transition meshes");
|
||||
for (unsigned int dir = 0; dir < mesh_data.transition_surfaces.size(); ++dir) {
|
||||
Ref<ArrayMesh> transition_mesh = build_mesh(to_span_const(mesh_data.transition_surfaces[dir]),
|
||||
mesh_data.primitive_type, mesh_data.mesh_flags, _material);
|
||||
@ -1495,7 +1495,7 @@ void VoxelLodTerrain::apply_mesh_update(const VoxelServer::BlockMeshOutput &ob)
|
||||
}
|
||||
|
||||
void VoxelLodTerrain::process_deferred_collision_updates(uint32_t timeout_msec) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
const unsigned int lod_count = _update_data->settings.lod_count;
|
||||
|
||||
@ -1553,7 +1553,7 @@ void VoxelLodTerrain::abort_async_edits() {
|
||||
}
|
||||
|
||||
void VoxelLodTerrain::process_fading_blocks(float delta) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
const float speed = _lod_fade_duration < 0.001f ? 99999.f : delta / _lod_fade_duration;
|
||||
|
||||
@ -1592,7 +1592,7 @@ void VoxelLodTerrain::set_instancer(VoxelInstancer *instancer) {
|
||||
// It will be slower than using the instancing generation events,
|
||||
// because it has to query VisualServer, which then allocates and decodes vertex buffers (assuming they are cached).
|
||||
Array VoxelLodTerrain::get_mesh_block_surface(Vector3i block_pos, int lod_index) const {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
const int lod_count = _update_data->settings.lod_count;
|
||||
ERR_FAIL_COND_V(lod_index < 0 || lod_index >= lod_count, Array());
|
||||
@ -1628,7 +1628,7 @@ void VoxelLodTerrain::get_meshed_block_positions_at_lod(int lod_index, std::vect
|
||||
}
|
||||
|
||||
void VoxelLodTerrain::save_all_modified_blocks(bool with_copy) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
// This is often called before quitting the game or forcing a global save.
|
||||
// This could be part of the update task if async, but here we want it to be immediate.
|
||||
@ -1986,7 +1986,7 @@ Array VoxelLodTerrain::debug_get_octrees_detailed() const {
|
||||
#ifdef TOOLS_ENABLED
|
||||
|
||||
void VoxelLodTerrain::update_gizmos() {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
// Hopefully this should not be skipped most of the time, because the task is started at the end of `_process`,
|
||||
// and gizmos update before. So the task has about 16ms to complete. If it takes longer, it will skip.
|
||||
|
@ -12,7 +12,7 @@ namespace zylann::voxel {
|
||||
|
||||
void VoxelLodTerrainUpdateTask::flush_pending_lod_edits(VoxelLodTerrainUpdateData::State &state, VoxelDataLodMap &data,
|
||||
Ref<VoxelGenerator> generator, bool full_load_mode, const int mesh_block_size) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
// Propagates edits performed so far to other LODs.
|
||||
// These LODs must be currently in memory, otherwise terrain data will miss it.
|
||||
// This is currently ensured by the fact we load blocks in a "pyramidal" way,
|
||||
@ -100,7 +100,7 @@ void VoxelLodTerrainUpdateTask::flush_pending_lod_edits(VoxelLodTerrainUpdateDat
|
||||
std::shared_ptr<VoxelBufferInternal> voxels = gd_make_shared<VoxelBufferInternal>();
|
||||
voxels->create(Vector3iUtil::create(data_block_size));
|
||||
if (generator.is_valid()) {
|
||||
VOXEL_PROFILE_SCOPE_NAMED("Generate");
|
||||
ZN_PROFILE_SCOPE_NAMED("Generate");
|
||||
VoxelGenerator::VoxelQueryData q{ //
|
||||
*voxels, //
|
||||
dst_bpos << (dst_lod_index + data_block_size_po2), //
|
||||
@ -145,7 +145,7 @@ void VoxelLodTerrainUpdateTask::flush_pending_lod_edits(VoxelLodTerrainUpdateDat
|
||||
// ugly.
|
||||
// TODO Optimization: try to narrow to edited region instead of taking whole block
|
||||
{
|
||||
VOXEL_PROFILE_SCOPE_NAMED("Downscale");
|
||||
ZN_PROFILE_SCOPE_NAMED("Downscale");
|
||||
RWLockWrite lock(src_block->get_voxels().get_lock());
|
||||
src_block->get_voxels().downscale_to(
|
||||
dst_block->get_voxels(), Vector3i(), src_block->get_voxels_const().get_size(), rel * half_bs);
|
||||
@ -183,7 +183,7 @@ struct BeforeUnloadDataAction {
|
||||
|
||||
static void unload_data_block_no_lock(VoxelLodTerrainUpdateData::Lod &lod, VoxelDataLodMap::Lod &data_lod,
|
||||
Vector3i block_pos, std::vector<VoxelLodTerrainUpdateData::BlockToSave> &blocks_to_save, bool can_save) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
data_lod.map.remove_block(block_pos, BeforeUnloadDataAction{ blocks_to_save, can_save });
|
||||
|
||||
@ -203,7 +203,7 @@ static void unload_data_block_no_lock(VoxelLodTerrainUpdateData::Lod &lod, Voxel
|
||||
static void process_unload_data_blocks_sliding_box(VoxelLodTerrainUpdateData::State &state, VoxelDataLodMap &data,
|
||||
Vector3 p_viewer_pos, std::vector<VoxelLodTerrainUpdateData::BlockToSave> &blocks_to_save, bool can_save,
|
||||
const VoxelLodTerrainUpdateData::Settings &settings) {
|
||||
VOXEL_PROFILE_SCOPE_NAMED("Sliding box data unload");
|
||||
ZN_PROFILE_SCOPE_NAMED("Sliding box data unload");
|
||||
// TODO Could it actually be enough to have a rolling update on all blocks?
|
||||
|
||||
// This should be the same distance relatively to each LOD
|
||||
@ -220,7 +220,7 @@ static void process_unload_data_blocks_sliding_box(VoxelLodTerrainUpdateData::St
|
||||
// Instead, those blocks are unloaded by the octree forest management.
|
||||
// Iterating from big to small LOD so we can exit earlier if bounds don't intersect.
|
||||
for (int lod_index = lod_count - 2; lod_index >= 0; --lod_index) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
VoxelLodTerrainUpdateData::Lod &lod = state.lods[lod_index];
|
||||
|
||||
// Each LOD keeps a box of loaded blocks, and only some of the blocks will get polygonized.
|
||||
@ -247,7 +247,7 @@ static void process_unload_data_blocks_sliding_box(VoxelLodTerrainUpdateData::St
|
||||
// Eliminate pending blocks that aren't needed
|
||||
|
||||
if (prev_box != new_box) {
|
||||
VOXEL_PROFILE_SCOPE_NAMED("Unload data");
|
||||
ZN_PROFILE_SCOPE_NAMED("Unload data");
|
||||
VoxelDataLodMap::Lod &data_lod = data.lods[lod_index];
|
||||
RWLockWrite wlock(data_lod.map_lock);
|
||||
prev_box.difference(new_box, [&lod, &data_lod, &blocks_to_save, can_save](Box3i out_of_range_box) {
|
||||
@ -259,7 +259,7 @@ static void process_unload_data_blocks_sliding_box(VoxelLodTerrainUpdateData::St
|
||||
}
|
||||
|
||||
{
|
||||
VOXEL_PROFILE_SCOPE_NAMED("Cancel updates");
|
||||
ZN_PROFILE_SCOPE_NAMED("Cancel updates");
|
||||
// Cancel block updates that are not within the padded region
|
||||
// (since neighbors are always required to remesh)
|
||||
|
||||
@ -292,7 +292,7 @@ static void process_unload_data_blocks_sliding_box(VoxelLodTerrainUpdateData::St
|
||||
|
||||
static void process_unload_mesh_blocks_sliding_box(VoxelLodTerrainUpdateData::State &state, Vector3 p_viewer_pos,
|
||||
const VoxelLodTerrainUpdateData::Settings &settings) {
|
||||
VOXEL_PROFILE_SCOPE_NAMED("Sliding box mesh unload");
|
||||
ZN_PROFILE_SCOPE_NAMED("Sliding box mesh unload");
|
||||
// TODO Could it actually be enough to have a rolling update on all blocks?
|
||||
|
||||
// This should be the same distance relatively to each LOD
|
||||
@ -305,7 +305,7 @@ static void process_unload_mesh_blocks_sliding_box(VoxelLodTerrainUpdateData::St
|
||||
// Instead, those blocks are unloaded by the octree forest management.
|
||||
// Iterating from big to small LOD so we can exit earlier if bounds don't intersect.
|
||||
for (int lod_index = settings.lod_count - 2; lod_index >= 0; --lod_index) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
VoxelLodTerrainUpdateData::Lod &lod = state.lods[lod_index];
|
||||
|
||||
unsigned int block_size_po2 = mesh_block_size_po2 + lod_index;
|
||||
@ -328,7 +328,7 @@ static void process_unload_mesh_blocks_sliding_box(VoxelLodTerrainUpdateData::St
|
||||
// Eliminate pending blocks that aren't needed
|
||||
|
||||
if (prev_box != new_box) {
|
||||
VOXEL_PROFILE_SCOPE_NAMED("Unload meshes");
|
||||
ZN_PROFILE_SCOPE_NAMED("Unload meshes");
|
||||
RWLockWrite wlock(lod.mesh_map_state.map_lock);
|
||||
prev_box.difference(new_box, [&lod](Box3i out_of_range_box) {
|
||||
out_of_range_box.for_each_cell([&lod](Vector3i pos) {
|
||||
@ -341,7 +341,7 @@ static void process_unload_mesh_blocks_sliding_box(VoxelLodTerrainUpdateData::St
|
||||
}
|
||||
|
||||
{
|
||||
VOXEL_PROFILE_SCOPE_NAMED("Cancel updates");
|
||||
ZN_PROFILE_SCOPE_NAMED("Cancel updates");
|
||||
// Cancel block updates that are not within the new region
|
||||
unordered_remove_if(lod.blocks_pending_update, [new_box](Vector3i bpos) { //
|
||||
return !new_box.contains(bpos);
|
||||
@ -355,7 +355,7 @@ static void process_unload_mesh_blocks_sliding_box(VoxelLodTerrainUpdateData::St
|
||||
|
||||
void process_octrees_sliding_box(VoxelLodTerrainUpdateData::State &state, Vector3 p_viewer_pos,
|
||||
const VoxelLodTerrainUpdateData::Settings &settings) {
|
||||
VOXEL_PROFILE_SCOPE_NAMED("Sliding box octrees");
|
||||
ZN_PROFILE_SCOPE_NAMED("Sliding box octrees");
|
||||
// TODO Investigate if multi-octree can produce cracks in the terrain (so far I haven't noticed)
|
||||
|
||||
const unsigned int mesh_block_size_po2 = settings.mesh_block_size_po2;
|
||||
@ -443,7 +443,7 @@ void process_octrees_sliding_box(VoxelLodTerrainUpdateData::State &state, Vector
|
||||
ExitAction exit_action{ state, settings.lod_count };
|
||||
EnterAction enter_action{ state, settings.lod_count };
|
||||
{
|
||||
VOXEL_PROFILE_SCOPE_NAMED("Unload octrees");
|
||||
ZN_PROFILE_SCOPE_NAMED("Unload octrees");
|
||||
|
||||
const unsigned int last_lod_index = settings.lod_count - 1;
|
||||
VoxelLodTerrainUpdateData::Lod &last_lod = state.lods[last_lod_index];
|
||||
@ -454,7 +454,7 @@ void process_octrees_sliding_box(VoxelLodTerrainUpdateData::State &state, Vector
|
||||
});
|
||||
}
|
||||
{
|
||||
VOXEL_PROFILE_SCOPE_NAMED("Load octrees");
|
||||
ZN_PROFILE_SCOPE_NAMED("Load octrees");
|
||||
new_box.difference(prev_box, [enter_action](Box3i box_to_load) { //
|
||||
box_to_load.for_each_cell(enter_action);
|
||||
});
|
||||
@ -542,7 +542,7 @@ bool check_block_mesh_updated(VoxelLodTerrainUpdateData::State &state, VoxelData
|
||||
VoxelLodTerrainUpdateData::MeshBlockState &mesh_block, Vector3i mesh_block_pos, uint8_t lod_index,
|
||||
std::vector<VoxelLodTerrainUpdateData::BlockLocation> &blocks_to_load,
|
||||
const VoxelLodTerrainUpdateData::Settings &settings) {
|
||||
//VOXEL_PROFILE_SCOPE();
|
||||
//ZN_PROFILE_SCOPE();
|
||||
|
||||
VoxelLodTerrainUpdateData::Lod &lod = state.lods[lod_index];
|
||||
|
||||
@ -791,7 +791,7 @@ static void process_octrees_fitting(VoxelLodTerrainUpdateData::State &state,
|
||||
const VoxelLodTerrainUpdateData::Settings &settings, VoxelDataLodMap &data, Vector3 p_viewer_pos,
|
||||
std::vector<VoxelLodTerrainUpdateData::BlockLocation> &data_blocks_to_load) {
|
||||
//
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
const int mesh_block_size = 1 << settings.mesh_block_size_po2;
|
||||
const int octree_leaf_node_size = mesh_block_size;
|
||||
@ -824,7 +824,7 @@ static void process_octrees_fitting(VoxelLodTerrainUpdateData::State &state,
|
||||
// TODO Maintain a vector to make iteration faster?
|
||||
for (Map<Vector3i, VoxelLodTerrainUpdateData::OctreeItem>::Element *E = state.lod_octrees.front(); E;
|
||||
E = E->next()) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
struct OctreeActions {
|
||||
VoxelLodTerrainUpdateData::State &state;
|
||||
@ -901,7 +901,7 @@ static void process_octrees_fitting(VoxelLodTerrainUpdateData::State &state,
|
||||
}
|
||||
|
||||
bool can_split(Vector3i node_pos, int lod_index, LodOctree::NodeData &node_data) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
if (!LodOctree::is_below_split_distance(
|
||||
node_pos, lod_index, viewer_pos_octree_space, lod_distance_octree_space)) {
|
||||
return false;
|
||||
@ -937,7 +937,7 @@ static void process_octrees_fitting(VoxelLodTerrainUpdateData::State &state,
|
||||
}
|
||||
|
||||
bool can_join(Vector3i node_pos, int parent_lod_index) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
if (LodOctree::is_below_split_distance(
|
||||
node_pos, parent_lod_index, viewer_pos_octree_space, lod_distance_octree_space)) {
|
||||
return false;
|
||||
@ -996,7 +996,7 @@ static void process_octrees_fitting(VoxelLodTerrainUpdateData::State &state,
|
||||
// In theory, blocks containing no surface have no reason to need a transition mask,
|
||||
// but when we get a new mesh update into a block that previously had no surface, we still need it.
|
||||
|
||||
VOXEL_PROFILE_SCOPE_NAMED("Transition masks");
|
||||
ZN_PROFILE_SCOPE_NAMED("Transition masks");
|
||||
for (unsigned int lod_index = 0; lod_index < tls_blocks_pending_transition_update_per_lod.size(); ++lod_index) {
|
||||
std::vector<Vector3i> &blocks_pending_transition_update =
|
||||
tls_blocks_pending_transition_update_per_lod[lod_index];
|
||||
@ -1174,7 +1174,7 @@ static void send_mesh_requests(uint32_t volume_id, VoxelLodTerrainUpdateData::St
|
||||
std::shared_ptr<PriorityDependency::ViewersData> &shared_viewers_data, const Transform3D &volume_transform,
|
||||
BufferedTaskScheduler &task_scheduler) {
|
||||
//
|
||||
VOXEL_PROFILE_SCOPE_NAMED("Send mesh requests");
|
||||
ZN_PROFILE_SCOPE_NAMED("Send mesh requests");
|
||||
|
||||
CRASH_COND(data_ptr == nullptr);
|
||||
const VoxelDataLodMap &data = *data_ptr;
|
||||
@ -1184,11 +1184,11 @@ static void send_mesh_requests(uint32_t volume_id, VoxelLodTerrainUpdateData::St
|
||||
const int render_to_data_factor = mesh_block_size / mesh_block_size;
|
||||
|
||||
for (unsigned int lod_index = 0; lod_index < settings.lod_count; ++lod_index) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
VoxelLodTerrainUpdateData::Lod &lod = state.lods[lod_index];
|
||||
|
||||
for (unsigned int bi = 0; bi < lod.blocks_pending_update.size(); ++bi) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
const Vector3i mesh_block_pos = lod.blocks_pending_update[bi];
|
||||
|
||||
auto mesh_block_it = lod.mesh_map_state.map.find(mesh_block_pos);
|
||||
@ -1241,7 +1241,7 @@ static std::shared_ptr<AsyncDependencyTracker> preload_boxes_async(VoxelLodTerra
|
||||
Span<IThreadedTask *> next_tasks, uint32_t volume_id, std::shared_ptr<StreamingDependency> &stream_dependency,
|
||||
std::shared_ptr<PriorityDependency::ViewersData> &shared_viewers_data, const Transform3D &volume_transform,
|
||||
BufferedTaskScheduler &task_scheduler) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
ERR_FAIL_COND_V_MSG(settings.full_load_mode == false, nullptr, "This function can only be used in full load mode");
|
||||
|
||||
@ -1256,7 +1256,7 @@ static std::shared_ptr<AsyncDependencyTracker> preload_boxes_async(VoxelLodTerra
|
||||
|
||||
for (unsigned int lod_index = 0; lod_index < settings.lod_count; ++lod_index) {
|
||||
for (unsigned int box_index = 0; box_index < voxel_boxes.size(); ++box_index) {
|
||||
VOXEL_PROFILE_SCOPE_NAMED("Box");
|
||||
ZN_PROFILE_SCOPE_NAMED("Box");
|
||||
|
||||
VoxelLodTerrainUpdateData::Lod &lod = state.lods[lod_index];
|
||||
const Box3i voxel_box = voxel_boxes[box_index];
|
||||
@ -1285,7 +1285,7 @@ static std::shared_ptr<AsyncDependencyTracker> preload_boxes_async(VoxelLodTerra
|
||||
// TODO `next_tasks` is executed in parallel. But since they can be edits, may we do them in sequence?
|
||||
|
||||
if (todo.size() > 0) {
|
||||
VOXEL_PROFILE_SCOPE_NAMED("Posting requests");
|
||||
ZN_PROFILE_SCOPE_NAMED("Posting requests");
|
||||
|
||||
// Only create the tracker if we actually are creating tasks. If we still create it,
|
||||
// no task will take ownership of it, so if it is not stored after this function returns,
|
||||
@ -1316,7 +1316,7 @@ static void process_async_edits(VoxelLodTerrainUpdateData::State &state,
|
||||
std::shared_ptr<StreamingDependency> &stream_dependency,
|
||||
std::shared_ptr<PriorityDependency::ViewersData> &shared_viewers_data, const Transform3D &volume_transform,
|
||||
BufferedTaskScheduler &task_scheduler) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
if (state.running_async_edits.size() == 0) {
|
||||
// Schedule all next edits when the previous ones are done
|
||||
@ -1354,7 +1354,7 @@ static void process_async_edits(VoxelLodTerrainUpdateData::State &state,
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void VoxelLodTerrainUpdateTask::run(ThreadedTaskContext ctx) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
struct SetCompleteOnScopeExit {
|
||||
std::atomic_bool &_complete;
|
||||
@ -1436,7 +1436,7 @@ void VoxelLodTerrainUpdateTask::run(ThreadedTaskContext ctx) {
|
||||
|
||||
profiling_clock.restart();
|
||||
{
|
||||
VOXEL_PROFILE_SCOPE_NAMED("IO requests");
|
||||
ZN_PROFILE_SCOPE_NAMED("IO requests");
|
||||
// It's possible the user didn't set a stream yet, or it is turned off
|
||||
if (stream_enabled) {
|
||||
const unsigned int data_block_size = data.lods[0].map.get_block_size();
|
||||
|
@ -192,7 +192,7 @@ void VoxelMeshBlockVLT::set_parent_visible(bool parent_visible) {
|
||||
}
|
||||
|
||||
void VoxelMeshBlockVLT::set_parent_transform(const Transform3D &parent_transform) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
if (_mesh_instance.is_valid() || _static_body.is_valid()) {
|
||||
const Transform3D local_transform(Basis(), _position_in_voxels);
|
||||
|
@ -112,7 +112,7 @@ void VoxelMeshBlock::set_parent_visible(bool parent_visible) {
|
||||
}
|
||||
|
||||
void VoxelMeshBlock::set_parent_transform(const Transform3D &parent_transform) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
if (_mesh_instance.is_valid() || _static_body.is_valid()) {
|
||||
const Transform3D local_transform(Basis(), _position_in_voxels);
|
||||
|
@ -44,7 +44,7 @@ void DirectMeshInstance::set_world(World3D *world) {
|
||||
}
|
||||
|
||||
void DirectMeshInstance::set_transform(Transform3D world_transform) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
ERR_FAIL_COND(!_mesh_instance.is_valid());
|
||||
RenderingServer &vs = *RenderingServer::get_singleton();
|
||||
vs.instance_set_transform(_mesh_instance, world_transform);
|
||||
|
@ -59,7 +59,7 @@ Ref<MultiMesh> DirectMultiMeshInstance::get_multimesh() const {
|
||||
}
|
||||
|
||||
void DirectMultiMeshInstance::set_transform(Transform3D world_transform) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
ERR_FAIL_COND(!_multimesh_instance.is_valid());
|
||||
RenderingServer &vs = *RenderingServer::get_singleton();
|
||||
vs.instance_set_transform(_multimesh_instance, world_transform);
|
||||
@ -106,7 +106,7 @@ inline void write_bulk_array_transform(float *dst, const Transform3D &t) {
|
||||
|
||||
void DirectMultiMeshInstance::make_transform_3d_bulk_array(
|
||||
Span<const Transform3D> transforms, PackedFloat32Array &bulk_array) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
const int item_size = 12; // In number of floats
|
||||
|
||||
@ -130,7 +130,7 @@ void DirectMultiMeshInstance::make_transform_3d_bulk_array(
|
||||
|
||||
void DirectMultiMeshInstance::make_transform_and_color8_3d_bulk_array(
|
||||
Span<const TransformAndColor8> data, PackedFloat32Array &bulk_array) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
const int transform_size = 12; // In number of floats
|
||||
const int item_size = transform_size + sizeof(Color8) / sizeof(float);
|
||||
@ -154,7 +154,7 @@ void DirectMultiMeshInstance::make_transform_and_color8_3d_bulk_array(
|
||||
|
||||
void DirectMultiMeshInstance::make_transform_and_color32_3d_bulk_array(
|
||||
Span<const TransformAndColor32> data, PackedFloat32Array &bulk_array) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
const int transform_size = 12; // In number of floats
|
||||
const int item_size = transform_size + sizeof(Color) / sizeof(float);
|
||||
|
@ -41,7 +41,7 @@ bool DirectStaticBody::is_valid() const {
|
||||
}
|
||||
|
||||
void DirectStaticBody::set_transform(Transform3D transform) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
ERR_FAIL_COND(!_body.is_valid());
|
||||
PhysicsServer3D::get_singleton()->body_set_state(_body, PhysicsServer3D::BODY_STATE_TRANSFORM, transform);
|
||||
|
||||
|
@ -31,7 +31,7 @@ bool is_mesh_empty(const Mesh &mesh) {
|
||||
// See https://github.com/Zylann/godot_voxel/issues/54
|
||||
//
|
||||
Ref<ConcavePolygonShape3D> create_concave_polygon_shape(Span<const Array> surfaces) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
PackedVector3Array face_points;
|
||||
int face_points_size = 0;
|
||||
@ -93,7 +93,7 @@ Ref<ConcavePolygonShape3D> create_concave_polygon_shape(Span<const Array> surfac
|
||||
|
||||
Ref<ConcavePolygonShape3D> shape;
|
||||
{
|
||||
VOXEL_PROFILE_SCOPE_NAMED("Godot shape");
|
||||
ZN_PROFILE_SCOPE_NAMED("Godot shape");
|
||||
shape.instantiate();
|
||||
shape->set_faces(face_points);
|
||||
}
|
||||
|
@ -1,34 +1,34 @@
|
||||
#ifndef VOXEL_PROFILING_H
|
||||
#define VOXEL_PROFILING_H
|
||||
#ifndef ZN_PROFILING_H
|
||||
#define ZN_PROFILING_H
|
||||
|
||||
#if defined(TRACY_ENABLE)
|
||||
|
||||
#include <thirdparty/tracy/Tracy.hpp>
|
||||
#include <thirdparty/tracy/common/TracySystem.hpp>
|
||||
|
||||
#define VOXEL_PROFILER_ENABLED
|
||||
#define ZN_PROFILER_ENABLED
|
||||
|
||||
#define VOXEL_PROFILE_SCOPE() ZoneScoped
|
||||
#define VOXEL_PROFILE_SCOPE_NAMED(name) ZoneScopedN(name)
|
||||
#define VOXEL_PROFILE_MARK_FRAME() FrameMark
|
||||
#define VOXEL_PROFILE_SET_THREAD_NAME(name) tracy::SetThreadName(name)
|
||||
#define VOXEL_PROFILE_PLOT(name, number) TracyPlot(name, number)
|
||||
#define VOXEL_PROFILE_MESSAGE(message) TracyMessageL(message)
|
||||
#define VOXEL_PROFILE_MESSAGE_DYN(message, size) TracyMessage(message, size)
|
||||
#define ZN_PROFILE_SCOPE() ZoneScoped
|
||||
#define ZN_PROFILE_SCOPE_NAMED(name) ZoneScopedN(name)
|
||||
#define ZN_PROFILE_MARK_FRAME() FrameMark
|
||||
#define ZN_PROFILE_SET_THREAD_NAME(name) tracy::SetThreadName(name)
|
||||
#define ZN_PROFILE_PLOT(name, number) TracyPlot(name, number)
|
||||
#define ZN_PROFILE_MESSAGE(message) TracyMessageL(message)
|
||||
#define ZN_PROFILE_MESSAGE_DYN(message, size) TracyMessage(message, size)
|
||||
|
||||
#else
|
||||
|
||||
#define VOXEL_PROFILE_SCOPE()
|
||||
#define ZN_PROFILE_SCOPE()
|
||||
// Name must be static const char* (usually string litteral)
|
||||
#define VOXEL_PROFILE_SCOPE_NAMED(name)
|
||||
#define VOXEL_PROFILE_MARK_FRAME()
|
||||
#define VOXEL_PROFILE_PLOT(name, number)
|
||||
#define VOXEL_PROFILE_MESSAGE(message)
|
||||
#define ZN_PROFILE_SCOPE_NAMED(name)
|
||||
#define ZN_PROFILE_MARK_FRAME()
|
||||
#define ZN_PROFILE_PLOT(name, number)
|
||||
#define ZN_PROFILE_MESSAGE(message)
|
||||
// Name must be const char*. An internal copy will be made so it can be temporary.
|
||||
// Size does not include the terminating character.
|
||||
#define VOXEL_PROFILE_MESSAGE_DYN(message, size)
|
||||
#define ZN_PROFILE_MESSAGE_DYN(message, size)
|
||||
// Name must be const char*. An internal copy will be made so it can be temporary.
|
||||
#define VOXEL_PROFILE_SET_THREAD_NAME(name)
|
||||
#define ZN_PROFILE_SET_THREAD_NAME(name)
|
||||
|
||||
#endif
|
||||
|
||||
@ -43,4 +43,4 @@ env_thirdparty.add_source_files(env.core_sources, ["#thirdparty/tracy/TracyClien
|
||||
```
|
||||
*/
|
||||
|
||||
#endif // VOXEL_PROFILING_H
|
||||
#endif // ZN_PROFILING_H
|
||||
|
@ -124,9 +124,9 @@ void ThreadedTaskRunner::thread_func_static(void *p_data) {
|
||||
if (!data.name.is_empty()) {
|
||||
Thread::set_name(data.name);
|
||||
|
||||
#ifdef VOXEL_PROFILER_ENABLED
|
||||
#ifdef ZN_PROFILER_ENABLED
|
||||
CharString thread_name = data.name.utf8();
|
||||
VOXEL_PROFILE_SET_THREAD_NAME(thread_name.get_data());
|
||||
ZN_PROFILE_SET_THREAD_NAME(thread_name.get_data());
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -141,7 +141,7 @@ void ThreadedTaskRunner::thread_func(ThreadData &data) {
|
||||
|
||||
while (!data.stop) {
|
||||
{
|
||||
VOXEL_PROFILE_SCOPE_NAMED("Task pickup");
|
||||
ZN_PROFILE_SCOPE_NAMED("Task pickup");
|
||||
|
||||
data.debug_state = STATE_PICKING;
|
||||
const uint64_t now = Time::get_singleton()->get_ticks_msec();
|
||||
|
@ -23,7 +23,7 @@ void TimeSpreadTaskRunner::push(Span<ITimeSpreadTask *> tasks) {
|
||||
}
|
||||
|
||||
void TimeSpreadTaskRunner::process(uint64_t time_budget_usec) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
const Time &time = *Time::get_singleton();
|
||||
|
||||
static thread_local std::vector<ITimeSpreadTask *> tls_postponed_tasks;
|
||||
|
@ -8,7 +8,7 @@ template <typename Predicate_F> // f(Vector3i position) -> bool
|
||||
bool voxel_raycast(Vector3 ray_origin, Vector3 ray_direction, Predicate_F predicate, real_t max_distance,
|
||||
Vector3i &out_hit_pos, Vector3i &out_prev_pos, float &out_distance_along_ray,
|
||||
float &out_distance_along_ray_prev) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
ZN_PROFILE_SCOPE();
|
||||
|
||||
ERR_FAIL_COND_V(math::has_nan(ray_origin), false);
|
||||
ERR_FAIL_COND_V(math::has_nan(ray_direction), false);
|
||||
|
Loading…
x
Reference in New Issue
Block a user