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 Render List Generation and Frame-Independent Task Scheduling #2887

Open
wants to merge 81 commits into
base: dev
Choose a base branch
from

Conversation

douira
Copy link
Collaborator

@douira douira commented Nov 22, 2024

Uses an octree to generate render lists independently of the, now asynchronous, slow graph search.

  • It runs the occlusion culler in a separate thread, which allows a large speedup in render list generation time. Correct culling results are ensured with a combination of different types of BFS, synchronous occlusion culling is used as a last resort if the camera teleports or moves extremely quickly.
  • Tasks are ordered based on a combination score of how long they've been pending, their distance from the camera, their type, and whether they're visible in the camera frustum. How many tasks can be scheduled is now independent of the frame rate and instead are limited based on their estimated duration and size.
  • There's an upload limit to ensure not too many tasks are submitted that will exceed the upload buffer's size. This isn't a hard limit and this PR doesn't implement a new way of handling task buffers, to avoid expanding the scope too far.

Testing has not shown regressions and generally frame rate has improved a little if a system was not limited by render list generation, and a lot if it was. (see testing thread)

Companion PR in Iris: IrisShaders/Iris#2539

…led yet, it just does the tree frustum test right after each bfs for testing purposes atm)
…g RenderSection objects, improve tree render list generation performance
…trees of varying accuracy to present as few sections as possible while not generating any errors when the camera is in motion.
…ssues when the distance changes (for example under water)
- rebuild tasks are scheduled in a queue and pruned each frame
- async culling tasks and results are classes in their own package
- chunk rebuild tasks are prioritized based on their distance to the camera, their type, how long the task has been pending, and whether the section is currently visible (in the frustum)
- generally cleaned up the update method in RSM
… not automatically correctly ordered since they're not coming from a tree

� Conflicts:
�	common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/lists/VisibleChunkCollectorAsync.java
…her issues with (at least vertical) sorting though and even important zero-frame blocking tasks are not scheduled within the same frame
…fallback and for use in iris. Now that there's a fallback, we don't need to accept using invalid trees if there's no other trees available.

fix tree isValid test for wide trees.
rename the trees field on RSM since it's misleading (it's actually forests, and they're cull results)
…parate from regular deferred task scheduling
tree traversal only does correct in-region sorting, not between regions
@douira douira force-pushed the decoupled-frustum-test branch from 29caa4b to 9c44397 Compare December 31, 2024 04:41
douira added 7 commits January 2, 2025 06:22
…matrix to avoid very long tail of camera changes after player movement
…k tree and updating the section's pending tasks by storing and then later catching up the tree with the changes
… render into one method,

fix bugs with disappearing entities and not rendered newly non-empty sections by refactoring is present code in SectionTree to use a predicate that checks for section emptiness
douira added 9 commits January 4, 2025 03:30
…flag from MC to "playerChanged" for clarity, don't schedule tasks as important if they're no longer in range and schedule tasks during cull task even if they're important to make sure tasks that were downgraded in importance are still processed eventually
…sion,

this improves scheduling accuracy and doesn't allow the estimator to get biased by fast tasks on small sections
…sync tasks whenever possible,

only perform out of graph fallback when really out of graph

Signed-off-by: douira <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-enhancement Type: Enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants