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

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
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 added the T-enhancement Type: Enhancement label Oct 21, 2024
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.

1 participant