Skip to content

Commit 427999f

Browse files
committed
feat(meshoptimizer) migrate Tootle demo
1 parent d292fed commit 427999f

File tree

2 files changed

+106
-222
lines changed

2 files changed

+106
-222
lines changed

Diff for: modules/samples/src/test/java/org/lwjgl/demo/util/meshoptimizer/HelloMeshOptimizer.java

+18-5
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public static void main(String[] args) {
6969

7070
memPutInt(mesh.address() + ParShapesMesh.NPOINTS, uniqueVertices);
7171

72-
System.out.println("AFTER:");
72+
System.out.println("\nAFTER:");
7373
System.out.println("------");
7474
printStats(mesh);
7575

@@ -84,14 +84,27 @@ private static void remap(FloatBuffer vertexBuffer, IntBuffer indexBuffer, Float
8484

8585
private static void printStats(ParShapesMesh mesh) {
8686
try (MemoryStack stack = stackPush()) {
87-
MeshoptVertexCacheStatistics stats = meshopt_analyzeVertexCache(
87+
MeshoptVertexCacheStatistics vcache = meshopt_analyzeVertexCache(
8888
mesh.triangles(mesh.ntriangles() * 3),
8989
mesh.npoints(),
90-
16, 0, 0,
90+
32, 32, 32, // NVIDIA
91+
//14, 64, 128, // AMD
92+
//128, 0, 0, // INTEL
9193
MeshoptVertexCacheStatistics.malloc(stack)
9294
);
93-
System.out.println("ACMR: " + stats.acmr());
94-
System.out.println("ATVR: " + stats.atvr());
95+
System.out.println("ACMR: " + vcache.acmr());
96+
System.out.println("ATVR: " + vcache.atvr());
97+
98+
MeshoptOverdrawStatistics overdraw = meshopt_analyzeOverdraw(
99+
mesh.triangles(mesh.ntriangles() * 3),
100+
mesh.points(mesh.npoints() * 3),
101+
mesh.npoints(),
102+
3 * Float.BYTES,
103+
MeshoptOverdrawStatistics.malloc(stack)
104+
);
105+
System.out.println("Overdraw: " + overdraw.overdraw());
106+
System.out.println("Pixels covered: " + overdraw.pixels_covered());
107+
System.out.println("Pixels shaded: " + overdraw.pixels_shaded());
95108
}
96109
}
97110

0 commit comments

Comments
 (0)