1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
use *;
/// Errors that can occur while asynchronously initializing a `WebGpuRenderer`.
///
/// Each variant maps to one specific failure mode that the WebGPU init
/// pipeline can encounter when calling into the browser's GPU API. The
/// underlying JS error (when available) is carried as a `JsValue` so callers
/// can surface the exact diagnostic string without losing fidelity.
///
/// Instead of logging diagnostics inside the engine, `WebGpuRenderer::init`
/// returns `Result<WebGpuRenderer, WebGpuInitError>` and lets the caller
/// decide how to react — typically via `Console::error` on the example side
/// or by falling back to the Canvas 2D backend.
/// WebGPU receiver-class discriminator for the `cached_method` cache.
///
/// JS class methods live on the prototype, so the same `Function` instance
/// is returned for every receiver of a given class — the `(class, method)`
/// pair uniquely identifies the cached `Function` and no receiver identity
/// is needed. This replaces the previous stack-address keying: per-frame
/// temporary `JsValue`s (pass encoders, command encoders) reuse stack
/// slots across frames, so an address-keyed cache could return the wrong
/// class's `Function` when a `GPUComputePassEncoder` landed on a slot that
/// previously held a `GPURenderPassEncoder` (both share `setPipeline` /
/// `setBindGroup` / `end`), producing a swallowed TypeError and a silently
/// skipped GPU call.