vk: Fix scratch allocation when doing GPU deswizzle

- We have to use double the memory because the transformation does not occur in-place like normal bswap
This commit is contained in:
kd-11 2021-07-27 19:42:41 +03:00 committed by kd-11
parent 0aa1aff6ba
commit ace187cdd0

View file

@ -969,7 +969,14 @@ namespace vk
if (!scratch_buf)
{
// Calculate enough scratch memory. We need 2x the size of layer 0 to fit all the mip levels and an extra 128 bytes per level as alignment overhead.
const auto scratch_buf_size = 128u * ::size32(subresource_layout) + image_linear_size + image_linear_size;
auto scratch_buf_size = 128u * ::size32(subresource_layout) + image_linear_size + image_linear_size;
if (opt.require_deswizzle)
{
// Double the memory if hw deswizzle is going to be used.
// For GPU deswizzle, the memory is not transformed in-place, rather the decoded texture is placed at the end of the uploaded data.
scratch_buf_size += scratch_buf_size;
}
scratch_buf = vk::get_scratch_buffer(scratch_buf_size);
buffer_copies.reserve(subresource_layout.size());
}