Skip to content
New issue

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

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

Already on GitHub? # to your account

Cache multi draw batches on regions #2771

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

Conversation

douira
Copy link
Collaborator

@douira douira commented Sep 23, 2024

I get an improvement of around 7% by caching multi draw batches on each region. The margin is somewhat smaller when in motion, but often the batch can still be reused. The increase in memory use seems to be minimal.

If only one section in the region changed, only re-writing the command buffer starting at that section might bring an improvement of 50% on average for regions with block updates, but the metadata management for such partial buffer writes is somewhat complicated and may not be worth it if we're going to be changing this part of the renderer anyway.

dev
dev

dev with this patch
dev with patch

@douira
Copy link
Collaborator Author

douira commented Sep 25, 2024

I've measured the cache hit ratios for some situations. Average over 100 frames (values eyeballed), limited to 150 fps, average world. The hit ratio will be better the higher the fps, but even with 30 fps the hit ratios were generally good.

not weighted by batch size (number of cached batches / total)

  • doing nothing: 1
  • random rare chunk updates: 0.98
  • flying around rapidly: 0.75
  • moving camera around on ground level: 0.65
  • violently moving the camera around: 0.45

weighted by batch size (number of commands from cached batches / total)

  • doing nothing: 1
  • random rare chunk updates: 0.98
  • flying around rapidly: 0.8
  • moving camera around on ground level: 0.75
  • violently moving the camera around: 0.52

@douira douira requested a review from jellysquid3 September 25, 2024 02:49
@douira
Copy link
Collaborator Author

douira commented Sep 25, 2024

I hope I found all the places where cache invalidation needs to happen, but that's something to look out for during review.

@douira douira force-pushed the cache-draw-batches branch from c7d8dc2 to d97e663 Compare October 4, 2024 15:15
@douira douira added the T-enhancement Type: Enhancement label Oct 21, 2024
@douira douira force-pushed the cache-draw-batches branch from d97e663 to 3cbdaf1 Compare October 26, 2024 22:18
@douira douira force-pushed the cache-draw-batches branch from 3cbdaf1 to a5fabd4 Compare November 25, 2024 17:54
@jellysquid3 jellysquid3 added this to the Sodium 0.7 milestone Dec 12, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
T-enhancement Type: Enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants