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
+7 -1
View File
@@ -13,6 +13,7 @@ code and the bot is moved there before the shot. SX, SY are the bot's starting p
Options:
--look pixel|smooth which look to draw (default: pixel; use smooth only to check graphics)
--renderer webgpu|legacy pixel renderer (default: webgpu)
--seed N world seed (default 424242)
--size WxH world size in grains (default 2048x1024)
--setup FILE.js code to run once the world is ready (see tools/scenes/ for examples)
@@ -51,6 +52,7 @@ def main():
ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
ap.add_argument('out')
ap.add_argument('--look', choices=['pixel', 'smooth'], default='pixel')
ap.add_argument('--renderer', choices=['webgpu', 'legacy'], default='webgpu')
ap.add_argument('--seed', type=int, default=424242)
ap.add_argument('--size', default='2048x1024')
ap.add_argument('--setup')
@@ -75,6 +77,8 @@ def main():
pg.add_init_script(FREEZE if a.freeze else '')
pg.goto(url)
pg.evaluate("SET.fog = false")
pg.evaluate('CAPS_CHECK')
pg.evaluate('(r) => { SET.renderer = r; if (r === \'webgpu\' && !GPU.ok) throw Error(GPU.error || \'WebGPU unavailable\'); }', a.renderer)
pg.wait_for_timeout(300)
# pause the moment the world exists, so the shot depends only on the seed, the setup
# code and --ticks (simTick is deterministic), not on how fast the browser ran
@@ -99,6 +103,8 @@ def main():
pg.evaluate("() => { window.__frozenNow = 5000; window.requestAnimationFrame = () => 0; }")
pg.wait_for_timeout(100)
pg.evaluate("() => { R.frame = 999; if (typeof SM !== 'undefined') SM.t0 = 0; frame(lastRender + 1000); }")
if a.look == 'pixel' and a.renderer == 'webgpu' and not pg.evaluate('R.gpuOn'):
raise RuntimeError('WebGPU fell back: ' + pg.evaluate('GPU.error'))
kw = {}
if a.clip:
x, y, w, h = (float(v) for v in a.clip.split(','))
@@ -107,7 +113,7 @@ def main():
pg.screenshot(path=a.out, **kw)
note = pg.evaluate("SET.look === 'smooth' ? (SM.ok ? 'smooth look' : 'smooth look FAILED: ' + SM.why) : 'pixel look'")
b.close()
print(f'saved {a.out} ({note})')
print(f"saved {a.out} ({note}, {a.renderer if a.look == 'pixel' else 'legacy'})")
for e in errors:
print('ERROR', e)
sys.exit(1 if errors else 0)