Shader performance: measure one filter pass per sprite (#67)
game-maker / suite (push) Successful in 8m23s
game-maker / suite (push) Successful in 8m23s
The wiki carried an estimate ("fine for dozens, not for thousands"). Measured
on the Intel HD 630 that CI uses, 48x48 sprites in a 640x360 camera, neutral
values, three runs agreeing to 1 fps:
sprites 25 50 100 200 400 800
fps 58 56 54 48 34 20
The same scene without shaders holds 60 fps at every one of those counts, 800
included. Quadrupling the sprite area (96x96) measures the same, so the cost is
the render target switch, not the pixels: roughly 20 us per pass up to 200,
40 us at 800.
tools/perf-shaders.mjs drives it (not run in CI, frame times are machine
dependent). New hook __gm.filterCount() counts visible nodes carrying a filter
and proves one pass per sprite; e2e 28 checks it.
Two traps the tool guards against, both cost a wrong answer first: the median
frame time is useless here (the distribution is bimodal under vsync, so the
rate comes from frames/duration), and --disable-gpu-vsync has no effect in
headless, so what is measured is the point where the frame rate breaks down.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5c1c3c6fd6
commit
82effb2c03
4 files changed
+183
-1
No files matched your search
@@ -230,6 +230,21 @@ export async function shader(t) {
|
||||
colourDistance(neutral, base) < 6,
|
||||
JSON.stringify({ base, neutral }),
|
||||
);
|
||||
// What the cost is made of (#67): one filter per sprite wearing a shader, so one render pass.
|
||||
const passesOn = await json('__gm.filterCount()');
|
||||
await assetProps({ shader: '' });
|
||||
await sleep(300);
|
||||
const passesOff = await json('__gm.filterCount()');
|
||||
await assetProps({ shader: ADJUST });
|
||||
await sleep(300);
|
||||
check(
|
||||
'a shaded sprite carries one filter – one render pass – and none without',
|
||||
passesOn === 1 && passesOff === 0,
|
||||
{
|
||||
on: passesOn,
|
||||
off: passesOff,
|
||||
},
|
||||
);
|
||||
await assetProps({ brightness: 1.25 });
|
||||
await sleep(300);
|
||||
const lighter = await centre();
|
||||
|
||||
Reference in new issue
Block a user