Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/main/java/net/vulkanmod/vulkan/texture/VulkanImage.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,10 @@ public void uploadSubTextureAsync(int mipLevel, int arrayLayer,
int unpackSkipRows, int unpackSkipPixels, int unpackRowLength,
long srcPtr)
{
long uploadSize = (long) (unpackRowLength * height - unpackSkipPixels) * this.formatSize;
// In GL a row length of 0 means rows are tightly packed, i.e. the row stride is the region width
final int rowLength = unpackRowLength != 0 ? unpackRowLength : width;

long uploadSize = (long) (rowLength * (height - 1) + width) * this.formatSize;

StagingBuffer stagingBuffer = Vulkan.getStagingBuffer();

Expand All @@ -240,7 +243,7 @@ public void uploadSubTextureAsync(int mipLevel, int arrayLayer,
stagingBuffer.scheduleFree();
}

srcPtr += ((long) unpackRowLength * unpackSkipRows + unpackSkipPixels) * this.formatSize;
srcPtr += ((long) rowLength * unpackSkipRows + unpackSkipPixels) * this.formatSize;

stagingBuffer.align(this.formatSize);
stagingBuffer.copyBuffer((int) uploadSize, srcPtr);
Expand All @@ -255,7 +258,7 @@ public void uploadSubTextureAsync(int mipLevel, int arrayLayer,

ImageUtil.copyBufferToImageCmd(stack, commandBuffer, bufferId, this.id,
arrayLayer, mipLevel, width, height, xOffset, yOffset,
srcOffset, unpackRowLength, height);
srcOffset, rowLength, height);

ImageUtil.imageTransferMemoryBarrier(stack, commandBuffer, this, mipLevel);
}
Expand Down