mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-08-03 19:28:49 -04:00
Fix a stupid bug in the gpu allocator. It maximized fragmentation instead of minimizing it.
Fixes #175
This commit is contained in:
parent
410db62d85
commit
e0ac22668b
@ -1276,7 +1276,7 @@ pub fn LargeBuffer(comptime Entry: type) type {
|
||||
if(size == block.len) {
|
||||
return self.freeBlocks.swapRemove(i);
|
||||
}
|
||||
if(size < block.len and if(smallestBlock) |_smallestBlock| block.len > _smallestBlock.len else true) {
|
||||
if(size < block.len and if(smallestBlock) |_smallestBlock| block.len < _smallestBlock.len else true) {
|
||||
smallestBlock = block;
|
||||
}
|
||||
}
|
||||
|
@ -42,9 +42,18 @@ fn flawedRender() !void {
|
||||
y += 8;
|
||||
try draw.print("Mesh Queue size: {}", .{main.renderer.RenderStructure.updatableList.items.len}, 0, y, 8, .left);
|
||||
y += 8;
|
||||
const faceDataSize = @sizeOf(main.chunk.meshing.FaceData);
|
||||
try draw.print("ChunkMesh memory: {} MiB / {} MiB (fragmentation: {})", .{main.chunk.meshing.faceBuffer.used*faceDataSize >> 20, main.chunk.meshing.faceBuffer.capacity*faceDataSize >> 20, main.chunk.meshing.faceBuffer.freeBlocks.items.len}, 0, y, 8, .left);
|
||||
y += 8;
|
||||
{
|
||||
const faceDataSize = @sizeOf(main.chunk.meshing.FaceData);
|
||||
const size = main.chunk.meshing.faceBuffer.capacity*faceDataSize;
|
||||
const used = main.chunk.meshing.faceBuffer.used*faceDataSize;
|
||||
var largestFreeBlock: usize = 0;
|
||||
for(main.chunk.meshing.faceBuffer.freeBlocks.items) |freeBlock| {
|
||||
largestFreeBlock = @max(largestFreeBlock, freeBlock.len);
|
||||
}
|
||||
const fragmentation = size - used - largestFreeBlock*faceDataSize;
|
||||
try draw.print("ChunkMesh memory: {} MiB / {} MiB (fragmentation: {} MiB)", .{used >> 20, size >> 20, fragmentation >> 20}, 0, y, 8, .left);
|
||||
y += 8;
|
||||
}
|
||||
try draw.print("Biome: {s}", .{main.game.world.?.playerBiome.load(.Monotonic).id}, 0, y, 8, .left);
|
||||
y += 8;
|
||||
try draw.print("Opaque faces: {}, Transparent faces: {}", .{main.chunk.meshing.quadsDrawn, main.chunk.meshing.transparentQuadsDrawn}, 0, y, 8, .left);
|
||||
|
Loading…
x
Reference in New Issue
Block a user