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

Add threaded chunk loaders and renderers #116

Merged
merged 18 commits into from
Jun 6, 2024

Conversation

cullumi
Copy link
Contributor

@cullumi cullumi commented May 30, 2024

Implemented some threaded chunk loaders (wrappers for the non-threaded ones). Mostly just intended to get the bulk of the loading process off of the main thread.

cullumi added 4 commits May 30, 2024 06:59
Note: chunk_updated, chunk_erased, and chunk_generation_finished signal emissions are now deferred for "threadability".
Note: chunk_updated, chunk_erased, and chunk_generation_finished signal emissions are now deferred for "threadability".
@cullumi
Copy link
Contributor Author

cullumi commented May 30, 2024

There's still some stuttering that happens, but I haven't quite narrowed down the cause. Pretty sure lag spikes are much shorter in length than when I started, though.

cullumi added 4 commits May 30, 2024 18:06
Introduced Error: "_octant_update: Condition "!cell_map.has(E) is true. Continuing." Happens only when "Threaded" is turned on for the Threaded Gridmap Gaea Renderer.
@cullumi
Copy link
Contributor Author

cullumi commented May 31, 2024

There's still some stuttering that happens, but I haven't quite narrowed down the cause. Pretty sure lag spikes are much shorter in length than when I started, though.

I figured out that the stuttering came from the Tilemap and Gridmap GaeaRenderers. I threaded them too and there is hardly any lag now. You do technically run a greater risk of falling into pits and the like, though there are ways around that I'm pretty sure.

The rate at which it renders can be improved by running each render task in parallel (currently it waits for one to complete, then moves on to the next in a queue).

@cullumi
Copy link
Contributor Author

cullumi commented May 31, 2024

Made is so that the Threaded Gridmap and Tilemap renderers can render chunks in parallel.

Next, I need to make them gracefully handle "misses" that I suspect are resulting from trying to un-render chunks that have already been or are being un-rendered.

Note that I also made it possible to turn the Actor's gravity off. This was just because I kept falling through the world before the chunks below my feet were rendered.

cullumi added 2 commits May 30, 2024 19:57
…g." error.

Renderers were missing some deferred calls for thread safety.
@cullumi
Copy link
Contributor Author

cullumi commented May 31, 2024

Fixed the errors I was encountering. It wasn't a logical error ("misses") after all, it was just that there were still a few method calls to the Tilemap and Gridmap that needed to be deferred. The error is gone now and the crashes that they were causes have stopped as well.

I also made it so the job count can be uncapped again; in 2D chunks render so blazingly fast you can barely tell it's happening, and in 3D chunks are getting rendered significantly faster now.

Tbh this may very well be as ready as it ever will be at this point.

@BenjaTK BenjaTK added the ✨ enhancement New feature or request label Jun 5, 2024
Copy link
Owner

@BenjaTK BenjaTK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ngl this brings tears to my eyes, it's beautiful. 3D is so much smoother now. This could actually push us to the 1.0 release and to upload it to the Godot Asset Library.

@BenjaTK
Copy link
Owner

BenjaTK commented Jun 5, 2024

This would probably be another PR, but we could also make it so chunk loaders prioritize chunks closer to the actor.

@BenjaTK BenjaTK changed the title Threaded chunk loaders Add threaded chunk loaders and renderers Jun 6, 2024
@BenjaTK BenjaTK merged commit 3eebc7d into BenjaTK:main Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants