WebGPU renderer complete: dirty uploads, default limits, legacy removed, WebGPU required, warm-up (t88 phase 2d)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-27 23:17:17 -04:00
co-authored by Claude Opus 5.5
parent 452b6aed32
commit 20963c776e
83 changed files with 776 additions and 1240 deletions
+3 -8
View File
@@ -13,7 +13,6 @@ 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)
@@ -52,7 +51,6 @@ 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')
@@ -78,7 +76,6 @@ def main():
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
@@ -93,7 +90,7 @@ def main():
if code:
pg.evaluate(f'() => {{ {code}\n}}')
# Setup scenes can change surfY after the renderer cached the world's horizon.
pg.evaluate('SM.surf = -1')
pg.evaluate('SM.surf = -1; renderDirty.fill(1); GPU.world=null;')
if a.ticks:
pg.evaluate(f'for (let k = 0; k < {a.ticks}; k++) simTick();')
pg.evaluate(f"""GAME.paused = true; $('hud').hidden = {'false' if a.hud else 'true'}; GAME.hidePreviews = {'false' if a.previews else 'true'};
@@ -105,17 +102,15 @@ 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.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(','))
kw['clip'] = {'x': x, 'y': y, 'width': w, 'height': h}
pathlib.Path(a.out).parent.mkdir(parents=True, exist_ok=True)
pg.screenshot(path=a.out, **kw)
note = pg.evaluate("SET.look === 'smooth' ? (R.smoothOn ? 'smooth look' : 'smooth look FAILED: ' + SM.why) : 'pixel look'")
note = pg.evaluate("SET.look === 'smooth' ? (R.smoothOn ? 'smooth look' : 'smooth look FAILED') : 'pixel look'")
b.close()
print(f"saved {a.out} ({note}, {a.renderer})")
print(f'saved {a.out} ({note}, WebGPU)')
for e in errors:
print('ERROR', e)
sys.exit(1 if errors else 0)