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

Rework zero buffer and resource initialization #4723

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

doitsujin
Copy link
Owner

TL;DR we have a buffer containing nothing but zeroes that is only used for image and buffer initialization, which can in some cases waste substantial amounts of memory, e.g. if we use it to initialize something like 16384x8192 BC1 texture, since the buffer needs to be large enough to hold one full subresource of the image.

If the device has good support for sparse binding, we can just create a sparse buffer that will implicitly read zeroes, and avoid having to allocate real memory for it.

This also moves all zero-initialization to the transfer queue so we may avoid eating graphics resources for no reason when the app creates a lot of resources back to back.

This is a scary change and will require a lot of testing across all sorts of different drivers, since accessing null tiles on a transfer queue is probably not a use case that drivers are frequently tested with.

Saves a small amount of memory since reading from an unbound
buffer will return zero anyway.
@doitsujin doitsujin force-pushed the sparse-zero-buffer branch from 9ba9ec2 to bb217f4 Compare March 2, 2025 13:07
@doitsujin doitsujin force-pushed the sparse-zero-buffer branch from bb217f4 to 210f02a Compare March 3, 2025 08:38
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