Strip core to render data and render graphs

Move glTF, picking, camera controls, and conventional handles into addons. Keep camera and material mutations in SIMD-aligned shared SOA rows and synchronize material updates directly into GPU buffers.

Amp-Thread-ID: https://ampcode.com/threads/T-01a01380-b478-77d0-84a0-102880a5c5ae
Co-authored-by: Heaust Azure <heaust.azure@gmail.com>
This commit is contained in:
Amp
2026-08-19 09:41:41 +00:00
co-authored by heaust
parent 0e44917f9e
commit 6bbf8039e4
67 changed files with 3152 additions and 3669 deletions
+25 -5
View File
@@ -2,7 +2,9 @@ import test from "node:test";
import assert from "node:assert/strict";
import { GltfImporter } from "@yawn/gltf-import";
import { gltfToRenderDataPacket } from "../addons/gltf-import/src/gltf.js";
import { writeSharedUpload } from "../addons/gltf-import/src/shared-upload.js";
import { createCubeGeometry, encodeGeometryGlb } from "../examples/render-graph-studio/demo-loadouts.js";
class WorkerMock extends EventTarget {
messages = [];
@@ -18,7 +20,7 @@ test("glTF addon stages fetched bytes in shared SOA and commits only metadata",
const memory = new SharedArrayBuffer(4096);
const descriptor = {
id: 9,
name: "upload.gltf",
name: "upload.renderData",
domain: "fixed",
scalar: "u32",
lanes: 4,
@@ -36,8 +38,8 @@ test("glTF addon stages fetched bytes in shared SOA and commits only metadata",
const calls = [];
const core = {
async allocateArray(layout) { calls.push(["allocate", layout]); return array; },
async commitGlbUpload(value, byteLength, options) {
calls.push(["commit", value, byteLength, options]);
async commitRenderDataUpload(value, byteLength) {
calls.push(["commit", value, byteLength]);
return { meshes: [] };
},
};
@@ -54,7 +56,7 @@ test("glTF addon stages fetched bytes in shared SOA and commits only metadata",
worker.reply({ type: "allocate", request: 1, byteLength: 20 });
await tick();
assert.deepEqual(calls[0], ["allocate", {
name: "upload.gltf", domain: "fixed", scalar: "u32", lanes: 4, stride: 16, length: 2,
name: "upload.renderData", domain: "fixed", scalar: "u32", lanes: 4, stride: 16, length: 2,
}]);
assert.equal(worker.messages[1].buffer, memory);
assert.equal(worker.messages[1].descriptor, descriptor);
@@ -65,7 +67,25 @@ test("glTF addon stages fetched bytes in shared SOA and commits only metadata",
worker.reply({ type: "ready", request: 1, byteLength: bytes.byteLength });
assert.deepEqual(await loading, { meshes: [] });
assert.deepEqual(new Uint8Array(memory, 64, 20), bytes);
assert.deepEqual(calls[1], ["commit", array, 20, { framing: "interior" }]);
assert.deepEqual(calls[1], ["commit", array, 20]);
importer.dispose();
assert.equal(worker.terminated, true);
});
test("glTF parsing produces a format-neutral typed render-data packet in the addon", async () => {
const glb = encodeGeometryGlb(createCubeGeometry());
const packet = await gltfToRenderDataPacket(
new Uint8Array(glb),
"https://example.test/scene.glb",
);
const header = new DataView(packet.buffer, packet.byteOffset, packet.byteLength);
assert.equal(header.getUint32(0, true), 0x50445259);
assert.equal(header.getUint32(4, true), 1);
const metadataLength = header.getUint32(8, true);
const payloadLength = header.getUint32(12, true);
const metadata = JSON.parse(new TextDecoder().decode(packet.subarray(16, 16 + metadataLength)));
assert.equal(metadata.geometries.length, 1);
assert.equal(metadata.occurrences.length, 9);
assert.deepEqual(metadata.geometries[0].instanceType.slice(0, 2), [5, 0]);
assert.equal(((16 + metadataLength + 3) & ~3) + payloadLength, packet.byteLength);
});