Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asynchronous chunk loading & rendering (using Thread Pool) #168

Merged
merged 5 commits into from
Aug 5, 2019

Conversation

EtlamGit
Copy link
Collaborator

@EtlamGit EtlamGit commented Aug 5, 2019

  • Fix current implementation for asynchronous Chunk loading. Due to a misplaced mutex unlock we only used one loading thread at the time.
  • Move Chunk rendering into own (runnable) class and let it render in global thread pool.
  • Use separated thread pools for loading and rendering, as Qt queues tasks in order they arrive. This would result in all loading tasks to be executed before anything gets rendered. By using optimal/2 for loading and optimal thread number for rendering we get 1.5x the number of threads than we have CPU cores. In my opinion this is fine, as loading implies disk activity which stalls the task.

Mutex is only necessary for modifying the QCache object.
When spanning Mutex also over parsing section, only one Chunk will be
loaded and all others are blocked.
const does not mean const here?
but it seems to be necessary to stay thread save
change to Singleton Pattern (only one instance makes sense)
removes passing around of object and mutex
renamed all x,z -> cx,cz to distinguish Chunk coordinates
dedicated ChunkRenderer to render parsed Chunk data into cached image
move code for Chunk rendering from Mapview to ChunkRenderer
use extra ThreadPool for loading to separate loading/rendering
@mrkite mrkite merged commit 7c35a2f into mrkite:master Aug 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants