@carbonenginejs/runtime-resource 0.16.0 → 0.18.0
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/format/CjsFormat.js +84 -83
- package/dist/format/CjsFormat.js.map +1 -1
- package/dist/format/CjsResourceProbe.js +87 -86
- package/dist/format/CjsResourceProbe.js.map +1 -1
- package/dist/format/carbonEffect/backendEngineId.js +98 -0
- package/dist/format/carbonEffect/backendEngineId.js.map +1 -0
- package/dist/format/carbonEffect/carbonEffectBackendBlock.js +24 -23
- package/dist/format/carbonEffect/carbonEffectBackendBlock.js.map +1 -1
- package/dist/format/carbonEffect/carbonEffectResourceTransform.js +1 -1
- package/dist/format/carbonEffect/carbonEffectResourceTransform.js.map +1 -1
- package/dist/format/effect/effectPermutationGraph.js +46 -29
- package/dist/format/effect/effectPermutationGraph.js.map +1 -1
- package/dist/format/index.js +1 -1
- package/dist/formats/hlsl/core/detailMapFamily.js +1 -1
- package/dist/formats/hlsl/core/detailMapFamily.js.map +1 -1
- package/dist/formats/hlsl/core/localLightFamily.js +1 -1
- package/dist/formats/hlsl/core/localLightFamily.js.map +1 -1
- package/dist/formats/png/core/helpers.js +27 -8
- package/dist/formats/png/core/helpers.js.map +1 -1
- package/dist/formats/webgl/core/effectPackage.js +143 -56
- package/dist/formats/webgl/core/effectPackage.js.map +1 -1
- package/dist/formats/webgl/core/glsl/DxbcGlslEmitter.js +799 -456
- package/dist/formats/webgl/core/glsl/DxbcGlslEmitter.js.map +1 -1
- package/dist/formats/webgl/core/glslBackendBlock.js +74 -30
- package/dist/formats/webgl/core/glslBackendBlock.js.map +1 -1
- package/dist/formats/webgl/core/glslBackendBodySet.js +0 -1
- package/dist/formats/webgl/core/glslBackendBodySet.js.map +1 -1
- package/dist/formats/webgl/core/helpers.js +53 -53
- package/dist/formats/webgl/core/helpers.js.map +1 -1
- package/dist/formats/webgl/core/readGlslEffectContainer.js +82 -67
- package/dist/formats/webgl/core/readGlslEffectContainer.js.map +1 -1
- package/dist/formats/webgpu/CjsWebgpuFormat.js +161 -163
- package/dist/formats/webgpu/CjsWebgpuFormat.js.map +1 -1
- package/dist/formats/webgpu/core/carbonWebgpu/CarbonWebgpuContainer.js +10 -1
- package/dist/formats/webgpu/core/carbonWebgpu/CarbonWebgpuContainer.js.map +1 -1
- package/dist/formats/webgpu/core/effectBackendBodySet.js +21 -22
- package/dist/formats/webgpu/core/effectBackendBodySet.js.map +1 -1
- package/dist/formats/webgpu/core/helpers.js +111 -99
- package/dist/formats/webgpu/core/helpers.js.map +1 -1
- package/dist/formats/webgpu/core/packageEffect.js +30 -32
- package/dist/formats/webgpu/core/packageEffect.js.map +1 -1
- package/dist/formats/wem/CjsWemFormat.js +121 -121
- package/dist/formats/wem/CjsWemFormat.js.map +1 -1
- package/dist/formats/wem/core/resolve.js +8 -8
- package/dist/formats/wem/core/resolve.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectStageInput.js +102 -60
- package/dist/resource/shader/reflection/Tr2EffectStageInput.js.map +1 -1
- package/docs/concepts/format-type-resolution.md +79 -0
- package/docs/formats/README.md +11 -0
- package/docs/formats/webgpu/formats/carbon-webgpu.md +11 -4
- package/docs/formats/webgpu/reference/api.md +7 -6
- package/docs/formats/wwise.md +25 -0
- package/docs/roadmap.md +19 -0
- package/package.json +2 -2
|
@@ -8,7 +8,6 @@ import { lowerDxbcToIr } from './ir/lowerDxbcToIr.js';
|
|
|
8
8
|
import { normalizeEffectPermutation, validateResolvedPermutation } from './packageEffectSelection.js';
|
|
9
9
|
|
|
10
10
|
const OUTPUT_JSON = "json";
|
|
11
|
-
const OUTPUT_RAW = "raw";
|
|
12
11
|
const CARBON_WEBGPU_FORMAT = "CARBON_WEBGPU";
|
|
13
12
|
const CARBON_WEBGPU_ANALYSIS_FORMAT = "CARBON_WEBGPU_ANALYSIS";
|
|
14
13
|
const CARBON_WEBGPU_ANALYSIS_VERSION = 1;
|
|
@@ -21,13 +20,27 @@ const DEFAULT_VALUES = Object.freeze({
|
|
|
21
20
|
classes: Object.freeze({})
|
|
22
21
|
});
|
|
23
22
|
const OPTION_KEYS = new Set(["emit", "source", "decodeInstructions", "permutation", "schema", "classes"]);
|
|
23
|
+
// One emit, as WebGL has. `Read` returns the container-backed document and that
|
|
24
|
+
// document is complete: the analysis, WGSL, metadata and permutation views the
|
|
25
|
+
// caller selects among, plus `backendBodySet`, which is every translated body
|
|
26
|
+
// joined to its shared translation units.
|
|
27
|
+
//
|
|
28
|
+
// A second `raw` emit used to hand back the live `CarbonWebgpuContainer` because
|
|
29
|
+
// the chunk package's JSON could not express the body set. It became the only way
|
|
30
|
+
// to reach a body, so `engine-webgpu` duck-typed the container instead of reading
|
|
31
|
+
// the document - and when the chunk package was replaced, the engine kept asking
|
|
32
|
+
// for a shape the producer had stopped emitting. Both halves then failed, in
|
|
33
|
+
// different directions, for weeks: the default emit built pipelines but resolved
|
|
34
|
+
// no bodies, and the raw emit resolved bodies but built no pipelines.
|
|
35
|
+
//
|
|
36
|
+
// Neither is reachable now. The container stays internal to this module.
|
|
37
|
+
const VALID_EMITS = new Set([OUTPUT_JSON]);
|
|
24
38
|
function hasOwn(value, key) {
|
|
25
39
|
return Object.prototype.hasOwnProperty.call(value, key);
|
|
26
40
|
}
|
|
27
41
|
function normalizeEmit(emit, readerName) {
|
|
28
|
-
if (emit === undefined || emit
|
|
29
|
-
|
|
30
|
-
throw new TypeError(`${readerName}: emit must be "${OUTPUT_JSON}" or "${OUTPUT_RAW}", got ${JSON.stringify(emit)}`);
|
|
42
|
+
if (emit === undefined || VALID_EMITS.has(emit)) return OUTPUT_JSON;
|
|
43
|
+
throw new TypeError(`${readerName}: emit must be "${OUTPUT_JSON}", got ${JSON.stringify(emit)}`);
|
|
31
44
|
}
|
|
32
45
|
function assertKnownOptions(options, readerName) {
|
|
33
46
|
for (const key of Object.keys(options)) {
|
|
@@ -52,12 +65,12 @@ function cloneValues(values) {
|
|
|
52
65
|
};
|
|
53
66
|
}
|
|
54
67
|
|
|
55
|
-
/**
|
|
56
|
-
* Rejects class override keys outside a format reader's supported class set.
|
|
57
|
-
*
|
|
58
|
-
* @param {string[]} classKeys Supported class override keys.
|
|
59
|
-
* @param {string} key Candidate override key.
|
|
60
|
-
* @param {string} readerName Reader name used in diagnostics.
|
|
68
|
+
/**
|
|
69
|
+
* Rejects class override keys outside a format reader's supported class set.
|
|
70
|
+
*
|
|
71
|
+
* @param {string[]} classKeys Supported class override keys.
|
|
72
|
+
* @param {string} key Candidate override key.
|
|
73
|
+
* @param {string} readerName Reader name used in diagnostics.
|
|
61
74
|
*/
|
|
62
75
|
function validateClassKey(classKeys, key, readerName) {
|
|
63
76
|
if (!classKeys.includes(key)) {
|
|
@@ -65,13 +78,13 @@ function validateClassKey(classKeys, key, readerName) {
|
|
|
65
78
|
}
|
|
66
79
|
}
|
|
67
80
|
|
|
68
|
-
/**
|
|
69
|
-
* Validates one constructor supplied through a format reader class override.
|
|
70
|
-
*
|
|
71
|
-
* @param {string[]} classKeys Supported class override keys.
|
|
72
|
-
* @param {string} type Candidate override key.
|
|
73
|
-
* @param {Function} Class Candidate constructor.
|
|
74
|
-
* @param {string} readerName Reader name used in diagnostics.
|
|
81
|
+
/**
|
|
82
|
+
* Validates one constructor supplied through a format reader class override.
|
|
83
|
+
*
|
|
84
|
+
* @param {string[]} classKeys Supported class override keys.
|
|
85
|
+
* @param {string} type Candidate override key.
|
|
86
|
+
* @param {Function} Class Candidate constructor.
|
|
87
|
+
* @param {string} readerName Reader name used in diagnostics.
|
|
75
88
|
*/
|
|
76
89
|
function validateClass(classKeys, type, Class, readerName) {
|
|
77
90
|
validateClassKey(classKeys, type, readerName);
|
|
@@ -93,14 +106,14 @@ function mergeClasses(values, classes, classKeys, readerName) {
|
|
|
93
106
|
values.classes = next;
|
|
94
107
|
}
|
|
95
108
|
|
|
96
|
-
/**
|
|
97
|
-
* Merge format values over a base set and validate them.
|
|
98
|
-
*
|
|
99
|
-
* @param {object} base Current values.
|
|
100
|
-
* @param {object} [options] Values to merge in.
|
|
101
|
-
* @param {string[]} classKeys Valid class keys.
|
|
102
|
-
* @param {string} readerName Reader name used in error messages.
|
|
103
|
-
* @returns {object} A validated copy of the merged values.
|
|
109
|
+
/**
|
|
110
|
+
* Merge format values over a base set and validate them.
|
|
111
|
+
*
|
|
112
|
+
* @param {object} base Current values.
|
|
113
|
+
* @param {object} [options] Values to merge in.
|
|
114
|
+
* @param {string[]} classKeys Valid class keys.
|
|
115
|
+
* @param {string} readerName Reader name used in error messages.
|
|
116
|
+
* @returns {object} A validated copy of the merged values.
|
|
104
117
|
*/
|
|
105
118
|
function normalizeValues(base, options = {}, classKeys = [], readerName = "CjsWebgpuFormat") {
|
|
106
119
|
if (!options || typeof options !== "object") {
|
|
@@ -117,11 +130,11 @@ function normalizeValues(base, options = {}, classKeys = [], readerName = "CjsWe
|
|
|
117
130
|
return values;
|
|
118
131
|
}
|
|
119
132
|
|
|
120
|
-
/**
|
|
121
|
-
* Normalize caller input into a Uint8Array of package bytes.
|
|
122
|
-
*
|
|
123
|
-
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Candidate payload.
|
|
124
|
-
* @returns {Uint8Array} The payload bytes.
|
|
133
|
+
/**
|
|
134
|
+
* Normalize caller input into a Uint8Array of package bytes.
|
|
135
|
+
*
|
|
136
|
+
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Candidate payload.
|
|
137
|
+
* @returns {Uint8Array} The payload bytes.
|
|
125
138
|
*/
|
|
126
139
|
function toBytes(input) {
|
|
127
140
|
if (input instanceof Uint8Array) return input;
|
|
@@ -130,17 +143,17 @@ function toBytes(input) {
|
|
|
130
143
|
throw new TypeError("CjsWebgpuFormat: input must be Carbon WebGPU package bytes (Uint8Array, Buffer, DataView or ArrayBuffer)");
|
|
131
144
|
}
|
|
132
145
|
|
|
133
|
-
/**
|
|
134
|
-
* Reports whether a payload has the Carbon v15 container shape.
|
|
135
|
-
*
|
|
136
|
-
* This is a **shape** check, not an identity check. Our containers are stock
|
|
137
|
-
* Carbon v15 files, so nothing in the bytes separates one from a shipped
|
|
138
|
-
* `effect.dx11` file -- and nothing should. Identity comes from the resource
|
|
139
|
-
* path the file was resolved through, exactly as it does for Carbon, whose own
|
|
140
|
-
* three backend trees are byte-format-identical with no language field anywhere.
|
|
141
|
-
*
|
|
142
|
-
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Candidate payload.
|
|
143
|
-
* @returns {boolean} True when the payload opens on Carbon's v15 version dword.
|
|
146
|
+
/**
|
|
147
|
+
* Reports whether a payload has the Carbon v15 container shape.
|
|
148
|
+
*
|
|
149
|
+
* This is a **shape** check, not an identity check. Our containers are stock
|
|
150
|
+
* Carbon v15 files, so nothing in the bytes separates one from a shipped
|
|
151
|
+
* `effect.dx11` file -- and nothing should. Identity comes from the resource
|
|
152
|
+
* path the file was resolved through, exactly as it does for Carbon, whose own
|
|
153
|
+
* three backend trees are byte-format-identical with no language field anywhere.
|
|
154
|
+
*
|
|
155
|
+
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Candidate payload.
|
|
156
|
+
* @returns {boolean} True when the payload opens on Carbon's v15 version dword.
|
|
144
157
|
*/
|
|
145
158
|
function isCarbonWebgpu(input) {
|
|
146
159
|
try {
|
|
@@ -150,12 +163,12 @@ function isCarbonWebgpu(input) {
|
|
|
150
163
|
}
|
|
151
164
|
}
|
|
152
165
|
|
|
153
|
-
/**
|
|
154
|
-
* The shared read path used by the instance Read/Inspect and static one-shots.
|
|
155
|
-
*
|
|
156
|
-
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Carbon WebGPU container payload.
|
|
157
|
-
* @param {object} values Normalized format values.
|
|
158
|
-
* @returns {CarbonWebgpuContainer} The loaded container.
|
|
166
|
+
/**
|
|
167
|
+
* The shared read path used by the instance Read/Inspect and static one-shots.
|
|
168
|
+
*
|
|
169
|
+
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Carbon WebGPU container payload.
|
|
170
|
+
* @param {object} values Normalized format values.
|
|
171
|
+
* @returns {CarbonWebgpuContainer} The loaded container.
|
|
159
172
|
*/
|
|
160
173
|
function readRaw(input, values) {
|
|
161
174
|
const bytes = toBytes(input);
|
|
@@ -183,20 +196,20 @@ function readRaw(input, values) {
|
|
|
183
196
|
return container;
|
|
184
197
|
}
|
|
185
198
|
|
|
186
|
-
/**
|
|
187
|
-
* Converts a loaded container to the documented plain JSON shape.
|
|
188
|
-
*
|
|
189
|
-
* `analysis` and `wgsl` are **derived views**, not stored documents. The chunk
|
|
190
|
-
* package kept them beside the reflection they were computed from and carried
|
|
191
|
-
* digests to detect the two disagreeing; there is now one document, so there is
|
|
192
|
-
* nothing left to disagree and no digest to carry.
|
|
193
|
-
*
|
|
194
|
-
* `chunks` is gone. It described a container that no longer exists, and a record
|
|
195
|
-
* layout has no chunk table to translate it into.
|
|
196
|
-
*
|
|
197
|
-
* @param {CarbonWebgpuContainer} container Loaded container.
|
|
198
|
-
* @param {object} [options] View options.
|
|
199
|
-
* @returns {object} Plain JSON data.
|
|
199
|
+
/**
|
|
200
|
+
* Converts a loaded container to the documented plain JSON shape.
|
|
201
|
+
*
|
|
202
|
+
* `analysis` and `wgsl` are **derived views**, not stored documents. The chunk
|
|
203
|
+
* package kept them beside the reflection they were computed from and carried
|
|
204
|
+
* digests to detect the two disagreeing; there is now one document, so there is
|
|
205
|
+
* nothing left to disagree and no digest to carry.
|
|
206
|
+
*
|
|
207
|
+
* `chunks` is gone. It described a container that no longer exists, and a record
|
|
208
|
+
* layout has no chunk table to translate it into.
|
|
209
|
+
*
|
|
210
|
+
* @param {CarbonWebgpuContainer} container Loaded container.
|
|
211
|
+
* @param {object} [options] View options.
|
|
212
|
+
* @returns {object} Plain JSON data.
|
|
200
213
|
*/
|
|
201
214
|
function packageToJson(container, options = {}) {
|
|
202
215
|
const source = options.source || container.sourcePath || "memory";
|
|
@@ -229,27 +242,26 @@ function packageToJson(container, options = {}) {
|
|
|
229
242
|
});
|
|
230
243
|
}
|
|
231
244
|
|
|
232
|
-
/**
|
|
233
|
-
* Shared read entry
|
|
234
|
-
*
|
|
235
|
-
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Carbon WebGPU container payload.
|
|
236
|
-
* @param {object} values Normalized format values.
|
|
237
|
-
* @returns {
|
|
245
|
+
/**
|
|
246
|
+
* Shared read entry.
|
|
247
|
+
*
|
|
248
|
+
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Carbon WebGPU container payload.
|
|
249
|
+
* @param {object} values Normalized format values.
|
|
250
|
+
* @returns {object} Plain JSON data.
|
|
238
251
|
*/
|
|
239
252
|
function readWithValues(input, values) {
|
|
240
|
-
|
|
241
|
-
return values.emit === OUTPUT_RAW ? container : packageToJson(container, {
|
|
253
|
+
return packageToJson(readRaw(input, values), {
|
|
242
254
|
source: values.source
|
|
243
255
|
});
|
|
244
256
|
}
|
|
245
257
|
|
|
246
|
-
/**
|
|
247
|
-
* Compact inspection: Carbon version and compiler bytes, body counts, and the
|
|
248
|
-
* resolved analysis/WGSL counts without building the full JSON package shape.
|
|
249
|
-
*
|
|
250
|
-
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Carbon WebGPU container payload.
|
|
251
|
-
* @param {object} values Normalized format values.
|
|
252
|
-
* @returns {object} Plain summary data.
|
|
258
|
+
/**
|
|
259
|
+
* Compact inspection: Carbon version and compiler bytes, body counts, and the
|
|
260
|
+
* resolved analysis/WGSL counts without building the full JSON package shape.
|
|
261
|
+
*
|
|
262
|
+
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Carbon WebGPU container payload.
|
|
263
|
+
* @param {object} values Normalized format values.
|
|
264
|
+
* @returns {object} Plain summary data.
|
|
253
265
|
*/
|
|
254
266
|
function inspectWithValues(input, values) {
|
|
255
267
|
const container = readRaw(input, values);
|
|
@@ -351,15 +363,15 @@ function analyzeStage(stage, options) {
|
|
|
351
363
|
return out;
|
|
352
364
|
}
|
|
353
365
|
|
|
354
|
-
/**
|
|
355
|
-
* Builds the normalized WebGPU analysis document from a resolved effect.
|
|
356
|
-
*
|
|
357
|
-
* @param {object} resolved Raw resolved-effect context from `readEffectAnalysis`.
|
|
358
|
-
* @param {object} [options] Analysis options.
|
|
359
|
-
* @param {string} [options.source] Source label for diagnostics.
|
|
360
|
-
* @param {boolean} [options.decodeBytecode] Whether stage bytecode is inspected.
|
|
361
|
-
* @param {boolean} [options.decodeInstructions] Whether DXBC instructions are decoded.
|
|
362
|
-
* @returns {object} Plain JSON-compatible analysis data.
|
|
366
|
+
/**
|
|
367
|
+
* Builds the normalized WebGPU analysis document from a resolved effect.
|
|
368
|
+
*
|
|
369
|
+
* @param {object} resolved Raw resolved-effect context from `readEffectAnalysis`.
|
|
370
|
+
* @param {object} [options] Analysis options.
|
|
371
|
+
* @param {string} [options.source] Source label for diagnostics.
|
|
372
|
+
* @param {boolean} [options.decodeBytecode] Whether stage bytecode is inspected.
|
|
373
|
+
* @param {boolean} [options.decodeInstructions] Whether DXBC instructions are decoded.
|
|
374
|
+
* @returns {object} Plain JSON-compatible analysis data.
|
|
363
375
|
*/
|
|
364
376
|
function buildEffectAnalysis(resolved, options = {}) {
|
|
365
377
|
const source = options.source || resolved.effectRes?.sourcePath || "memory";
|
|
@@ -390,14 +402,14 @@ function buildEffectAnalysis(resolved, options = {}) {
|
|
|
390
402
|
});
|
|
391
403
|
}
|
|
392
404
|
|
|
393
|
-
/**
|
|
394
|
-
* Analyzes one compiled effect payload into a normalized WebGPU-facing
|
|
395
|
-
* document: selected permutation, Carbon binding manifest, and per-stage DXBC
|
|
396
|
-
* decode.
|
|
397
|
-
*
|
|
398
|
-
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Tr2 effect payload.
|
|
399
|
-
* @param {object} values Normalized format values.
|
|
400
|
-
* @returns {object} Plain JSON-compatible analysis data.
|
|
405
|
+
/**
|
|
406
|
+
* Analyzes one compiled effect payload into a normalized WebGPU-facing
|
|
407
|
+
* document: selected permutation, Carbon binding manifest, and per-stage DXBC
|
|
408
|
+
* decode.
|
|
409
|
+
*
|
|
410
|
+
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Tr2 effect payload.
|
|
411
|
+
* @param {object} values Normalized format values.
|
|
412
|
+
* @returns {object} Plain JSON-compatible analysis data.
|
|
401
413
|
*/
|
|
402
414
|
function analyzeEffectWithValues(input, values) {
|
|
403
415
|
const permutation = normalizeEffectPermutation(values.permutation);
|
|
@@ -412,11 +424,11 @@ function analyzeEffectWithValues(input, values) {
|
|
|
412
424
|
});
|
|
413
425
|
}
|
|
414
426
|
|
|
415
|
-
/**
|
|
416
|
-
* Deep-convert a value to plain JSON-compatible data.
|
|
417
|
-
*
|
|
418
|
-
* @param {any} value Value to convert.
|
|
419
|
-
* @returns {any} Plain data.
|
|
427
|
+
/**
|
|
428
|
+
* Deep-convert a value to plain JSON-compatible data.
|
|
429
|
+
*
|
|
430
|
+
* @param {any} value Value to convert.
|
|
431
|
+
* @returns {any} Plain data.
|
|
420
432
|
*/
|
|
421
433
|
function toJsonValue(value) {
|
|
422
434
|
if (value === null || value === undefined) return value ?? null;
|
|
@@ -439,5 +451,5 @@ function toJsonValue(value) {
|
|
|
439
451
|
return null;
|
|
440
452
|
}
|
|
441
453
|
|
|
442
|
-
export { CARBON_WEBGPU_ANALYSIS_FORMAT, CARBON_WEBGPU_ANALYSIS_VERSION, CARBON_WEBGPU_FORMAT, DEFAULT_VALUES, OUTPUT_JSON,
|
|
454
|
+
export { CARBON_WEBGPU_ANALYSIS_FORMAT, CARBON_WEBGPU_ANALYSIS_VERSION, CARBON_WEBGPU_FORMAT, DEFAULT_VALUES, OUTPUT_JSON, WebgpuReadError, analyzeEffectWithValues, buildEffectAnalysis, inspectWithValues, isCarbonWebgpu, normalizeValues, packageToJson, readRaw, readWithValues, toBytes, toJsonValue, validateClass, validateClassKey };
|
|
443
455
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sources":["../../../../../src/formats/webgpu/core/helpers.js"],"sourcesContent":["import CjsDxbcFormat from \"../../dxbc/index.js\";\nimport { normalizeBytecodeBytes, readEffectAnalysis } from \"./effectAnalysis.js\";\n\nimport { CarbonWebgpuContainer, looksLikeCarbonWebgpuContainer } from \"./carbonWebgpu/CarbonWebgpuContainer.js\";\nimport { validateEffectContainer } from \"./carbonWebgpu/validateContainer.js\";\nimport {\n deriveAnalysis,\n deriveBackendBodySet,\n deriveInfo,\n deriveMetadata,\n deriveWgsl,\n resolvedPermutationIndex\n} from \"./carbonWebgpu/containerViews.js\";\nimport { WebgpuReadError } from \"./errors.js\";\nimport { lowerDxbcToIr } from \"./ir/lowerDxbcToIr.js\";\nimport {\n normalizeEffectPermutation,\n validateResolvedPermutation\n} from \"./packageEffectSelection.js\";\n\nexport const OUTPUT_JSON = \"json\";\nexport const OUTPUT_RAW = \"raw\";\nexport const CARBON_WEBGPU_FORMAT = \"CARBON_WEBGPU\";\nexport const CARBON_WEBGPU_ANALYSIS_FORMAT = \"CARBON_WEBGPU_ANALYSIS\";\nexport const CARBON_WEBGPU_ANALYSIS_VERSION = 1;\n\nexport const DEFAULT_VALUES = Object.freeze({\n emit: OUTPUT_JSON,\n source: \"memory\",\n decodeInstructions: true,\n permutation: null,\n schema: null,\n classes: Object.freeze({})\n});\n\nconst OPTION_KEYS = new Set([ \"emit\", \"source\", \"decodeInstructions\", \"permutation\", \"schema\", \"classes\" ]);\nconst VALID_EMITS = new Set([ OUTPUT_JSON, OUTPUT_RAW ]);\n\nfunction hasOwn(value, key)\n{\n return Object.prototype.hasOwnProperty.call(value, key);\n}\n\nfunction normalizeEmit(emit, readerName)\n{\n if (emit === undefined || emit === OUTPUT_JSON) return OUTPUT_JSON;\n if (emit === OUTPUT_RAW) return OUTPUT_RAW;\n throw new TypeError(`${readerName}: emit must be \"${OUTPUT_JSON}\" or \"${OUTPUT_RAW}\", got ${JSON.stringify(emit)}`);\n}\n\nfunction assertKnownOptions(options, readerName)\n{\n for (const key of Object.keys(options))\n {\n if (!OPTION_KEYS.has(key))\n {\n throw new TypeError(`${readerName}: unknown option ${JSON.stringify(key)}`);\n }\n }\n}\n\nfunction classMap(values)\n{\n return values && values.classes ? values.classes : {};\n}\n\nfunction cloneValues(values)\n{\n return {\n emit: values.emit,\n source: values.source ?? DEFAULT_VALUES.source,\n decodeInstructions: values.decodeInstructions ?? DEFAULT_VALUES.decodeInstructions,\n permutation: values.permutation ?? null,\n schema: values.schema ?? null,\n classes: { ...classMap(values) }\n };\n}\n\n/**\n * Rejects class override keys outside a format reader's supported class set.\n *\n * @param {string[]} classKeys Supported class override keys.\n * @param {string} key Candidate override key.\n * @param {string} readerName Reader name used in diagnostics.\n */\nexport function validateClassKey(classKeys, key, readerName)\n{\n if (!classKeys.includes(key))\n {\n throw new Error(`${readerName} unknown class type \"${String(key)}\"`);\n }\n}\n\n/**\n * Validates one constructor supplied through a format reader class override.\n *\n * @param {string[]} classKeys Supported class override keys.\n * @param {string} type Candidate override key.\n * @param {Function} Class Candidate constructor.\n * @param {string} readerName Reader name used in diagnostics.\n */\nexport function validateClass(classKeys, type, Class, readerName)\n{\n validateClassKey(classKeys, type, readerName);\n if (typeof Class !== \"function\")\n {\n throw new TypeError(`${readerName} class \"${type}\" must be a constructor`);\n }\n}\n\nfunction mergeClasses(values, classes, classKeys, readerName)\n{\n if (!classes || typeof classes !== \"object\")\n {\n throw new TypeError(`${readerName} classes option must be an object`);\n }\n\n const next = { ...values.classes };\n for (const [ type, Class ] of Object.entries(classes))\n {\n validateClass(classKeys, type, Class, readerName);\n next[type] = Class;\n }\n values.classes = next;\n}\n\n/**\n * Merge format values over a base set and validate them.\n *\n * @param {object} base Current values.\n * @param {object} [options] Values to merge in.\n * @param {string[]} classKeys Valid class keys.\n * @param {string} readerName Reader name used in error messages.\n * @returns {object} A validated copy of the merged values.\n */\nexport function normalizeValues(base, options = {}, classKeys = [], readerName = \"CjsWebgpuFormat\")\n{\n if (!options || typeof options !== \"object\")\n {\n throw new TypeError(`${readerName} options must be an object`);\n }\n\n assertKnownOptions(options, readerName);\n\n const values = cloneValues(base);\n if (hasOwn(options, \"emit\")) values.emit = normalizeEmit(options.emit, readerName);\n if (hasOwn(options, \"source\")) values.source = typeof options.source === \"string\" && options.source ? options.source : DEFAULT_VALUES.source;\n if (hasOwn(options, \"decodeInstructions\")) values.decodeInstructions = !!options.decodeInstructions;\n if (hasOwn(options, \"permutation\")) values.permutation = options.permutation ?? null;\n if (hasOwn(options, \"schema\")) values.schema = options.schema ?? null;\n if (hasOwn(options, \"classes\")) mergeClasses(values, options.classes, classKeys, readerName);\n return values;\n}\n\n/**\n * Normalize caller input into a Uint8Array of package bytes.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Candidate payload.\n * @returns {Uint8Array} The payload bytes.\n */\nexport function toBytes(input)\n{\n if (input instanceof Uint8Array) return input;\n if (typeof ArrayBuffer !== \"undefined\" && input instanceof ArrayBuffer) return new Uint8Array(input);\n if (ArrayBuffer.isView(input)) return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);\n throw new TypeError(\"CjsWebgpuFormat: input must be Carbon WebGPU package bytes (Uint8Array, Buffer, DataView or ArrayBuffer)\");\n}\n\n/**\n * Reports whether a payload has the Carbon v15 container shape.\n *\n * This is a **shape** check, not an identity check. Our containers are stock\n * Carbon v15 files, so nothing in the bytes separates one from a shipped\n * `effect.dx11` file -- and nothing should. Identity comes from the resource\n * path the file was resolved through, exactly as it does for Carbon, whose own\n * three backend trees are byte-format-identical with no language field anywhere.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Candidate payload.\n * @returns {boolean} True when the payload opens on Carbon's v15 version dword.\n */\nexport function isCarbonWebgpu(input)\n{\n try\n {\n return looksLikeCarbonWebgpuContainer(toBytes(input));\n }\n catch\n {\n return false;\n }\n}\n\n/**\n * The shared read path used by the instance Read/Inspect and static one-shots.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Carbon WebGPU container payload.\n * @param {object} values Normalized format values.\n * @returns {CarbonWebgpuContainer} The loaded container.\n */\nexport function readRaw(input, values)\n{\n const bytes = toBytes(input);\n const container = new CarbonWebgpuContainer();\n const ok = container.Read(bytes, { sourcePath: values.source });\n\n if (!ok)\n {\n throw new WebgpuReadError(\n container.readError ? container.readError.message : \"Failed to read Carbon WebGPU container\",\n {\n source: values.source,\n cause: container.readError || null\n }\n );\n }\n\n try\n {\n validateEffectContainer(container, { source: values.source });\n }\n catch (error)\n {\n if (error instanceof WebgpuReadError) throw error;\n throw new WebgpuReadError(error.message, {\n source: values.source,\n cause: error\n });\n }\n\n return container;\n}\n\n/**\n * Converts a loaded container to the documented plain JSON shape.\n *\n * `analysis` and `wgsl` are **derived views**, not stored documents. The chunk\n * package kept them beside the reflection they were computed from and carried\n * digests to detect the two disagreeing; there is now one document, so there is\n * nothing left to disagree and no digest to carry.\n *\n * `chunks` is gone. It described a container that no longer exists, and a record\n * layout has no chunk table to translate it into.\n *\n * @param {CarbonWebgpuContainer} container Loaded container.\n * @param {object} [options] View options.\n * @returns {object} Plain JSON data.\n */\nexport function packageToJson(container, options = {})\n{\n const source = options.source || container.sourcePath || \"memory\";\n const permutationIndex = options.permutationIndex ?? resolvedPermutationIndex(container);\n const analysis = deriveAnalysis(container, { source, permutationIndex });\n const wgsl = deriveWgsl(container, { permutationIndex });\n\n return toJsonValue({\n format: CARBON_WEBGPU_FORMAT,\n version: container.carbon.version,\n sourcePath: source,\n info: deriveInfo(container, { source }),\n metadata: deriveMetadata(container, { source, permutationIndex }),\n permutationGraph: container.permutationGraph,\n analysis,\n wgsl,\n backendBodySet: deriveBackendBodySet(container),\n stages: analysis.stages ?? [],\n shaders: wgsl.shaders ?? [],\n layouts: wgsl.layouts ?? []\n });\n}\n\n/**\n * Shared read entry honouring the emit mode.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Carbon WebGPU container payload.\n * @param {object} values Normalized format values.\n * @returns {CarbonWebgpuContainer|object} Raw container or plain JSON data.\n */\nexport function readWithValues(input, values)\n{\n const container = readRaw(input, values);\n return values.emit === OUTPUT_RAW\n ? container\n : packageToJson(container, { source: values.source });\n}\n\n/**\n * Compact inspection: Carbon version and compiler bytes, body counts, and the\n * resolved analysis/WGSL counts without building the full JSON package shape.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Carbon WebGPU container payload.\n * @param {object} values Normalized format values.\n * @returns {object} Plain summary data.\n */\nexport function inspectWithValues(input, values)\n{\n const container = readRaw(input, values);\n const graph = container.permutationGraph;\n const permutationIndex = resolvedPermutationIndex(container);\n const analysis = deriveAnalysis(container, { source: values.source, permutationIndex });\n const wgsl = deriveWgsl(container, { permutationIndex });\n\n return {\n source: values.source,\n isCarbonWebgpu: true,\n version: container.carbon.version,\n compilerVersion: [ ...container.carbon.compilerVersion ],\n permutationCount: graph.variants.length,\n uniqueBodyCount: graph.bodies.length,\n stageCount: analysis.stages.length,\n shaderCount: wgsl.shaders.length,\n layoutCount: wgsl.layouts.length\n };\n}\n\nfunction dxbcSource(source, key)\n{\n return source ? `${source}#${key}` : key;\n}\n\nfunction resolvedStageBytecode(stage, key, bytecodeByKey)\n{\n if (!Number.isInteger(stage.stageType)\n || !Number.isInteger(stage.passIndex)\n || typeof stage.techniqueName !== \"string\"\n || !stage.techniqueName\n || typeof stage.stageName !== \"string\"\n || !stage.stageName)\n {\n throw new Error(`${key} manifest stage identity is invalid`);\n }\n\n const innerStageType = stage.shaderBytecode?.stageType;\n if (innerStageType !== undefined && !Number.isInteger(innerStageType))\n {\n throw new Error(`${key} manifest stage bytecode type is invalid`);\n }\n\n let raw = bytecodeByKey?.get(key);\n if (!raw && bytecodeByKey instanceof Map)\n {\n raw = Array.from(bytecodeByKey.values()).find((entry) =>\n entry.techniqueName === stage.techniqueName\n && entry.passIndex === stage.passIndex\n && entry.stageType === stage.stageType\n );\n }\n if (!raw) return stage.shaderBytecode?.bytes;\n\n if (!Number.isInteger(raw.stageType)\n || stage.stageType !== raw.stageType\n || (innerStageType !== undefined && innerStageType !== raw.stageType)\n || stage.stageName !== raw.stageName\n || (stage.shaderBytecode?.stageName !== undefined\n && stage.shaderBytecode.stageName !== raw.stageName))\n {\n throw new Error(`${key} manifest and raw stage metadata disagree`);\n }\n\n if (stage.shaderBytecode?.bytes !== undefined)\n {\n const manifestBytes = normalizeBytecodeBytes(\n stage.shaderBytecode.bytes,\n `${key} manifest stage bytecode`\n );\n if (!manifestBytes\n || manifestBytes.length !== raw.bytes.length\n || manifestBytes.some((value, index) => value !== raw.bytes[index]))\n {\n throw new Error(`${key} manifest and raw stage bytecode disagree`);\n }\n }\n\n return raw.bytes;\n}\n\nfunction analyzeStage(stage, options)\n{\n const key = `${stage.techniqueName}.pass${stage.passIndex}.${stage.stageName}`;\n const shaderBytecode = stage.shaderBytecode && typeof stage.shaderBytecode === \"object\"\n ? { ...stage.shaderBytecode }\n : stage.shaderBytecode;\n if (shaderBytecode && typeof shaderBytecode === \"object\")\n {\n delete shaderBytecode.bytes;\n }\n const out = {\n ...stage,\n shaderBytecode,\n key,\n dxbc: null,\n dxbcError: null,\n ir: null,\n irError: null\n };\n\n if (options.decodeBytecode === false)\n {\n return out;\n }\n\n const bytecodeBytes = normalizeBytecodeBytes(\n options.bytecodeBytes ?? stage.shaderBytecode?.bytes,\n `${key} stage bytecode`\n );\n if (!bytecodeBytes?.length)\n {\n return out;\n }\n\n try\n {\n out.dxbc = CjsDxbcFormat.read(bytecodeBytes, {\n source: dxbcSource(options.source, key),\n decodeInstructions: options.decodeInstructions\n });\n if (options.decodeInstructions && Array.isArray(out.dxbc.instructions))\n {\n try\n {\n out.ir = lowerDxbcToIr(out.dxbc, { source: dxbcSource(options.source, key) });\n }\n catch (error)\n {\n out.irError = {\n name: error.name,\n message: error.message\n };\n }\n }\n }\n catch (error)\n {\n out.dxbcError = {\n name: error.name,\n message: error.message\n };\n }\n\n return out;\n}\n\n/**\n * Builds the normalized WebGPU analysis document from a resolved effect.\n *\n * @param {object} resolved Raw resolved-effect context from `readEffectAnalysis`.\n * @param {object} [options] Analysis options.\n * @param {string} [options.source] Source label for diagnostics.\n * @param {boolean} [options.decodeBytecode] Whether stage bytecode is inspected.\n * @param {boolean} [options.decodeInstructions] Whether DXBC instructions are decoded.\n * @returns {object} Plain JSON-compatible analysis data.\n */\nexport function buildEffectAnalysis(resolved, options = {})\n{\n const source = options.source || resolved.effectRes?.sourcePath || \"memory\";\n const decodeBytecode = options.decodeBytecode !== undefined ? !!options.decodeBytecode : true;\n const decodeInstructions = options.decodeInstructions !== undefined ? !!options.decodeInstructions : true;\n const manifest = resolved.bindingManifest?.toJSON?.() ?? null;\n const bytecodeByKey = resolved.stageBytecodeByKey instanceof Map\n ? resolved.stageBytecodeByKey\n : null;\n const stages = (manifest?.stages || []).map((stage) =>\n {\n const key = `${stage.techniqueName}.pass${stage.passIndex}.${stage.stageName}`;\n\n return analyzeStage(stage, {\n source,\n decodeBytecode,\n decodeInstructions,\n bytecodeBytes: resolvedStageBytecode(stage, key, bytecodeByKey)\n });\n });\n\n return toJsonValue({\n format: CARBON_WEBGPU_ANALYSIS_FORMAT,\n formatVersion: CARBON_WEBGPU_ANALYSIS_VERSION,\n source,\n effectVersion: resolved.effectDescription?.version ?? manifest?.version ?? resolved.effectRes?.m_version ?? null,\n compilerVersion: resolved.effectRes?.m_compilerVersion ?? null,\n effectName: manifest?.effectName || resolved.effectDescription?.effectName || null,\n bodyIndex: resolved.selection?.bodyIndex ?? 0,\n selectedOptions: resolved.selection?.selectedOptions ?? [],\n passes: manifest?.passes || [],\n stages\n });\n}\n\n/**\n * Analyzes one compiled effect payload into a normalized WebGPU-facing\n * document: selected permutation, Carbon binding manifest, and per-stage DXBC\n * decode.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Tr2 effect payload.\n * @param {object} values Normalized format values.\n * @returns {object} Plain JSON-compatible analysis data.\n */\nexport function analyzeEffectWithValues(input, values)\n{\n const permutation = normalizeEffectPermutation(values.permutation);\n const resolved = readEffectAnalysis(input, {\n source: values.source,\n permutation\n });\n validateResolvedPermutation(\n permutation,\n resolved.selection?.selectedOptions ?? []\n );\n\n return buildEffectAnalysis(resolved, {\n source: values.source,\n decodeInstructions: values.decodeInstructions\n });\n}\n\n/**\n * Deep-convert a value to plain JSON-compatible data.\n *\n * @param {any} value Value to convert.\n * @returns {any} Plain data.\n */\nexport function toJsonValue(value)\n{\n if (value === null || value === undefined) return value ?? null;\n if (typeof value === \"number\" || typeof value === \"string\" || typeof value === \"boolean\") return value;\n if (typeof value === \"bigint\") return value.toString();\n if (ArrayBuffer.isView(value)) return Array.from(value);\n if (Array.isArray(value)) return value.map(toJsonValue);\n if (value instanceof Map)\n {\n const out = {};\n for (const [ key, entry ] of value) out[key] = toJsonValue(entry);\n return out;\n }\n if (value instanceof Set) return Array.from(value, toJsonValue);\n if (typeof value === \"object\")\n {\n if (typeof value.toJSON === \"function\") return toJsonValue(value.toJSON());\n const out = {};\n for (const key of Object.keys(value)) out[key] = toJsonValue(value[key]);\n return out;\n }\n return null;\n}\n\nexport { WebgpuReadError };\n"],"names":["OUTPUT_JSON","OUTPUT_RAW","CARBON_WEBGPU_FORMAT","CARBON_WEBGPU_ANALYSIS_FORMAT","CARBON_WEBGPU_ANALYSIS_VERSION","DEFAULT_VALUES","Object","freeze","emit","source","decodeInstructions","permutation","schema","classes","OPTION_KEYS","Set","hasOwn","value","key","prototype","hasOwnProperty","call","normalizeEmit","readerName","undefined","TypeError","JSON","stringify","assertKnownOptions","options","keys","has","classMap","values","cloneValues","validateClassKey","classKeys","includes","Error","String","validateClass","type","Class","mergeClasses","next","entries","normalizeValues","base","toBytes","input","Uint8Array","ArrayBuffer","isView","buffer","byteOffset","byteLength","isCarbonWebgpu","looksLikeCarbonWebgpuContainer","readRaw","bytes","container","CarbonWebgpuContainer","ok","Read","sourcePath","WebgpuReadError","readError","message","cause","validateEffectContainer","error","packageToJson","permutationIndex","resolvedPermutationIndex","analysis","deriveAnalysis","wgsl","deriveWgsl","toJsonValue","format","version","carbon","info","deriveInfo","metadata","deriveMetadata","permutationGraph","backendBodySet","deriveBackendBodySet","stages","shaders","layouts","readWithValues","inspectWithValues","graph","compilerVersion","permutationCount","variants","length","uniqueBodyCount","bodies","stageCount","shaderCount","layoutCount","dxbcSource","resolvedStageBytecode","stage","bytecodeByKey","Number","isInteger","stageType","passIndex","techniqueName","stageName","innerStageType","shaderBytecode","raw","get","Map","Array","from","find","entry","manifestBytes","normalizeBytecodeBytes","some","index","analyzeStage","out","dxbc","dxbcError","ir","irError","decodeBytecode","bytecodeBytes","CjsDxbcFormat","read","isArray","instructions","lowerDxbcToIr","name","buildEffectAnalysis","resolved","effectRes","manifest","bindingManifest","toJSON","stageBytecodeByKey","map","formatVersion","effectVersion","effectDescription","m_version","m_compilerVersion","effectName","bodyIndex","selection","selectedOptions","passes","analyzeEffectWithValues","normalizeEffectPermutation","readEffectAnalysis","validateResolvedPermutation","toString"],"mappings":";;;;;;;;;AAoBO,MAAMA,WAAW,GAAG;AACpB,MAAMC,UAAU,GAAG;AACnB,MAAMC,oBAAoB,GAAG;AAC7B,MAAMC,6BAA6B,GAAG;AACtC,MAAMC,8BAA8B,GAAG;MAEjCC,cAAc,GAAGC,MAAM,CAACC,MAAM,CAAC;AACxCC,EAAAA,IAAI,EAAER,WAAW;AACjBS,EAAAA,MAAM,EAAE,QAAQ;AAChBC,EAAAA,kBAAkB,EAAE,IAAI;AACxBC,EAAAA,WAAW,EAAE,IAAI;AACjBC,EAAAA,MAAM,EAAE,IAAI;AACZC,EAAAA,OAAO,EAAEP,MAAM,CAACC,MAAM,CAAC,EAAE;AAC7B,CAAC;AAED,MAAMO,WAAW,GAAG,IAAIC,GAAG,CAAC,CAAE,MAAM,EAAE,QAAQ,EAAE,oBAAoB,EAAE,aAAa,EAAE,QAAQ,EAAE,SAAS,CAAE,CAAC;AAG3G,SAASC,MAAMA,CAACC,KAAK,EAAEC,GAAG,EAC1B;EACI,OAAOZ,MAAM,CAACa,SAAS,CAACC,cAAc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d,EAAA;AACA,EAAA,OAAO,IAAI;AACf;;;;"}
|
|
1
|
+
{"version":3,"file":"helpers.js","sources":["../../../../../src/formats/webgpu/core/helpers.js"],"sourcesContent":["import CjsDxbcFormat from \"../../dxbc/index.js\";\r\nimport { normalizeBytecodeBytes, readEffectAnalysis } from \"./effectAnalysis.js\";\r\n\r\nimport { CarbonWebgpuContainer, looksLikeCarbonWebgpuContainer } from \"./carbonWebgpu/CarbonWebgpuContainer.js\";\r\nimport { validateEffectContainer } from \"./carbonWebgpu/validateContainer.js\";\r\nimport {\r\n deriveAnalysis,\r\n deriveBackendBodySet,\r\n deriveInfo,\r\n deriveMetadata,\r\n deriveWgsl,\r\n resolvedPermutationIndex\r\n} from \"./carbonWebgpu/containerViews.js\";\r\nimport { WebgpuReadError } from \"./errors.js\";\r\nimport { lowerDxbcToIr } from \"./ir/lowerDxbcToIr.js\";\r\nimport {\r\n normalizeEffectPermutation,\r\n validateResolvedPermutation\r\n} from \"./packageEffectSelection.js\";\r\n\r\nexport const OUTPUT_JSON = \"json\";\r\nexport const CARBON_WEBGPU_FORMAT = \"CARBON_WEBGPU\";\r\nexport const CARBON_WEBGPU_ANALYSIS_FORMAT = \"CARBON_WEBGPU_ANALYSIS\";\r\nexport const CARBON_WEBGPU_ANALYSIS_VERSION = 1;\r\n\r\nexport const DEFAULT_VALUES = Object.freeze({\r\n emit: OUTPUT_JSON,\r\n source: \"memory\",\r\n decodeInstructions: true,\r\n permutation: null,\r\n schema: null,\r\n classes: Object.freeze({})\r\n});\r\n\r\nconst OPTION_KEYS = new Set([ \"emit\", \"source\", \"decodeInstructions\", \"permutation\", \"schema\", \"classes\" ]);\r\n// One emit, as WebGL has. `Read` returns the container-backed document and that\r\n// document is complete: the analysis, WGSL, metadata and permutation views the\r\n// caller selects among, plus `backendBodySet`, which is every translated body\r\n// joined to its shared translation units.\r\n//\r\n// A second `raw` emit used to hand back the live `CarbonWebgpuContainer` because\r\n// the chunk package's JSON could not express the body set. It became the only way\r\n// to reach a body, so `engine-webgpu` duck-typed the container instead of reading\r\n// the document - and when the chunk package was replaced, the engine kept asking\r\n// for a shape the producer had stopped emitting. Both halves then failed, in\r\n// different directions, for weeks: the default emit built pipelines but resolved\r\n// no bodies, and the raw emit resolved bodies but built no pipelines.\r\n//\r\n// Neither is reachable now. The container stays internal to this module.\r\nconst VALID_EMITS = new Set([ OUTPUT_JSON ]);\r\n\r\nfunction hasOwn(value, key)\r\n{\r\n return Object.prototype.hasOwnProperty.call(value, key);\r\n}\r\n\r\nfunction normalizeEmit(emit, readerName)\r\n{\r\n if (emit === undefined || VALID_EMITS.has(emit)) return OUTPUT_JSON;\r\n throw new TypeError(`${readerName}: emit must be \"${OUTPUT_JSON}\", got ${JSON.stringify(emit)}`);\r\n}\r\n\r\nfunction assertKnownOptions(options, readerName)\r\n{\r\n for (const key of Object.keys(options))\r\n {\r\n if (!OPTION_KEYS.has(key))\r\n {\r\n throw new TypeError(`${readerName}: unknown option ${JSON.stringify(key)}`);\r\n }\r\n }\r\n}\r\n\r\nfunction classMap(values)\r\n{\r\n return values && values.classes ? values.classes : {};\r\n}\r\n\r\nfunction cloneValues(values)\r\n{\r\n return {\r\n emit: values.emit,\r\n source: values.source ?? DEFAULT_VALUES.source,\r\n decodeInstructions: values.decodeInstructions ?? DEFAULT_VALUES.decodeInstructions,\r\n permutation: values.permutation ?? null,\r\n schema: values.schema ?? null,\r\n classes: { ...classMap(values) }\r\n };\r\n}\r\n\r\n/**\r\n * Rejects class override keys outside a format reader's supported class set.\r\n *\r\n * @param {string[]} classKeys Supported class override keys.\r\n * @param {string} key Candidate override key.\r\n * @param {string} readerName Reader name used in diagnostics.\r\n */\r\nexport function validateClassKey(classKeys, key, readerName)\r\n{\r\n if (!classKeys.includes(key))\r\n {\r\n throw new Error(`${readerName} unknown class type \"${String(key)}\"`);\r\n }\r\n}\r\n\r\n/**\r\n * Validates one constructor supplied through a format reader class override.\r\n *\r\n * @param {string[]} classKeys Supported class override keys.\r\n * @param {string} type Candidate override key.\r\n * @param {Function} Class Candidate constructor.\r\n * @param {string} readerName Reader name used in diagnostics.\r\n */\r\nexport function validateClass(classKeys, type, Class, readerName)\r\n{\r\n validateClassKey(classKeys, type, readerName);\r\n if (typeof Class !== \"function\")\r\n {\r\n throw new TypeError(`${readerName} class \"${type}\" must be a constructor`);\r\n }\r\n}\r\n\r\nfunction mergeClasses(values, classes, classKeys, readerName)\r\n{\r\n if (!classes || typeof classes !== \"object\")\r\n {\r\n throw new TypeError(`${readerName} classes option must be an object`);\r\n }\r\n\r\n const next = { ...values.classes };\r\n for (const [ type, Class ] of Object.entries(classes))\r\n {\r\n validateClass(classKeys, type, Class, readerName);\r\n next[type] = Class;\r\n }\r\n values.classes = next;\r\n}\r\n\r\n/**\r\n * Merge format values over a base set and validate them.\r\n *\r\n * @param {object} base Current values.\r\n * @param {object} [options] Values to merge in.\r\n * @param {string[]} classKeys Valid class keys.\r\n * @param {string} readerName Reader name used in error messages.\r\n * @returns {object} A validated copy of the merged values.\r\n */\r\nexport function normalizeValues(base, options = {}, classKeys = [], readerName = \"CjsWebgpuFormat\")\r\n{\r\n if (!options || typeof options !== \"object\")\r\n {\r\n throw new TypeError(`${readerName} options must be an object`);\r\n }\r\n\r\n assertKnownOptions(options, readerName);\r\n\r\n const values = cloneValues(base);\r\n if (hasOwn(options, \"emit\")) values.emit = normalizeEmit(options.emit, readerName);\r\n if (hasOwn(options, \"source\")) values.source = typeof options.source === \"string\" && options.source ? options.source : DEFAULT_VALUES.source;\r\n if (hasOwn(options, \"decodeInstructions\")) values.decodeInstructions = !!options.decodeInstructions;\r\n if (hasOwn(options, \"permutation\")) values.permutation = options.permutation ?? null;\r\n if (hasOwn(options, \"schema\")) values.schema = options.schema ?? null;\r\n if (hasOwn(options, \"classes\")) mergeClasses(values, options.classes, classKeys, readerName);\r\n return values;\r\n}\r\n\r\n/**\r\n * Normalize caller input into a Uint8Array of package bytes.\r\n *\r\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Candidate payload.\r\n * @returns {Uint8Array} The payload bytes.\r\n */\r\nexport function toBytes(input)\r\n{\r\n if (input instanceof Uint8Array) return input;\r\n if (typeof ArrayBuffer !== \"undefined\" && input instanceof ArrayBuffer) return new Uint8Array(input);\r\n if (ArrayBuffer.isView(input)) return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);\r\n throw new TypeError(\"CjsWebgpuFormat: input must be Carbon WebGPU package bytes (Uint8Array, Buffer, DataView or ArrayBuffer)\");\r\n}\r\n\r\n/**\r\n * Reports whether a payload has the Carbon v15 container shape.\r\n *\r\n * This is a **shape** check, not an identity check. Our containers are stock\r\n * Carbon v15 files, so nothing in the bytes separates one from a shipped\r\n * `effect.dx11` file -- and nothing should. Identity comes from the resource\r\n * path the file was resolved through, exactly as it does for Carbon, whose own\r\n * three backend trees are byte-format-identical with no language field anywhere.\r\n *\r\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Candidate payload.\r\n * @returns {boolean} True when the payload opens on Carbon's v15 version dword.\r\n */\r\nexport function isCarbonWebgpu(input)\r\n{\r\n try\r\n {\r\n return looksLikeCarbonWebgpuContainer(toBytes(input));\r\n }\r\n catch\r\n {\r\n return false;\r\n }\r\n}\r\n\r\n/**\r\n * The shared read path used by the instance Read/Inspect and static one-shots.\r\n *\r\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Carbon WebGPU container payload.\r\n * @param {object} values Normalized format values.\r\n * @returns {CarbonWebgpuContainer} The loaded container.\r\n */\r\nexport function readRaw(input, values)\r\n{\r\n const bytes = toBytes(input);\r\n const container = new CarbonWebgpuContainer();\r\n const ok = container.Read(bytes, { sourcePath: values.source });\r\n\r\n if (!ok)\r\n {\r\n throw new WebgpuReadError(\r\n container.readError ? container.readError.message : \"Failed to read Carbon WebGPU container\",\r\n {\r\n source: values.source,\r\n cause: container.readError || null\r\n }\r\n );\r\n }\r\n\r\n try\r\n {\r\n validateEffectContainer(container, { source: values.source });\r\n }\r\n catch (error)\r\n {\r\n if (error instanceof WebgpuReadError) throw error;\r\n throw new WebgpuReadError(error.message, {\r\n source: values.source,\r\n cause: error\r\n });\r\n }\r\n\r\n return container;\r\n}\r\n\r\n/**\r\n * Converts a loaded container to the documented plain JSON shape.\r\n *\r\n * `analysis` and `wgsl` are **derived views**, not stored documents. The chunk\r\n * package kept them beside the reflection they were computed from and carried\r\n * digests to detect the two disagreeing; there is now one document, so there is\r\n * nothing left to disagree and no digest to carry.\r\n *\r\n * `chunks` is gone. It described a container that no longer exists, and a record\r\n * layout has no chunk table to translate it into.\r\n *\r\n * @param {CarbonWebgpuContainer} container Loaded container.\r\n * @param {object} [options] View options.\r\n * @returns {object} Plain JSON data.\r\n */\r\nexport function packageToJson(container, options = {})\r\n{\r\n const source = options.source || container.sourcePath || \"memory\";\r\n const permutationIndex = options.permutationIndex ?? resolvedPermutationIndex(container);\r\n const analysis = deriveAnalysis(container, { source, permutationIndex });\r\n const wgsl = deriveWgsl(container, { permutationIndex });\r\n\r\n return toJsonValue({\r\n format: CARBON_WEBGPU_FORMAT,\r\n version: container.carbon.version,\r\n sourcePath: source,\r\n info: deriveInfo(container, { source }),\r\n metadata: deriveMetadata(container, { source, permutationIndex }),\r\n permutationGraph: container.permutationGraph,\r\n analysis,\r\n wgsl,\r\n backendBodySet: deriveBackendBodySet(container),\r\n stages: analysis.stages ?? [],\r\n shaders: wgsl.shaders ?? [],\r\n layouts: wgsl.layouts ?? []\r\n });\r\n}\r\n\r\n/**\r\n * Shared read entry.\r\n *\r\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Carbon WebGPU container payload.\r\n * @param {object} values Normalized format values.\r\n * @returns {object} Plain JSON data.\r\n */\r\nexport function readWithValues(input, values)\r\n{\r\n return packageToJson(readRaw(input, values), { source: values.source });\r\n}\r\n\r\n/**\r\n * Compact inspection: Carbon version and compiler bytes, body counts, and the\r\n * resolved analysis/WGSL counts without building the full JSON package shape.\r\n *\r\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Carbon WebGPU container payload.\r\n * @param {object} values Normalized format values.\r\n * @returns {object} Plain summary data.\r\n */\r\nexport function inspectWithValues(input, values)\r\n{\r\n const container = readRaw(input, values);\r\n const graph = container.permutationGraph;\r\n const permutationIndex = resolvedPermutationIndex(container);\r\n const analysis = deriveAnalysis(container, { source: values.source, permutationIndex });\r\n const wgsl = deriveWgsl(container, { permutationIndex });\r\n\r\n return {\r\n source: values.source,\r\n isCarbonWebgpu: true,\r\n version: container.carbon.version,\r\n compilerVersion: [ ...container.carbon.compilerVersion ],\r\n permutationCount: graph.variants.length,\r\n uniqueBodyCount: graph.bodies.length,\r\n stageCount: analysis.stages.length,\r\n shaderCount: wgsl.shaders.length,\r\n layoutCount: wgsl.layouts.length\r\n };\r\n}\r\n\r\nfunction dxbcSource(source, key)\r\n{\r\n return source ? `${source}#${key}` : key;\r\n}\r\n\r\nfunction resolvedStageBytecode(stage, key, bytecodeByKey)\r\n{\r\n if (!Number.isInteger(stage.stageType)\r\n || !Number.isInteger(stage.passIndex)\r\n || typeof stage.techniqueName !== \"string\"\r\n || !stage.techniqueName\r\n || typeof stage.stageName !== \"string\"\r\n || !stage.stageName)\r\n {\r\n throw new Error(`${key} manifest stage identity is invalid`);\r\n }\r\n\r\n const innerStageType = stage.shaderBytecode?.stageType;\r\n if (innerStageType !== undefined && !Number.isInteger(innerStageType))\r\n {\r\n throw new Error(`${key} manifest stage bytecode type is invalid`);\r\n }\r\n\r\n let raw = bytecodeByKey?.get(key);\r\n if (!raw && bytecodeByKey instanceof Map)\r\n {\r\n raw = Array.from(bytecodeByKey.values()).find((entry) =>\r\n entry.techniqueName === stage.techniqueName\r\n && entry.passIndex === stage.passIndex\r\n && entry.stageType === stage.stageType\r\n );\r\n }\r\n if (!raw) return stage.shaderBytecode?.bytes;\r\n\r\n if (!Number.isInteger(raw.stageType)\r\n || stage.stageType !== raw.stageType\r\n || (innerStageType !== undefined && innerStageType !== raw.stageType)\r\n || stage.stageName !== raw.stageName\r\n || (stage.shaderBytecode?.stageName !== undefined\r\n && stage.shaderBytecode.stageName !== raw.stageName))\r\n {\r\n throw new Error(`${key} manifest and raw stage metadata disagree`);\r\n }\r\n\r\n if (stage.shaderBytecode?.bytes !== undefined)\r\n {\r\n const manifestBytes = normalizeBytecodeBytes(\r\n stage.shaderBytecode.bytes,\r\n `${key} manifest stage bytecode`\r\n );\r\n if (!manifestBytes\r\n || manifestBytes.length !== raw.bytes.length\r\n || manifestBytes.some((value, index) => value !== raw.bytes[index]))\r\n {\r\n throw new Error(`${key} manifest and raw stage bytecode disagree`);\r\n }\r\n }\r\n\r\n return raw.bytes;\r\n}\r\n\r\nfunction analyzeStage(stage, options)\r\n{\r\n const key = `${stage.techniqueName}.pass${stage.passIndex}.${stage.stageName}`;\r\n const shaderBytecode = stage.shaderBytecode && typeof stage.shaderBytecode === \"object\"\r\n ? { ...stage.shaderBytecode }\r\n : stage.shaderBytecode;\r\n if (shaderBytecode && typeof shaderBytecode === \"object\")\r\n {\r\n delete shaderBytecode.bytes;\r\n }\r\n const out = {\r\n ...stage,\r\n shaderBytecode,\r\n key,\r\n dxbc: null,\r\n dxbcError: null,\r\n ir: null,\r\n irError: null\r\n };\r\n\r\n if (options.decodeBytecode === false)\r\n {\r\n return out;\r\n }\r\n\r\n const bytecodeBytes = normalizeBytecodeBytes(\r\n options.bytecodeBytes ?? stage.shaderBytecode?.bytes,\r\n `${key} stage bytecode`\r\n );\r\n if (!bytecodeBytes?.length)\r\n {\r\n return out;\r\n }\r\n\r\n try\r\n {\r\n out.dxbc = CjsDxbcFormat.read(bytecodeBytes, {\r\n source: dxbcSource(options.source, key),\r\n decodeInstructions: options.decodeInstructions\r\n });\r\n if (options.decodeInstructions && Array.isArray(out.dxbc.instructions))\r\n {\r\n try\r\n {\r\n out.ir = lowerDxbcToIr(out.dxbc, { source: dxbcSource(options.source, key) });\r\n }\r\n catch (error)\r\n {\r\n out.irError = {\r\n name: error.name,\r\n message: error.message\r\n };\r\n }\r\n }\r\n }\r\n catch (error)\r\n {\r\n out.dxbcError = {\r\n name: error.name,\r\n message: error.message\r\n };\r\n }\r\n\r\n return out;\r\n}\r\n\r\n/**\r\n * Builds the normalized WebGPU analysis document from a resolved effect.\r\n *\r\n * @param {object} resolved Raw resolved-effect context from `readEffectAnalysis`.\r\n * @param {object} [options] Analysis options.\r\n * @param {string} [options.source] Source label for diagnostics.\r\n * @param {boolean} [options.decodeBytecode] Whether stage bytecode is inspected.\r\n * @param {boolean} [options.decodeInstructions] Whether DXBC instructions are decoded.\r\n * @returns {object} Plain JSON-compatible analysis data.\r\n */\r\nexport function buildEffectAnalysis(resolved, options = {})\r\n{\r\n const source = options.source || resolved.effectRes?.sourcePath || \"memory\";\r\n const decodeBytecode = options.decodeBytecode !== undefined ? !!options.decodeBytecode : true;\r\n const decodeInstructions = options.decodeInstructions !== undefined ? !!options.decodeInstructions : true;\r\n const manifest = resolved.bindingManifest?.toJSON?.() ?? null;\r\n const bytecodeByKey = resolved.stageBytecodeByKey instanceof Map\r\n ? resolved.stageBytecodeByKey\r\n : null;\r\n const stages = (manifest?.stages || []).map((stage) =>\r\n {\r\n const key = `${stage.techniqueName}.pass${stage.passIndex}.${stage.stageName}`;\r\n\r\n return analyzeStage(stage, {\r\n source,\r\n decodeBytecode,\r\n decodeInstructions,\r\n bytecodeBytes: resolvedStageBytecode(stage, key, bytecodeByKey)\r\n });\r\n });\r\n\r\n return toJsonValue({\r\n format: CARBON_WEBGPU_ANALYSIS_FORMAT,\r\n formatVersion: CARBON_WEBGPU_ANALYSIS_VERSION,\r\n source,\r\n effectVersion: resolved.effectDescription?.version ?? manifest?.version ?? resolved.effectRes?.m_version ?? null,\r\n compilerVersion: resolved.effectRes?.m_compilerVersion ?? null,\r\n effectName: manifest?.effectName || resolved.effectDescription?.effectName || null,\r\n bodyIndex: resolved.selection?.bodyIndex ?? 0,\r\n selectedOptions: resolved.selection?.selectedOptions ?? [],\r\n passes: manifest?.passes || [],\r\n stages\r\n });\r\n}\r\n\r\n/**\r\n * Analyzes one compiled effect payload into a normalized WebGPU-facing\r\n * document: selected permutation, Carbon binding manifest, and per-stage DXBC\r\n * decode.\r\n *\r\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Tr2 effect payload.\r\n * @param {object} values Normalized format values.\r\n * @returns {object} Plain JSON-compatible analysis data.\r\n */\r\nexport function analyzeEffectWithValues(input, values)\r\n{\r\n const permutation = normalizeEffectPermutation(values.permutation);\r\n const resolved = readEffectAnalysis(input, {\r\n source: values.source,\r\n permutation\r\n });\r\n validateResolvedPermutation(\r\n permutation,\r\n resolved.selection?.selectedOptions ?? []\r\n );\r\n\r\n return buildEffectAnalysis(resolved, {\r\n source: values.source,\r\n decodeInstructions: values.decodeInstructions\r\n });\r\n}\r\n\r\n/**\r\n * Deep-convert a value to plain JSON-compatible data.\r\n *\r\n * @param {any} value Value to convert.\r\n * @returns {any} Plain data.\r\n */\r\nexport function toJsonValue(value)\r\n{\r\n if (value === null || value === undefined) return value ?? null;\r\n if (typeof value === \"number\" || typeof value === \"string\" || typeof value === \"boolean\") return value;\r\n if (typeof value === \"bigint\") return value.toString();\r\n if (ArrayBuffer.isView(value)) return Array.from(value);\r\n if (Array.isArray(value)) return value.map(toJsonValue);\r\n if (value instanceof Map)\r\n {\r\n const out = {};\r\n for (const [ key, entry ] of value) out[key] = toJsonValue(entry);\r\n return out;\r\n }\r\n if (value instanceof Set) return Array.from(value, toJsonValue);\r\n if (typeof value === \"object\")\r\n {\r\n if (typeof value.toJSON === \"function\") return toJsonValue(value.toJSON());\r\n const out = {};\r\n for (const key of Object.keys(value)) out[key] = toJsonValue(value[key]);\r\n return out;\r\n }\r\n return null;\r\n}\r\n\r\nexport { WebgpuReadError };\r\n"],"names":["OUTPUT_JSON","CARBON_WEBGPU_FORMAT","CARBON_WEBGPU_ANALYSIS_FORMAT","CARBON_WEBGPU_ANALYSIS_VERSION","DEFAULT_VALUES","Object","freeze","emit","source","decodeInstructions","permutation","schema","classes","OPTION_KEYS","Set","VALID_EMITS","hasOwn","value","key","prototype","hasOwnProperty","call","normalizeEmit","readerName","undefined","has","TypeError","JSON","stringify","assertKnownOptions","options","keys","classMap","values","cloneValues","validateClassKey","classKeys","includes","Error","String","validateClass","type","Class","mergeClasses","next","entries","normalizeValues","base","toBytes","input","Uint8Array","ArrayBuffer","isView","buffer","byteOffset","byteLength","isCarbonWebgpu","looksLikeCarbonWebgpuContainer","readRaw","bytes","container","CarbonWebgpuContainer","ok","Read","sourcePath","WebgpuReadError","readError","message","cause","validateEffectContainer","error","packageToJson","permutationIndex","resolvedPermutationIndex","analysis","deriveAnalysis","wgsl","deriveWgsl","toJsonValue","format","version","carbon","info","deriveInfo","metadata","deriveMetadata","permutationGraph","backendBodySet","deriveBackendBodySet","stages","shaders","layouts","readWithValues","inspectWithValues","graph","compilerVersion","permutationCount","variants","length","uniqueBodyCount","bodies","stageCount","shaderCount","layoutCount","dxbcSource","resolvedStageBytecode","stage","bytecodeByKey","Number","isInteger","stageType","passIndex","techniqueName","stageName","innerStageType","shaderBytecode","raw","get","Map","Array","from","find","entry","manifestBytes","normalizeBytecodeBytes","some","index","analyzeStage","out","dxbc","dxbcError","ir","irError","decodeBytecode","bytecodeBytes","CjsDxbcFormat","read","isArray","instructions","lowerDxbcToIr","name","buildEffectAnalysis","resolved","effectRes","manifest","bindingManifest","toJSON","stageBytecodeByKey","map","formatVersion","effectVersion","effectDescription","m_version","m_compilerVersion","effectName","bodyIndex","selection","selectedOptions","passes","analyzeEffectWithValues","normalizeEffectPermutation","readEffectAnalysis","validateResolvedPermutation","toString"],"mappings":";;;;;;;;;AAoBO,MAAMA,WAAW,GAAG;AACpB,MAAMC,oBAAoB,GAAG;AAC7B,MAAMC,6BAA6B,GAAG;AACtC,MAAMC,8BAA8B,GAAG;MAEjCC,cAAc,GAAGC,MAAM,CAACC,MAAM,CAAC;AACxCC,EAAAA,IAAI,EAAEP,WAAW;AACjBQ,EAAAA,MAAM,EAAE,QAAQ;AAChBC,EAAAA,kB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AC/D,EAAA,IAAI,OAAO7D,KAAK,KAAK,QAAQ,EAC7B;AACI,IAAA,IAAI,OAAOA,KAAK,CAACiI,MAAM,KAAK,UAAU,EAAE,OAAOpE,WAAW,CAAC7D,KAAK,CAACiI,MAAM,EAAE,CAAC;IAC1E,MAAMlB,GAAG,GAAG,EAAE;IACd,KAAK,MAAM9G,GAAG,IAAIb,MAAM,CAAC0B,IAAI,CAACd,KAAK,CAAC,EAAE+G,GAAG,CAAC9G,GAAG,CAAC,GAAG4D,WAAW,CAAC7D,KAAK,CAACC,GAAG,CAAC,CAAC;AACxE,IAAA,OAAO8G,GAAG;AACd,EAAA;AACA,EAAA,OAAO,IAAI;AACf;;;;"}
|
|
@@ -6,24 +6,24 @@ import { buildWgslBindingPlan } from './wgsl/buildWgslBindingPlan.js';
|
|
|
6
6
|
import { buildWgsl } from './wgsl/emitWgsl.js';
|
|
7
7
|
import { buildWgslSet } from './wgsl/buildWgslSet.js';
|
|
8
8
|
import { buildResourceTransformPlan } from './wgsl/buildResourceTransformPlan.js';
|
|
9
|
-
import { buildEffectPermutationGraph, EFFECT_PERMUTATION_GRAPH_VERSION, EFFECT_PERMUTATION_GRAPH_FORMAT
|
|
10
|
-
import { buildEffectBackendBodySet, EFFECT_BACKEND_BODY_SET_VERSION, EFFECT_BACKEND_BODY_SET_FORMAT
|
|
9
|
+
import { buildEffectPermutationGraph, EFFECT_PERMUTATION_GRAPH_VERSION, EFFECT_PERMUTATION_GRAPH_FORMAT } from '../../../format/effect/effectPermutationGraph.js';
|
|
10
|
+
import { buildEffectBackendBodySet, EFFECT_BACKEND_BODY_SET_VERSION, EFFECT_BACKEND_BODY_SET_FORMAT } from './effectBackendBodySet.js';
|
|
11
11
|
import { DXBC_WGSL_TRANSLATOR_VERSION, DXBC_WGSL_TRANSLATOR_NAME, FORMAT_WEBGPU_PACKAGE_VERSION, FORMAT_WEBGPU_PACKAGE_NAME, WEBGPU_BACKEND_NAME, EFFECT_INFO_VERSION } from './packageMetadata.js';
|
|
12
12
|
import { sha256Utf8, sha256Bytes } from '../../../format/effect/sha256.js';
|
|
13
13
|
import { isParticleClearEffectCandidate, preflightParticleClearEffectProfile, particleClearEffectProofFor } from './wgsl/lowerParticleClearComputePrograms.js';
|
|
14
14
|
import { normalizeEffectPermutation, validateResolvedPermutation, selectEffectStages, buildWgslSelectionMetadata } from './packageEffectSelection.js';
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* Build one structurally valid Carbon WebGPU package from compiled Tr2 effect bytes.
|
|
18
|
-
*
|
|
19
|
-
* The version-15 build result retains every unique body's portable source
|
|
20
|
-
* reflection as in-memory evidence while the emitted Carbon wire stores WGSL
|
|
21
|
-
* or empty program slots plus representable non-program fields. Filesystem
|
|
22
|
-
* concerns remain in callers.
|
|
23
|
-
*
|
|
24
|
-
* @param {Uint8Array|ArrayBuffer|ArrayBufferView} input Compiled effect bytes.
|
|
25
|
-
* @param {object} [options] Source, body-mode, permutation, and stage-selection policy.
|
|
26
|
-
* @returns {object} Package bytes plus inspection and provenance documents.
|
|
16
|
+
/**
|
|
17
|
+
* Build one structurally valid Carbon WebGPU package from compiled Tr2 effect bytes.
|
|
18
|
+
*
|
|
19
|
+
* The version-15 build result retains every unique body's portable source
|
|
20
|
+
* reflection as in-memory evidence while the emitted Carbon wire stores WGSL
|
|
21
|
+
* or empty program slots plus representable non-program fields. Filesystem
|
|
22
|
+
* concerns remain in callers.
|
|
23
|
+
*
|
|
24
|
+
* @param {Uint8Array|ArrayBuffer|ArrayBufferView} input Compiled effect bytes.
|
|
25
|
+
* @param {object} [options] Source, body-mode, permutation, and stage-selection policy.
|
|
26
|
+
* @returns {object} Package bytes plus inspection and provenance documents.
|
|
27
27
|
*/
|
|
28
28
|
function buildEffectPackage(input, options = {}) {
|
|
29
29
|
const mode = normalizeMode(options.mode, options.allPermutations);
|
|
@@ -148,7 +148,6 @@ function buildEffectPackage(input, options = {}) {
|
|
|
148
148
|
translator: DXBC_WGSL_TRANSLATOR_NAME,
|
|
149
149
|
translatorVersion: DXBC_WGSL_TRANSLATOR_VERSION,
|
|
150
150
|
permutationGraph: Object.freeze({
|
|
151
|
-
chunk: EFFECT_PERMUTATION_GRAPH_CHUNK,
|
|
152
151
|
format: EFFECT_PERMUTATION_GRAPH_FORMAT,
|
|
153
152
|
formatVersion: EFFECT_PERMUTATION_GRAPH_VERSION,
|
|
154
153
|
sha256: sha256Utf8(`${JSON.stringify(permutationGraph)}\n`),
|
|
@@ -161,7 +160,6 @@ function buildEffectPackage(input, options = {}) {
|
|
|
161
160
|
} : {}),
|
|
162
161
|
...(backendBodySet ? {
|
|
163
162
|
backendBodySet: Object.freeze({
|
|
164
|
-
chunk: EFFECT_BACKEND_BODY_SET_CHUNK,
|
|
165
163
|
format: EFFECT_BACKEND_BODY_SET_FORMAT,
|
|
166
164
|
formatVersion: EFFECT_BACKEND_BODY_SET_VERSION,
|
|
167
165
|
sha256: sha256Utf8(`${JSON.stringify(backendBodySet)}\n`),
|
|
@@ -234,23 +232,23 @@ function buildEffectPackage(input, options = {}) {
|
|
|
234
232
|
});
|
|
235
233
|
}
|
|
236
234
|
|
|
237
|
-
/**
|
|
238
|
-
* Wraps a selected-mode translation as the body set the container emitter takes.
|
|
239
|
-
*
|
|
240
|
-
* `mode: "all"` builds a real body set covering every unique body. `mode:
|
|
241
|
-
* "selected"` translates exactly one, and the container still carries every
|
|
242
|
-
* permutation — that asymmetry is the format working as intended rather than a
|
|
243
|
-
* gap. When the container emitter rebuilds an untranslated body, it retains
|
|
244
|
-
* representable non-program description fields and writes zero-length program
|
|
245
|
-
* slots.
|
|
246
|
-
*
|
|
247
|
-
* So this does not translate anything. It reshapes the one translation already
|
|
248
|
-
* performed into the body-set contract, and marks every other body unsupported.
|
|
249
|
-
*
|
|
250
|
-
* @param {object} permutationGraph Validated permutation graph.
|
|
251
|
-
* @param {object} wgsl Emitted WGSL set for the selected body.
|
|
252
|
-
* @param {number} bodyIndex Selected permutation index.
|
|
253
|
-
* @returns {object} Body set covering one translated body.
|
|
235
|
+
/**
|
|
236
|
+
* Wraps a selected-mode translation as the body set the container emitter takes.
|
|
237
|
+
*
|
|
238
|
+
* `mode: "all"` builds a real body set covering every unique body. `mode:
|
|
239
|
+
* "selected"` translates exactly one, and the container still carries every
|
|
240
|
+
* permutation — that asymmetry is the format working as intended rather than a
|
|
241
|
+
* gap. When the container emitter rebuilds an untranslated body, it retains
|
|
242
|
+
* representable non-program description fields and writes zero-length program
|
|
243
|
+
* slots.
|
|
244
|
+
*
|
|
245
|
+
* So this does not translate anything. It reshapes the one translation already
|
|
246
|
+
* performed into the body-set contract, and marks every other body unsupported.
|
|
247
|
+
*
|
|
248
|
+
* @param {object} permutationGraph Validated permutation graph.
|
|
249
|
+
* @param {object} wgsl Emitted WGSL set for the selected body.
|
|
250
|
+
* @param {number} bodyIndex Selected permutation index.
|
|
251
|
+
* @returns {object} Body set covering one translated body.
|
|
254
252
|
*/
|
|
255
253
|
function selectedModeBodySet(permutationGraph, wgsl, bodyIndex) {
|
|
256
254
|
const selectedBodyKey = permutationGraph.variants.find(variant => variant.permutationIndex === bodyIndex)?.bodyKey ?? permutationGraph.variants[0]?.bodyKey ?? null;
|