Skip to content

Commit 378e3d7

Browse files
committed
Add buffer debug label
1 parent 1e6db2d commit 378e3d7

7 files changed

Lines changed: 20 additions & 8 deletions

File tree

src/main/java/net/vulkanmod/render/engine/VkGpuBuffer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class VkGpuBuffer extends GpuBuffer {
2121

2222
Buffer buffer;
2323

24-
protected VkGpuBuffer(VkDebugLabel glDebugLabel, @Nullable Supplier<String> supplier, int usage, int size) {
24+
protected VkGpuBuffer(VkDebugLabel debugLabel, @Nullable Supplier<String> supplier, int usage, int size) {
2525
super(usage, size);
2626
this.label = supplier;
2727

@@ -51,7 +51,7 @@ protected VkGpuBuffer(VkDebugLabel glDebugLabel, @Nullable Supplier<String> supp
5151

5252
MemoryType memoryType = mappable ? MemoryTypes.HOST_MEM : MemoryTypes.GPU_MEM;
5353

54-
this.buffer = new Buffer(vkUsage, memoryType);
54+
this.buffer = new Buffer(supplier.get(), vkUsage, memoryType);
5555
this.buffer.createBuffer(this.size());
5656
}
5757

src/main/java/net/vulkanmod/vulkan/memory/buffer/Buffer.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
package net.vulkanmod.vulkan.memory.buffer;
22

3+
import net.vulkanmod.vulkan.Vulkan;
34
import net.vulkanmod.vulkan.memory.MemoryManager;
45
import net.vulkanmod.vulkan.memory.MemoryType;
6+
import org.lwjgl.system.MemoryStack;
57

68
import java.nio.ByteBuffer;
79

10+
import static org.lwjgl.vulkan.VK10.VK_OBJECT_TYPE_BUFFER;
11+
812
public class Buffer {
13+
public final String name;
914
public final MemoryType type;
1015
public final int usage;
1116

@@ -18,14 +23,21 @@ public class Buffer {
1823

1924
protected long dataPtr;
2025

21-
public Buffer(int usage, MemoryType type) {
26+
public Buffer(String name, int usage, MemoryType type) {
27+
this.name = name;
2228
this.usage = usage;
2329
this.type = type;
2430
}
2531

2632
public void createBuffer(long bufferSize) {
2733
this.type.createBuffer(this, bufferSize);
2834

35+
if (this.name != null) {
36+
try (MemoryStack stack = MemoryStack.stackPush()) {
37+
Vulkan.setDebugLabel(stack, VK_OBJECT_TYPE_BUFFER, this.id, this.name);
38+
}
39+
}
40+
2941
if (this.type.mappable()) {
3042
this.dataPtr = MemoryManager.getInstance().Map(this.allocation).get(0);
3143
}

src/main/java/net/vulkanmod/vulkan/memory/buffer/IndexBuffer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public IndexBuffer(int size, MemoryType type) {
1313
}
1414

1515
public IndexBuffer(int size, MemoryType type, IndexType indexType) {
16-
super(VK_BUFFER_USAGE_INDEX_BUFFER_BIT, type);
16+
super("Index buffer", VK_BUFFER_USAGE_INDEX_BUFFER_BIT, type);
1717
this.indexType = indexType;
1818

1919
this.createBuffer(size);

src/main/java/net/vulkanmod/vulkan/memory/buffer/IndirectBuffer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class IndirectBuffer extends Buffer {
1616
CommandPool.CommandBuffer commandBuffer;
1717

1818
public IndirectBuffer(int size, MemoryType type) {
19-
super(VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT, type);
19+
super("Indirect buffer", VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT, type);
2020
this.createBuffer(size);
2121
}
2222

src/main/java/net/vulkanmod/vulkan/memory/buffer/StagingBuffer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public StagingBuffer() {
2020
}
2121

2222
public StagingBuffer(long size) {
23-
super(VK_BUFFER_USAGE_TRANSFER_SRC_BIT, MemoryTypes.HOST_MEM);
23+
super("Staging buffer", VK_BUFFER_USAGE_TRANSFER_SRC_BIT, MemoryTypes.HOST_MEM);
2424
this.createBuffer(size);
2525
}
2626

src/main/java/net/vulkanmod/vulkan/memory/buffer/UniformBuffer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public static int getAlignedSize(int uploadSize) {
1414
}
1515

1616
public UniformBuffer(int size, MemoryType memoryType) {
17-
super(VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, memoryType);
17+
super("Uniform buffer", VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, memoryType);
1818
this.createBuffer(size);
1919
}
2020

src/main/java/net/vulkanmod/vulkan/memory/buffer/VertexBuffer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public VertexBuffer(int size) {
1212
}
1313

1414
public VertexBuffer(int size, MemoryType type) {
15-
super(VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, type);
15+
super("Vertex buffer", VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, type);
1616
this.createBuffer(size);
1717
}
1818

0 commit comments

Comments
 (0)