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

Chunk Rendering Optimisations + VRAM Usage Reductions #328

Closed

Conversation

thr3343
Copy link
Contributor

@thr3343 thr3343 commented Nov 19, 2023

This was originally a part of an older version of the Wayland PR,
But was later spun off into a separate PR with additional improvements and cleanups

This heavily leverages and exploits TerrainRenderTypes to enable certain optimisations,
This will replace much of the prior usages of RenderTypes, so hopefully this won't cause too many issues

Quick/Brief Summary (Badly formatted sorry)

  • Greatly reduce CPU overhead of PushConstants/Chunk Translations with Draw Direct
    • PushConstants are now updated per ChunkArea instead of per DrawCall
    • Can reduce CPU overhead by over 100x depending on number of DrawCommands per ChunkArea
  • Merge Direct and Indirect shaders into one unified Terrain shader
  • Refactor DrawBuffers structure to improve CPU Cache Locality
    • (i.e. Using Structure of Arrays (SoA) + reducing class sizes in hot code paths)
  • Greatly reduce rate of empty Draw calls
    • Usually only very rarely occur when new chunk generation is happening
    • (All other types of conventional Chunk Loads no longer generate empty Draw calls AFAIK)
  • Potentially make Chunk Build Tasks slightly faster
  • Use per TerrainRenderType AreaBuffers to improve GPU Utilisation
  • Selectively enable/Allocate AreaBuffers based on needed TerrainRenderType
    • This helps to reduce VRAM utilisation, especially if chunks don't used mixed Types
    • (i.e. If the chunk(s) are only solid or only translucent materials)

@thr3343 thr3343 force-pushed the ExpChunkRefactors+Optimisations branch from 62c2e6a to b321d56 Compare November 20, 2023 12:55
(Hopefully won't cause performance regressions due to the Int to Float Casts + Mixed Integer + Float Workloads)
@thr3343 thr3343 force-pushed the ExpChunkRefactors+Optimisations branch from b321d56 to dcff864 Compare November 20, 2023 12:55
@thr3343 thr3343 force-pushed the ExpChunkRefactors+Optimisations branch 2 times, most recently from 333a145 to a86a65a Compare November 21, 2023 15:24
@thr3343 thr3343 changed the title Chunk Rendering Optimisations + Refactors Chunk Rendering Optimisations + VRAM Usage Reductions Nov 21, 2023
@thr3343 thr3343 force-pushed the ExpChunkRefactors+Optimisations branch 2 times, most recently from e6be2a7 to d5349e2 Compare November 21, 2023 17:02
@thr3343 thr3343 force-pushed the ExpChunkRefactors+Optimisations branch from d5349e2 to a7c95e0 Compare November 21, 2023 17:28
(i.e. Typically those using custom world height mods/datapacks that permit for world heights > 320)
@thr3343 thr3343 force-pushed the ExpChunkRefactors+Optimisations branch from 9ac99ed to 39e608b Compare November 21, 2023 22:29
@thr3343 thr3343 force-pushed the ExpChunkRefactors+Optimisations branch from a6222c1 to 92bb190 Compare November 25, 2023 18:08
@thr3343 thr3343 force-pushed the ExpChunkRefactors+Optimisations branch from 92bb190 to 5d544c9 Compare November 25, 2023 18:11
@thr3343
Copy link
Contributor Author

thr3343 commented Dec 1, 2023

Think i'll do a way better + cleaned up version of this PR rebased on 0.3.6 code, so will close this atm.

@thr3343 thr3343 closed this Dec 1, 2023
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.

1 participant