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:
+4
-13
@@ -1,4 +1,4 @@
|
||||
"""Capability detection, title warnings and the future startup gate."""
|
||||
"""Capability detection, title notices and the required-WebGPU startup gate."""
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
@@ -8,23 +8,18 @@ ensure_playwright()
|
||||
from browser import capabilities, consume_gpu_option, launch
|
||||
|
||||
consume_gpu_option()
|
||||
for case in ['native', 'absent', 'null', 'reject', 'firefox', 'required']:
|
||||
for case in ['native', 'absent', 'null', 'reject', 'firefox', 'limits']:
|
||||
with launch() as (_, page, url):
|
||||
errors = []
|
||||
page.on('pageerror', lambda e: errors.append(str(e)))
|
||||
if case != 'native':
|
||||
gpu = 'undefined' if case == 'absent' else "{requestAdapter: async () => null}"
|
||||
if case == 'reject': gpu = "{requestAdapter: async () => {throw new Error('adapter denied')}}"
|
||||
if case == 'limits': gpu="{requestAdapter:async()=>({limits:{maxStorageTexturesPerShaderStage:3}})}"
|
||||
page.add_init_script(f"Object.defineProperty(navigator, 'gpu', {{value: {gpu}}});")
|
||||
page.add_init_script("Object.defineProperty(self, 'crossOriginIsolated', {value: false});")
|
||||
if case == 'firefox':
|
||||
page.add_init_script("Object.defineProperty(navigator, 'userAgent', {value: 'Firefox/157.0'});")
|
||||
if case == 'required':
|
||||
def require(route):
|
||||
response = route.fetch()
|
||||
route.fulfill(response=response, body=response.text().replace(
|
||||
'const REQUIRE_GPU_AND_THREADS = false;', 'const REQUIRE_GPU_AND_THREADS = true;'))
|
||||
page.route('**/index.html', require)
|
||||
page.goto(url)
|
||||
caps = capabilities(page)
|
||||
page.wait_for_function("!$('title').hidden")
|
||||
@@ -36,17 +31,13 @@ for case in ['native', 'absent', 'null', 'reject', 'firefox', 'required']:
|
||||
notice = page.inner_text('#cap-notice')
|
||||
assert 'python3 tools/serve.py' in notice and "opened from a file it can't" in notice
|
||||
assert ('Firefox Nightly' in notice and 'dom.webgpu.enabled' in notice) if case == 'firefox' else 'Chrome or Edge' in notice
|
||||
if case == 'required':
|
||||
if case != 'native':
|
||||
assert not page.evaluate('canStartGame()')
|
||||
page.evaluate('startNewWorld(424242, 512, 384)')
|
||||
assert not page.evaluate('GAME.running || GAME.loading')
|
||||
assert not page.evaluate('startFromSave({})')
|
||||
else:
|
||||
assert page.evaluate('canStartGame()')
|
||||
if case == 'absent':
|
||||
Path('shots').mkdir(exist_ok=True)
|
||||
page.screenshot(path='shots/t88-p1-notice.png')
|
||||
page.evaluate("SET.look='pixel'; startNewWorld(424242, 512, 384)")
|
||||
page.wait_for_function('GAME.running && !GAME.loading', timeout=60000)
|
||||
assert not errors, errors
|
||||
print(f'PASS capabilities: {case}')
|
||||
|
||||
Reference in New Issue
Block a user