Skip to content

Commit

Permalink
fixed resize buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
Collateral committed Jul 15, 2022
1 parent c6fca9b commit 39ff26f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/main/java/net/vulkanmod/vulkan/memory/UniformBuffers.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

public class UniformBuffers {


private int bufferSize;
private int usedBytes;

Expand Down Expand Up @@ -42,10 +41,10 @@ public void uploadUBO(ByteBuffer buffer, int offset, int frame) {
int alignedSize = align(size, minOffset);
if (alignedSize > this.bufferSize - this.usedBytes) {
resizeBuffer((int) ((this.bufferSize + alignedSize) * 2));
} else {
uniformBuffers.get(frame).uploadUBO(buffer, offset);
usedBytes += alignedSize;
}

uniformBuffers.get(frame).uploadUBO(buffer, offset);
usedBytes += alignedSize;
}

private void resizeBuffer(int newSize) {
Expand All @@ -54,6 +53,8 @@ private void resizeBuffer(int newSize) {
uniformBuffer.resizeBuffer(newSize);
}

this.bufferSize = newSize;

System.out.println("resized UniformBuffer to: " + newSize);
}

Expand Down

0 comments on commit 39ff26f

Please sign in to comment.