adding thread pool

This commit is contained in:
2025-06-03 17:50:05 +02:00
parent 8dfb6af3ec
commit 66c42af1b8
5 changed files with 118 additions and 61 deletions

View File

@@ -9,10 +9,11 @@
#include <Chunk.h>
#include <Utils.h>
#include <FpsCounter.h>
#include <ThreadPool.h>
#include <NoiseCollection.h>
constexpr std::uint8_t RENDER_DISTANCE = 15;
constexpr std::uint8_t CHUNKS_UPLOAD_PER_FRAME = 3;
constexpr std::uint8_t CHUNKS_UPLOAD_PER_FRAME = 12;
enum class GenerationState: std::uint8_t
{
@@ -28,7 +29,6 @@ struct PostProcessData
std::int32_t underwater;
};
class World
{
public:
@@ -52,6 +52,7 @@ class World
private:
NoiseCollection m_noisecollection;
FpsCounter m_fps_counter;
ThreadPool m_thread_pool;
std::unordered_map<Scop::Vec2i, Chunk> m_chunks;
ThreadSafeQueue<std::reference_wrapper<Chunk>> m_chunks_to_upload;
std::shared_ptr<Scop::Material> p_block_material;
@@ -64,7 +65,7 @@ class World
std::atomic<GenerationState> m_generation_status = GenerationState::Ready;
Scop::NonOwningPtr<Scop::Text> p_fps_text;
Scop::NonOwningPtr<Scop::Text> p_loading_text;
std::atomic_uint32_t m_loading_progress = 0;
std::atomic<float> m_loading_progress = 0.0f;
std::uint32_t m_last_fps_count = 0;
bool m_show_loading_screen = true;
};