55 lines
1.5 KiB
JavaScript
55 lines
1.5 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
import { analyzeGlbJson } from "./glb-performance.mjs";
|
|
|
|
test("counts repeated mesh placements as avoidable draw calls", () => {
|
|
const report = analyzeGlbJson({
|
|
meshes: [
|
|
{ primitives: [{}, {}] },
|
|
{ primitives: [{}] },
|
|
],
|
|
nodes: [
|
|
{ mesh: 0 },
|
|
{ mesh: 0 },
|
|
{ mesh: 0 },
|
|
{ mesh: 1 },
|
|
],
|
|
materials: [
|
|
{ doubleSided: true, alphaMode: "BLEND" },
|
|
{},
|
|
],
|
|
textures: [{}, {}],
|
|
});
|
|
|
|
assert.equal(report.estimatedDrawCalls, 7);
|
|
assert.equal(report.expandedPrimitiveInstances, 7);
|
|
assert.equal(report.eligibleRepeatedMeshes, 1);
|
|
assert.equal(report.eligibleRepeatedNodes, 3);
|
|
assert.equal(report.unbatchedDrawCallSavings, 4);
|
|
assert.equal(report.doubleSidedMaterials, 1);
|
|
assert.equal(report.blendedMaterials, 1);
|
|
});
|
|
|
|
test("counts one draw-call set for an EXT_mesh_gpu_instancing batch", () => {
|
|
const report = analyzeGlbJson({
|
|
extensionsUsed: ["EXT_mesh_gpu_instancing"],
|
|
accessors: [{ count: 12 }],
|
|
meshes: [{ primitives: [{}, {}, {}] }],
|
|
nodes: [{
|
|
mesh: 0,
|
|
extensions: {
|
|
EXT_mesh_gpu_instancing: {
|
|
attributes: { TRANSLATION: 0 },
|
|
},
|
|
},
|
|
}],
|
|
});
|
|
|
|
assert.equal(report.estimatedDrawCalls, 3);
|
|
assert.equal(report.expandedPrimitiveInstances, 36);
|
|
assert.equal(report.gpuInstanceBatches, 1);
|
|
assert.equal(report.gpuInstances, 12);
|
|
assert.equal(report.unbatchedDrawCallSavings, 0);
|
|
assert.equal(report.usesGpuInstancing, true);
|
|
});
|