Aggressively optimize multidraw command emission #32

Merged
embeddedt merged 5 commits from command-emit-opts into stonecutter 2026-08-11 18:46:23 -04:00
2 changed files with 4 additions and 8 deletions
Showing only changes of commit 5bc47e50d2 - Show all commits

No files matched your search

@@ -22,7 +22,7 @@ public class SectionRenderDataStorage {
public SectionRenderDataStorage(ChunkPrimitiveType primitiveType, boolean sorted) { public SectionRenderDataStorage(ChunkPrimitiveType primitiveType, boolean sorted) {
this.storageStrategy = sorted ? SectionRenderDataUnsafe.Strategy.FULL : SectionRenderDataUnsafe.Strategy.COMPACT; this.storageStrategy = sorted ? SectionRenderDataUnsafe.Strategy.FULL : SectionRenderDataUnsafe.Strategy.COMPACT;
this.pMeshDataArray = this.storageStrategy.allocateHeap(RenderRegion.REGION_SIZE); this.pMeshDataArray = this.storageStrategy.allocateHeap();
if (this.pMeshDataArray == 0) { if (this.pMeshDataArray == 0) {
throw new OutOfMemoryError("Failed to allocate mesh data array"); throw new OutOfMemoryError("Failed to allocate mesh data array");
} }
@@ -318,8 +318,8 @@ public class SectionRenderDataUnsafe {
return heap + this.getHeaderSize(); return heap + this.getHeaderSize();
} }
public final long allocateHeap(int count) { public final long allocateHeap() {
long size = this.getHeaderSize() + (count * this.getStride()); long size = this.getHeaderSize() + (RenderRegion.REGION_SIZE * this.getStride());
long pointer = LWJGL.nmemAlignedAlloc(64, size); long pointer = LWJGL.nmemAlignedAlloc(64, size);
if (pointer != 0) { if (pointer != 0) {
@@ -333,10 +333,6 @@ public class SectionRenderDataUnsafe {
LWJGL.nmemAlignedFree(pointer); LWJGL.nmemAlignedFree(pointer);
} }
public final void clear(long pointer) {
LWJGL.memSet(pointer, 0x0, this.getStride());
}
public final long heapPointer(long ptr, int index) { public final long heapPointer(long ptr, int index) {
return this.getRowBasePointer(ptr) + (index * this.getStride()); return this.getRowBasePointer(ptr) + (index * this.getStride());
} }
@@ -362,7 +358,7 @@ public class SectionRenderDataUnsafe {
*/ */
public final void clearRow(long heap, int index) { public final void clearRow(long heap, int index) {
this.setSliceMask(heap, index, 0); this.setSliceMask(heap, index, 0);
this.clear(this.heapPointer(heap, index)); LWJGL.memSet(this.heapPointer(heap, index), 0x0, this.getStride());
} }
private static int vertexCountOf(Map<ModelQuadFacing, VertexRange> ranges, int facing) { private static int vertexCountOf(Map<ModelQuadFacing, VertexRange> ranges, int facing) {