Rework zero buffer and resource initialization #4723
+180
−80
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.