Commit f9929e0
SpawnDev.ILGPU 4.9.5-rc.8: Wasm multi-view body-struct kernel param decomp
WasmKernelFunctionGenerator.IsViewType was returning `true` for any
StructureType whose first DirectField is AddressSpaceType — including
multi-view containers like Tuvok's VorbisPacketDecodeStaticInputs (38
ArrayView fields) and any user struct-of-views. The dispatcher routed
the param through the single-view path which only registered the FIRST
view's buffer in uniqueBuffers; the remaining N-1 view-pointers in the
serialized struct never got their wasm offsets written, so the kernel
read fields 1..N-1 as offset 0 of V0's buffer plus the IR struct's
per-field byte offset.
Symptom on Tests21.BodyStruct_12ArrayViewInt_PerFieldDiagnostic:
V0[0]=100000 (correct), V1..V11=100004 (= V0[4], because the IR field
offset for field 1 was 16 bytes and the kernel divided by 4 to index
into V0). Tuvok's Vorbis Wasm path was producing silently-wrong PCM
for the same reason — fell back to v1 path because of this.
Fix: count AddressSpaceType DirectFields and only return `true` if
exactly one (real ArrayView/ArrayView1D). Multi-view structs flow
through the scalar-struct serialization path which already correctly
registers each view's buffer via ExtractBuffersFromStruct and writes
each view-pointer to its own field offset.
Verification:
- Tests21.BodyStruct_12ArrayViewInt_CoalesceTest Wasm PASS
- Tests21.BodyStruct_12ArrayViewInt_PerFieldDiagnostic Wasm PASS
- Tests21.BodyStruct_MixedIntFloatCoalesceTest Wasm PASS
- Tests21.BodyStruct_VariableLengthCoalesceTest Wasm PASS
- All Tests21 cases pass on every backend except WebGL (still gated
with sharp technical reason — task #26 tracks the WebGL per-field
sampler decomposition workstream).
Partial WebGL improvement: GLSLKernelFunctionGenerator.IsMultiDim got
the same multi-view detection fix — only treats a struct as a view
when NumFields matches a known ArrayView shape (3, 4, or 6). This
is necessary for the WebGL fix but not sufficient — the GLSL kernel
codegen still needs per-field sampler decomposition + struct-aware
GetField + dispatcher binding multiple samplers per param. Samplers
cannot be struct members in GLSL ES 3.0, so the current `uniform
struct_X u_param2` emit is invalid for multi-view containers.
What this unblocks:
- SpawnDev.Codecs Vorbis Wasm path — VorbisPacketDecodeStaticInputs
(36 ArrayView<int> + 2 ArrayView<double>) now works on Wasm. Tuvok's
dual-path branch in VorbisAudioDecoderGpu.DecodePacketAsync can
drop the v1 fallback arm entirely.
- Opus SILK + CELT Wasm decoder primitives — same struct-of-ArrayView
pattern, browser-clean from day one on Wasm.
- Possibly some of Data's Wasm async-mode race cluster (DDPM, MoveNet,
5 Style transfers, SqueezeNet, ESPCN, DepthAnything). Some of these
may have been hitting multi-view-decomp rather than a true async
race. Recommend re-running ML pipeline + reference suite on Wasm.
Four-package bundle: Fork stays at 2.0.4. No edits to the forked
ILGPU/ tree.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent d39f8af commit f9929e0
7 files changed
Lines changed: 227 additions & 37 deletions
File tree
- SpawnDev.ILGPU.Demo/UnitTests
- SpawnDev.ILGPU
- Wasm/Backend
- WebGL/Backend
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 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 | + | |
5 | 63 | | |
6 | 64 | | |
7 | 65 | | |
| |||
Lines changed: 95 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 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 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
59 | 154 | | |
60 | 155 | | |
61 | 156 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
382 | 382 | | |
383 | 383 | | |
384 | 384 | | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | | - | |
400 | | - | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
401 | 394 | | |
402 | 395 | | |
403 | 396 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
116 | 124 | | |
117 | 125 | | |
118 | | - | |
| 126 | + | |
119 | 127 | | |
120 | 128 | | |
121 | | - | |
| 129 | + | |
122 | 130 | | |
123 | 131 | | |
124 | | - | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
125 | 136 | | |
126 | 137 | | |
127 | 138 | | |
| |||
0 commit comments