Skip to content

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.

feat(rhi): a device can say which GPU it is while it still works

esengine2a9a79a87c50
diff --git a/CHANGELOG.md b/CHANGELOG.md
index dc5bc85c0..0336f08a8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,37 @@ Version numbers here track the **Estella release** — the engine + editor + SDK
shipped together, matching the Git tags and GitHub Releases. The SDK is not
published separately; it ships inside the editor.
+## [Unreleased]
+
+### Added
+
+- **Export Diagnostics: one document that answers "the editor crashed yesterday".**
+ Everything a reproduction needs was already in the process — the build stamp the
+ boot guard reads, the census `resource_census` reads, the log the console
+ renders — with nothing that put them in one place. **Help ▸ Export Diagnostics**
+ now writes a structured report: editor and engine build (ABI, git sha, built-at),
+ the GPU, the project's shape, every census counter, the recent log, and the
+ settings that differ from their defaults.
+
+ The exporter knows no section names; a subsystem registers what it can say and
+ the bundle walks the registry, so a plugin contributes diagnostics through the
+ same door core uses. What a studio can hand out is decided per VALUE rather than
+ per collector: names, paths and values travel as stable placeholders, and the
+ full thing is a separate, explicit export. The placeholders are stable so one
+ name reads the same everywhere it appears, and keep the shape, because a value
+ that was `undefined` and one that was `0` are different bugs.
+
+- **The GPU is readable while it works.** The engine captured its backend, vendor,
+ renderer and driver version at init all along — a lost backend cannot be asked
+ who it was — but the only way to read them was off a *loss report*, so a healthy
+ session could not say which GPU it was running on. Identity is now its own type
+ with its own accessor (`getDeviceIdentity()`), and the loss report snapshots it.
+
+ On the web that answer used to be worthless anyway: `GL_VENDOR` and
+ `GL_RENDERER` are masked, and every Mac reports "WebKit WebGL" — a browser, not
+ a GPU. The unmasked strings are read where the browser allows it, so a report
+ now names `ANGLE Metal Renderer: Apple M4` instead of a constant.
+
## [0.47.0] - 2026-08-08
### Added
diff --git a/desktop/src/diagnostics/sections.ts b/desktop/src/diagnostics/sections.ts
index 62b71e1b6..9d9212ee4 100644
--- a/desktop/src/diagnostics/sections.ts
+++ b/desktop/src/diagnostics/sections.ts
@@ -10,7 +10,7 @@
* the counters from the same census the agent's `resource_census` tool
* reads, the log from the store the console renders.
*/
-import { takeCensus } from 'esengine';
+import { takeCensus, getDeviceIdentity, getDeviceStatus, getDeviceLostReport } from 'esengine';
import { diagnosticsRegistry } from './registry';
import { personal } from './redact';
import { EngineHost } from '@/engine/EngineHost';
@@ -62,6 +62,23 @@ diagnosticsRegistry.register({
}),
});
+/**
+ * The GPU, as the driver names itself. Not personal: it identifies the machine's
+ * hardware, which is the point, and says nothing about the project.
+ *
+ * `lostReport` is empty on a healthy session — its presence in a bundle is the
+ * finding, not a field to fill in.
+ */
+diagnosticsRegistry.register({
+ id: 'gpu',
+ collect: () => {
+ const id = getDeviceIdentity();
+ if (!id) return null;
+ const lost = getDeviceLostReport();
+ return { ...id, status: getDeviceStatus(), ...(lost ? { lostReport: lost } : {}) };
+ },
+});
+
/**
* The project, in the shape a reproduction needs: which scene, how big, how dirty.
*
diff --git a/desktop/tests/diagnostic-bundle.test.ts b/desktop/tests/diagnostic-bundle.test.ts
index 284c8d4ee..debdc34eb 100644
--- a/desktop/tests/diagnostic-bundle.test.ts
+++ b/desktop/tests/diagnostic-bundle.test.ts
@@ -116,6 +116,19 @@ describe('the core sections', () => {
expect(ids).toEqual(expect.arrayContaining(['editor', 'engine', 'project', 'census', 'log']));
});
+ it('report the GPU in the clear — it is the machine, not the project', () => {
+ // The one section deliberately NOT redacted. A crash on "ANGLE Metal
+ // Renderer: Apple M4" is attributable; the same crash on a placeholder
+ // is not, and the string says nothing about what the user is building.
+ const gpu = diagnosticsRegistry.get('gpu');
+ expect(gpu).toBeDefined();
+ const collected = gpu!.collect() as Record<string, unknown> | null;
+ // Null without a live device (this suite has no wasm), which is the
+ // other half of the contract: absent rather than invented.
+ if (collected === null) return;
+ expect(JSON.stringify(resolve(collected, 'safe'))).toBe(JSON.stringify(collected));
+ });
+
it('have distinct ids, so none silently replaces another', () => {
const ids = diagnosticsRegistry.all().map((s) => s.id);
expect(new Set(ids).size).toBe(ids.length);
diff --git a/sdk/etc/index.api.md b/sdk/etc/index.api.md
index 083b0b1e4..30f7f5bc2 100644
--- a/sdk/etc/index.api.md
+++ b/sdk/etc/index.api.md
@@ -1,7 +1,7 @@
# API surface — esengine/index
<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->
-Symbols: 1478 stable · 17 beta · 1 deprecated
+Symbols: 1480 stable · 17 beta · 1 deprecated
## ABI_LAYOUT_HASH — const
```
@@ -2201,6 +2201,14 @@ pixels: Uint8Array<ArrayBufferLike>
width: number
```
+## DeviceIdentity — interface
+```
+backend: string
+renderer: string
+vendor: string
+version: string
+```
+
## DeviceLostReason — const
```
{ readonly Unknown: 0; readonly ContextLost: 1; readonly OutOfMemory: 2; readonly Reset: 3; readonly Removed: 4; readonly Destroyed: 5; readonly Validation: 6; readonly Internal: 7; }
@@ -2566,6 +2574,7 @@ anim_resumeTween: (registry: CppRegistry, tweenEntity: number) => void
anim_setSequenceNext: (registry: CppRegistry, tweenEntity: number, nextEntity: number) => void
anim_setTweenBezier: (registry: CppRegistry, tweenEntity: number, p1x: number, p1y: number, p2x: number, p2y: number) => void
anim_updateTweens: (registry: CppRegistry, deltaTime: number) => void
+deviceIdentity: (() => string) | undefined
deviceLostReport: (() => string) | undefined
deviceStatus: (() => number) | undefined
draw_begin: (matrixPtr: number) => void
@@ -9771,6 +9780,11 @@ FsmPlugin
(): AppContext
```
+## getDeviceIdentity — function
+```
+(): DeviceIdentity | null
+```
+
## getDeviceLostReport — function
```
(): string
diff --git a/sdk/etc/index.native.api.md b/sdk/etc/index.native.api.md
index 4970fbb81..523accf24 100644
--- a/sdk/etc/index.native.api.md
+++ b/sdk/etc/index.native.api.md
@@ -1,7 +1,7 @@
# API surface — esengine/index.native
<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->
-Symbols: 1497 stable · 22 beta · 1 deprecated
+Symbols: 1499 stable · 22 beta · 1 deprecated
## ABI_LAYOUT_HASH — const
```
@@ -2209,6 +2209,14 @@ pixels: Uint8Array<ArrayBufferLike>
width: number
```
+## DeviceIdentity — interface
+```
+backend: string
+renderer: string
+vendor: string
+version: string
+```
+
## DeviceLostReason — const
```
{ readonly Unknown: 0; readonly ContextLost: 1; readonly OutOfMemory: 2; readonly Reset: 3; readonly Removed: 4; readonly Destroyed: 5; readonly Validation: 6; readonly Internal: 7; }
@@ -2574,6 +2582,7 @@ anim_resumeTween: (registry: CppRegistry, tweenEntity: number) => void
anim_setSequenceNext: (registry: CppRegistry, tweenEntity: number, nextEntity: number) => void
anim_setTweenBezier: (registry: CppRegistry, tweenEntity: number, p1x: number, p1y: number, p2x: number, p2y: number) => void
anim_updateTweens: (registry: CppRegistry, deltaTime: number) => void
+deviceIdentity: (() => string) | undefined
deviceLostReport: (() => string) | undefined
deviceStatus: (() => number) | undefined
draw_begin: (matrixPtr: number) => void
@@ -10004,6 +10013,11 @@ FsmPlugin
(): AppContext
```
+## getDeviceIdentity — function
+```
+(): DeviceIdentity | null
+```
+
## getDeviceLostReport — function
```
(): string
diff --git a/sdk/etc/index.node.api.md b/sdk/etc/index.node.api.md
index d3c53ef20..5a352b29d 100644
--- a/sdk/etc/index.node.api.md
+++ b/sdk/etc/index.node.api.md
@@ -1,7 +1,7 @@
# API surface — esengine/index.node
<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->
-Symbols: 1477 stable · 19 beta · 1 deprecated
+Symbols: 1479 stable · 19 beta · 1 deprecated
## ANCHOR_AXES — const
```
@@ -2196,6 +2196,14 @@ pixels: Uint8Array<ArrayBufferLike>
width: number
```
+## DeviceIdentity — interface
+```
+backend: string
+renderer: string
+vendor: string
+version: string
+```
+
## DeviceLostReason — const
```
{ readonly Unknown: 0; readonly ContextLost: 1; readonly OutOfMemory: 2; readonly Reset: 3; readonly Removed: 4; readonly Destroyed: 5; readonly Validation: 6; readonly Internal: 7; }
@@ -2561,6 +2569,7 @@ anim_resumeTween: (registry: CppRegistry, tweenEntity: number) => void
anim_setSequenceNext: (registry: CppRegistry, tweenEntity: number, nextEntity: number) => void
anim_setTweenBezier: (registry: CppRegistry, tweenEntity: number, p1x: number, p1y: number, p2x: number, p2y: number) => void
anim_updateTweens: (registry: CppRegistry, deltaTime: number) => void
+deviceIdentity: (() => string) | undefined
deviceLostReport: (() => string) | undefined
deviceStatus: (() => number) | undefined
draw_begin: (matrixPtr: number) => void
@@ -9766,6 +9775,11 @@ FsmPlugin
(): AppContext
```
+## getDeviceIdentity — function
+```
+(): DeviceIdentity | null
+```
+
## getDeviceLostReport — function
```
(): string
diff --git a/sdk/etc/minigame.api.md b/sdk/etc/minigame.api.md
index 8feb348cb..3f6d51834 100644
--- a/sdk/etc/minigame.api.md
+++ b/sdk/etc/minigame.api.md
@@ -1,7 +1,7 @@
# API surface — esengine/minigame
<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->
-Symbols: 1498 stable · 17 beta · 1 deprecated
+Symbols: 1500 stable · 17 beta · 1 deprecated
## ANCHOR_AXES — const
```
@@ -2196,6 +2196,14 @@ pixels: Uint8Array<ArrayBufferLike>
width: number
```
+## DeviceIdentity — interface
+```
+backend: string
+renderer: string
+vendor: string
+version: string
+```
+
## DeviceLostReason — const
```
{ readonly Unknown: 0; readonly ContextLost: 1; readonly OutOfMemory: 2; readonly Reset: 3; readonly Removed: 4; readonly Destroyed: 5; readonly Validation: 6; readonly Internal: 7; }
@@ -2561,6 +2569,7 @@ anim_resumeTween: (registry: CppRegistry, tweenEntity: number) => void
anim_setSequenceNext: (registry: CppRegistry, tweenEntity: number, nextEntity: number) => void
anim_setTweenBezier: (registry: CppRegistry, tweenEntity: number, p1x: number, p1y: number, p2x: number, p2y: number) => void
anim_updateTweens: (registry: CppRegistry, deltaTime: number) => void
+deviceIdentity: (() => string) | undefined
deviceLostReport: (() => string) | undefined
deviceStatus: (() => number) | undefined
draw_begin: (matrixPtr: number) => void
@@ -10016,6 +10025,11 @@ FsmPlugin
(): AppContext
```
+## getDeviceIdentity — function
+```
+(): DeviceIdentity | null
+```
+
## getDeviceLostReport — function
```
(): string
diff --git a/sdk/etc/wasm.api.md b/sdk/etc/wasm.api.md
index b86b2653c..8f1115efe 100644
--- a/sdk/etc/wasm.api.md
+++ b/sdk/etc/wasm.api.md
@@ -193,6 +193,7 @@ anim_resumeTween: (registry: CppRegistry, tweenEntity: number) => void
anim_setSequenceNext: (registry: CppRegistry, tweenEntity: number, nextEntity: number) => void
anim_setTweenBezier: (registry: CppRegistry, tweenEntity: number, p1x: number, p1y: number, p2x: number, p2y: number) => void
anim_updateTweens: (registry: CppRegistry, deltaTime: number) => void
+deviceIdentity: (() => string) | undefined
deviceLostReport: (() => string) | undefined
deviceStatus: (() => number) | undefined
draw_begin: (matrixPtr: number) => void
diff --git a/sdk/etc/wechat.api.md b/sdk/etc/wechat.api.md
index c00f4a4f3..e60b4768e 100644
--- a/sdk/etc/wechat.api.md
+++ b/sdk/etc/wechat.api.md
@@ -1,7 +1,7 @@
# API surface — esengine/wechat
<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->
-Symbols: 1488 stable · 17 beta · 1 deprecated
+Symbols: 1490 stable · 17 beta · 1 deprecated
## ANCHOR_AXES — const
```
@@ -2196,6 +2196,14 @@ pixels: Uint8Array<ArrayBufferLike>
width: number
```
+## DeviceIdentity — interface
+```
+backend: string
+renderer: string
+vendor: string
+version: string
+```
+
## DeviceLostReason — const
```
{ readonly Unknown: 0; readonly ContextLost: 1; readonly OutOfMemory: 2; readonly Reset: 3; readonly Removed: 4; readonly Destroyed: 5; readonly Validation: 6; readonly Internal: 7; }
@@ -2561,6 +2569,7 @@ anim_resumeTween: (registry: CppRegistry, tweenEntity: number) => void
anim_setSequenceNext: (registry: CppRegistry, tweenEntity: number, nextEntity: number) => void
anim_setTweenBezier: (registry: CppRegistry, tweenEntity: number, p1x: number, p1y: number, p2x: number, p2y: number) => void
anim_updateTweens: (registry: CppRegistry, deltaTime: number) => void
+deviceIdentity: (() => string) | undefined
deviceLostReport: (() => string) | undefined
deviceStatus: (() => number) | undefined
draw_begin: (matrixPtr: number) => void
@@ -9793,6 +9802,11 @@ FsmPlugin
(): AppContext
```
+## getDeviceIdentity — function
+```
+(): DeviceIdentity | null
+```
+
## getDeviceLostReport — function
```
(): string
diff --git a/sdk/src/core-render.ts b/sdk/src/core-render.ts
index 1586afb62..43c8627d0 100644
--- a/sdk/src/core-render.ts
+++ b/sdk/src/core-render.ts
@@ -168,6 +168,8 @@ export {
DeviceStatus,
DeviceLostReason,
getDeviceStatus,
+ getDeviceIdentity,
+ type DeviceIdentity,
getDeviceLostReport,
reportDeviceLost,
recoverDevice,
diff --git a/sdk/src/render/renderer.ts b/sdk/src/render/renderer.ts
index 16236da75..0c72abff1 100644
--- a/sdk/src/render/renderer.ts
+++ b/sdk/src/render/renderer.ts
@@ -158,6 +158,29 @@ export function getDeviceLostReport(): string {
return module?.deviceLostReport?.() ?? '';
}
+/** Who the device is. */
+export interface DeviceIdentity {
+ backend: string;
+ vendor: string;
+ renderer: string;
+ /** Driver / API version string, as the driver spells it. */
+ version: string;
+}
+
+/**
+ * The GPU this session is running on, readable WHILE it works.
+ *
+ * The engine captured this at init all along — a lost backend cannot be asked
+ * who it was — but it could only be read off a loss report, so a healthy session
+ * could not say which GPU it had. Null before a device exists.
+ */
+export function getDeviceIdentity(): DeviceIdentity | null {
+ const raw = module?.deviceIdentity?.() ?? '';
+ if (!raw) return null;
+ const [backend = '', vendor = '', renderer = '', version = ''] = raw.split('|');
+ return { backend, vendor, renderer, version };
+}
+
/**
* Tell the engine about a loss the host observed.
*
diff --git a/sdk/src/wasm.ts b/sdk/src/wasm.ts
index 9c2c9ed75..c81fb4cce 100644
--- a/sdk/src/wasm.ts
+++ b/sdk/src/wasm.ts
@@ -190,6 +190,8 @@ export interface ESEngineModule {
deviceStatus?(): number;
/** One-line loss report naming backend, GPU, driver and reason; empty while live. */
deviceLostReport?(): string;
+ /** `backend|vendor|renderer|version`, or empty before a device exists. */
+ deviceIdentity?(): string;
/**
* Report a loss the page observed (`webglcontextlost`, a rejected GPUDevice
* `lost` promise) so the engine stops submitting on this frame rather than
diff --git a/src/esengine/bindings/WebSDKEntry.cpp b/src/esengine/bindings/WebSDKEntry.cpp
index aaab157a1..86450862e 100644
--- a/src/esengine/bindings/WebSDKEntry.cpp
+++ b/src/esengine/bindings/WebSDKEntry.cpp
@@ -262,6 +262,21 @@ std::string deviceLostReport() {
return info ? gfxFormatDeviceLost(*info) : std::string();
}
+/**
+ * @brief Who the device is, as `backend|vendor|renderer|version`.
+ * @details Readable while the device is LIVE, which the loss report is not — a
+ * crash report needs the GPU it ran on, and by then the backend cannot
+ * be asked. Pipe-joined: one crossing, and these are driver strings
+ * rather than a schema.
+ */
+std::string deviceIdentity() {
+ GfxDevice* device = activeGfxDevice();
+ if (!device) return {};
+ const GfxDeviceIdentity& id = device->deviceIdentity();
+ if (!id.known()) return {};
+ return id.backend + "|" + id.vendor + "|" + id.renderer + "|" + id.version;
+}
+
/**
* @brief Rebuilds the renderer after a loss; see EstellaContext::recoverDevice.
* @details Leaves the device Recovering — drawable, but its textures are
@@ -402,6 +417,7 @@ EMSCRIPTEN_BINDINGS(esengine_renderer) {
emscripten::function("sdfFromAlpha", &esengine::web_sdfFromAlpha);
emscripten::function("deviceStatus", &esengine::deviceStatus);
emscripten::function("deviceLostReport", &esengine::deviceLostReport);
+ emscripten::function("deviceIdentity", &esengine::deviceIdentity);
emscripten::function("notifyDeviceLost", &esengine::notifyDeviceLost);
emscripten::function("recoverDevice", &esengine::recoverDevice);
emscripten::function("markDeviceRestored", &esengine::markDeviceRestored);
diff --git a/src/esengine/renderer/rhi/GLDevice.cpp b/src/esengine/renderer/rhi/GLDevice.cpp
index 0b9dca845..4df65aed8 100644
--- a/src/esengine/renderer/rhi/GLDevice.cpp
+++ b/src/esengine/renderer/rhi/GLDevice.cpp
@@ -257,10 +257,29 @@ void GLDevice::init() {
}
void GLDevice::captureDeviceIdentity() {
+ std::string vendor = getString(GfxStringName::Vendor);
+ std::string renderer = getString(GfxStringName::Renderer);
+#ifdef __EMSCRIPTEN__
+ // On the web GL_VENDOR/GL_RENDERER are MASKED — every Mac answers "WebKit
+ // WebGL", which names a browser, not a GPU. The real strings sit behind an
+ // extension that must be enabled before its enums resolve.
+ constexpr GLenum UNMASKED_VENDOR = 0x9245;
+ constexpr GLenum UNMASKED_RENDERER = 0x9246;
+ if (emscripten_webgl_enable_extension(emscripten_webgl_get_current_context(),
+ "WEBGL_debug_renderer_info")) {
+ const char* v = reinterpret_cast<const char*>(glGetString(UNMASKED_VENDOR));
+ const char* r = reinterpret_cast<const char*>(glGetString(UNMASKED_RENDERER));
+ // Kept only when the driver actually answered: a browser that refuses
+ // the extension leaves the masked pair, which is worse than nothing only
+ // if it is silently replaced by an empty string.
+ if (v && *v) vendor = v;
+ if (r && *r) renderer = r;
+ }
+#endif
// Asked while the answer still exists: glGetString returns null on a lost
// context, so a report assembled after the loss would name no driver.
- setDeviceIdentity("WebGL2", getString(GfxStringName::Vendor),
- getString(GfxStringName::Renderer), getString(GfxStringName::Version));
+ setDeviceIdentity("WebGL2", std::move(vendor), std::move(renderer),
+ getString(GfxStringName::Version));
}
bool GLDevice::recreateDevice() {
diff --git a/src/esengine/renderer/rhi/GfxDevice.hpp b/src/esengine/renderer/rhi/GfxDevice.hpp
index 1573b3aa2..4df104e6c 100644
--- a/src/esengine/renderer/rhi/GfxDevice.hpp
+++ b/src/esengine/renderer/rhi/GfxDevice.hpp
@@ -111,6 +111,14 @@ public:
return device_status_ == GfxDeviceStatus::Live ? nullptr : &device_info_;
}
+ /**
+ * @brief Who this device is — available WHILE it is alive, unlike the loss report.
+ * @details The identity was always captured at init; it was only reachable
+ * through a report that exists after a loss, so a healthy session
+ * could not say which GPU it was running on.
+ */
+ const GfxDeviceIdentity& deviceIdentity() const { return identity_; }
+
/**
* @brief Declares the device lost from outside the backend.
* @details The host observes losses the backend cannot: a browser firing
@@ -200,9 +208,6 @@ public:
device_lost_handler_ = std::move(handler);
}
- /** @brief Backend identity captured at init (see {@link GfxDeviceLostInfo}). */
- const GfxDeviceLostInfo& deviceIdentity() const { return device_info_; }
-
// =========================================================================
// Viewport & Clear
// =========================================================================
@@ -600,10 +605,10 @@ protected:
/** @brief Records the backend identity; see {@link captureDeviceIdentity}. */
void setDeviceIdentity(std::string backend, std::string vendor,
std::string renderer, std::string version) {
- device_info_.backend = std::move(backend);
- device_info_.vendor = std::move(vendor);
- device_info_.renderer = std::move(renderer);
- device_info_.version = std::move(version);
+ identity_.backend = std::move(backend);
+ identity_.vendor = std::move(vendor);
+ identity_.renderer = std::move(renderer);
+ identity_.version = std::move(version);
}
/**
@@ -617,6 +622,7 @@ protected:
if (device_status_ != GfxDeviceStatus::Live) return false;
device_status_ = GfxDeviceStatus::Lost;
device_info_.reason = reason;
+ device_info_.identity = identity_;
device_info_.message = std::move(message);
device_info_.context = std::move(context);
device_info_.frame = device_frame_;
@@ -626,6 +632,7 @@ protected:
private:
GfxDeviceStatus device_status_ = GfxDeviceStatus::Live;
+ GfxDeviceIdentity identity_;
GfxDeviceLostInfo device_info_;
u64 device_frame_ = 0;
std::function<void(const GfxDeviceLostInfo&)> device_lost_handler_;
diff --git a/src/esengine/renderer/rhi/GfxEnums.hpp b/src/esengine/renderer/rhi/GfxEnums.hpp
index 4775f71d6..e3983f402 100644
--- a/src/esengine/renderer/rhi/GfxEnums.hpp
+++ b/src/esengine/renderer/rhi/GfxEnums.hpp
@@ -375,20 +375,29 @@ enum class GfxDeviceLostReason : u8 {
* that says only "the context was lost" is what this type exists to
* replace.
*/
-struct GfxDeviceLostInfo {
- GfxDeviceLostReason reason = GfxDeviceLostReason::Unknown;
-
- /**
- * Backend identity, captured at init() rather than at loss.
- *
- * A lost backend cannot be asked who it was — GL returns null from
- * glGetString once the context is gone — so a report assembled at loss time
- * would name no vendor, no driver and no GPU.
- */
+/**
+ * @brief Who a device IS, captured at init() and true whether or not it still lives.
+ *
+ * @details A lost backend cannot be asked who it was (glGetString returns null
+ * once the context is gone), so this is read while the device works.
+ * Its own type because a device has an identity for its whole life,
+ * while a loss report exists only after one.
+ */
+struct GfxDeviceIdentity {
std::string backend; ///< "WebGL2", "WebGPU".
std::string vendor;
std::string renderer;
- std::string version;
+ std::string version; ///< Driver / API version string.
+
+ bool known() const { return !backend.empty(); }
+};
+
+struct GfxDeviceLostInfo {
+ GfxDeviceLostReason reason = GfxDeviceLostReason::Unknown;
+
+ /** Snapshotted from the device at the moment of loss, so the report stays
+ * immutable while the device goes on to be rebuilt with a new identity. */
+ GfxDeviceIdentity identity;
/** Driver-supplied text; empty when the backend offered no detail. */
std::string message;
@@ -425,10 +434,10 @@ inline const char* gfxDeviceLostReasonName(GfxDeviceLostReason reason) {
inline std::string gfxFormatDeviceLost(const GfxDeviceLostInfo& info) {
std::string out = "GPU device lost: ";
out += gfxDeviceLostReasonName(info.reason);
- out += " [backend=" + (info.backend.empty() ? std::string("unknown") : info.backend);
- if (!info.vendor.empty()) out += ", vendor=" + info.vendor;
- if (!info.renderer.empty()) out += ", gpu=" + info.renderer;
- if (!info.version.empty()) out += ", driver=" + info.version;
+ out += " [backend=" + (info.identity.backend.empty() ? std::string("unknown") : info.identity.backend);
+ if (!info.identity.vendor.empty()) out += ", vendor=" + info.identity.vendor;
+ if (!info.identity.renderer.empty()) out += ", gpu=" + info.identity.renderer;
+ if (!info.identity.version.empty()) out += ", driver=" + info.identity.version;
out += ", frame=" + std::to_string(info.frame) + "]";
if (!info.context.empty()) out += " during " + info.context;
if (!info.message.empty()) out += " — " + info.message;