Skip to content

Commit 5231929

Browse files
committed
Fix: buffer size
1 parent 16e8cda commit 5231929

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/main/java/net/vulkanmod/gl/GlTexture.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ private static ByteBuffer getByteBuffer(int width, int height, long pixels) {
137137
ByteBuffer src;
138138
// TODO: hardcoded format size
139139
int formatSize = 4;
140-
src = MemoryUtil.memByteBuffer(pixels, width * height * formatSize);
140+
int rowLength = unpackRowLength != 0 ? unpackRowLength : width;
141+
int offset = (unpackSkipRows * rowLength + unpackSkipPixels) * formatSize;
142+
src = MemoryUtil.memByteBuffer(pixels + offset, (rowLength * height - unpackSkipPixels) * formatSize);
141143
return src;
142144
}
143145

@@ -338,7 +340,7 @@ private void uploadSubImage(int level, int xOffset, int yOffset, int width, int
338340
src = pixels;
339341
}
340342

341-
this.vulkanImage.uploadSubTextureAsync(level, width, height, xOffset, yOffset, unpackSkipRows, unpackSkipPixels, unpackRowLength, src);
343+
this.vulkanImage.uploadSubTextureAsync(level, width, height, xOffset, yOffset, 0, 0, unpackRowLength, src);
342344

343345
if (src != pixels) {
344346
MemoryUtil.memFree(src);

0 commit comments

Comments
 (0)