A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
feat(editor): make the WebGPU backend actually selectable + prompt to apply
yhhbe27feec92e6
diff --git a/desktop/electron/main.ts b/desktop/electron/main.tsindex df2212c4f..911404f87 100644--- a/desktop/electron/main.ts+++ b/desktop/electron/main.ts@@ -35,6 +35,12 @@ import { checkForUpdate } from './updateCheck';import { resolveScripts } from '../src/project/format';import type { WorkspaceState } from '../src/project/format';+// Enable WebGPU in the renderer so the viewport's WebGPU backend (Settings →+// Renderer) has an adapter to acquire. Without it navigator.gpu has no adapter and+// the engine falls back to WebGL2. Must be set before app is ready; mirrors the+// switch the headless verify harness sets.+app.commandLine.appendSwitch('enable-unsafe-webgpu');+// Two privileged custom schemes (must be declared before app ready):// • estella:// serves files from the open project root (sandboxed) — lets the// engine fetch project assets (textures via Assets.loadTexture → fetch).@@ -141,6 +147,8 @@ async function runScreenshot(w: BrowserWindow, out: string): Promise<void> {// headless failures otherwise die silently inside the window.w.webContents.on('console-message', (_e, level, message) => {if (level >= 2) console.log(`[console:${level === 3 ? 'error' : 'warn'}]`, message);+ // Surface engine diagnostics (e.g. the resolved GPU backend) in the dev terminal.+ else if (message.startsWith('[engine]')) console.log(message);});// Deterministic waits — poll a real in-page condition instead of guessing at adiff --git a/desktop/src/settings/editorSettings.ts b/desktop/src/settings/editorSettings.tsindex a199e73da..3e9e59c46 100644--- a/desktop/src/settings/editorSettings.ts+++ b/desktop/src/settings/editorSettings.ts@@ -15,6 +15,8 @@ import { useEditorStore } from '@/store/editorStore';import { LogStore } from '@/store/LogStore';import { commands } from '@/commands';import { setUseLessCpuInBackground } from '@/engine/backgroundThrottle';+import { EngineHost } from '@/engine/EngineHost';+import { Toasts } from '@/store/Toasts';const root = () => document.documentElement.style;@@ -63,6 +65,8 @@ settingsRegistry.register({});// ── Renderer (read at engine boot; the GfxDevice backend seam) ──────────────+// Skips the boot-time effect replay so the reload prompt only fires on a real change.+let backendPrimed = false;settingsRegistry.register({id: 'renderer.backend',type: 'enum',@@ -79,6 +83,20 @@ settingsRegistry.register({{ value: 'webgl2', label: 'WebGL2' },{ value: 'webgpu', label: 'WebGPU' },],+ // The backend is fixed at engine instantiation, so a change applies on reload.+ // Prompt for it — but skip the boot-time replay (the first call), and only when+ // the target differs from the live device. `backendPrimed` is module-local so it+ // resets with a page reload (when applySettings replays effects again).+ effect: (v) => {+ if (!backendPrimed) { backendPrimed = true; return; }+ if (v === EngineHost.activeBackend) return;+ Toasts.push(+ `Reload to render with ${v === 'webgpu' ? 'WebGPU' : 'WebGL2'}`,+ 'info',+ 8000,+ { label: 'Reload now', run: () => location.reload() },+ );+ },});// ── Viewport (bound to editorStore — one source with the viewport toolbar) ───