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(renderer): a lost GPU device now comes all the way back
esengine39dff28b9dd5
diff --git a/desktop/scripts/headless-verify.mjs b/desktop/scripts/headless-verify.mjsindex f99b2cd60..c7213c093 100644--- a/desktop/scripts/headless-verify.mjs+++ b/desktop/scripts/headless-verify.mjs@@ -243,6 +243,7 @@ app.whenReady().then(async () => {out.reportAfterLoss = d.report();out.guard = d.guard();+ out.tablesAtLoss = d.glTables();out.glLostBeforeRestore = d.contextLost();out.restoreCalled = d.restore();await new Promise((r) => setTimeout(r, 500));@@ -259,6 +260,7 @@ app.whenReady().then(async () => {// The full cycle: rebuild, re-upload the textures, and declare it whole.out.fullRecovered = await d.recoverFull();out.statusAfterFull = d.status();+ out.tablesAfterFull = d.glTables();api.step(${STEPS}, 1 / 60);out.drawCallsAfterRecover = api.getStats ? api.getStats().drawCalls : -1;return out;diff --git a/desktop/src/headless.ts b/desktop/src/headless.tsindex 40ac21346..e2f71a507 100644--- a/desktop/src/headless.ts+++ b/desktop/src/headless.ts@@ -33,6 +33,7 @@ declare global {recover(): boolean;finishRecovery(): void;recoverFull(): Promise<boolean>;+ glTables(): Record<string, number>;lose(): boolean;contextLost(): boolean | null;guard(): { target: string; lostEventsSeen: number };@@ -85,6 +86,23 @@ window.__estellaHeadless = {if (!assets) return false;return assets.recoverFromDeviceLoss();},+ // EXPERIMENT: emscripten's GL object tables are the suspected blocker —+ // they hold wrappers minted against the dead context. Counting them says+ // whether a rebuild refilled them or merely added to the stale ones.+ glTables: () => {+ const GL = (EngineHost.module as unknown as { GL?: Record<string, unknown> } | null)?.GL;+ const count = (name: string): number => {+ const t = GL?.[name] as unknown[] | undefined;+ if (!t) return -1;+ let n = 0;+ for (const e of t) if (e) n++;+ return n;+ };+ return {+ programs: count('programs'), shaders: count('shaders'), buffers: count('buffers'),+ textures: count('textures'), vaos: count('vaos'), framebuffers: count('framebuffers'),+ };+ },guard: () => getContextLossGuardInfo(),contextLost: () => {const gl = EngineHost.canvas?.getContext('webgl2') as WebGL2RenderingContext | null;diff --git a/src/esengine/renderer/frame/RenderFrame.cpp b/src/esengine/renderer/frame/RenderFrame.cppindex 04da440aa..a8147ecbd 100644--- a/src/esengine/renderer/frame/RenderFrame.cpp+++ b/src/esengine/renderer/frame/RenderFrame.cpp@@ -186,6 +186,23 @@ void RenderFrame::recreateGpuResources() {#ifdef ES_ENABLE_POSTPROCESSif (post_process_) post_process_->recreateGpuResources();#endif++ // Plugins cache the batch program id at init, and that id died with the+ // device — a collect pass would keep keying draws to a program the restored+ // context rejects. init() is where they take it, so init() is what runs.+ RenderFrameContext ctx{+ context_,+ resource_manager_,+ context_.getWhiteTextureId(),+ batch_shader_id_,+ RenderStage::Transparent,+ glm::mat4(1.0f),+ nullptr,+ this+ };+ for (auto& plugin : plugins_) {+ plugin->init(ctx);+ }}void RenderFrame::resize(u32 width, u32 height) {