From c53b7e5d38c24bce7ba55abf3060ffd012783086 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Mon, 27 Oct 2014 23:58:09 +0100 Subject: QtBiomeVisualiser: Switched caching to entire regions. This speeds up the rendering preparation for small zooms. --- Tools/QtBiomeVisualiser/ChunkSource.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Tools/QtBiomeVisualiser/ChunkSource.h') diff --git a/Tools/QtBiomeVisualiser/ChunkSource.h b/Tools/QtBiomeVisualiser/ChunkSource.h index 5332c5d3f..ed2f457e9 100644 --- a/Tools/QtBiomeVisualiser/ChunkSource.h +++ b/Tools/QtBiomeVisualiser/ChunkSource.h @@ -26,7 +26,7 @@ public: /** Fills the a_DestChunk with the biomes for the specified coords. It is expected to be thread-safe and re-entrant. Usually QThread::idealThreadCount() threads are used. */ - virtual void getChunkBiomes(int a_ChunkX, int a_ChunkZ, ChunkPtr a_DestChunk) = 0; + virtual void getChunkBiomes(int a_ChunkX, int a_ChunkZ, Chunk & a_DestChunk) = 0; /** Forces a fresh reload of the source. Useful mainly for the generator, whose underlying definition file may have been changed. */ virtual void reload() = 0; @@ -45,7 +45,7 @@ public: BioGenSource(cIniFilePtr a_IniFile); // ChunkSource overrides: - virtual void getChunkBiomes(int a_ChunkX, int a_ChunkZ, ChunkPtr a_DestChunk) override; + virtual void getChunkBiomes(int a_ChunkX, int a_ChunkZ, Chunk & a_DestChunk) override; virtual void reload(void) override; protected: @@ -70,7 +70,7 @@ public: AnvilSource(QString a_WorldRegionFolder); // ChunkSource overrides: - virtual void getChunkBiomes(int a_ChunkX, int a_ChunkZ, ChunkPtr a_DestChunk) override; + virtual void getChunkBiomes(int a_ChunkX, int a_ChunkZ, Chunk & a_DestChunk) override; virtual void reload() override; protected: -- cgit v1.2.3 From d6c663cbc508859b36543797a7ebbee52a27dc6a Mon Sep 17 00:00:00 2001 From: Mattes D Date: Tue, 28 Oct 2014 15:44:58 +0100 Subject: QtBiomeVisualiser: Fixed compilation on Linux. --- Tools/QtBiomeVisualiser/ChunkSource.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Tools/QtBiomeVisualiser/ChunkSource.h') diff --git a/Tools/QtBiomeVisualiser/ChunkSource.h b/Tools/QtBiomeVisualiser/ChunkSource.h index 5332c5d3f..65b2c3449 100644 --- a/Tools/QtBiomeVisualiser/ChunkSource.h +++ b/Tools/QtBiomeVisualiser/ChunkSource.h @@ -10,7 +10,7 @@ // fwd: class cBiomeGen; -typedef std::shared_ptr cBiomeGenPtr; +typedef SharedPtr cBiomeGenPtr; class cIniFile; typedef std::shared_ptr cIniFilePtr; -- cgit v1.2.3 From 4e0cef0ff6080b67e4740bd33ccf4a491a82fb52 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Wed, 29 Oct 2014 23:04:59 +0100 Subject: QtBiomeVisualiser: Generator uses all machine threads. The previous limit of 1 thread was lifted, now the generator source runs on all CPU threads available. --- Tools/QtBiomeVisualiser/ChunkSource.h | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'Tools/QtBiomeVisualiser/ChunkSource.h') diff --git a/Tools/QtBiomeVisualiser/ChunkSource.h b/Tools/QtBiomeVisualiser/ChunkSource.h index a6bc3849b..62f9b5626 100644 --- a/Tools/QtBiomeVisualiser/ChunkSource.h +++ b/Tools/QtBiomeVisualiser/ChunkSource.h @@ -53,10 +53,30 @@ protected: cIniFilePtr m_IniFile; /** The generator used for generating biomes. */ - cBiomeGenPtr m_BiomeGen; + std::vector m_BiomeGens; - /** Guards m_BiomeGen against multithreaded access. */ + /** Guards m_BiomeGens against multithreaded access. */ QMutex m_Mtx; + + /** Keeps track of the current settings of the biomegens. + Incremented by one each time reload() is called. Provides the means of releasing old biomegens that were + in use while reload() was being processed and thus couldn't be changed back then. releaseBiomeGen() does + the job of filtering the biogens before reusing them. */ + int m_CurrentTag; + + + /** Retrieves one cBiomeGenPtr from m_BiomeGens. + If there's no biogen available there, creates a new one based on the ini file. + When done with it, the caller should call releaseBiomeGen() to put the biogen back to m_BiomeGens. + a_Tag receives the value of m_CurrentTag from when the lock was held; it should be passed to + releaseBiomeGen() together with the biogen. */ + cBiomeGenPtr getBiomeGen(int & a_Tag); + + /** Marks the specified biogen as available for reuse (puts it back into m_BiomeGens). + a_Tag is the value of m_CurrentTag from the time when the biogen was retrieved; if it is different from + current m_CurrentTagValue, the biogen will be disposed of (because reload() has been called in the + meantime). */ + void releaseBiomeGen(cBiomeGenPtr && a_BiomeGen, int a_Tag); }; -- cgit v1.2.3