Rename tasks:

- As verbs for the task they do
- Suffixed with Task instead of Request,
  to avoid confusion with network stuff
This commit is contained in:
Marc Gilleron 2022-02-06 13:45:51 +00:00
parent ba1930769f
commit 320cc7422c
12 changed files with 140 additions and 143 deletions

View File

@ -1,8 +1,8 @@
#include "block_generate_request.h"
#include "generate_block_task.h"
#include "../util/godot/funcs.h"
#include "../util/macros.h"
#include "../util/profiling.h"
#include "save_block_data_request.h"
#include "save_block_data_task.h"
#include "voxel_server.h"
namespace zylann::voxel {
@ -11,19 +11,19 @@ namespace {
std::atomic_int g_debug_generate_tasks_count;
}
BlockGenerateRequest::BlockGenerateRequest() {
GenerateBlockTask::GenerateBlockTask() {
++g_debug_generate_tasks_count;
}
BlockGenerateRequest::~BlockGenerateRequest() {
GenerateBlockTask::~GenerateBlockTask() {
--g_debug_generate_tasks_count;
}
int BlockGenerateRequest::debug_get_running_count() {
int GenerateBlockTask::debug_get_running_count() {
return g_debug_generate_tasks_count;
}
void BlockGenerateRequest::run(zylann::ThreadedTaskContext ctx) {
void GenerateBlockTask::run(zylann::ThreadedTaskContext ctx) {
VOXEL_PROFILE_SCOPE();
CRASH_COND(stream_dependency == nullptr);
@ -57,28 +57,28 @@ void BlockGenerateRequest::run(zylann::ThreadedTaskContext ctx) {
// No instances, generators are not designed to produce them at this stage yet.
// No priority data, saving doesnt need sorting
SaveBlockDataRequest *save_request =
memnew(SaveBlockDataRequest(volume_id, position, lod, block_size, voxels_copy, stream_dependency));
SaveBlockDataTask *save_task =
memnew(SaveBlockDataTask(volume_id, position, lod, block_size, voxels_copy, stream_dependency));
VoxelServer::get_singleton()->push_async_task(save_request);
VoxelServer::get_singleton()->push_async_task(save_task);
}
}
has_run = true;
}
int BlockGenerateRequest::get_priority() {
int GenerateBlockTask::get_priority() {
float closest_viewer_distance_sq;
const int p = priority_dependency.evaluate(lod, &closest_viewer_distance_sq);
too_far = drop_beyond_max_distance && closest_viewer_distance_sq > priority_dependency.drop_distance_squared;
return p;
}
bool BlockGenerateRequest::is_cancelled() {
bool GenerateBlockTask::is_cancelled() {
return !stream_dependency->valid || too_far; // || stream_dependency->stream->get_fallback_generator().is_null();
}
void BlockGenerateRequest::apply_result() {
void GenerateBlockTask::apply_result() {
bool aborted = true;
if (VoxelServer::get_singleton()->is_volume_valid(volume_id)) {

View File

@ -1,5 +1,5 @@
#ifndef BLOCK_GENERATE_REQUEST_H
#define BLOCK_GENERATE_REQUEST_H
#ifndef GENERATE_BLOCK_TASK_H
#define GENERATE_BLOCK_TASK_H
#include "../util/tasks/async_dependency_tracker.h"
#include "../util/tasks/threaded_task.h"
@ -8,10 +8,10 @@
namespace zylann::voxel {
class BlockGenerateRequest : public IThreadedTask {
class GenerateBlockTask : public IThreadedTask {
public:
BlockGenerateRequest();
~BlockGenerateRequest();
GenerateBlockTask();
~GenerateBlockTask();
void run(ThreadedTaskContext ctx) override;
int get_priority() override;
@ -36,4 +36,4 @@ public:
} // namespace zylann::voxel
#endif // BLOCK_GENERATE_REQUEST_H
#endif // GENERATE_BLOCK_TASK_H

View File

@ -1,11 +1,11 @@
#include "all_blocks_data_request.h"
#include "load_all_blocks_data_task.h"
#include "../util/macros.h"
#include "../util/profiling.h"
#include "voxel_server.h"
namespace zylann::voxel {
void AllBlocksDataRequest::run(zylann::ThreadedTaskContext ctx) {
void LoadAllBlocksDataTask::run(zylann::ThreadedTaskContext ctx) {
VOXEL_PROFILE_SCOPE();
CRASH_COND(stream_dependency == nullptr);
@ -17,15 +17,15 @@ void AllBlocksDataRequest::run(zylann::ThreadedTaskContext ctx) {
PRINT_VERBOSE(String("Loaded {0} blocks for volume {1}").format(varray(_result.blocks.size(), volume_id)));
}
int AllBlocksDataRequest::get_priority() {
int LoadAllBlocksDataTask::get_priority() {
return 0;
}
bool AllBlocksDataRequest::is_cancelled() {
bool LoadAllBlocksDataTask::is_cancelled() {
return !stream_dependency->valid;
}
void AllBlocksDataRequest::apply_result() {
void LoadAllBlocksDataTask::apply_result() {
if (VoxelServer::get_singleton()->is_volume_valid(volume_id)) {
// TODO Comparing pointer may not be guaranteed
// The request response must match the dependency it would have been requested with.

View File

@ -1,5 +1,5 @@
#ifndef ALL_BLOCKS_DATA_REQUEST_H
#define ALL_BLOCKS_DATA_REQUEST_H
#ifndef LOAD_ALL_BLOCKS_DATA_TASK_H
#define LOAD_ALL_BLOCKS_DATA_TASK_H
#include "../streams/voxel_stream.h"
#include "../util/tasks/threaded_task.h"
@ -8,7 +8,7 @@
namespace zylann::voxel {
class AllBlocksDataRequest : public IThreadedTask {
class LoadAllBlocksDataTask : public IThreadedTask {
public:
void run(ThreadedTaskContext ctx) override;
int get_priority() override;
@ -24,4 +24,4 @@ private:
} // namespace zylann::voxel
#endif // ALL_BLOCKS_DATA_REQUEST_H
#endif // LOAD_ALL_BLOCKS_DATA_TASK_H

View File

@ -1,8 +1,8 @@
#include "load_block_data_request.h"
#include "load_block_data_task.h"
#include "../util/godot/funcs.h"
#include "../util/macros.h"
#include "../util/profiling.h"
#include "block_generate_request.h"
#include "generate_block_task.h"
#include "voxel_server.h"
namespace zylann::voxel {
@ -11,8 +11,8 @@ namespace {
std::atomic_int g_debug_load_block_tasks_count;
}
LoadBlockDataRequest::LoadBlockDataRequest(uint32_t p_volume_id, Vector3i p_block_pos, uint8_t p_lod,
uint8_t p_block_size, bool p_request_instances, std::shared_ptr<StreamingDependency> p_stream_dependency,
LoadBlockDataTask::LoadBlockDataTask(uint32_t p_volume_id, Vector3i p_block_pos, uint8_t p_lod, uint8_t p_block_size,
bool p_request_instances, std::shared_ptr<StreamingDependency> p_stream_dependency,
PriorityDependency p_priority_dependency) :
_priority_dependency(p_priority_dependency),
_position(p_block_pos),
@ -26,15 +26,15 @@ LoadBlockDataRequest::LoadBlockDataRequest(uint32_t p_volume_id, Vector3i p_bloc
++g_debug_load_block_tasks_count;
}
LoadBlockDataRequest::~LoadBlockDataRequest() {
LoadBlockDataTask::~LoadBlockDataTask() {
--g_debug_load_block_tasks_count;
}
int LoadBlockDataRequest::debug_get_running_count() {
int LoadBlockDataTask::debug_get_running_count() {
return g_debug_load_block_tasks_count;
}
void LoadBlockDataRequest::run(zylann::ThreadedTaskContext ctx) {
void LoadBlockDataTask::run(zylann::ThreadedTaskContext ctx) {
VOXEL_PROFILE_SCOPE();
CRASH_COND(_stream_dependency == nullptr);
@ -62,16 +62,16 @@ void LoadBlockDataRequest::run(zylann::ThreadedTaskContext ctx) {
Ref<VoxelGenerator> generator = _stream_dependency->generator;
if (generator.is_valid()) {
BlockGenerateRequest *r = memnew(BlockGenerateRequest);
r->voxels = _voxels;
r->volume_id = _volume_id;
r->position = _position;
r->lod = _lod;
r->block_size = _block_size;
r->stream_dependency = _stream_dependency;
r->priority_dependency = _priority_dependency;
GenerateBlockTask *task = memnew(GenerateBlockTask);
task->voxels = _voxels;
task->volume_id = _volume_id;
task->position = _position;
task->lod = _lod;
task->block_size = _block_size;
task->stream_dependency = _stream_dependency;
task->priority_dependency = _priority_dependency;
VoxelServer::get_singleton()->push_async_task(r);
VoxelServer::get_singleton()->push_async_task(task);
_fallback_on_generator = true;
} else {
@ -105,18 +105,18 @@ void LoadBlockDataRequest::run(zylann::ThreadedTaskContext ctx) {
_has_run = true;
}
int LoadBlockDataRequest::get_priority() {
int LoadBlockDataTask::get_priority() {
float closest_viewer_distance_sq;
const int p = _priority_dependency.evaluate(_lod, &closest_viewer_distance_sq);
_too_far = closest_viewer_distance_sq > _priority_dependency.drop_distance_squared;
return p;
}
bool LoadBlockDataRequest::is_cancelled() {
bool LoadBlockDataTask::is_cancelled() {
return !_stream_dependency->valid || _too_far;
}
void LoadBlockDataRequest::apply_result() {
void LoadBlockDataTask::apply_result() {
if (VoxelServer::get_singleton()->is_volume_valid(_volume_id)) {
// TODO Comparing pointer may not be guaranteed
// The request response must match the dependency it would have been requested with.

View File

@ -1,5 +1,5 @@
#ifndef LOAD_BLOCK_DATA_REQUEST_H
#define LOAD_BLOCK_DATA_REQUEST_H
#ifndef LOAD_BLOCK_DATA_TASK_H
#define LOAD_BLOCK_DATA_TASK_H
#include "../util/tasks/threaded_task.h"
#include "priority_dependency.h"
@ -7,13 +7,13 @@
namespace zylann::voxel {
class LoadBlockDataRequest : public IThreadedTask {
class LoadBlockDataTask : public IThreadedTask {
public:
LoadBlockDataRequest(uint32_t p_volume_id, Vector3i p_block_pos, uint8_t p_lod, uint8_t p_block_size,
LoadBlockDataTask(uint32_t p_volume_id, Vector3i p_block_pos, uint8_t p_lod, uint8_t p_block_size,
bool p_request_instances, std::shared_ptr<StreamingDependency> p_stream_dependency,
PriorityDependency p_priority_dependency);
~LoadBlockDataRequest();
~LoadBlockDataTask();
void run(ThreadedTaskContext ctx) override;
int get_priority() override;
@ -41,4 +41,4 @@ private:
} // namespace zylann::voxel
#endif // LOAD_BLOCK_DATA_REQUEST_H
#endif // LOAD_BLOCK_DATA_TASK_H

View File

@ -1,4 +1,4 @@
#include "block_mesh_request.h"
#include "mesh_block_task.h"
#include "../util/macros.h"
#include "../util/profiling.h"
#include "voxel_server.h"
@ -137,19 +137,19 @@ namespace {
std::atomic_int g_debug_mesh_tasks_count;
} //namespace
BlockMeshRequest::BlockMeshRequest() {
MeshBlockTask::MeshBlockTask() {
++g_debug_mesh_tasks_count;
}
BlockMeshRequest::~BlockMeshRequest() {
MeshBlockTask::~MeshBlockTask() {
--g_debug_mesh_tasks_count;
}
int BlockMeshRequest::debug_get_running_count() {
int MeshBlockTask::debug_get_running_count() {
return g_debug_mesh_tasks_count;
}
void BlockMeshRequest::run(zylann::ThreadedTaskContext ctx) {
void MeshBlockTask::run(zylann::ThreadedTaskContext ctx) {
VOXEL_PROFILE_SCOPE();
CRASH_COND(meshing_dependency == nullptr);
@ -169,18 +169,18 @@ void BlockMeshRequest::run(zylann::ThreadedTaskContext ctx) {
_has_run = true;
}
int BlockMeshRequest::get_priority() {
int MeshBlockTask::get_priority() {
float closest_viewer_distance_sq;
const int p = priority_dependency.evaluate(lod, &closest_viewer_distance_sq);
_too_far = closest_viewer_distance_sq > priority_dependency.drop_distance_squared;
return p;
}
bool BlockMeshRequest::is_cancelled() {
bool MeshBlockTask::is_cancelled() {
return !meshing_dependency->valid || _too_far;
}
void BlockMeshRequest::apply_result() {
void MeshBlockTask::apply_result() {
if (VoxelServer::get_singleton()->is_volume_valid(volume_id)) {
// The request response must match the dependency it would have been requested with.
// If it doesn't match, we are no longer interested in the result.

View File

@ -1,5 +1,5 @@
#ifndef VOXEL_BLOCK_MESH_REQUEST_H
#define VOXEL_BLOCK_MESH_REQUEST_H
#ifndef VOXEL_MESH_BLOCK_TASK_H
#define VOXEL_MESH_BLOCK_TASK_H
#include "../constants/voxel_constants.h"
#include "../generators/voxel_generator.h"
@ -11,7 +11,7 @@
namespace zylann::voxel {
// Asynchronous task generating a mesh from voxel blocks and their neighbors, in a particular volume
class BlockMeshRequest : public IThreadedTask {
class MeshBlockTask : public IThreadedTask {
public:
struct MeshingDependency {
Ref<VoxelMesher> mesher;
@ -19,8 +19,8 @@ public:
bool valid = true;
};
BlockMeshRequest();
~BlockMeshRequest();
MeshBlockTask();
~MeshBlockTask();
void run(ThreadedTaskContext ctx) override;
int get_priority() override;
@ -49,4 +49,4 @@ private:
} // namespace zylann::voxel
#endif // VOXEL_BLOCK_MESH_REQUEST_H
#endif // VOXEL_MESH_BLOCK_TASK_H

View File

@ -1,8 +1,8 @@
#include "save_block_data_request.h"
#include "save_block_data_task.h"
#include "../util/godot/funcs.h"
#include "../util/macros.h"
#include "../util/profiling.h"
#include "block_generate_request.h"
#include "generate_block_task.h"
#include "voxel_server.h"
namespace zylann::voxel {
@ -11,9 +11,8 @@ namespace {
std::atomic_int g_debug_save_block_tasks_count;
}
SaveBlockDataRequest::SaveBlockDataRequest(uint32_t p_volume_id, Vector3i p_block_pos, uint8_t p_lod,
uint8_t p_block_size, std::shared_ptr<VoxelBufferInternal> p_voxels,
std::shared_ptr<StreamingDependency> p_stream_dependency) :
SaveBlockDataTask::SaveBlockDataTask(uint32_t p_volume_id, Vector3i p_block_pos, uint8_t p_lod, uint8_t p_block_size,
std::shared_ptr<VoxelBufferInternal> p_voxels, std::shared_ptr<StreamingDependency> p_stream_dependency) :
_voxels(p_voxels),
_position(p_block_pos),
_volume_id(p_volume_id),
@ -26,9 +25,8 @@ SaveBlockDataRequest::SaveBlockDataRequest(uint32_t p_volume_id, Vector3i p_bloc
++g_debug_save_block_tasks_count;
}
SaveBlockDataRequest::SaveBlockDataRequest(uint32_t p_volume_id, Vector3i p_block_pos, uint8_t p_lod,
uint8_t p_block_size, std::unique_ptr<InstanceBlockData> p_instances,
std::shared_ptr<StreamingDependency> p_stream_dependency) :
SaveBlockDataTask::SaveBlockDataTask(uint32_t p_volume_id, Vector3i p_block_pos, uint8_t p_lod, uint8_t p_block_size,
std::unique_ptr<InstanceBlockData> p_instances, std::shared_ptr<StreamingDependency> p_stream_dependency) :
_instances(std::move(p_instances)),
_position(p_block_pos),
_volume_id(p_volume_id),
@ -41,15 +39,15 @@ SaveBlockDataRequest::SaveBlockDataRequest(uint32_t p_volume_id, Vector3i p_bloc
++g_debug_save_block_tasks_count;
}
SaveBlockDataRequest::~SaveBlockDataRequest() {
SaveBlockDataTask::~SaveBlockDataTask() {
--g_debug_save_block_tasks_count;
}
int SaveBlockDataRequest::debug_get_running_count() {
int SaveBlockDataTask::debug_get_running_count() {
return g_debug_save_block_tasks_count;
}
void SaveBlockDataRequest::run(zylann::ThreadedTaskContext ctx) {
void SaveBlockDataTask::run(zylann::ThreadedTaskContext ctx) {
VOXEL_PROFILE_SCOPE();
CRASH_COND(_stream_dependency == nullptr);
@ -90,15 +88,15 @@ void SaveBlockDataRequest::run(zylann::ThreadedTaskContext ctx) {
_has_run = true;
}
int SaveBlockDataRequest::get_priority() {
int SaveBlockDataTask::get_priority() {
return 0;
}
bool SaveBlockDataRequest::is_cancelled() {
bool SaveBlockDataTask::is_cancelled() {
return false;
}
void SaveBlockDataRequest::apply_result() {
void SaveBlockDataTask::apply_result() {
if (VoxelServer::get_singleton()->is_volume_valid(_volume_id)) {
if (_stream_dependency->valid) {
VoxelServer::BlockDataOutput o;

View File

@ -1,22 +1,22 @@
#ifndef SAVE_BLOCK_DATA_REQUEST_H
#define SAVE_BLOCK_DATA_REQUEST_H
#ifndef SAVE_BLOCK_DATA_TASK_H
#define SAVE_BLOCK_DATA_TASK_H
#include "../util/tasks/threaded_task.h"
#include "streaming_dependency.h"
namespace zylann::voxel {
class SaveBlockDataRequest : public IThreadedTask {
class SaveBlockDataTask : public IThreadedTask {
public:
// For saving voxels only
SaveBlockDataRequest(uint32_t p_volume_id, Vector3i p_block_pos, uint8_t p_lod, uint8_t p_block_size,
SaveBlockDataTask(uint32_t p_volume_id, Vector3i p_block_pos, uint8_t p_lod, uint8_t p_block_size,
std::shared_ptr<VoxelBufferInternal> p_voxels, std::shared_ptr<StreamingDependency> p_stream_dependency);
// For saving instances only
SaveBlockDataRequest(uint32_t p_volume_id, Vector3i p_block_pos, uint8_t p_lod, uint8_t p_block_size,
SaveBlockDataTask(uint32_t p_volume_id, Vector3i p_block_pos, uint8_t p_lod, uint8_t p_block_size,
std::unique_ptr<InstanceBlockData> p_instances, std::shared_ptr<StreamingDependency> p_stream_dependency);
~SaveBlockDataRequest();
~SaveBlockDataTask();
void run(ThreadedTaskContext ctx) override;
int get_priority() override;
@ -40,4 +40,4 @@ private:
} // namespace zylann::voxel
#endif // SAVE_BLOCK_DATA_REQUEST_H
#endif // SAVE_BLOCK_DATA_TASK_H

View File

@ -5,10 +5,10 @@
#include "../util/godot/funcs.h"
#include "../util/macros.h"
#include "../util/profiling.h"
#include "all_blocks_data_request.h"
#include "block_generate_request.h"
#include "load_block_data_request.h"
#include "save_block_data_request.h"
#include "generate_block_task.h"
#include "load_all_blocks_data_task.h"
#include "load_block_data_task.h"
#include "save_block_data_task.h"
#include <core/config/project_settings.h>
#include <core/os/memory.h>
@ -101,9 +101,9 @@ VoxelServer::VoxelServer() {
// Init world
_world.shared_priority_dependency = gd_make_shared<PriorityDependency::ViewersData>();
PRINT_VERBOSE(String("Size of LoadBlockDataRequest: {0}").format(varray((int)sizeof(LoadBlockDataRequest))));
PRINT_VERBOSE(String("Size of SaveBlockDataRequest: {0}").format(varray((int)sizeof(SaveBlockDataRequest))));
PRINT_VERBOSE(String("Size of BlockMeshRequest: {0}").format(varray((int)sizeof(BlockMeshRequest))));
PRINT_VERBOSE(String("Size of LoadBlockDataTask: {0}").format(varray((int)sizeof(LoadBlockDataTask))));
PRINT_VERBOSE(String("Size of SaveBlockDataTask: {0}").format(varray((int)sizeof(SaveBlockDataTask))));
PRINT_VERBOSE(String("Size of MeshBlockTask: {0}").format(varray((int)sizeof(MeshBlockTask))));
}
VoxelServer::~VoxelServer() {
@ -144,7 +144,7 @@ uint32_t VoxelServer::add_volume(VolumeCallbacks callbacks, VolumeType type) {
Volume volume;
volume.type = type;
volume.callbacks = callbacks;
volume.meshing_dependency = gd_make_shared<BlockMeshRequest::MeshingDependency>();
volume.meshing_dependency = gd_make_shared<MeshBlockTask::MeshingDependency>();
return _world.volumes.create(volume);
}
@ -194,7 +194,7 @@ void VoxelServer::set_volume_generator(uint32_t volume_id, Ref<VoxelGenerator> g
volume.meshing_dependency->valid = false;
}
volume.meshing_dependency = gd_make_shared<BlockMeshRequest::MeshingDependency>();
volume.meshing_dependency = gd_make_shared<MeshBlockTask::MeshingDependency>();
volume.meshing_dependency->mesher = volume.mesher;
volume.meshing_dependency->generator = volume.generator;
}
@ -207,7 +207,7 @@ void VoxelServer::set_volume_mesher(uint32_t volume_id, Ref<VoxelMesher> mesher)
volume.meshing_dependency->valid = false;
}
volume.meshing_dependency = gd_make_shared<BlockMeshRequest::MeshingDependency>();
volume.meshing_dependency = gd_make_shared<MeshBlockTask::MeshingDependency>();
volume.meshing_dependency->mesher = volume.mesher;
volume.meshing_dependency->generator = volume.generator;
}
@ -220,7 +220,7 @@ void VoxelServer::set_volume_octree_lod_distance(uint32_t volume_id, float lod_d
void VoxelServer::invalidate_volume_mesh_requests(uint32_t volume_id) {
Volume &volume = _world.volumes.get(volume_id);
volume.meshing_dependency->valid = false;
volume.meshing_dependency = gd_make_shared<BlockMeshRequest::MeshingDependency>();
volume.meshing_dependency = gd_make_shared<MeshBlockTask::MeshingDependency>();
volume.meshing_dependency->mesher = volume.mesher;
volume.meshing_dependency->generator = volume.generator;
}
@ -271,20 +271,20 @@ void VoxelServer::request_block_mesh(uint32_t volume_id, const BlockMeshInput &i
ERR_FAIL_COND(volume.meshing_dependency->mesher.is_null());
ERR_FAIL_COND(volume.data_block_size > 255);
BlockMeshRequest *r = memnew(BlockMeshRequest);
r->volume_id = volume_id;
r->blocks = input.data_blocks;
r->blocks_count = input.data_blocks_count;
r->position = input.render_block_position;
r->lod = input.lod;
r->meshing_dependency = volume.meshing_dependency;
r->data_block_size = volume.data_block_size;
MeshBlockTask *task = memnew(MeshBlockTask);
task->volume_id = volume_id;
task->blocks = input.data_blocks;
task->blocks_count = input.data_blocks_count;
task->position = input.render_block_position;
task->lod = input.lod;
task->meshing_dependency = volume.meshing_dependency;
task->data_block_size = volume.data_block_size;
init_priority_dependency(
r->priority_dependency, input.render_block_position, input.lod, volume, volume.render_block_size);
task->priority_dependency, input.render_block_position, input.lod, volume, volume.render_block_size);
// We'll allocate this quite often. If it becomes a problem, it should be easy to pool.
_general_thread_pool.enqueue(r);
_general_thread_pool.enqueue(task);
}
void VoxelServer::request_block_load(uint32_t volume_id, Vector3i block_pos, int lod, bool request_instances) {
@ -296,25 +296,25 @@ void VoxelServer::request_block_load(uint32_t volume_id, Vector3i block_pos, int
PriorityDependency priority_dependency;
init_priority_dependency(priority_dependency, block_pos, lod, volume, volume.data_block_size);
LoadBlockDataRequest *r = memnew(LoadBlockDataRequest(volume_id, block_pos, lod, volume.data_block_size,
LoadBlockDataTask *task = memnew(LoadBlockDataTask(volume_id, block_pos, lod, volume.data_block_size,
request_instances, volume.stream_dependency, priority_dependency));
_streaming_thread_pool.enqueue(r);
_streaming_thread_pool.enqueue(task);
} else {
// Directly generate the block without checking the stream
ERR_FAIL_COND(volume.stream_dependency->generator.is_null());
BlockGenerateRequest *r = memnew(BlockGenerateRequest);
r->volume_id = volume_id;
r->position = block_pos;
r->lod = lod;
r->block_size = volume.data_block_size;
r->stream_dependency = volume.stream_dependency;
GenerateBlockTask *task = memnew(GenerateBlockTask);
task->volume_id = volume_id;
task->position = block_pos;
task->lod = lod;
task->block_size = volume.data_block_size;
task->stream_dependency = volume.stream_dependency;
init_priority_dependency(r->priority_dependency, block_pos, lod, volume, volume.data_block_size);
init_priority_dependency(task->priority_dependency, block_pos, lod, volume, volume.data_block_size);
_general_thread_pool.enqueue(r);
_general_thread_pool.enqueue(task);
}
}
@ -324,18 +324,18 @@ void VoxelServer::request_block_generate(
const Volume &volume = _world.volumes.get(volume_id);
ERR_FAIL_COND(volume.stream_dependency->generator.is_null());
BlockGenerateRequest *r = memnew(BlockGenerateRequest);
r->volume_id = volume_id;
r->position = block_pos;
r->lod = lod;
r->block_size = volume.data_block_size;
r->stream_dependency = volume.stream_dependency;
r->tracker = tracker;
r->drop_beyond_max_distance = false;
GenerateBlockTask *task = memnew(GenerateBlockTask);
task->volume_id = volume_id;
task->position = block_pos;
task->lod = lod;
task->block_size = volume.data_block_size;
task->stream_dependency = volume.stream_dependency;
task->tracker = tracker;
task->drop_beyond_max_distance = false;
init_priority_dependency(r->priority_dependency, block_pos, lod, volume, volume.data_block_size);
init_priority_dependency(task->priority_dependency, block_pos, lod, volume, volume.data_block_size);
_general_thread_pool.enqueue(r);
_general_thread_pool.enqueue(task);
}
void VoxelServer::request_all_stream_blocks(uint32_t volume_id) {
@ -344,11 +344,11 @@ void VoxelServer::request_all_stream_blocks(uint32_t volume_id) {
ERR_FAIL_COND(volume.stream.is_null());
CRASH_COND(volume.stream_dependency == nullptr);
AllBlocksDataRequest *r = memnew(AllBlocksDataRequest);
r->volume_id = volume_id;
r->stream_dependency = volume.stream_dependency;
LoadAllBlocksDataTask *task = memnew(LoadAllBlocksDataTask);
task->volume_id = volume_id;
task->stream_dependency = volume.stream_dependency;
_general_thread_pool.enqueue(r);
_general_thread_pool.enqueue(task);
}
void VoxelServer::request_voxel_block_save(
@ -358,12 +358,12 @@ void VoxelServer::request_voxel_block_save(
ERR_FAIL_COND(volume.stream.is_null());
CRASH_COND(volume.stream_dependency == nullptr);
SaveBlockDataRequest *r = memnew(
SaveBlockDataRequest(volume_id, block_pos, lod, volume.data_block_size, voxels, volume.stream_dependency));
SaveBlockDataTask *task = memnew(
SaveBlockDataTask(volume_id, block_pos, lod, volume.data_block_size, voxels, volume.stream_dependency));
// No priority data, saving doesnt need sorting
_streaming_thread_pool.enqueue(r);
_streaming_thread_pool.enqueue(task);
}
void VoxelServer::request_instance_block_save(
@ -372,12 +372,12 @@ void VoxelServer::request_instance_block_save(
ERR_FAIL_COND(volume.stream.is_null());
CRASH_COND(volume.stream_dependency == nullptr);
SaveBlockDataRequest *r = memnew(SaveBlockDataRequest(
SaveBlockDataTask *task = memnew(SaveBlockDataTask(
volume_id, block_pos, lod, volume.data_block_size, std::move(instances), volume.stream_dependency));
// No priority data, saving doesnt need sorting
_streaming_thread_pool.enqueue(r);
_streaming_thread_pool.enqueue(task);
}
void VoxelServer::remove_volume(uint32_t volume_id) {
@ -587,10 +587,9 @@ VoxelServer::Stats VoxelServer::get_stats() const {
Stats s;
s.streaming = debug_get_pool_stats(_streaming_thread_pool);
s.general = debug_get_pool_stats(_general_thread_pool);
s.generation_tasks = BlockGenerateRequest::debug_get_running_count();
s.meshing_tasks = BlockMeshRequest::debug_get_running_count();
s.streaming_tasks =
LoadBlockDataRequest::debug_get_running_count() + SaveBlockDataRequest::debug_get_running_count();
s.generation_tasks = GenerateBlockTask::debug_get_running_count();
s.meshing_tasks = GenerateBlockTask::debug_get_running_count();
s.streaming_tasks = LoadBlockDataTask::debug_get_running_count() + SaveBlockDataTask::debug_get_running_count();
s.main_thread_tasks = _time_spread_task_runner.get_pending_count() + _progressive_task_runner.get_pending_count();
return s;
}

View File

@ -9,7 +9,7 @@
#include "../util/tasks/progressive_task_runner.h"
#include "../util/tasks/threaded_task_runner.h"
#include "../util/tasks/time_spread_task_runner.h"
#include "block_mesh_request.h"
#include "mesh_block_task.h"
#include "streaming_dependency.h"
#include <memory>
@ -227,7 +227,7 @@ private:
uint32_t data_block_size = 16;
float octree_lod_distance = 0;
std::shared_ptr<StreamingDependency> stream_dependency;
std::shared_ptr<BlockMeshRequest::MeshingDependency> meshing_dependency;
std::shared_ptr<MeshBlockTask::MeshingDependency> meshing_dependency;
};
struct World {