Fix alignment when getting slice in GrVkGpu for upload
Previous code would not align to 4 but not necessarily bytes-per-block. Cq-Include-Trybots: luci.skia.skia.primary:Test-Debian10-Clang-NUC5PPYH-GPU-IntelHD405-x86_64-Debug-All-Vulkan Change-Id: I06ffc9c38f52c645bafd22d0ac30712efb815e76 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/345134 Auto-Submit: Brian Salomon <bsalomon@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
6ed863a30a
commit
abea2ac413
@ -19,7 +19,7 @@ GrStagingBufferManager::Slice GrStagingBufferManager::allocateStagingBufferSlice
|
||||
for (size_t i = 0; i < fBuffers.size(); ++i) {
|
||||
size_t totalBufferSize = fBuffers[i].fBuffer->size();
|
||||
size_t currentOffset = fBuffers[i].fOffset;
|
||||
offset = GrAlignTo(currentOffset, requiredAlignment);
|
||||
offset = ((currentOffset + requiredAlignment - 1)/requiredAlignment)*requiredAlignment;
|
||||
if (totalBufferSize - offset >= size) {
|
||||
buffer = &fBuffers[i];
|
||||
break;
|
||||
|
@ -753,7 +753,12 @@ static size_t fill_in_regions(GrStagingBufferManager* stagingBufferManager,
|
||||
|
||||
// Get a staging buffer slice to hold our mip data.
|
||||
// Vulkan requires offsets in the buffer to be aligned to multiple of the texel size and 4
|
||||
size_t alignment = SkAlign4(bytesPerBlock);
|
||||
size_t alignment = bytesPerBlock;
|
||||
switch (alignment & 0b11) {
|
||||
case 0: break; // alignment is already a multiple of 4.
|
||||
case 2: alignment *= 2; break; // alignment is a multiple of 2 but not 4.
|
||||
default: alignment *= 4; break; // alignment is not a multiple of 2.
|
||||
}
|
||||
*slice = stagingBufferManager->allocateStagingBufferSlice(combinedBufferSize, alignment);
|
||||
if (!slice->fBuffer) {
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user