Display light and texture buffer sizes.

This commit is contained in:
IntegratedQuantum 2024-07-06 15:01:36 +02:00
parent 8616289b47
commit 7e3694f1c6
2 changed files with 21 additions and 13 deletions

View File

@ -1298,7 +1298,7 @@ pub const SubAllocation = struct {
}; };
/// A big SSBO that is able to allocate/free smaller regions. /// A big SSBO that is able to allocate/free smaller regions.
pub fn LargeBuffer(comptime Entry: type) type { pub fn LargeBuffer(comptime _Entry: type) type {
return struct { return struct {
ssbo: SSBO, ssbo: SSBO,
freeBlocks: main.List(SubAllocation), freeBlocks: main.List(SubAllocation),
@ -1311,6 +1311,8 @@ pub fn LargeBuffer(comptime Entry: type) type {
const Self = @This(); const Self = @This();
pub const Entry = _Entry;
fn createBuffer(self: *Self, size: u31) void { fn createBuffer(self: *Self, size: u31) void {
self.ssbo = SSBO.init(); self.ssbo = SSBO.init();
c.glBindBuffer(c.GL_SHADER_STORAGE_BUFFER, self.ssbo.bufferID); c.glBindBuffer(c.GL_SHADER_STORAGE_BUFFER, self.ssbo.bufferID);

View File

@ -22,6 +22,18 @@ pub var window = GuiWindow {
.hideIfMouseIsGrabbed = false, .hideIfMouseIsGrabbed = false,
}; };
fn renderLargeBufferSize(buffer: anytype, comptime fmt: []const u8, y: f32) void {
const dataSize: usize = @sizeOf(@TypeOf(buffer).Entry);
const size: usize = buffer.capacity*dataSize;
const used: usize = buffer.used*dataSize;
var largestFreeBlock: usize = 0;
for(buffer.freeBlocks.items) |freeBlock| {
largestFreeBlock = @max(largestFreeBlock, freeBlock.len);
}
const fragmentation = size - used - largestFreeBlock*dataSize;
draw.print(fmt, .{used >> 20, size >> 20, fragmentation >> 20}, 0, y, 8, .left);
}
pub fn render() void { pub fn render() void {
draw.setColor(0xffffffff); draw.setColor(0xffffffff);
var y: f32 = 0; var y: f32 = 0;
@ -47,18 +59,12 @@ pub fn render() void {
y += 8; y += 8;
draw.print("Mesh Queue size: {}", .{main.renderer.mesh_storage.updatableList.items.len}, 0, y, 8, .left); draw.print("Mesh Queue size: {}", .{main.renderer.mesh_storage.updatableList.items.len}, 0, y, 8, .left);
y += 8; y += 8;
{ renderLargeBufferSize(main.renderer.chunk_meshing.faceBuffer, "ChunkMesh memory: {} MiB / {} MiB (fragmentation: {} MiB)", y);
const faceDataSize: usize = @sizeOf(main.renderer.chunk_meshing.FaceData); y += 8;
const size: usize = main.renderer.chunk_meshing.faceBuffer.capacity*faceDataSize; renderLargeBufferSize(main.renderer.chunk_meshing.lightBuffer, "ChunkMesh light memory: {} MiB / {} MiB (fragmentation: {} MiB)", y);
const used: usize = main.renderer.chunk_meshing.faceBuffer.used*faceDataSize; y += 8;
var largestFreeBlock: usize = 0; renderLargeBufferSize(main.renderer.chunk_meshing.textureBuffer, "ChunkMesh texture memory: {} MiB / {} MiB (fragmentation: {} MiB)", y);
for(main.renderer.chunk_meshing.faceBuffer.freeBlocks.items) |freeBlock| {
largestFreeBlock = @max(largestFreeBlock, freeBlock.len);
}
const fragmentation = size - used - largestFreeBlock*faceDataSize;
draw.print("ChunkMesh memory: {} MiB / {} MiB (fragmentation: {} MiB)", .{used >> 20, size >> 20, fragmentation >> 20}, 0, y, 8, .left);
y += 8; y += 8;
}
draw.print("Biome: {s}", .{main.game.world.?.playerBiome.load(.monotonic).id}, 0, y, 8, .left); draw.print("Biome: {s}", .{main.game.world.?.playerBiome.load(.monotonic).id}, 0, y, 8, .left);
y += 8; y += 8;
draw.print("Opaque faces: {}, Transparent faces: {}", .{main.renderer.chunk_meshing.quadsDrawn, main.renderer.chunk_meshing.transparentQuadsDrawn}, 0, y, 8, .left); draw.print("Opaque faces: {}, Transparent faces: {}", .{main.renderer.chunk_meshing.quadsDrawn, main.renderer.chunk_meshing.transparentQuadsDrawn}, 0, y, 8, .left);