mirror of
https://github.com/EduApps-CDG/OpenDX
synced 2024-12-30 09:45:37 +01:00
[dxvk] Fix broken row/slice alignment in buffer<->image copies
If the specified row or slice alignment matches the row size exactly but is not a power of two, we could accidentally screw up the alignment.
This commit is contained in:
parent
ba4938e201
commit
9f7a5a077f
@ -2751,12 +2751,12 @@ namespace dxvk {
|
|||||||
VkDeviceSize rowPitch = blockCount.width * elementSize;
|
VkDeviceSize rowPitch = blockCount.width * elementSize;
|
||||||
|
|
||||||
if (bufferRowAlignment > elementSize)
|
if (bufferRowAlignment > elementSize)
|
||||||
rowPitch = bufferRowAlignment > rowPitch ? bufferRowAlignment : align(rowPitch, bufferRowAlignment);
|
rowPitch = bufferRowAlignment >= rowPitch ? bufferRowAlignment : align(rowPitch, bufferRowAlignment);
|
||||||
|
|
||||||
VkDeviceSize slicePitch = blockCount.height * rowPitch;
|
VkDeviceSize slicePitch = blockCount.height * rowPitch;
|
||||||
|
|
||||||
if (image->info().type == VK_IMAGE_TYPE_3D && bufferSliceAlignment > elementSize)
|
if (image->info().type == VK_IMAGE_TYPE_3D && bufferSliceAlignment > elementSize)
|
||||||
slicePitch = bufferSliceAlignment > slicePitch ? bufferSliceAlignment : align(slicePitch, bufferSliceAlignment);
|
slicePitch = bufferSliceAlignment >= slicePitch ? bufferSliceAlignment : align(slicePitch, bufferSliceAlignment);
|
||||||
|
|
||||||
copyRegion.bufferOffset = aspectOffset;
|
copyRegion.bufferOffset = aspectOffset;
|
||||||
copyRegion.bufferRowLength = formatInfo->blockSize.width * rowPitch / elementSize;
|
copyRegion.bufferRowLength = formatInfo->blockSize.width * rowPitch / elementSize;
|
||||||
@ -2779,7 +2779,7 @@ namespace dxvk {
|
|||||||
VkDeviceSize layerPitch = aspectOffset - bufferOffset;
|
VkDeviceSize layerPitch = aspectOffset - bufferOffset;
|
||||||
|
|
||||||
if (bufferSliceAlignment)
|
if (bufferSliceAlignment)
|
||||||
layerPitch = bufferSliceAlignment > layerPitch ? bufferSliceAlignment : align(layerPitch, bufferSliceAlignment);
|
layerPitch = bufferSliceAlignment >= layerPitch ? bufferSliceAlignment : align(layerPitch, bufferSliceAlignment);
|
||||||
|
|
||||||
bufferOffset += layerPitch;
|
bufferOffset += layerPitch;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user