@carbonenginejs/runtime-resource 0.12.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CjsResMan.js +4 -4
- package/dist/CjsResMan.js.map +1 -1
- package/dist/_virtual/_rollupPluginBabelHelpers.js +1 -4
- package/dist/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
- package/dist/format/CjsByteReader.js +310 -0
- package/dist/format/CjsByteReader.js.map +1 -0
- package/dist/format/CjsByteWriter.js +242 -0
- package/dist/format/CjsByteWriter.js.map +1 -0
- package/dist/format/CjsFormatError.js +41 -0
- package/dist/format/CjsFormatError.js.map +1 -0
- package/dist/format/CjsStringTable.js +268 -0
- package/dist/format/CjsStringTable.js.map +1 -0
- package/dist/format/carbonEffect/CjsCarbonEffectReader.js +361 -0
- package/dist/format/carbonEffect/CjsCarbonEffectReader.js.map +1 -0
- package/dist/format/carbonEffect/CjsCarbonEffectWriter.js +373 -0
- package/dist/format/carbonEffect/CjsCarbonEffectWriter.js.map +1 -0
- package/dist/format/carbonEffect/carbonDescriptionFromPortable.js +372 -0
- package/dist/format/carbonEffect/carbonDescriptionFromPortable.js.map +1 -0
- package/dist/format/carbonEffect/carbonEffectBackendBlock.js +427 -0
- package/dist/format/carbonEffect/carbonEffectBackendBlock.js.map +1 -0
- package/dist/format/carbonEffect/carbonEffectRecords.js +955 -0
- package/dist/format/carbonEffect/carbonEffectRecords.js.map +1 -0
- package/dist/format/compareUtf8.js +36 -0
- package/dist/format/compareUtf8.js.map +1 -0
- package/dist/format/index.js +11 -0
- package/dist/format/index.js.map +1 -0
- package/dist/formats/bnk/CjsBnkFormat.js +10 -4
- package/dist/formats/bnk/CjsBnkFormat.js.map +1 -1
- package/dist/formats/bnk/core/eventAction.js +305 -0
- package/dist/formats/bnk/core/eventAction.js.map +1 -0
- package/dist/formats/bnk/core/helpers.js +11 -2
- package/dist/formats/bnk/core/helpers.js.map +1 -1
- package/dist/formats/bnk/core/nodeBase.js +532 -0
- package/dist/formats/bnk/core/nodeBase.js.map +1 -0
- package/dist/formats/bnk/core/sfxNodes.js +252 -152
- package/dist/formats/bnk/core/sfxNodes.js.map +1 -1
- package/dist/formats/hlsl/core/HlslReader.js +7 -257
- package/dist/formats/hlsl/core/HlslReader.js.map +1 -1
- package/dist/formats/hlsl/core/carbonDescriptionToRuntime.js +781 -0
- package/dist/formats/hlsl/core/carbonDescriptionToRuntime.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/resources/HlslEffectRes.js +21 -1
- package/dist/formats/hlsl/core/tr2/resources/HlslEffectRes.js.map +1 -1
- package/dist/formats/index.js +1 -1
- package/dist/formats/webgl/core/cewg/CewgPackage.js +2 -1
- package/dist/formats/webgl/core/cewg/CewgPackage.js.map +1 -1
- package/dist/formats/webgl/core/cewg/binary.js +11 -93
- package/dist/formats/webgl/core/cewg/binary.js.map +1 -1
- package/dist/formats/webgl/core/effectPackage.js +1 -1
- package/dist/formats/webgpu/CjsWebgpuFormat.js +4 -23
- package/dist/formats/webgpu/CjsWebgpuFormat.js.map +1 -1
- package/dist/formats/webgpu/core/buildCarbonEffectContainer.js +197 -0
- package/dist/formats/webgpu/core/buildCarbonEffectContainer.js.map +1 -0
- package/dist/formats/webgpu/core/cewgpu/CewgpuContainer.js +368 -0
- package/dist/formats/webgpu/core/cewgpu/CewgpuContainer.js.map +1 -0
- package/dist/formats/webgpu/core/cewgpu/containerViews.js +355 -0
- package/dist/formats/webgpu/core/cewgpu/containerViews.js.map +1 -0
- package/dist/formats/webgpu/core/cewgpu/validateContainer.js +90 -0
- package/dist/formats/webgpu/core/cewgpu/validateContainer.js.map +1 -0
- package/dist/formats/webgpu/core/effectBackendBodySet.js +21 -20
- package/dist/formats/webgpu/core/effectBackendBodySet.js.map +1 -1
- package/dist/formats/webgpu/core/helpers.js +87 -92
- package/dist/formats/webgpu/core/helpers.js.map +1 -1
- package/dist/formats/webgpu/core/ir/analyzeRegisterValues.js +14 -13
- package/dist/formats/webgpu/core/ir/analyzeRegisterValues.js.map +1 -1
- package/dist/formats/webgpu/core/ir/inferValueTypes.js +10 -8
- package/dist/formats/webgpu/core/ir/inferValueTypes.js.map +1 -1
- package/dist/formats/webgpu/core/packageEffect.js +94 -9
- package/dist/formats/webgpu/core/packageEffect.js.map +1 -1
- package/dist/formats/webgpu/core/packageMetadata.js +10 -1
- package/dist/formats/webgpu/core/packageMetadata.js.map +1 -1
- package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js +17 -15
- package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js.map +1 -1
- package/dist/formats/webgpu/core/wgsl/buildWgslBindingPlan.js +13 -12
- package/dist/formats/webgpu/core/wgsl/buildWgslBindingPlan.js.map +1 -1
- package/dist/formats/webgpu/core/wgsl/buildWgslSet.js +9 -8
- package/dist/formats/webgpu/core/wgsl/buildWgslSet.js.map +1 -1
- package/dist/formats/webgpu/core/wgsl/lowerComputeProgram.js +23 -22
- package/dist/formats/webgpu/core/wgsl/lowerComputeProgram.js.map +1 -1
- package/dist/formats/webgpu/core/wgsl/selectionPlans.js +46 -44
- package/dist/formats/webgpu/core/wgsl/selectionPlans.js.map +1 -1
- package/dist/resource/CjsResource.js +700 -684
- package/dist/resource/CjsResource.js.map +1 -1
- package/dist/resource/Tr2LightProfileRes.js +18 -27
- package/dist/resource/Tr2LightProfileRes.js.map +1 -1
- package/dist/resource/audio/CjsAudioBufferRes.js +2 -2
- package/dist/resource/audio/CjsAudioBufferRes.js.map +1 -1
- package/dist/resource/audio/CjsAudioRes.js +2 -2
- package/dist/resource/audio/CjsAudioRes.js.map +1 -1
- package/dist/resource/geometry/TriGeometryRes.js +605 -586
- package/dist/resource/geometry/TriGeometryRes.js.map +1 -1
- package/dist/resource/geometry/granny/Tr2GrannyStateRes.js +21 -30
- package/dist/resource/geometry/granny/Tr2GrannyStateRes.js.map +1 -1
- package/dist/resource/geometry/granny/TriGrannyRes.js +21 -30
- package/dist/resource/geometry/granny/TriGrannyRes.js.map +1 -1
- package/dist/resource/shader/Tr2EffectRes.js +9 -7
- package/dist/resource/shader/Tr2EffectRes.js.map +1 -1
- package/dist/resource/shader/Tr2MaterialArea.js +5 -3
- package/dist/resource/shader/Tr2MaterialArea.js.map +1 -1
- package/dist/resource/shader/Tr2MaterialMesh.js +4 -2
- package/dist/resource/shader/Tr2MaterialMesh.js.map +1 -1
- package/dist/resource/shader/Tr2MaterialRes.js +5 -3
- package/dist/resource/shader/Tr2MaterialRes.js.map +1 -1
- package/dist/resource/shader/Tr2Shader.js +26 -21
- package/dist/resource/shader/Tr2Shader.js.map +1 -1
- package/dist/resource/shader/Tr2ShaderPermutation.js +8 -6
- package/dist/resource/shader/Tr2ShaderPermutation.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectDefine.js +5 -3
- package/dist/resource/shader/reflection/Tr2EffectDefine.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectDescription.js +5 -3
- package/dist/resource/shader/reflection/Tr2EffectDescription.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectLibrary.js +17 -15
- package/dist/resource/shader/reflection/Tr2EffectLibrary.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js +11 -9
- package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectResource.js +8 -6
- package/dist/resource/shader/reflection/Tr2EffectResource.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectStageInput.js +15 -13
- package/dist/resource/shader/reflection/Tr2EffectStageInput.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectTechnique.js +7 -5
- package/dist/resource/shader/reflection/Tr2EffectTechnique.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2Pass.js +11 -9
- package/dist/resource/shader/reflection/Tr2Pass.js.map +1 -1
- package/dist/resource/shader/sampler/Tr2SamplerSetup.js +8 -6
- package/dist/resource/shader/sampler/Tr2SamplerSetup.js.map +1 -1
- package/dist/resource/texture/CjsTextureArrayRes.js +400 -411
- package/dist/resource/texture/CjsTextureArrayRes.js.map +1 -1
- package/dist/resource/texture/Tr2ImageRes.js +99 -95
- package/dist/resource/texture/Tr2ImageRes.js.map +1 -1
- package/dist/resource/texture/TriTextureRes.js +312 -273
- package/dist/resource/texture/TriTextureRes.js.map +1 -1
- package/docs/README.md +13 -1
- package/docs/architecture.md +3 -3
- package/docs/concepts/resource-lifecycle.md +9 -2
- package/docs/concepts/shader-resource-model.md +114 -0
- package/docs/concepts/writing-an-engine-adapter.md +115 -0
- package/docs/formats/README.md +24 -1
- package/docs/formats/carbon-effect-container.md +452 -0
- package/docs/formats/dxbc/reference/classes/README.md +5 -72
- package/docs/formats/hlsl/reference/api.md +5 -4
- package/docs/formats/hlsl/reference/classes/README.md +6 -11
- package/docs/formats/provenance.md +23 -13
- package/docs/formats/webgl/reference/classes/README.md +5 -92
- package/docs/formats/webgpu/README.md +19 -16
- package/docs/formats/webgpu/architecture.md +15 -12
- package/docs/formats/webgpu/formats/cewgpu.md +175 -438
- package/docs/formats/webgpu/guides/effect-packaging.md +132 -140
- package/docs/formats/webgpu/reference/api.md +131 -131
- package/docs/formats/webgpu/reference/classes/README.md +5 -62
- package/docs/formats/webgpu/reference/wgsl-compatibility.md +146 -45
- package/docs/formats/wwise.md +34 -8
- package/docs/reference/classes/core.md +80 -0
- package/docs/reference/classes/formats.md +18 -28
- package/docs/reference/events.md +25 -0
- package/docs/reference/motherlode-cache.md +22 -8
- package/docs/reference/workers.md +5 -5
- package/docs/roadmap.md +61 -41
- package/package.json +2 -1
- package/dist/formats/webgpu/core/cewgpu/CewgpuPackage.js +0 -415
- package/dist/formats/webgpu/core/cewgpu/CewgpuPackage.js.map +0 -1
- package/dist/formats/webgpu/core/cewgpu/CewgpuPackageBuilder.js +0 -100
- package/dist/formats/webgpu/core/cewgpu/CewgpuPackageBuilder.js.map +0 -1
- package/dist/formats/webgpu/core/cewgpu/binary.js +0 -93
- package/dist/formats/webgpu/core/cewgpu/binary.js.map +0 -1
- package/dist/formats/webgpu/core/cewgpu/tags.js +0 -17
- package/dist/formats/webgpu/core/cewgpu/tags.js.map +0 -1
- package/dist/formats/webgpu/core/effectPackageValidation.js +0 -1078
- package/dist/formats/webgpu/core/effectPackageValidation.js.map +0 -1
- package/docs/formats/hlsl/reference/classes/carbon-compatibility.md +0 -66
- package/docs/formats/hlsl/reference/classes/public-api.md +0 -26
- package/docs/formats/hlsl/reference/classes/tr2-effect-model.md +0 -150
|
@@ -1,383 +1,156 @@
|
|
|
1
|
-
# CEWGPU
|
|
1
|
+
# CEWGPU effect container
|
|
2
2
|
|
|
3
3
|
Status: Evolving
|
|
4
|
-
Scope: `@carbonenginejs/runtime-resource/formats/webgpu`
|
|
4
|
+
Scope: `@carbonenginejs/runtime-resource/formats/webgpu`
|
|
5
5
|
Audience: Shader-tool authors and engine integrators
|
|
6
|
-
Summary: Defines the
|
|
6
|
+
Summary: Defines the Carbon v15 record container used for WebGPU effects, its backend block, and its derived compatibility views.
|
|
7
7
|
|
|
8
8
|
## Purpose
|
|
9
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
|
-
source
|
|
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
|
-
or disagreeing counts/digest fail closed. Older selected-effect INFO v1/v2
|
|
149
|
-
packages without either remain readable.
|
|
150
|
-
|
|
151
|
-
PGRF preserves:
|
|
152
|
-
|
|
153
|
-
- ordered axes with index, exact name/options/default, description, and type;
|
|
154
|
-
- one variant for every first-axis-least-significant mixed-radix permutation
|
|
155
|
-
index;
|
|
156
|
-
- the exact option-index tuple and source body record for every variant;
|
|
157
|
-
- deterministic package-local body keys; and
|
|
158
|
-
- the byte length and lower-case SHA-256 digest of every unique raw source body
|
|
159
|
-
record.
|
|
160
|
-
|
|
161
|
-
The complete version-1 document shape is:
|
|
162
|
-
|
|
163
|
-
```json
|
|
164
|
-
{
|
|
165
|
-
"format": "CJS_EFFECT_PERMUTATION_GRAPH",
|
|
166
|
-
"formatVersion": 1,
|
|
167
|
-
"coverage": {
|
|
168
|
-
"permutations": "complete",
|
|
169
|
-
"bodies": "identity-only",
|
|
170
|
-
"reflection": "absent"
|
|
171
|
-
},
|
|
172
|
-
"axes": [
|
|
173
|
-
{
|
|
174
|
-
"index": 0,
|
|
175
|
-
"name": "QUALITY",
|
|
176
|
-
"options": [ "LOW", "HIGH" ],
|
|
177
|
-
"defaultOption": 1,
|
|
178
|
-
"description": "quality tier",
|
|
179
|
-
"type": 0
|
|
180
|
-
}
|
|
181
|
-
],
|
|
182
|
-
"variants": [
|
|
183
|
-
{
|
|
184
|
-
"permutationIndex": 0,
|
|
185
|
-
"optionIndices": [ 0 ],
|
|
186
|
-
"bodyKey": "body0",
|
|
187
|
-
"sourceRecord": { "offset": 256, "byteLength": 64 }
|
|
188
|
-
},
|
|
189
|
-
{
|
|
190
|
-
"permutationIndex": 1,
|
|
191
|
-
"optionIndices": [ 1 ],
|
|
192
|
-
"bodyKey": "body0",
|
|
193
|
-
"sourceRecord": { "offset": 256, "byteLength": 64 }
|
|
194
|
-
}
|
|
195
|
-
],
|
|
196
|
-
"bodies": [
|
|
197
|
-
{
|
|
198
|
-
"key": "body0",
|
|
199
|
-
"byteLength": 64,
|
|
200
|
-
"sha256": "0000000000000000000000000000000000000000000000000000000000000000"
|
|
201
|
-
}
|
|
202
|
-
]
|
|
203
|
-
}
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
Axis and option counts plus `axes[].type` use the source format's unsigned
|
|
207
|
-
8-bit limits. Permutation indices, `bodies[].byteLength`, and source-record
|
|
208
|
-
offset/length fields use unsigned 32-bit limits. A `sourceRecord.offset` is an
|
|
209
|
-
absolute byte offset from the beginning of the exact compiled-effect input,
|
|
210
|
-
and `offset + byteLength` must not exceed `INFO.sourceIdentity.byteLength`.
|
|
211
|
-
Source ranges may be exact aliases or disjoint; partial overlaps fail closed.
|
|
212
|
-
The synchronous browser-safe producer and reader add an implementation
|
|
213
|
-
resource limit of 65,536 Cartesian permutations per effect; larger graphs fail
|
|
214
|
-
explicitly before variant materialization.
|
|
215
|
-
|
|
216
|
-
Raw body bytes are deduplicated with SHA-256 as a lookup accelerator and exact
|
|
217
|
-
byte equality as the final identity check. A body entry therefore provides one
|
|
218
|
-
package-local identity for a unique raw source-body byte sequence; the bytes
|
|
219
|
-
themselves are not embedded, and duplicate body digests are invalid. Body keys
|
|
220
|
-
are package-local because compiled body records refer to the enclosing
|
|
221
|
-
effect's shared string table; they are not cross-package content identities.
|
|
222
|
-
|
|
223
|
-
The graph's `coverage` declares `permutations: "complete"`,
|
|
224
|
-
`bodies: "identity-only"`, and `reflection: "absent"`. It records
|
|
225
|
-
builder-derived source topology that can be verified against the original
|
|
226
|
-
compiled effect; a package reader can validate only the graph's schema and
|
|
227
|
-
internal relationships because raw bodies are not embedded. It does not claim
|
|
228
|
-
reflection or backend translation by itself; INFO v3 joins separate RFLX v2
|
|
229
|
-
for complete source reflection. `META.bodyIndex` remains the
|
|
230
|
-
selected permutation index; the matching PGRF variant supplies its body key.
|
|
231
|
-
Stage filtering remains selected-body-local and does not change the graph.
|
|
232
|
-
|
|
233
|
-
The package-kind marker is the opt-in discriminator: without it, a container is
|
|
234
|
-
generic even when it happens to use the standard chunk tags. A consumer that
|
|
235
|
-
expects an effect package must therefore require the marker as well as calling
|
|
236
|
-
the reader.
|
|
237
|
-
|
|
238
|
-
## Complete source reflection
|
|
239
|
-
|
|
240
|
-
For compiled-effect version 15, `BuildEffect` emits
|
|
241
|
-
`CJS_CEWGPU_EFFECT_REFLECTION` version 2 in `RFLX` and one shared raw `RBLB`
|
|
242
|
-
byte arena. INFO v3 points to both, binds the exact RFLX chunk with SHA-256,
|
|
243
|
-
and records all-unique coverage plus permutation, body, source-program, blob,
|
|
244
|
-
and byte counts. A missing pointer/chunk, a digest or count disagreement, or
|
|
245
|
-
partial coverage fails closed. Versions 8-14 remain INFO v2 without RFLX/RBLB.
|
|
246
|
-
|
|
247
|
-
RFLX v2 stores common source identity and a `bodies` array in exact PGRF body
|
|
248
|
-
order. Each body records its PGRF `bodyKey`, first representative permutation
|
|
249
|
-
index, byte length, SHA-256, and complete body-local
|
|
250
|
-
`CJS_EFFECT_BODY_REFLECTION` version-1 effect graph. It preserves:
|
|
251
|
-
|
|
252
|
-
- complete technique, pass, stage, and library topology;
|
|
253
|
-
- render states, authored constants/resources/UAVs/samplers and annotations;
|
|
254
|
-
- exact stage and library source programs;
|
|
255
|
-
- exact immutable constant-default byte vectors;
|
|
256
|
-
- signatures, registers, static samplers, pipeline inputs, and thread groups;
|
|
257
|
-
- the opaque version-15 native source hash; and
|
|
258
|
-
- source/body identities joined to INFO and PGRF.
|
|
259
|
-
|
|
260
|
-
Every portable byte array is replaced by an exact reference containing
|
|
261
|
-
`blobKey`, `offset`, `byteLength`, and lower-case SHA-256. One
|
|
262
|
-
`RFLX.blobStore` lists canonical contiguous `blobN` records covering RBLB
|
|
263
|
-
exactly. Identical payloads are deduplicated across every reflected body by
|
|
264
|
-
digest plus exact byte equality; dangling, overlapping, corrupt, or
|
|
265
|
-
unreferenced payloads are rejected.
|
|
266
|
-
|
|
267
|
-
The reader reconstructs and validates one portable document for every unique
|
|
268
|
-
body. It requires every PGRF body exactly once in PGRF order, with the first
|
|
269
|
-
matching variant as representative. For selected-backend reconciliation it
|
|
270
|
-
joins `META.bodyIndex` to `PGRF.variants[index].bodyKey`, then to the matching
|
|
271
|
-
RFLX body and ANLS pass/stage identities.
|
|
272
|
-
|
|
273
|
-
JSON reads expose RFLX references plus `reflectionBlobByteLength`. To consume
|
|
274
|
-
the exact bytes, read with `emit: "raw"` and use
|
|
275
|
-
`CewgpuPackage.GetReflectionBlob(referenceOrKey)`, which returns an owned copy.
|
|
276
|
-
An object reference must exactly equal its inventory record; a string performs
|
|
277
|
-
a package-local blob-key lookup. To consume one complete portable body, use
|
|
278
|
-
`CewgpuPackage.GetPortableEffectReflection(permutationIndex)`. It selects the
|
|
279
|
-
PGRF variant (defaulting to `META.bodyIndex`), joins its RFLX body, expands all
|
|
280
|
-
references to fresh owned `Uint8Array` payloads, and reruns the
|
|
281
|
-
`@carbonenginejs/runtime-resource/formats/hlsl/portable` validator.
|
|
282
|
-
|
|
283
|
-
INFO v3 declares `sourceBodyCoverage: "all-unique"` and
|
|
284
|
-
`completeness.sourceComplete: true`. This means complete portable source-effect
|
|
285
|
-
semantics for that exact compiled input. It does not embed raw body records and
|
|
286
|
-
is not an archival reconstruction of the original `.sm_*` bytes. The accessor
|
|
287
|
-
returns a fresh, owned plain portable document. `runtime-resource`
|
|
288
|
-
`Tr2EffectRes` consumes it to select and cache a canonical device-free
|
|
289
|
-
`Tr2Shader`; renderer handles, resource-set descriptions, derived dynamic
|
|
290
|
-
classifications, layouts, and programs remain engine-owned.
|
|
291
|
-
PGRF
|
|
292
|
-
correctly continues to describe its own body table as `identity-only` with
|
|
293
|
-
`reflection: "absent"` because RFLX is a separate document.
|
|
294
|
-
|
|
295
|
-
`bodyMode: "selected"` and `backendBodyCoverage: "selected"` describe ANLS and
|
|
296
|
-
WGSL scope. `backendComplete` and `runtimeComplete` remain false.
|
|
297
|
-
|
|
298
|
-
## All-body backend graph (`WGSB`)
|
|
299
|
-
|
|
300
|
-
`mode: "all"` (or the `allPermutations: true` compatibility request) additionally
|
|
301
|
-
translates every unique source body and stores the result in a `WGSB`
|
|
302
|
-
`CJS_WGSL_BODY_SET` chunk. It requires complete version-15 source reflection,
|
|
303
|
-
because the unique-body inventory comes from RFLX/PGRF.
|
|
304
|
-
|
|
305
|
-
The translation unit is one pass of one body: the binding plan, the
|
|
306
|
-
resource-transform plan, and every stage's WGSL are derived together, so bodies
|
|
307
|
-
whose pass carries byte-identical stage bytecode, semantic bindings, and render
|
|
308
|
-
states share exactly one unit. `bodies[]` maps each `bodyKey` to
|
|
309
|
-
`{passKey, unitKey}` references, and `passUnits[]` holds the shared translated
|
|
310
|
-
programs, layouts, and transforms. Real Quad ship families collapse several
|
|
311
|
-
hundred passes into a small fraction of that many units.
|
|
312
|
-
|
|
313
|
-
A body that cannot be lowered is retained as
|
|
314
|
-
`status: "unsupported"` with an explicit reason and no passes. Its complete
|
|
315
|
-
source reflection remains in RFLX, so a partial backend never removes source
|
|
316
|
-
truth; `coverage.bodies` and `INFO.backendBodyCoverage` then report `partial`
|
|
317
|
-
instead of `all-unique`.
|
|
318
|
-
|
|
319
|
-
`INFO.backendBodySet` binds the exact chunk digest and counts. Selected-mode
|
|
320
|
-
packages must not carry the chunk, and an all-body package must contain one
|
|
321
|
-
record for every unique permutation-graph body. All-body packages still emit
|
|
322
|
-
`WGSL` for the selected body, and its programs are byte-identical to the
|
|
323
|
-
corresponding shared translation units.
|
|
324
|
-
|
|
325
|
-
Translating every body still does not make the package backend- or
|
|
326
|
-
runtime-complete: `backendComplete` and `runtimeComplete` stay false until the
|
|
327
|
-
engine parses these records, realizes their layouts and resource transforms,
|
|
328
|
-
and passes an exact draw gate.
|
|
329
|
-
|
|
330
|
-
Legacy INFO v2 may omit reflection or carry selected-body RFLX v1/RBLB. The
|
|
331
|
-
current reader validates both forms. INFO v3 requires PGRF plus RFLX v2/RBLB;
|
|
332
|
-
older readers do not accept this new schema.
|
|
333
|
-
|
|
334
|
-
## Analysis document
|
|
335
|
-
|
|
336
|
-
The current analysis document records normalized data for one selected effect
|
|
337
|
-
body:
|
|
338
|
-
|
|
339
|
-
- selected permutation and effect body;
|
|
340
|
-
- techniques, passes, and stage topology;
|
|
341
|
-
- Carbon binding-manifest data;
|
|
342
|
-
- per-stage bytecode summaries without raw byte arrays; and
|
|
343
|
-
- null DXBC/IR fields reserved for return-only `AnalyzeEffect` diagnostics.
|
|
344
|
-
|
|
345
|
-
Analysis is retained as provenance even when `BuildEffect` emits WGSL for only
|
|
346
|
-
some complete selected passes. `ANLS` is not lossless source reflection. It
|
|
347
|
-
omits exact constant-default bytes, complete nested reflection/libraries, and
|
|
348
|
-
some typed annotations needed to hydrate a complete source effect resource.
|
|
349
|
-
Those values live in RFLX/RBLB for version-15 input. Ordered axes and the total
|
|
350
|
-
permutation-index-to-body mapping live in PGRF rather than ANLS.
|
|
351
|
-
|
|
352
|
-
`AnalyzeEffect` uses transient selected-body bytecode to return DXBC and,
|
|
353
|
-
when requested, shader-IR diagnostics. `BuildEffect` uses the same transient
|
|
354
|
-
byte index for WGSL compilation but does not persist raw bytecode, decoded
|
|
355
|
-
instructions, or compiler IR in `ANLS`.
|
|
356
|
-
|
|
357
|
-
`BuildEffect` records `bodyMode` in `INFO` and `META`; for INFO v3 this is
|
|
358
|
-
explicitly backend scope, and it stays `selected` unless all-body packaging was
|
|
359
|
-
requested. Its returned qualification record uses
|
|
360
|
-
`validator: "cewgpu-structural"` and reports `packageValid: true`. Version-15
|
|
361
|
-
packages report `sourceComplete: true`, `backendComplete: false`, and
|
|
362
|
-
`runtimeComplete: false`; versions 8-14 report all three completeness flags
|
|
363
|
-
false. These flags prevent source preservation from being mistaken for
|
|
364
|
-
all-body translation or runtime validation. The same booleans are embedded
|
|
365
|
-
under `INFO.completeness`.
|
|
366
|
-
|
|
367
|
-
`@carbonenginejs/runtime-resource/formats/hlsl` owns source parsing, selected-body resolution,
|
|
368
|
-
unique-body enumeration, and the shared browser-safe portable reflection
|
|
369
|
-
contract. `format-webgpu` validates the parsed header into PGRF, aggregates
|
|
370
|
-
every unique version-15 body into RFLX/RBLB, owns transient byte indexing for
|
|
371
|
-
diagnostics/translation, and owns selected backend programs, layouts, and
|
|
372
|
-
transforms. Lossless reflection remains separate from compact ANLS
|
|
373
|
-
diagnostics.
|
|
10
|
+
A `.cewgpu` file is a stock Carbon version-15 compiled-effect container whose
|
|
11
|
+
program slots carry WGSL instead of DXBC. It preserves every permutation row
|
|
12
|
+
and representable non-program description/reflection fields. Non-dynamic
|
|
13
|
+
sampler names are unrecoverable and stage order is canonicalized. Source-stage
|
|
14
|
+
programs are not stored: a translated slot contains WGSL and an untranslated slot is empty.
|
|
15
|
+
Each translated pass may also carry one WebGPU backend block containing
|
|
16
|
+
bind-group layouts and resource transforms.
|
|
17
|
+
|
|
18
|
+
There is no CEWGPU-specific magic, envelope, payload tag, or container version.
|
|
19
|
+
Backend identity comes from the resource path, such as `effect.webgpu/`, just
|
|
20
|
+
as Carbon selects `effect.dx11/`, `effect.dx12/`, or `effect.metal/`.
|
|
21
|
+
`isCewgpu(bytes)` is therefore only a Carbon-v15 shape check. It cannot prove
|
|
22
|
+
that arbitrary version-15 bytes contain WGSL.
|
|
23
|
+
|
|
24
|
+
## Wire layout
|
|
25
|
+
|
|
26
|
+
The shared Carbon container contract is documented in
|
|
27
|
+
[Carbon compiled-effect container](../../carbon-effect-container.md). In
|
|
28
|
+
outline, the file contains:
|
|
29
|
+
|
|
30
|
+
- Carbon's version-15 header, compiler version, source-hash slot (zero-filled
|
|
31
|
+
by the current builder), string table, and permutation axes;
|
|
32
|
+
- one dense offset-table row for every permutation;
|
|
33
|
+
- one stored description tree for every distinct emitted body, with exact
|
|
34
|
+
emitted-description-byte aliases sharing that body; and
|
|
35
|
+
- one optional backend block after each pass's render states.
|
|
36
|
+
|
|
37
|
+
The Carbon region is backend-invariant. CEWGPU substitutes:
|
|
38
|
+
|
|
39
|
+
- UTF-8 WGSL in each translated stage's `shaderData`;
|
|
40
|
+
- the fixed entry point `main`, which is omitted from the wire because every
|
|
41
|
+
current lowerer must emit it; and
|
|
42
|
+
- a versioned backend block for bind-group layouts and resource transforms
|
|
43
|
+
that Carbon reflection cannot derive.
|
|
44
|
+
|
|
45
|
+
A stage with zero program bytes is reflection-only. This is how selected-mode
|
|
46
|
+
packages retain untranslated bodies and how unsupported Carbon stage types
|
|
47
|
+
remain represented without pretending WebGPU can execute them.
|
|
48
|
+
|
|
49
|
+
## No stored chunks
|
|
50
|
+
|
|
51
|
+
The former flat CEWGPU format stored `INFO`, `META`, `PGRF`, `RFLX`, `RBLB`,
|
|
52
|
+
`ANLS`, `WGSL`, and `WGSB` chunks. The current wire stores none of them.
|
|
53
|
+
|
|
54
|
+
Equivalent read surfaces are derived from the one Carbon record tree:
|
|
55
|
+
|
|
56
|
+
| Former document | Current source of truth |
|
|
57
|
+
| --- | --- |
|
|
58
|
+
| `INFO` | Carbon version, compiler version, zero-filled rebuilt source hash, and counted records |
|
|
59
|
+
| `META` | The resolved permutation and the passes/stages that carry programs |
|
|
60
|
+
| `PGRF` | Carbon's permutation axes, dense offset table, and emitted-body aliases |
|
|
61
|
+
| `RFLX` / `RBLB` | Representable non-program description fields and exact arena-backed values |
|
|
62
|
+
| `ANLS` | A normalized analysis view rebuilt from one description |
|
|
63
|
+
| `WGSL` | Program text and layouts read from stage records and backend blocks |
|
|
64
|
+
| `WGSB` | A body-set view derived across distinct stored bodies |
|
|
65
|
+
|
|
66
|
+
`Read(..., { emit: "json" })` returns these compatibility views as plain data.
|
|
67
|
+
They are not independent stored documents and carry no cross-document digests.
|
|
68
|
+
`Read(..., { emit: "raw" })` returns the internal `CewgpuContainer` reader.
|
|
69
|
+
There is no `chunks` array and no generic `Build(chunks)` API.
|
|
70
|
+
|
|
71
|
+
## Building
|
|
72
|
+
|
|
73
|
+
`BuildEffect` accepts version-15 compiled-effect bytes only. It parses the
|
|
74
|
+
complete input, resolves the requested permutation, lowers selected programs,
|
|
75
|
+
and writes a new Carbon v15 container. Full portable source reflection exists
|
|
76
|
+
in the in-memory build result; source-stage program bytes and the caller's
|
|
77
|
+
source hash are not retained in the emitted wire.
|
|
78
|
+
|
|
79
|
+
The returned build record is richer than the bytes. Its `info`, `metadata`,
|
|
80
|
+
`permutationGraph`, `reflection`, `analysis`, `wgsl`, `backendBodySet`, and
|
|
81
|
+
`qualification` fields are build-time evidence for callers. They must not be
|
|
82
|
+
interpreted as separate records stored in the container.
|
|
83
|
+
|
|
84
|
+
### Selected mode
|
|
85
|
+
|
|
86
|
+
`mode: "selected"` is the default. The container still carries every
|
|
87
|
+
permutation row and representable non-program description fields, but only the
|
|
88
|
+
resolved body's requested complete passes carry translated WGSL. Other bodies
|
|
89
|
+
have zero-length program slots.
|
|
90
|
+
|
|
91
|
+
Selected mode narrows backend translation without reducing permutation
|
|
92
|
+
topology.
|
|
93
|
+
|
|
94
|
+
### All mode
|
|
95
|
+
|
|
96
|
+
`mode: "all"` first lowers the resolved selection through the same initial gate
|
|
97
|
+
as selected mode; an unsupported resolved body therefore aborts the build.
|
|
98
|
+
After that precondition succeeds, the builder attempts every distinct body. A
|
|
99
|
+
later body that cannot be lowered remains in the container with its non-program
|
|
100
|
+
description fields and zero-length programs. The in-memory body-set view
|
|
101
|
+
records its specific failure; rereading the wire can report only that the body
|
|
102
|
+
carries no translated programs.
|
|
103
|
+
|
|
104
|
+
Translation units are pass-scoped because binding plans and resource
|
|
105
|
+
transforms are pass contracts. Arena deduplication shares identical emitted
|
|
106
|
+
program and backend blobs; the wire does not contain a separate unit table.
|
|
107
|
+
|
|
108
|
+
## Reading and validation
|
|
109
|
+
|
|
110
|
+
The shared Carbon reader validates version, count caps, dense positional
|
|
111
|
+
offsets, arena bounds, and exact record ends. The WebGPU layer then checks each
|
|
112
|
+
distinct body and rejects any program-bearing stage outside vertex, pixel, and
|
|
113
|
+
compute. Geometry, hull, and domain reflection may remain only when the
|
|
114
|
+
corresponding program slot is empty.
|
|
115
|
+
|
|
116
|
+
Inspection reports:
|
|
117
|
+
|
|
118
|
+
- Carbon version and compiler-version bytes;
|
|
119
|
+
- permutation and distinct-body counts; and
|
|
120
|
+
- stage, shader, and layout counts for the resolved translation.
|
|
121
|
+
|
|
122
|
+
The JSON read shape contains `info`, `metadata`, `permutationGraph`,
|
|
123
|
+
`analysis`, `wgsl`, `backendBodySet`, and convenience `stages`, `shaders`, and
|
|
124
|
+
`layouts` arrays. `analysis`, `wgsl`, and `backendBodySet` are derived views.
|
|
125
|
+
|
|
126
|
+
## Backend block
|
|
127
|
+
|
|
128
|
+
Each translated pass may reference one version-1 backend block from the Carbon
|
|
129
|
+
arena. The block carries:
|
|
130
|
+
|
|
131
|
+
- physical bind-group and binding slots;
|
|
132
|
+
- resource kind, stage visibility, register identity, generated symbol, and
|
|
133
|
+
optional structured-buffer or array-layer metadata; and
|
|
134
|
+
- resource-transform family, identifier, and ordered source inputs.
|
|
135
|
+
|
|
136
|
+
Strings inside the block are inline and length-prefixed. The block contains no
|
|
137
|
+
arena offsets, so its bytes remain independent of the arena's content sort and
|
|
138
|
+
can deduplicate safely. An unknown backend-block version is skipped instead of
|
|
139
|
+
being guessed.
|
|
140
|
+
|
|
141
|
+
Fields such as `identity`, `layoutKey`, transform output, and fixed layer
|
|
142
|
+
numbers are reconstructed from the block plus record position. Backend-block
|
|
143
|
+
version 1 stores visibility but not the original `scopeIdentity`; the reader
|
|
144
|
+
reconstructs `${identity}@${visibility[0]}`. A multi-stage shared binding
|
|
145
|
+
therefore rereads as stage-qualified rather than recovering its original bare
|
|
146
|
+
scope. Callers must not use the wire view to infer that original sharing
|
|
147
|
+
decision.
|
|
374
148
|
|
|
375
149
|
## Structured WGSL set
|
|
376
150
|
|
|
377
|
-
`CJS_WGSL_SET` version
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
when its source resources map one-to-one to physical WebGPU bindings.
|
|
151
|
+
The derived `CJS_WGSL_SET` version-2 view contains shader descriptors and
|
|
152
|
+
pass-level layouts. A layout records the numeric bind group and binding slots
|
|
153
|
+
already present in the WGSL source.
|
|
381
154
|
|
|
382
155
|
Each binding keeps:
|
|
383
156
|
|
|
@@ -387,66 +160,30 @@ Each binding keeps:
|
|
|
387
160
|
- the buffer, texture, or sampler layout; and
|
|
388
161
|
- its numeric group and binding.
|
|
389
162
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
set assembly.
|
|
163
|
+
Resource tuples are stage-scoped unless the caller explicitly proves one
|
|
164
|
+
compatible shared identity. The builder rejects duplicate scopes, duplicate
|
|
165
|
+
numeric slots, mixed shared and stage-scoped forms, incomplete visibility,
|
|
166
|
+
and stage/layout conflicts. It never renumbers slots during WGSL-set assembly.
|
|
395
167
|
|
|
396
|
-
Version
|
|
168
|
+
Version-1 binding plans remain accepted as legacy input. Ordinary new plans
|
|
397
169
|
and WGSL sets use version 2.
|
|
398
170
|
|
|
399
171
|
### Version 3 resource transforms
|
|
400
172
|
|
|
401
|
-
A set becomes version 3 when the compiler proves that several logical
|
|
402
|
-
resources can be represented by one physical WebGPU resource.
|
|
403
|
-
`resourceTransforms` array
|
|
404
|
-
physical layout binding carries
|
|
405
|
-
|
|
406
|
-
The currently
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
"inputs": [
|
|
416
|
-
{
|
|
417
|
-
"parameter": "Detail1Map",
|
|
418
|
-
"layer": 0,
|
|
419
|
-
"identity": "sampled-resource:0:16",
|
|
420
|
-
"scopeIdentity": "sampled-resource:0:16@fragment"
|
|
421
|
-
},
|
|
422
|
-
{
|
|
423
|
-
"parameter": "Detail2Map",
|
|
424
|
-
"layer": 1,
|
|
425
|
-
"identity": "sampled-resource:0:17",
|
|
426
|
-
"scopeIdentity": "sampled-resource:0:17@fragment"
|
|
427
|
-
}
|
|
428
|
-
],
|
|
429
|
-
"output": {
|
|
430
|
-
"name": "DetailMapArray",
|
|
431
|
-
"identity": "sampled-resource:0:16",
|
|
432
|
-
"scopeIdentity": "sampled-resource:0:16@fragment",
|
|
433
|
-
"viewDimension": "2d-array",
|
|
434
|
-
"layerCount": 2
|
|
435
|
-
},
|
|
436
|
-
"representation": "native-or-rgba8",
|
|
437
|
-
"missingLayer": "reject"
|
|
438
|
-
}
|
|
439
|
-
```
|
|
440
|
-
|
|
441
|
-
Inputs are ordered by their exact fixed array layer. The output reuses layer
|
|
442
|
-
zero's D3D identity; later logical inputs do not remain as physical bindings.
|
|
443
|
-
The compiler emits every affected sample with that fixed integer layer.
|
|
444
|
-
|
|
445
|
-
`native-or-rgba8` requires the consumer to realize one compatible
|
|
446
|
-
`texture_2d_array` from the named source textures, either in a shared native
|
|
447
|
-
representation or after decoding every layer to RGBA8. Dimensions, mip
|
|
448
|
-
coverage, sample type, and texture format must be compatible with one WebGPU
|
|
449
|
-
array view. `missingLayer: "reject"` forbids substituting a fallback layer.
|
|
173
|
+
A derived set becomes version 3 when the compiler proves that several logical
|
|
174
|
+
source resources can be represented by one physical WebGPU resource. Its
|
|
175
|
+
`resourceTransforms` array describes the realization recipe; the matching
|
|
176
|
+
physical layout binding carries `transformId` and `arrayLayerCount`.
|
|
177
|
+
|
|
178
|
+
The currently supported version-1 recipe is `kind: "texture-2d-array"`.
|
|
179
|
+
Inputs are ordered by fixed array layer. The output reuses layer zero's D3D
|
|
180
|
+
identity, and later logical inputs do not remain as physical bindings.
|
|
181
|
+
|
|
182
|
+
`representation: "native-or-rgba8"` requires the consumer to assemble one
|
|
183
|
+
compatible `texture_2d_array` from the named inputs, either in a shared native
|
|
184
|
+
format or after decoding every layer to RGBA8. Dimensions, mip coverage,
|
|
185
|
+
sample type, and texture format must agree. `missingLayer: "reject"` forbids a
|
|
186
|
+
fallback layer.
|
|
450
187
|
|
|
451
188
|
The set builder fails closed unless every recipe:
|
|
452
189
|
|
|
@@ -456,24 +193,24 @@ The set builder fails closed unless every recipe:
|
|
|
456
193
|
- matches the binding's identity, view dimension, and layer count; and
|
|
457
194
|
- removes only the later input scopes from that recipe's owning pass.
|
|
458
195
|
|
|
459
|
-
WGSL-set
|
|
460
|
-
`
|
|
461
|
-
|
|
462
|
-
packages. Raw emitted modules may still be validated independently.
|
|
196
|
+
`engine-webgpu` accepts WGSL-set versions 1, 2, and 3 and realizes the
|
|
197
|
+
version-1 `texture-2d-array` recipe. Unsupported recipe kinds or versions fail
|
|
198
|
+
closed.
|
|
463
199
|
|
|
464
|
-
##
|
|
200
|
+
## Compatibility boundary
|
|
465
201
|
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
202
|
+
The JSON compatibility views exist so current consumers can cross the
|
|
203
|
+
container switchover without a second artifact. New code should treat the
|
|
204
|
+
Carbon record tree as the wire authority and should not rebuild assumptions
|
|
205
|
+
around the retired chunk names.
|
|
469
206
|
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
or reread a package instead.
|
|
207
|
+
The raw container's current reflection-to-`Tr2Shader` adapter and the engine's
|
|
208
|
+
body-program view remain integration boundaries under active repair. Their
|
|
209
|
+
existence does not change the wire contract described here.
|
|
474
210
|
|
|
475
211
|
## Related documentation
|
|
476
212
|
|
|
213
|
+
- [Carbon compiled-effect container](../../carbon-effect-container.md)
|
|
477
214
|
- [Effect packaging guide](../guides/effect-packaging.md)
|
|
478
215
|
- [Public API reference](../reference/api.md)
|
|
479
216
|
- [WGSL compatibility](../reference/wgsl-compatibility.md)
|