More memes
This commit is contained in:
@@ -24,11 +24,18 @@ public class DefaultGeometryManager extends AbstractGeometryManager {
|
|||||||
private final GlBuffer sectionMetaBuffer;
|
private final GlBuffer sectionMetaBuffer;
|
||||||
private final BufferArena geometryBuffer;
|
private final BufferArena geometryBuffer;
|
||||||
|
|
||||||
|
private final int geometryElementSize;
|
||||||
|
|
||||||
public DefaultGeometryManager(long geometryBufferSize, int maxSections) {
|
public DefaultGeometryManager(long geometryBufferSize, int maxSections) {
|
||||||
|
this(geometryBufferSize, maxSections, 8);//8 is default quad size
|
||||||
|
}
|
||||||
|
|
||||||
|
public DefaultGeometryManager(long geometryBufferSize, int maxSections, int elementSize) {
|
||||||
super(maxSections);
|
super(maxSections);
|
||||||
this.sectionMetaBuffer = new GlBuffer(((long) maxSections) * SECTION_METADATA_SIZE);
|
this.sectionMetaBuffer = new GlBuffer(((long) maxSections) * SECTION_METADATA_SIZE);
|
||||||
this.geometryBuffer = new BufferArena(geometryBufferSize, 8);
|
this.geometryBuffer = new BufferArena(geometryBufferSize, elementSize);
|
||||||
this.pos2id.defaultReturnValue(-1);
|
this.pos2id.defaultReturnValue(-1);
|
||||||
|
this.geometryElementSize = elementSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
IntArrayList uploadResults() {
|
IntArrayList uploadResults() {
|
||||||
@@ -169,7 +176,7 @@ public class DefaultGeometryManager extends AbstractGeometryManager {
|
|||||||
System.err.println(msg);
|
System.err.println(msg);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new SectionMeta(geometry.position, geometry.aabb, geometryPtr, (int) (geometry.geometryBuffer.size/8), geometry.offsets);
|
return new SectionMeta(geometry.position, geometry.aabb, geometryPtr, (int) (geometry.geometryBuffer.size/this.geometryElementSize), geometry.offsets);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void freeMeta(SectionMeta meta) {
|
protected void freeMeta(SectionMeta meta) {
|
||||||
|
|||||||
@@ -32,6 +32,13 @@ import static org.lwjgl.opengl.GL45C.nglClearNamedBufferData;
|
|||||||
import static org.lwjgl.opengl.NVMeshShader.glDrawMeshTasksNV;
|
import static org.lwjgl.opengl.NVMeshShader.glDrawMeshTasksNV;
|
||||||
import static org.lwjgl.opengl.NVRepresentativeFragmentTest.GL_REPRESENTATIVE_FRAGMENT_TEST_NV;
|
import static org.lwjgl.opengl.NVRepresentativeFragmentTest.GL_REPRESENTATIVE_FRAGMENT_TEST_NV;
|
||||||
|
|
||||||
|
//TODO: NOTE
|
||||||
|
// can do "meshlet compaction"
|
||||||
|
// that is, meshlets are refered not by the meshlet id but by an 8 byte alligned index, (the quad index)
|
||||||
|
// this means that non full meshlets can have the tailing data be truncated and used in the next meshlet
|
||||||
|
// as long as the number of quads in the meshlet is stored in the header
|
||||||
|
// the shader can cull the verticies of any quad that has its index over the expected quuad count
|
||||||
|
// this could potentially result in a fair bit of memory savings (especially if used in normal mc terrain rendering)
|
||||||
public class Gl46MeshletsFarWorldRenderer extends AbstractFarWorldRenderer<Gl46MeshletViewport, DefaultGeometryManager> {
|
public class Gl46MeshletsFarWorldRenderer extends AbstractFarWorldRenderer<Gl46MeshletViewport, DefaultGeometryManager> {
|
||||||
private final Shader meshletGenerator = Shader.make()
|
private final Shader meshletGenerator = Shader.make()
|
||||||
.add(ShaderType.COMPUTE, "voxy:lod/gl46mesh/cmdgen.comp")
|
.add(ShaderType.COMPUTE, "voxy:lod/gl46mesh/cmdgen.comp")
|
||||||
@@ -51,9 +58,9 @@ public class Gl46MeshletsFarWorldRenderer extends AbstractFarWorldRenderer<Gl46M
|
|||||||
private final GlBuffer meshletBuffer;
|
private final GlBuffer meshletBuffer;
|
||||||
|
|
||||||
public Gl46MeshletsFarWorldRenderer(int geometrySize, int maxSections) {
|
public Gl46MeshletsFarWorldRenderer(int geometrySize, int maxSections) {
|
||||||
super(new DefaultGeometryManager(geometrySize*8L, maxSections));
|
super(new DefaultGeometryManager(alignUp(geometrySize*8L, 8*128), maxSections, 8*128));
|
||||||
this.glDrawIndirect = new GlBuffer(4*5);
|
this.glDrawIndirect = new GlBuffer(4*5);
|
||||||
this.meshletBuffer = new GlBuffer(4*1000000);//TODO: Make max meshlet count configurable
|
this.meshletBuffer = new GlBuffer(4*1000000);//TODO: Make max meshlet count configurable, not just 1 million (even tho thats a max of 126 million quads per frame)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void bindResources(Gl46MeshletViewport viewport) {
|
protected void bindResources(Gl46MeshletViewport viewport) {
|
||||||
@@ -161,4 +168,8 @@ public class Gl46MeshletsFarWorldRenderer extends AbstractFarWorldRenderer<Gl46M
|
|||||||
this.glDrawIndirect.free();
|
this.glDrawIndirect.free();
|
||||||
this.meshletBuffer.free();
|
this.meshletBuffer.free();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static long alignUp(long n, long alignment) {
|
||||||
|
return (n + alignment - 1) & -alignment;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,6 +85,8 @@ public class RenderDataFactory {
|
|||||||
return new BuiltSection(section.key);
|
return new BuiltSection(section.key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: generate the meshlets here
|
||||||
|
|
||||||
var buff = new MemoryBuffer(quadCount*8L);
|
var buff = new MemoryBuffer(quadCount*8L);
|
||||||
long ptr = buff.address;
|
long ptr = buff.address;
|
||||||
int[] offsets = new int[8];
|
int[] offsets = new int[8];
|
||||||
|
|||||||
Reference in New Issue
Block a user