From e7db35218a47c533604d2bf8711ba22099ddc6ed Mon Sep 17 00:00:00 2001 From: Iwo Plaza Date: Fri, 4 Dec 2026 15:53:37 +0100 Subject: [PATCH] fix(docs): Remove timestamp queries from the "Game of Life" example --- .../examples/simulation/game-of-life/index.ts | 33 ++++--------------- 1 file changed, 6 insertions(+), 27 deletions(-) diff --git a/apps/typegpu-docs/src/examples/simulation/game-of-life/index.ts b/apps/typegpu-docs/src/examples/simulation/game-of-life/index.ts index 8322752ecf..9b8113f488 100644 --- a/apps/typegpu-docs/src/examples/simulation/game-of-life/index.ts +++ b/apps/typegpu-docs/src/examples/simulation/game-of-life/index.ts @@ -9,10 +9,7 @@ import { sdLine, sdRoundedBox2d } from '@typegpu/sdf'; import { setupInput } from './input.ts'; import { defineControls } from '../../common/defineControls.ts'; -const root = await tgpu.init({ - device: { optionalFeatures: ['timestamp-query'] }, -}); -const hasTimestamp = root.enabledFeatures.has('timestamp-query'); +const root = await tgpu.init(); const canvas = document.querySelector('canvas') as HTMLCanvasElement; const context = root.configureContext({ canvas, alphaMode: 'premultiplied' }); @@ -141,30 +138,14 @@ const handleDrawBitpacked = root.createGuardedComputePipeline((px, py) => { std.textureStore(computeLayout.$.next, d.vec2u(px, py), d.vec4u(result, 0, 0, 0)); }); -const perf = { sum: 0, count: 0, window: 120 }; - -function createPipeline(name: string, compute: TgpuComputeFn) { - const base = root.with(gameSizeAccessor, gameSizeUniform).createComputePipeline({ compute }); - - return !hasTimestamp - ? base - : base.withPerformanceCallback((start, end) => { - perf.sum += Number(end - start) / 1_000_00; - perf.count++; - if (perf.count >= perf.window) { - console.log( - `${name}: ${(perf.sum / perf.count).toFixed(3)}ms average over ${perf.window} frames`, - ); - perf.sum = 0; - perf.count = 0; - } - }); +function createPipeline(compute: TgpuComputeFn) { + return root.with(gameSizeAccessor, gameSizeUniform).createComputePipeline({ compute }); } const computePipelines = { - tiled: createPipeline('Tiled', tiledCompute), - naive: createPipeline('Naive', naiveCompute), - bitpacked: createPipeline('Bitpacked', bitpackedCompute), + tiled: createPipeline(tiledCompute), + naive: createPipeline(naiveCompute), + bitpacked: createPipeline(bitpackedCompute), }; const sampleRegular = (sampleUv: d.v2f, gs: number): number => { @@ -435,8 +416,6 @@ export const controls = defineControls({ const wasBitpacked = chosenPipeline === 'bitpacked'; const isBitpacked = value === 'bitpacked'; chosenPipeline = value; - perf.sum = 0; - perf.count = 0; if (wasBitpacked !== isBitpacked) { recreateResources(gameSize); }