WebGPU pixel look: GPU colours the world, CPU only rare cells (t88 phase 2a)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-27 19:49:36 -04:00
co-authored by Claude Opus 5.5
parent b2c9ad9533
commit fc05146887
29 changed files with 949 additions and 386 deletions
+14 -5
View File
@@ -29,7 +29,7 @@ function perfSim(names, scene, w, h) {
return { total_ms: total, ticks: n, start, end: perfState(), steps,
rest_ms: total - Object.values(data).reduce((s, d) => s + d.ms / n, 0) };
}
function perfRender(lighting, overlays) {
async function perfRender(lighting, overlays) {
SET.lighting = lighting;
PERF_MARKS = true;
try {
@@ -48,13 +48,22 @@ function perfRender(lighting, overlays) {
// Exercise the actual overlay calls and their arguments/conditions in frame().
PERF_MARKS = false;
for (let k = 0; k < 5; k++) frame(lastT + 1000 / 60);
const data = {}, restore = perfWrap(overlays, data);
const data = {}, restore = perfWrap(overlays, data), frameStart = performance.now();
try { for (let k = 0; k < n; k++) frame(lastT + 1000 / 60); }
finally { restore(); }
return { drawWorld_ms: draw, computeLight_ms: light, marks_ms: marks,
const frame_ms = (performance.now() - frameStart) / n;
// One completed timestamp sample for this configuration, outside the CPU measurements.
let gpu_ms = null;
if (R.gpuOn && GPU.queries) {
await GPU.timingPromise;
PERF_MARKS = true; drawWorld();
await GPU.timingPromise;
PERF_MARKS = false; gpu_ms = GPU.gpuMs; marks.gpu = gpu_ms;
}
return { frame_ms, drawWorld_ms: draw, computeLight_ms: light, marks_ms: marks,
overlays: Object.fromEntries(Object.entries(data).map(([key, d]) => [key, { ms_per_frame: d.ms / n, calls: d.calls }])),
overlay_ms: Object.values(data).reduce((sum, d) => sum + d.ms / n, 0),
scale: SM.scale, actual_look: SET.look };
scale: SM.scale, actual_look: SET.look, renderer: R.gpuOn ? 'webgpu' : 'legacy', override_cells: GPU.overrideCount || 0, gpu_ms };
} finally { PERF_MARKS = false; }
}
function perfRun(seconds) {
@@ -72,7 +81,7 @@ function perfRun(seconds) {
requestAnimationFrame(frame);
setTimeout(() => {
window.__perfHalt(); PERF_FRAME = null; GAME.paused = true;
resolve({ samples, end: perfState(), scale: SM.scale, actual_look: SET.look });
resolve({ samples, end: perfState(), scale: SM.scale, actual_look: SET.look, renderer: R.gpuOn ? 'webgpu' : 'legacy', override_cells: GPU.overrideCount || 0, gpu_ms: R.gpuOn ? GPU.gpuMs : null });
}, seconds * 1000);
});
}