Skip to content

Commit d3c34fe

Browse files
committed
test(engine): Add test for GPU timing graceful fallback
Verifies that AnimationLoop: - Creates gpuTime and cpuTime stats regardless of timer support - Initializes _gpuTimeQuery only when timer-query-webgl is available - Cleans up query resources on destroy without errors https://claude.ai/code/session_01H614UvusgZQfwVssKtezh9
1 parent 3bb2ad1 commit d3c34fe

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

modules/engine/test/lib/animation-loop.spec.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,30 @@ test('engine#AnimationLoop a start/stop/start should not call initialize again',
147147
t.end();
148148
}, 150);
149149
});
150+
151+
test('engine#AnimationLoop GPU timing graceful fallback', async t => {
152+
const device = await getWebGLTestDevice();
153+
154+
const animationLoop = new AnimationLoop({device});
155+
await animationLoop.start();
156+
await animationLoop.waitForRender();
157+
158+
// Stats should exist regardless of timer support
159+
t.ok(animationLoop.gpuTime, 'gpuTime stat exists');
160+
t.ok(animationLoop.cpuTime, 'cpuTime stat exists');
161+
162+
// _gpuTimeQuery should match feature availability
163+
const hasTimerQuery = device.features.has('timer-query-webgl');
164+
t.is(
165+
animationLoop._gpuTimeQuery !== null,
166+
hasTimerQuery,
167+
`_gpuTimeQuery created when feature ${hasTimerQuery ? 'available' : 'unavailable'}`
168+
);
169+
170+
// Destroy should not throw
171+
animationLoop.stop();
172+
animationLoop.destroy();
173+
t.is(animationLoop._gpuTimeQuery, null, 'Query cleaned up on destroy');
174+
175+
t.end();
176+
});

0 commit comments

Comments
 (0)