@carbonenginejs/runtime-resource 0.17.0 → 0.18.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.
Files changed (89) hide show
  1. package/dist/format/carbonEffect/CjsCarbonEffectWriter.js +16 -4
  2. package/dist/format/carbonEffect/CjsCarbonEffectWriter.js.map +1 -1
  3. package/dist/format/carbonEffect/backendEngineId.js +1 -3
  4. package/dist/format/carbonEffect/backendEngineId.js.map +1 -1
  5. package/dist/format/carbonEffect/buildCarbonEffectContainer.js +11 -1
  6. package/dist/format/carbonEffect/buildCarbonEffectContainer.js.map +1 -1
  7. package/dist/format/carbonEffect/carbonEffectBackendBlock.js +38 -1
  8. package/dist/format/carbonEffect/carbonEffectBackendBlock.js.map +1 -1
  9. package/dist/format/carbonEffect/carbonEffectRecords.js +45 -1
  10. package/dist/format/carbonEffect/carbonEffectRecords.js.map +1 -1
  11. package/dist/format/carbonEffect/carbonEffectResourceTransform.js +120 -60
  12. package/dist/format/carbonEffect/carbonEffectResourceTransform.js.map +1 -1
  13. package/dist/format/effect/effectPermutationGraph.js +46 -29
  14. package/dist/format/effect/effectPermutationGraph.js.map +1 -1
  15. package/dist/format/index.js +1 -1
  16. package/dist/formats/dds/core/helpers.js +35 -6
  17. package/dist/formats/dds/core/helpers.js.map +1 -1
  18. package/dist/formats/hlsl/core/carbonDescriptionToRuntime.js +53 -1
  19. package/dist/formats/hlsl/core/carbonDescriptionToRuntime.js.map +1 -1
  20. package/dist/formats/hlsl/core/detailMapFamily.js +1 -1
  21. package/dist/formats/hlsl/core/detailMapFamily.js.map +1 -1
  22. package/dist/formats/hlsl/core/localLightFamily.js +1 -1
  23. package/dist/formats/hlsl/core/localLightFamily.js.map +1 -1
  24. package/dist/formats/hlsl/core/tr2/shader/HlslEffectBindingManifest.js +10 -1
  25. package/dist/formats/hlsl/core/tr2/shader/HlslEffectBindingManifest.js.map +1 -1
  26. package/dist/formats/index.js +3 -0
  27. package/dist/formats/index.js.map +1 -1
  28. package/dist/formats/schemabound/CjsSchemaBoundFormat.js +236 -0
  29. package/dist/formats/schemabound/CjsSchemaBoundFormat.js.map +1 -0
  30. package/dist/formats/schemabound/core/schemaBoundErrors.js +9 -0
  31. package/dist/formats/schemabound/core/schemaBoundErrors.js.map +1 -0
  32. package/dist/formats/schemabound/core/schemaBoundValues.js +307 -0
  33. package/dist/formats/schemabound/core/schemaBoundValues.js.map +1 -0
  34. package/dist/formats/schemabound/index.js +2 -0
  35. package/dist/formats/schemabound/index.js.map +1 -0
  36. package/dist/formats/sqlite/CjsSqliteFormat.js +244 -0
  37. package/dist/formats/sqlite/CjsSqliteFormat.js.map +1 -0
  38. package/dist/formats/sqlite/core/sqlitePages.js +159 -0
  39. package/dist/formats/sqlite/core/sqlitePages.js.map +1 -0
  40. package/dist/formats/sqlite/core/sqliteRecords.js +174 -0
  41. package/dist/formats/sqlite/core/sqliteRecords.js.map +1 -0
  42. package/dist/formats/sqlite/core/sqliteSchema.js +100 -0
  43. package/dist/formats/sqlite/core/sqliteSchema.js.map +1 -0
  44. package/dist/formats/sqlite/index.js +2 -0
  45. package/dist/formats/sqlite/index.js.map +1 -0
  46. package/dist/formats/static/CjsStaticFormat.js +220 -0
  47. package/dist/formats/static/CjsStaticFormat.js.map +1 -0
  48. package/dist/formats/static/index.js +2 -0
  49. package/dist/formats/static/index.js.map +1 -0
  50. package/dist/formats/webgl/core/buildGlslEffectContainer.js +3 -1
  51. package/dist/formats/webgl/core/buildGlslEffectContainer.js.map +1 -1
  52. package/dist/formats/webgl/core/effectPackage.js +13 -5
  53. package/dist/formats/webgl/core/effectPackage.js.map +1 -1
  54. package/dist/formats/webgl/core/glsl/DxbcGlslEmitter.js +10 -2
  55. package/dist/formats/webgl/core/glsl/DxbcGlslEmitter.js.map +1 -1
  56. package/dist/formats/webgl/core/glslBackendBlock.js +6 -5
  57. package/dist/formats/webgl/core/glslBackendBlock.js.map +1 -1
  58. package/dist/formats/webgl/core/glslBackendBodySet.js +0 -1
  59. package/dist/formats/webgl/core/glslBackendBodySet.js.map +1 -1
  60. package/dist/formats/webgpu/CjsWebgpuFormat.js +161 -163
  61. package/dist/formats/webgpu/CjsWebgpuFormat.js.map +1 -1
  62. package/dist/formats/webgpu/core/buildCarbonEffectContainer.js +3 -1
  63. package/dist/formats/webgpu/core/buildCarbonEffectContainer.js.map +1 -1
  64. package/dist/formats/webgpu/core/carbonWebgpu/containerViews.js +179 -131
  65. package/dist/formats/webgpu/core/carbonWebgpu/containerViews.js.map +1 -1
  66. package/dist/formats/webgpu/core/effectBackendBodySet.js +2 -3
  67. package/dist/formats/webgpu/core/effectBackendBodySet.js.map +1 -1
  68. package/dist/formats/webgpu/core/helpers.js +111 -99
  69. package/dist/formats/webgpu/core/helpers.js.map +1 -1
  70. package/dist/formats/webgpu/core/packageEffect.js +44 -33
  71. package/dist/formats/webgpu/core/packageEffect.js.map +1 -1
  72. package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js +9 -1
  73. package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js.map +1 -1
  74. package/dist/resource/shader/reflection/Tr2EffectStageInput.js +14 -0
  75. package/dist/resource/shader/reflection/Tr2EffectStageInput.js.map +1 -1
  76. package/docs/concepts/shader-resource-model.md +34 -1
  77. package/docs/formats/README.md +21 -0
  78. package/docs/formats/carbon-effect-container.md +54 -27
  79. package/docs/formats/schemabound.md +112 -0
  80. package/docs/formats/static.md +119 -0
  81. package/docs/formats/webgl/README.md +5 -3
  82. package/docs/formats/webgpu/README.md +2 -2
  83. package/docs/formats/webgpu/architecture.md +2 -2
  84. package/docs/formats/webgpu/formats/carbon-webgpu.md +24 -6
  85. package/docs/formats/webgpu/guides/effect-packaging.md +1 -2
  86. package/docs/formats/webgpu/reference/api.md +7 -6
  87. package/docs/formats/webgpu/reference/wgsl-compatibility.md +2 -2
  88. package/docs/reference/classes/formats.md +33 -0
  89. package/package.json +5 -2
@@ -6,41 +6,41 @@ import { buildEffectAnalysis } from '../helpers.js';
6
6
  import { WGSL_SET_VERSION } from '../wgsl/buildWgslSet.js';
7
7
  import { sha256Utf8 } from '../../../../format/effect/sha256.js';
8
8
 
9
- /**
10
- * Derived compatibility views over a container.
11
- *
12
- * The chunk package stored `ANLS` and `WGSL` as documents beside the reflection
13
- * they were computed from, and carried digests to detect the two disagreeing.
14
- * The container stores one document, so these are **views**: functions of the
15
- * records, computed on read. The class of bug the digests guarded cannot occur,
16
- * because there is no second copy to drift.
17
- *
18
- * The analysis view is deliberately not a reimplementation. It runs
19
- * `buildEffectAnalysis` — the same function the packager runs on source — over a
20
- * description rebuilt by `runtimeDescriptionFromCarbon`. That is what keeps the
21
- * view honest: if it were rewritten to emit the fields consumers read today, it
22
- * would be free to drift from the real analysis, and nothing would notice.
23
- * `carbon-analysis-adapter-corpus.test.mjs` diffs the two over every shipped
24
- * permutation and finds zero differences.
25
- *
26
- * These views exist for `engine-webgpu`, which reads format-package JSON for
27
- * Carbon reflection instead of reading `Tr2Shader`. That is a recorded layering
28
- * defect and is not this port's to fix; the views keep it working unchanged
29
- * while the wire format moves underneath it. They go away with that cleanup.
9
+ /**
10
+ * Derived compatibility views over a container.
11
+ *
12
+ * The chunk package stored `ANLS` and `WGSL` as documents beside the reflection
13
+ * they were computed from, and carried digests to detect the two disagreeing.
14
+ * The container stores one document, so these are **views**: functions of the
15
+ * records, computed on read. The class of bug the digests guarded cannot occur,
16
+ * because there is no second copy to drift.
17
+ *
18
+ * The analysis view is deliberately not a reimplementation. It runs
19
+ * `buildEffectAnalysis` — the same function the packager runs on source — over a
20
+ * description rebuilt by `runtimeDescriptionFromCarbon`. That is what keeps the
21
+ * view honest: if it were rewritten to emit the fields consumers read today, it
22
+ * would be free to drift from the real analysis, and nothing would notice.
23
+ * `carbon-analysis-adapter-corpus.test.mjs` diffs the two over every shipped
24
+ * permutation and finds zero differences.
25
+ *
26
+ * These views exist for `engine-webgpu`, which reads format-package JSON for
27
+ * Carbon reflection instead of reading `Tr2Shader`. That is a recorded layering
28
+ * defect and is not this port's to fix; the views keep it working unchanged
29
+ * while the wire format moves underneath it. They go away with that cleanup.
30
30
  */
31
31
 
32
- /**
33
- * Resolves the permutation Carbon's own `GetShader()` would select with no
34
- * option overrides.
35
- *
36
- * Carbon multiplies each axis's default option by the running product of the
37
- * preceding axes' option counts. The chunk package stored a single selected
38
- * body and its index; the container carries every permutation, so the view has
39
- * to name a default rather than inherit one, and Carbon's own default is the
40
- * only defensible choice.
41
- *
42
- * @param {object} container Loaded container.
43
- * @returns {number} Permutation index.
32
+ /**
33
+ * Resolves the permutation Carbon's own `GetShader()` would select with no
34
+ * option overrides.
35
+ *
36
+ * Carbon multiplies each axis's default option by the running product of the
37
+ * preceding axes' option counts. The chunk package stored a single selected
38
+ * body and its index; the container carries every permutation, so the view has
39
+ * to name a default rather than inherit one, and Carbon's own default is the
40
+ * only defensible choice.
41
+ *
42
+ * @param {object} container Loaded container.
43
+ * @returns {number} Permutation index.
44
44
  */
45
45
  function defaultPermutationIndex(container) {
46
46
  let multiplier = 1;
@@ -52,13 +52,13 @@ function defaultPermutationIndex(container) {
52
52
  return index < container.carbon.records.length ? index : 0;
53
53
  }
54
54
 
55
- /**
56
- * Rebuilds the runtime effect description for one permutation.
57
- *
58
- * @param {object} container Loaded container.
59
- * @param {number} permutationIndex Permutation index.
60
- * @param {string} source Source label.
61
- * @returns {object} Runtime-shaped effect description.
55
+ /**
56
+ * Rebuilds the runtime effect description for one permutation.
57
+ *
58
+ * @param {object} container Loaded container.
59
+ * @param {number} permutationIndex Permutation index.
60
+ * @param {string} source Source label.
61
+ * @returns {object} Runtime-shaped effect description.
62
62
  */
63
63
  function describeRuntime(container, permutationIndex, source) {
64
64
  return runtimeDescriptionFromCarbon(container.GetDescription(permutationIndex), {
@@ -77,25 +77,64 @@ function describeRuntime(container, permutationIndex, source) {
77
77
  });
78
78
  }
79
79
 
80
- /**
81
- * Derives the analysis document for one permutation.
82
- *
83
- * One field is honestly different from the stored `ANLS` it replaces:
84
- * `stages[].shaderBytecode` describes the **WGSL** program the container
85
- * carries, where the stored document described the source DXBC. The container
86
- * does not carry DXBC, so reproducing the old numbers would mean inventing
87
- * them. Nothing in the engine's read surface uses this field; it is a
88
- * diagnostic.
89
- *
90
- * @param {object} container Loaded container.
91
- * @param {object} [options] View options.
92
- * @param {string} [options.source] Source label.
93
- * @param {number} [options.permutationIndex] Permutation to describe.
94
- * @returns {object} Analysis document.
80
+ /**
81
+ * Derives the analysis document for one permutation.
82
+ *
83
+ * One field is honestly different from the stored `ANLS` it replaces:
84
+ * `stages[].shaderBytecode` describes the **WGSL** program the container
85
+ * carries, where the stored document described the source DXBC. The container
86
+ * does not carry DXBC, so reproducing the old numbers would mean inventing
87
+ * them. Nothing in the engine's read surface uses this field; it is a
88
+ * diagnostic.
89
+ *
90
+ * @param {object} container Loaded container.
91
+ * @param {object} [options] View options.
92
+ * @param {string} [options.source] Source label.
93
+ * @param {number} [options.permutationIndex] Permutation to describe.
94
+ * @returns {object} Analysis document.
95
95
  */
96
+ /**
97
+ * Names the option each axis carries for one permutation.
98
+ *
99
+ * The variant's `optionIndices` are the authority; an axis default is only the
100
+ * fallback for an axis the variant does not pin. Shared by the analysis and
101
+ * metadata views so the two cannot describe the same permutation differently.
102
+ *
103
+ * @param {object} container Loaded container.
104
+ * @param {number} permutationIndex Permutation to describe.
105
+ * @returns {Array<{name: string, value: *}>} Selected option per axis.
106
+ */
107
+ function SelectedOptions(container, permutationIndex) {
108
+ const variant = container.permutationGraph?.variants?.[permutationIndex];
109
+ return container.carbon.permutations.map((axis, axisIndex) => {
110
+ const optionIndex = variant?.optionIndices?.[axisIndex] ?? axis.defaultOption;
111
+
112
+ // `optionIndex`, `defaultOption` and `defaultValue` are derived, not
113
+ // stored: the axis carries its options and its default, and the variant
114
+ // carries which option this permutation took. Emitting them lets a
115
+ // consumer see that a selection departs from the defaults without
116
+ // rebuilding the axis table itself.
117
+ //
118
+ // There is deliberately no `source` field. Carbon's build-time resolver
119
+ // records whether a value arrived as "default", "local" or "global"
120
+ // (formats/hlsl/core/metadata.js), and that is who CHOSE the value, not
121
+ // what the value is. The container stores only which permutation was
122
+ // translated, so a permutation that happens to equal the default is
123
+ // indistinguishable from one explicitly requested. Synthesising a
124
+ // plausible `source` here would be inventing build-time policy, which
125
+ // this view already refuses to do for `bodyMode` and `completeness`.
126
+ return {
127
+ name: axis.name.value,
128
+ value: axis.options[optionIndex]?.value ?? null,
129
+ optionIndex,
130
+ defaultOption: axis.defaultOption,
131
+ defaultValue: axis.options[axis.defaultOption]?.value ?? null
132
+ };
133
+ });
134
+ }
96
135
  function deriveAnalysis(container, options = {}) {
97
136
  const source = options.source || container.sourcePath || "memory";
98
- const permutationIndex = options.permutationIndex ?? defaultPermutationIndex(container);
137
+ const permutationIndex = options.permutationIndex ?? resolvedPermutationIndex(container);
99
138
  const effectDescription = describeRuntime(container, permutationIndex, source);
100
139
  return buildEffectAnalysis({
101
140
  effectDescription,
@@ -108,10 +147,13 @@ function deriveAnalysis(container, options = {}) {
108
147
  },
109
148
  selection: {
110
149
  bodyIndex: permutationIndex,
111
- selectedOptions: container.carbon.permutations.map(axis => ({
112
- name: axis.name.value,
113
- value: axis.options[axis.defaultOption]?.value ?? null
114
- }))
150
+ // Report the options of the permutation this view actually
151
+ // resolved, not the axis defaults. Reading `axis.defaultOption`
152
+ // here described permutation zero while `bodyIndex` named another,
153
+ // so a package could report an option enabled in its metadata view
154
+ // and disabled in its analysis view. `deriveMetadata` has always
155
+ // read the variant; this now matches it.
156
+ selectedOptions: SelectedOptions(container, permutationIndex)
115
157
  }
116
158
  }, {
117
159
  source,
@@ -120,21 +162,21 @@ function deriveAnalysis(container, options = {}) {
120
162
  });
121
163
  }
122
164
 
123
- /**
124
- * Derives the WGSL set document for one permutation.
125
- *
126
- * `sourceMap` is absent rather than empty, and that is not an oversight: its
127
- * offsets index DXBC bytes the container does not carry, so it is a translator
128
- * diagnostic and was dropped on write. It was separately measured to suppress
129
- * no sharing, so keeping it would have bought nothing either.
130
- *
131
- * @param {object} container Loaded container.
132
- * @param {object} [options] View options.
133
- * @param {number} [options.permutationIndex] Permutation to describe.
134
- * @returns {object} WGSL set document.
165
+ /**
166
+ * Derives the WGSL set document for one permutation.
167
+ *
168
+ * `sourceMap` is absent rather than empty, and that is not an oversight: its
169
+ * offsets index DXBC bytes the container does not carry, so it is a translator
170
+ * diagnostic and was dropped on write. It was separately measured to suppress
171
+ * no sharing, so keeping it would have bought nothing either.
172
+ *
173
+ * @param {object} container Loaded container.
174
+ * @param {object} [options] View options.
175
+ * @param {number} [options.permutationIndex] Permutation to describe.
176
+ * @returns {object} WGSL set document.
135
177
  */
136
178
  function deriveWgsl(container, options = {}) {
137
- const permutationIndex = options.permutationIndex ?? defaultPermutationIndex(container);
179
+ const permutationIndex = options.permutationIndex ?? resolvedPermutationIndex(container);
138
180
  const body = container.GetBackendBodyPrograms(permutationIndex);
139
181
  const shaders = [];
140
182
  const layouts = [];
@@ -169,21 +211,21 @@ function deriveWgsl(container, options = {}) {
169
211
  };
170
212
  }
171
213
 
172
- /**
173
- * Derives the `WGSB` body-set view the chunk package used to store.
174
- *
175
- * `engine-webgpu` resolves a permutation's translated programs through this,
176
- * which is part of the recorded layering defect -- it should read the shader,
177
- * not a package document. The view keeps that path working unchanged while the
178
- * wire format moves underneath it, and goes away with the cleanup.
179
- *
180
- * Nothing here is stored. A body's status is whether its stages carry programs,
181
- * its passes are the record tree's passes, and a pass unit is that pass's
182
- * shaders and layouts. Bodies are keyed by distinct stored offset, which is
183
- * exactly what Carbon's alias dedupe produces.
184
- *
185
- * @param {object} container Loaded container.
186
- * @returns {object} Body-set document.
214
+ /**
215
+ * Derives the `WGSB` body-set view the chunk package used to store.
216
+ *
217
+ * `engine-webgpu` resolves a permutation's translated programs through this,
218
+ * which is part of the recorded layering defect -- it should read the shader,
219
+ * not a package document. The view keeps that path working unchanged while the
220
+ * wire format moves underneath it, and goes away with the cleanup.
221
+ *
222
+ * Nothing here is stored. A body's status is whether its stages carry programs,
223
+ * its passes are the record tree's passes, and a pass unit is that pass's
224
+ * shaders and layouts. Bodies are keyed by distinct stored offset, which is
225
+ * exactly what Carbon's alias dedupe produces.
226
+ *
227
+ * @param {object} container Loaded container.
228
+ * @returns {object} Body-set document.
187
229
  */
188
230
  function deriveBackendBodySet(container) {
189
231
  const bodyKeys = container.bodyKeyByOffset;
@@ -253,17 +295,28 @@ function deriveBackendBodySet(container) {
253
295
  };
254
296
  }
255
297
 
256
- /**
257
- * Finds the permutation a package resolves to.
258
- *
259
- * A "selected" package is not a different format -- the container always carries
260
- * every permutation. What makes it selected is that exactly one body was
261
- * translated, so the resolved permutation is the first one whose body carries
262
- * programs. When every body is translated, there is nothing to single out and
263
- * Carbon's own default applies.
264
- *
265
- * @param {object} container Loaded container.
266
- * @returns {number} Permutation index.
298
+ /**
299
+ * Finds the permutation a package resolves to.
300
+ *
301
+ * A "selected" package is not a different format -- the container always carries
302
+ * every permutation. What makes it selected is that exactly one body was
303
+ * translated, so the resolved permutation is the first one whose body carries
304
+ * programs. When every body is translated, there is nothing to single out and
305
+ * Carbon's own default applies.
306
+ *
307
+ * This is the default for *every* view, not just this one. The views used to
308
+ * disagree -- analysis and wgsl fell back to `defaultPermutationIndex` while
309
+ * metadata fell back to here -- so a direct caller that omitted an index got
310
+ * documents describing different permutations of the same package. On a
311
+ * selected package those differ: measured on a real QuadV5 package, the default
312
+ * resolves to 0 and the translated body to 4. The public read path never hit it
313
+ * because it resolves one index and passes it to all three; the divergence was
314
+ * only reachable by calling a view directly. Falling back to here can never be
315
+ * worse, because it degrades to Carbon's default in exactly the case where
316
+ * there is no single translated body to prefer.
317
+ *
318
+ * @param {object} container Loaded container.
319
+ * @returns {number} Permutation index.
267
320
  */
268
321
  function resolvedPermutationIndex(container) {
269
322
  const translated = [];
@@ -279,31 +332,26 @@ function resolvedPermutationIndex(container) {
279
332
  return translated.length === 1 ? translated[0] : defaultPermutationIndex(container);
280
333
  }
281
334
 
282
- /**
283
- * Derives the `META`-shaped view the chunk package used to store.
284
- *
285
- * Every field here is recovered from the records rather than carried:
286
- * `selectedOptions` from the resolved permutation's option indices, and
287
- * `wgslSelection` from which passes and stages actually hold programs. Build-time
288
- * *policy* -- `bodyMode`, `sourceIdentity`, `completeness` -- is deliberately not
289
- * here: it describes how the artifact was produced, not what it is, and Carbon
290
- * stores none of it.
291
- *
292
- * @param {object} container Loaded container.
293
- * @param {object} [options] View options.
294
- * @param {string} [options.source] Source label.
295
- * @param {number} [options.permutationIndex] Permutation to describe.
296
- * @returns {object} Metadata document.
335
+ /**
336
+ * Derives the `META`-shaped view the chunk package used to store.
337
+ *
338
+ * Every field here is recovered from the records rather than carried:
339
+ * `selectedOptions` from the resolved permutation's option indices, and
340
+ * `wgslSelection` from which passes and stages actually hold programs. Build-time
341
+ * *policy* -- `bodyMode`, `sourceIdentity`, `completeness` -- is deliberately not
342
+ * here: it describes how the artifact was produced, not what it is, and Carbon
343
+ * stores none of it.
344
+ *
345
+ * @param {object} container Loaded container.
346
+ * @param {object} [options] View options.
347
+ * @param {string} [options.source] Source label.
348
+ * @param {number} [options.permutationIndex] Permutation to describe.
349
+ * @returns {object} Metadata document.
297
350
  */
298
351
  function deriveMetadata(container, options = {}) {
299
352
  const source = options.source || container.sourcePath || "memory";
300
353
  const permutationIndex = options.permutationIndex ?? resolvedPermutationIndex(container);
301
- const variant = container.permutationGraph.variants[permutationIndex];
302
- const axes = container.carbon.permutations;
303
- const selectedOptions = axes.map((axis, axisIndex) => ({
304
- name: axis.name.value,
305
- value: axis.options[variant?.optionIndices?.[axisIndex] ?? axis.defaultOption]?.value ?? null
306
- }));
354
+ const selectedOptions = SelectedOptions(container, permutationIndex);
307
355
  const body = container.GetBackendBodyPrograms(permutationIndex);
308
356
  const selectedStageKeys = (body?.passes ?? []).flatMap(pass => pass.shaders.map(shader => shader.key));
309
357
  const passKeys = (body?.passes ?? []).map(pass => pass.passKey);
@@ -325,17 +373,17 @@ function deriveMetadata(container, options = {}) {
325
373
  };
326
374
  }
327
375
 
328
- /**
329
- * Derives the `INFO`-shaped summary the chunk package used to store.
330
- *
331
- * Everything here is counted from the records rather than trusted from a stored
332
- * field, which is why no digest accompanies it: a count derived from the thing
333
- * it counts cannot disagree with it.
334
- *
335
- * @param {object} container Loaded container.
336
- * @param {object} [options] View options.
337
- * @param {string} [options.source] Source label.
338
- * @returns {object} Info document.
376
+ /**
377
+ * Derives the `INFO`-shaped summary the chunk package used to store.
378
+ *
379
+ * Everything here is counted from the records rather than trusted from a stored
380
+ * field, which is why no digest accompanies it: a count derived from the thing
381
+ * it counts cannot disagree with it.
382
+ *
383
+ * @param {object} container Loaded container.
384
+ * @param {object} [options] View options.
385
+ * @param {string} [options.source] Source label.
386
+ * @returns {object} Info document.
339
387
  */
340
388
  function deriveInfo(container, options = {}) {
341
389
  const source = options.source || container.sourcePath || "memory";
@@ -1 +1 @@
1
- {"version":3,"file":"containerViews.js","sources":["../../../../../../src/formats/webgpu/core/carbonWebgpu/containerViews.js"],"sourcesContent":["import { HlslEffectBindingManifest } from \"../../../hlsl/core/tr2/shader/HlslEffectBindingManifest.js\";\nimport { HlslShaderBytecode } from \"../../../hlsl/core/HlslShaderBytecode.js\";\nimport { hlslShaderStageName } from \"../../../hlsl/core/tr2/HlslRenderContextEnum.js\";\nimport { runtimeDescriptionFromCarbon } from \"../../../hlsl/core/carbonDescriptionToRuntime.js\";\nimport { buildEffectAnalysis } from \"../helpers.js\";\nimport { WGSL_SET_VERSION } from \"../wgsl/buildWgslSet.js\";\nimport { sha256Utf8 } from \"../../../../format/effect/sha256.js\";\n\n/**\n * Derived compatibility views over a container.\n *\n * The chunk package stored `ANLS` and `WGSL` as documents beside the reflection\n * they were computed from, and carried digests to detect the two disagreeing.\n * The container stores one document, so these are **views**: functions of the\n * records, computed on read. The class of bug the digests guarded cannot occur,\n * because there is no second copy to drift.\n *\n * The analysis view is deliberately not a reimplementation. It runs\n * `buildEffectAnalysis` — the same function the packager runs on source — over a\n * description rebuilt by `runtimeDescriptionFromCarbon`. That is what keeps the\n * view honest: if it were rewritten to emit the fields consumers read today, it\n * would be free to drift from the real analysis, and nothing would notice.\n * `carbon-analysis-adapter-corpus.test.mjs` diffs the two over every shipped\n * permutation and finds zero differences.\n *\n * These views exist for `engine-webgpu`, which reads format-package JSON for\n * Carbon reflection instead of reading `Tr2Shader`. That is a recorded layering\n * defect and is not this port's to fix; the views keep it working unchanged\n * while the wire format moves underneath it. They go away with that cleanup.\n */\n\n/**\n * Resolves the permutation Carbon's own `GetShader()` would select with no\n * option overrides.\n *\n * Carbon multiplies each axis's default option by the running product of the\n * preceding axes' option counts. The chunk package stored a single selected\n * body and its index; the container carries every permutation, so the view has\n * to name a default rather than inherit one, and Carbon's own default is the\n * only defensible choice.\n *\n * @param {object} container Loaded container.\n * @returns {number} Permutation index.\n */\nexport function defaultPermutationIndex(container)\n{\n let multiplier = 1;\n let index = 0;\n for (const axis of container.carbon.permutations)\n {\n index += axis.defaultOption * multiplier;\n multiplier *= axis.options.length || 1;\n }\n return index < container.carbon.records.length ? index : 0;\n}\n\n/**\n * Rebuilds the runtime effect description for one permutation.\n *\n * @param {object} container Loaded container.\n * @param {number} permutationIndex Permutation index.\n * @param {string} source Source label.\n * @returns {object} Runtime-shaped effect description.\n */\nfunction describeRuntime(container, permutationIndex, source)\n{\n return runtimeDescriptionFromCarbon(container.GetDescription(permutationIndex), {\n effectName: source,\n version: container.carbon.version,\n bytecodeFor: (stage, stageType) => new HlslShaderBytecode({\n stageType,\n // Carbon's six stage names, not WebGPU's three. A three-entry table\n // reports a geometry stage as null, which the corpus caught.\n stageName: hlslShaderStageName(stageType),\n bytes: stage.shaderData.bytes,\n shaderSize: stage.shaderData.size,\n stringTableOffset: stage.shaderData.offset,\n effectName: source\n })\n });\n}\n\n/**\n * Derives the analysis document for one permutation.\n *\n * One field is honestly different from the stored `ANLS` it replaces:\n * `stages[].shaderBytecode` describes the **WGSL** program the container\n * carries, where the stored document described the source DXBC. The container\n * does not carry DXBC, so reproducing the old numbers would mean inventing\n * them. Nothing in the engine's read surface uses this field; it is a\n * diagnostic.\n *\n * @param {object} container Loaded container.\n * @param {object} [options] View options.\n * @param {string} [options.source] Source label.\n * @param {number} [options.permutationIndex] Permutation to describe.\n * @returns {object} Analysis document.\n */\nexport function deriveAnalysis(container, options = {})\n{\n const source = options.source || container.sourcePath || \"memory\";\n const permutationIndex = options.permutationIndex ?? defaultPermutationIndex(container);\n const effectDescription = describeRuntime(container, permutationIndex, source);\n\n return buildEffectAnalysis({\n effectDescription,\n bindingManifest: HlslEffectBindingManifest.fromEffectDescription(effectDescription, {\n effectName: source\n }),\n effectRes: {\n sourcePath: source,\n m_compilerVersion: null\n },\n selection: {\n bodyIndex: permutationIndex,\n selectedOptions: container.carbon.permutations.map((axis) => ({\n name: axis.name.value,\n value: axis.options[axis.defaultOption]?.value ?? null\n }))\n }\n }, { source, decodeBytecode: false, decodeInstructions: false });\n}\n\n/**\n * Derives the WGSL set document for one permutation.\n *\n * `sourceMap` is absent rather than empty, and that is not an oversight: its\n * offsets index DXBC bytes the container does not carry, so it is a translator\n * diagnostic and was dropped on write. It was separately measured to suppress\n * no sharing, so keeping it would have bought nothing either.\n *\n * @param {object} container Loaded container.\n * @param {object} [options] View options.\n * @param {number} [options.permutationIndex] Permutation to describe.\n * @returns {object} WGSL set document.\n */\nexport function deriveWgsl(container, options = {})\n{\n const permutationIndex = options.permutationIndex ?? defaultPermutationIndex(container);\n const body = container.GetBackendBodyPrograms(permutationIndex);\n const shaders = [];\n const layouts = [];\n const resourceTransforms = [];\n\n for (const pass of body?.passes ?? [])\n {\n for (const shader of pass.shaders)\n {\n shaders.push({\n key: shader.key,\n techniqueName: shader.techniqueName,\n passIndex: shader.passIndex,\n stageName: shader.stageName,\n stage: shader.stage,\n stageType: shader.stageType,\n entryPoint: shader.entryPoint,\n code: shader.code,\n ...(shader.threadGroupSize ? { threadGroupSize: [ ...shader.threadGroupSize ] } : {})\n });\n }\n for (const layout of pass.layouts) layouts.push(layout);\n for (const transform of pass.resourceTransforms ?? []) resourceTransforms.push(transform);\n }\n\n return {\n format: \"CJS_WGSL_SET\",\n formatVersion: WGSL_SET_VERSION,\n shaders,\n layouts,\n ...(resourceTransforms.length ? { resourceTransforms } : {})\n };\n}\n\n/**\n * Derives the `WGSB` body-set view the chunk package used to store.\n *\n * `engine-webgpu` resolves a permutation's translated programs through this,\n * which is part of the recorded layering defect -- it should read the shader,\n * not a package document. The view keeps that path working unchanged while the\n * wire format moves underneath it, and goes away with the cleanup.\n *\n * Nothing here is stored. A body's status is whether its stages carry programs,\n * its passes are the record tree's passes, and a pass unit is that pass's\n * shaders and layouts. Bodies are keyed by distinct stored offset, which is\n * exactly what Carbon's alias dedupe produces.\n *\n * @param {object} container Loaded container.\n * @returns {object} Body-set document.\n */\nexport function deriveBackendBodySet(container)\n{\n const bodyKeys = container.bodyKeyByOffset;\n const passUnits = [];\n const bodies = [];\n const seen = new Set();\n\n for (let index = 0; index < container.carbon.records.length; index += 1)\n {\n const offset = container.carbon.records[index].offset;\n if (seen.has(offset)) continue;\n seen.add(offset);\n\n const bodyKey = bodyKeys.get(offset);\n const body = container.GetBackendBodyPrograms(index);\n\n if (!body || body.status !== \"translated\")\n {\n bodies.push({\n bodyKey,\n representativePermutationIndex: index,\n status: \"unsupported\",\n error: body?.error ?? \"body carries no translated programs\",\n passCount: 0,\n passes: []\n });\n continue;\n }\n\n const passes = [];\n for (const pass of body.passes)\n {\n const unit = {\n key: `unit${passUnits.length}`,\n // Hashed from the unit's own content. The chunk body set stored\n // this digest to detect a unit drifting from what referenced it;\n // derived from the content it identifies, it cannot.\n sha256: sha256Utf8(`${JSON.stringify({\n shaders: pass.shaders,\n layouts: pass.layouts,\n resourceTransforms: pass.resourceTransforms ?? []\n })}\n`),\n wgslSetVersion: WGSL_SET_VERSION,\n shaders: pass.shaders,\n layouts: pass.layouts,\n ...(pass.resourceTransforms?.length\n ? { resourceTransforms: pass.resourceTransforms }\n : {})\n };\n passUnits.push(unit);\n passes.push({ passKey: pass.passKey, unitKey: unit.key });\n }\n\n bodies.push({\n bodyKey,\n representativePermutationIndex: index,\n status: \"translated\",\n error: null,\n passCount: passes.length,\n passes\n });\n }\n\n return {\n format: \"CJS_WGSL_BODY_SET\",\n formatVersion: 1,\n bodyCount: bodies.length,\n translatedBodyCount: bodies.filter((body) => body.status === \"translated\").length,\n passUnitCount: passUnits.length,\n passUnits,\n bodies\n };\n}\n\n/**\n * Finds the permutation a package resolves to.\n *\n * A \"selected\" package is not a different format -- the container always carries\n * every permutation. What makes it selected is that exactly one body was\n * translated, so the resolved permutation is the first one whose body carries\n * programs. When every body is translated, there is nothing to single out and\n * Carbon's own default applies.\n *\n * @param {object} container Loaded container.\n * @returns {number} Permutation index.\n */\nexport function resolvedPermutationIndex(container)\n{\n const translated = [];\n const seen = new Set();\n\n for (let index = 0; index < container.carbon.records.length; index += 1)\n {\n const offset = container.carbon.records[index].offset;\n if (seen.has(offset)) continue;\n seen.add(offset);\n\n const body = container.GetBackendBodyPrograms(index);\n if (body?.status === \"translated\") translated.push(index);\n if (translated.length > 1) return defaultPermutationIndex(container);\n }\n\n return translated.length === 1 ? translated[0] : defaultPermutationIndex(container);\n}\n\n/**\n * Derives the `META`-shaped view the chunk package used to store.\n *\n * Every field here is recovered from the records rather than carried:\n * `selectedOptions` from the resolved permutation's option indices, and\n * `wgslSelection` from which passes and stages actually hold programs. Build-time\n * *policy* -- `bodyMode`, `sourceIdentity`, `completeness` -- is deliberately not\n * here: it describes how the artifact was produced, not what it is, and Carbon\n * stores none of it.\n *\n * @param {object} container Loaded container.\n * @param {object} [options] View options.\n * @param {string} [options.source] Source label.\n * @param {number} [options.permutationIndex] Permutation to describe.\n * @returns {object} Metadata document.\n */\nexport function deriveMetadata(container, options = {})\n{\n const source = options.source || container.sourcePath || \"memory\";\n const permutationIndex = options.permutationIndex ?? resolvedPermutationIndex(container);\n const variant = container.permutationGraph.variants[permutationIndex];\n const axes = container.carbon.permutations;\n\n const selectedOptions = axes.map((axis, axisIndex) => ({\n name: axis.name.value,\n value: axis.options[variant?.optionIndices?.[axisIndex] ?? axis.defaultOption]?.value ?? null\n }));\n\n const body = container.GetBackendBodyPrograms(permutationIndex);\n const selectedStageKeys = (body?.passes ?? [])\n .flatMap((pass) => pass.shaders.map((shader) => shader.key));\n const passKeys = (body?.passes ?? []).map((pass) => pass.passKey);\n\n return {\n effectName: source,\n sourcePath: source,\n bodyIndex: permutationIndex,\n selectedOptions,\n ...(passKeys.length === 1\n ? {\n wgslSelection: {\n mode: \"explicit\",\n completePasses: true,\n techniqueName: passKeys[0].slice(0, passKeys[0].lastIndexOf(\".pass\")),\n passIndex: Number(/\\.pass([0-9]+)$/u.exec(passKeys[0])?.[1] ?? 0),\n requestedStageNames: Array.from(new Set(\n (body?.passes ?? []).flatMap((pass) => pass.shaders.map((shader) => shader.stageName))\n )),\n selectedStageKeys\n }\n }\n : {})\n };\n}\n\n/**\n * Derives the `INFO`-shaped summary the chunk package used to store.\n *\n * Everything here is counted from the records rather than trusted from a stored\n * field, which is why no digest accompanies it: a count derived from the thing\n * it counts cannot disagree with it.\n *\n * @param {object} container Loaded container.\n * @param {object} [options] View options.\n * @param {string} [options.source] Source label.\n * @returns {object} Info document.\n */\nexport function deriveInfo(container, options = {})\n{\n const source = options.source || container.sourcePath || \"memory\";\n const graph = container.permutationGraph;\n return {\n format: \"CARBON_WEBGPU\",\n packageKind: \"tr2-effect-webgpu\",\n sourcePath: source,\n effectVersion: container.carbon.version,\n compilerVersion: [ ...container.carbon.compilerVersion ],\n permutationCount: graph.variants.length,\n uniqueBodyCount: graph.bodies.length\n };\n}\n\nexport default deriveAnalysis;\n"],"names":["defaultPermutationIndex","container","multiplier","index","axis","carbon","permutations","defaultOption","options","length","records","describeRuntime","permutationIndex","source","runtimeDescriptionFromCarbon","GetDescription","effectName","version","bytecodeFor","stage","stageType","HlslShaderBytecode","stageName","hlslShaderStageName","bytes","shaderData","shaderSize","size","stringTableOffset","offset","deriveAnalysis","sourcePath","effectDescription","buildEffectAnalysis","bindingManifest","HlslEffectBindingManifest","fromEffectDescription","effectRes","m_compilerVersion","selection","bodyIndex","selectedOptions","map","name","value","decodeBytecode","decodeInstructions","deriveWgsl","body","GetBackendBodyPrograms","shaders","layouts","resourceTransforms","pass","passes","shader","push","key","techniqueName","passIndex","entryPoint","code","threadGroupSize","layout","transform","format","formatVersion","WGSL_SET_VERSION","deriveBackendBodySet","bodyKeys","bodyKeyByOffset","passUnits","bodies","seen","Set","has","add","bodyKey","get","status","representativePermutationIndex","error","passCount","unit","sha256","sha256Utf8","JSON","stringify","wgslSetVersion","passKey","unitKey","bodyCount","translatedBodyCount","filter","passUnitCount","resolvedPermutationIndex","translated","deriveMetadata","variant","permutationGraph","variants","axes","axisIndex","optionIndices","selectedStageKeys","flatMap","passKeys","wgslSelection","mode","completePasses","slice","lastIndexOf","Number","exec","requestedStageNames","Array","from","deriveInfo","graph","packageKind","effectVersion","compilerVersion","permutationCount","uniqueBodyCount"],"mappings":";;;;;;;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,uBAAuBA,CAACC,SAAS,EACjD;EACI,IAAIC,UAAU,GAAG,CAAC;EAClB,IAAIC,KAAK,GAAG,CAAC;EACb,KAAK,MAAMC,IAAI,IAAIH,SAAS,CAACI,MAAM,CAACC,YAAY,EAChD;AACIH,IAAAA,KAAK,IAAIC,IAAI,CAACG,aAAa,GAAGL,UAAU;AACxCA,IAAAA,UAAU,IAAIE,IAAI,CAACI,OAAO,CAACC,MAAM,IAAI,CAAC;AAC1C,EAAA;AACA,EAAA,OAAON,KAAK,GAAGF,SAAS,CAACI,MAAM,CAACK,OAAO,CAACD,MAAM,GAAGN,KAAK,GAAG,CAAC;AAC9D;;AA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,IAAKA,IAAI,CAACH,OAAO,CAACR,GAAG,CAAEa,MAAM,IAAKA,MAAM,CAACjC,SAAS,CAAC,CACzF,CAAC,CAAC;AACFkF,QAAAA;AACJ;KACH,GACC,EAAE;GACX;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASa,UAAUA,CAACpH,SAAS,EAAEO,OAAO,GAAG,EAAE,EAClD;EACI,MAAMK,MAAM,GAAGL,OAAO,CAACK,MAAM,IAAIZ,SAAS,CAAC8B,UAAU,IAAI,QAAQ;AACjE,EAAA,MAAMuF,KAAK,GAAGrH,SAAS,CAACkG,gBAAgB;EACxC,OAAO;AACHlC,IAAAA,MAAM,EAAE,eAAe;AACvBsD,IAAAA,WAAW,EAAE,mBAAmB;AAChCxF,IAAAA,UAAU,EAAElB,MAAM;AAClB2G,IAAAA,aAAa,EAAEvH,SAAS,CAACI,MAAM,CAACY,OAAO;IACvCwG,eAAe,EAAE,CAAE,GAAGxH,SAAS,CAACI,MAAM,CAACoH,eAAe,CAAE;AACxDC,IAAAA,gBAAgB,EAAEJ,KAAK,CAAClB,QAAQ,CAAC3F,MAAM;AACvCkH,IAAAA,eAAe,EAAEL,KAAK,CAAC9C,MAAM,CAAC/D;GACjC;AACL;;;;"}
1
+ {"version":3,"file":"containerViews.js","sources":["../../../../../../src/formats/webgpu/core/carbonWebgpu/containerViews.js"],"sourcesContent":["import { HlslEffectBindingManifest } from \"../../../hlsl/core/tr2/shader/HlslEffectBindingManifest.js\";\r\nimport { HlslShaderBytecode } from \"../../../hlsl/core/HlslShaderBytecode.js\";\r\nimport { hlslShaderStageName } from \"../../../hlsl/core/tr2/HlslRenderContextEnum.js\";\r\nimport { runtimeDescriptionFromCarbon } from \"../../../hlsl/core/carbonDescriptionToRuntime.js\";\r\nimport { buildEffectAnalysis } from \"../helpers.js\";\r\nimport { WGSL_SET_VERSION } from \"../wgsl/buildWgslSet.js\";\r\nimport { sha256Utf8 } from \"../../../../format/effect/sha256.js\";\r\n\r\n/**\r\n * Derived compatibility views over a container.\r\n *\r\n * The chunk package stored `ANLS` and `WGSL` as documents beside the reflection\r\n * they were computed from, and carried digests to detect the two disagreeing.\r\n * The container stores one document, so these are **views**: functions of the\r\n * records, computed on read. The class of bug the digests guarded cannot occur,\r\n * because there is no second copy to drift.\r\n *\r\n * The analysis view is deliberately not a reimplementation. It runs\r\n * `buildEffectAnalysis` — the same function the packager runs on source — over a\r\n * description rebuilt by `runtimeDescriptionFromCarbon`. That is what keeps the\r\n * view honest: if it were rewritten to emit the fields consumers read today, it\r\n * would be free to drift from the real analysis, and nothing would notice.\r\n * `carbon-analysis-adapter-corpus.test.mjs` diffs the two over every shipped\r\n * permutation and finds zero differences.\r\n *\r\n * These views exist for `engine-webgpu`, which reads format-package JSON for\r\n * Carbon reflection instead of reading `Tr2Shader`. That is a recorded layering\r\n * defect and is not this port's to fix; the views keep it working unchanged\r\n * while the wire format moves underneath it. They go away with that cleanup.\r\n */\r\n\r\n/**\r\n * Resolves the permutation Carbon's own `GetShader()` would select with no\r\n * option overrides.\r\n *\r\n * Carbon multiplies each axis's default option by the running product of the\r\n * preceding axes' option counts. The chunk package stored a single selected\r\n * body and its index; the container carries every permutation, so the view has\r\n * to name a default rather than inherit one, and Carbon's own default is the\r\n * only defensible choice.\r\n *\r\n * @param {object} container Loaded container.\r\n * @returns {number} Permutation index.\r\n */\r\nexport function defaultPermutationIndex(container)\r\n{\r\n let multiplier = 1;\r\n let index = 0;\r\n for (const axis of container.carbon.permutations)\r\n {\r\n index += axis.defaultOption * multiplier;\r\n multiplier *= axis.options.length || 1;\r\n }\r\n return index < container.carbon.records.length ? index : 0;\r\n}\r\n\r\n/**\r\n * Rebuilds the runtime effect description for one permutation.\r\n *\r\n * @param {object} container Loaded container.\r\n * @param {number} permutationIndex Permutation index.\r\n * @param {string} source Source label.\r\n * @returns {object} Runtime-shaped effect description.\r\n */\r\nfunction describeRuntime(container, permutationIndex, source)\r\n{\r\n return runtimeDescriptionFromCarbon(container.GetDescription(permutationIndex), {\r\n effectName: source,\r\n version: container.carbon.version,\r\n bytecodeFor: (stage, stageType) => new HlslShaderBytecode({\r\n stageType,\r\n // Carbon's six stage names, not WebGPU's three. A three-entry table\r\n // reports a geometry stage as null, which the corpus caught.\r\n stageName: hlslShaderStageName(stageType),\r\n bytes: stage.shaderData.bytes,\r\n shaderSize: stage.shaderData.size,\r\n stringTableOffset: stage.shaderData.offset,\r\n effectName: source\r\n })\r\n });\r\n}\r\n\r\n/**\r\n * Derives the analysis document for one permutation.\r\n *\r\n * One field is honestly different from the stored `ANLS` it replaces:\r\n * `stages[].shaderBytecode` describes the **WGSL** program the container\r\n * carries, where the stored document described the source DXBC. The container\r\n * does not carry DXBC, so reproducing the old numbers would mean inventing\r\n * them. Nothing in the engine's read surface uses this field; it is a\r\n * diagnostic.\r\n *\r\n * @param {object} container Loaded container.\r\n * @param {object} [options] View options.\r\n * @param {string} [options.source] Source label.\r\n * @param {number} [options.permutationIndex] Permutation to describe.\r\n * @returns {object} Analysis document.\r\n */\r\n/**\r\n * Names the option each axis carries for one permutation.\r\n *\r\n * The variant's `optionIndices` are the authority; an axis default is only the\r\n * fallback for an axis the variant does not pin. Shared by the analysis and\r\n * metadata views so the two cannot describe the same permutation differently.\r\n *\r\n * @param {object} container Loaded container.\r\n * @param {number} permutationIndex Permutation to describe.\r\n * @returns {Array<{name: string, value: *}>} Selected option per axis.\r\n */\r\nfunction SelectedOptions(container, permutationIndex)\r\n{\r\n const variant = container.permutationGraph?.variants?.[permutationIndex];\r\n\r\n return container.carbon.permutations.map((axis, axisIndex) =>\r\n {\r\n const optionIndex = variant?.optionIndices?.[axisIndex] ?? axis.defaultOption;\r\n\r\n // `optionIndex`, `defaultOption` and `defaultValue` are derived, not\r\n // stored: the axis carries its options and its default, and the variant\r\n // carries which option this permutation took. Emitting them lets a\r\n // consumer see that a selection departs from the defaults without\r\n // rebuilding the axis table itself.\r\n //\r\n // There is deliberately no `source` field. Carbon's build-time resolver\r\n // records whether a value arrived as \"default\", \"local\" or \"global\"\r\n // (formats/hlsl/core/metadata.js), and that is who CHOSE the value, not\r\n // what the value is. The container stores only which permutation was\r\n // translated, so a permutation that happens to equal the default is\r\n // indistinguishable from one explicitly requested. Synthesising a\r\n // plausible `source` here would be inventing build-time policy, which\r\n // this view already refuses to do for `bodyMode` and `completeness`.\r\n return {\r\n name: axis.name.value,\r\n value: axis.options[optionIndex]?.value ?? null,\r\n optionIndex,\r\n defaultOption: axis.defaultOption,\r\n defaultValue: axis.options[axis.defaultOption]?.value ?? null\r\n };\r\n });\r\n}\r\n\r\nexport function deriveAnalysis(container, options = {})\r\n{\r\n const source = options.source || container.sourcePath || \"memory\";\r\n const permutationIndex = options.permutationIndex ?? resolvedPermutationIndex(container);\r\n const effectDescription = describeRuntime(container, permutationIndex, source);\r\n\r\n return buildEffectAnalysis({\r\n effectDescription,\r\n bindingManifest: HlslEffectBindingManifest.fromEffectDescription(effectDescription, {\r\n effectName: source\r\n }),\r\n effectRes: {\r\n sourcePath: source,\r\n m_compilerVersion: null\r\n },\r\n selection: {\r\n bodyIndex: permutationIndex,\r\n // Report the options of the permutation this view actually\r\n // resolved, not the axis defaults. Reading `axis.defaultOption`\r\n // here described permutation zero while `bodyIndex` named another,\r\n // so a package could report an option enabled in its metadata view\r\n // and disabled in its analysis view. `deriveMetadata` has always\r\n // read the variant; this now matches it.\r\n selectedOptions: SelectedOptions(container, permutationIndex)\r\n }\r\n }, { source, decodeBytecode: false, decodeInstructions: false });\r\n}\r\n\r\n/**\r\n * Derives the WGSL set document for one permutation.\r\n *\r\n * `sourceMap` is absent rather than empty, and that is not an oversight: its\r\n * offsets index DXBC bytes the container does not carry, so it is a translator\r\n * diagnostic and was dropped on write. It was separately measured to suppress\r\n * no sharing, so keeping it would have bought nothing either.\r\n *\r\n * @param {object} container Loaded container.\r\n * @param {object} [options] View options.\r\n * @param {number} [options.permutationIndex] Permutation to describe.\r\n * @returns {object} WGSL set document.\r\n */\r\nexport function deriveWgsl(container, options = {})\r\n{\r\n const permutationIndex = options.permutationIndex ?? resolvedPermutationIndex(container);\r\n const body = container.GetBackendBodyPrograms(permutationIndex);\r\n const shaders = [];\r\n const layouts = [];\r\n const resourceTransforms = [];\r\n\r\n for (const pass of body?.passes ?? [])\r\n {\r\n for (const shader of pass.shaders)\r\n {\r\n shaders.push({\r\n key: shader.key,\r\n techniqueName: shader.techniqueName,\r\n passIndex: shader.passIndex,\r\n stageName: shader.stageName,\r\n stage: shader.stage,\r\n stageType: shader.stageType,\r\n entryPoint: shader.entryPoint,\r\n code: shader.code,\r\n ...(shader.threadGroupSize ? { threadGroupSize: [ ...shader.threadGroupSize ] } : {})\r\n });\r\n }\r\n for (const layout of pass.layouts) layouts.push(layout);\r\n for (const transform of pass.resourceTransforms ?? []) resourceTransforms.push(transform);\r\n }\r\n\r\n return {\r\n format: \"CJS_WGSL_SET\",\r\n formatVersion: WGSL_SET_VERSION,\r\n shaders,\r\n layouts,\r\n ...(resourceTransforms.length ? { resourceTransforms } : {})\r\n };\r\n}\r\n\r\n/**\r\n * Derives the `WGSB` body-set view the chunk package used to store.\r\n *\r\n * `engine-webgpu` resolves a permutation's translated programs through this,\r\n * which is part of the recorded layering defect -- it should read the shader,\r\n * not a package document. The view keeps that path working unchanged while the\r\n * wire format moves underneath it, and goes away with the cleanup.\r\n *\r\n * Nothing here is stored. A body's status is whether its stages carry programs,\r\n * its passes are the record tree's passes, and a pass unit is that pass's\r\n * shaders and layouts. Bodies are keyed by distinct stored offset, which is\r\n * exactly what Carbon's alias dedupe produces.\r\n *\r\n * @param {object} container Loaded container.\r\n * @returns {object} Body-set document.\r\n */\r\nexport function deriveBackendBodySet(container)\r\n{\r\n const bodyKeys = container.bodyKeyByOffset;\r\n const passUnits = [];\r\n const bodies = [];\r\n const seen = new Set();\r\n\r\n for (let index = 0; index < container.carbon.records.length; index += 1)\r\n {\r\n const offset = container.carbon.records[index].offset;\r\n if (seen.has(offset)) continue;\r\n seen.add(offset);\r\n\r\n const bodyKey = bodyKeys.get(offset);\r\n const body = container.GetBackendBodyPrograms(index);\r\n\r\n if (!body || body.status !== \"translated\")\r\n {\r\n bodies.push({\r\n bodyKey,\r\n representativePermutationIndex: index,\r\n status: \"unsupported\",\r\n error: body?.error ?? \"body carries no translated programs\",\r\n passCount: 0,\r\n passes: []\r\n });\r\n continue;\r\n }\r\n\r\n const passes = [];\r\n for (const pass of body.passes)\r\n {\r\n const unit = {\r\n key: `unit${passUnits.length}`,\r\n // Hashed from the unit's own content. The chunk body set stored\r\n // this digest to detect a unit drifting from what referenced it;\r\n // derived from the content it identifies, it cannot.\r\n sha256: sha256Utf8(`${JSON.stringify({\r\n shaders: pass.shaders,\r\n layouts: pass.layouts,\r\n resourceTransforms: pass.resourceTransforms ?? []\r\n })}\r\n`),\r\n wgslSetVersion: WGSL_SET_VERSION,\r\n shaders: pass.shaders,\r\n layouts: pass.layouts,\r\n ...(pass.resourceTransforms?.length\r\n ? { resourceTransforms: pass.resourceTransforms }\r\n : {})\r\n };\r\n passUnits.push(unit);\r\n passes.push({ passKey: pass.passKey, unitKey: unit.key });\r\n }\r\n\r\n bodies.push({\r\n bodyKey,\r\n representativePermutationIndex: index,\r\n status: \"translated\",\r\n error: null,\r\n passCount: passes.length,\r\n passes\r\n });\r\n }\r\n\r\n return {\r\n format: \"CJS_WGSL_BODY_SET\",\r\n formatVersion: 1,\r\n bodyCount: bodies.length,\r\n translatedBodyCount: bodies.filter((body) => body.status === \"translated\").length,\r\n passUnitCount: passUnits.length,\r\n passUnits,\r\n bodies\r\n };\r\n}\r\n\r\n/**\r\n * Finds the permutation a package resolves to.\r\n *\r\n * A \"selected\" package is not a different format -- the container always carries\r\n * every permutation. What makes it selected is that exactly one body was\r\n * translated, so the resolved permutation is the first one whose body carries\r\n * programs. When every body is translated, there is nothing to single out and\r\n * Carbon's own default applies.\r\n *\r\n * This is the default for *every* view, not just this one. The views used to\r\n * disagree -- analysis and wgsl fell back to `defaultPermutationIndex` while\r\n * metadata fell back to here -- so a direct caller that omitted an index got\r\n * documents describing different permutations of the same package. On a\r\n * selected package those differ: measured on a real QuadV5 package, the default\r\n * resolves to 0 and the translated body to 4. The public read path never hit it\r\n * because it resolves one index and passes it to all three; the divergence was\r\n * only reachable by calling a view directly. Falling back to here can never be\r\n * worse, because it degrades to Carbon's default in exactly the case where\r\n * there is no single translated body to prefer.\r\n *\r\n * @param {object} container Loaded container.\r\n * @returns {number} Permutation index.\r\n */\r\nexport function resolvedPermutationIndex(container)\r\n{\r\n const translated = [];\r\n const seen = new Set();\r\n\r\n for (let index = 0; index < container.carbon.records.length; index += 1)\r\n {\r\n const offset = container.carbon.records[index].offset;\r\n if (seen.has(offset)) continue;\r\n seen.add(offset);\r\n\r\n const body = container.GetBackendBodyPrograms(index);\r\n if (body?.status === \"translated\") translated.push(index);\r\n if (translated.length > 1) return defaultPermutationIndex(container);\r\n }\r\n\r\n return translated.length === 1 ? translated[0] : defaultPermutationIndex(container);\r\n}\r\n\r\n/**\r\n * Derives the `META`-shaped view the chunk package used to store.\r\n *\r\n * Every field here is recovered from the records rather than carried:\r\n * `selectedOptions` from the resolved permutation's option indices, and\r\n * `wgslSelection` from which passes and stages actually hold programs. Build-time\r\n * *policy* -- `bodyMode`, `sourceIdentity`, `completeness` -- is deliberately not\r\n * here: it describes how the artifact was produced, not what it is, and Carbon\r\n * stores none of it.\r\n *\r\n * @param {object} container Loaded container.\r\n * @param {object} [options] View options.\r\n * @param {string} [options.source] Source label.\r\n * @param {number} [options.permutationIndex] Permutation to describe.\r\n * @returns {object} Metadata document.\r\n */\r\nexport function deriveMetadata(container, options = {})\r\n{\r\n const source = options.source || container.sourcePath || \"memory\";\r\n const permutationIndex = options.permutationIndex ?? resolvedPermutationIndex(container);\r\n const selectedOptions = SelectedOptions(container, permutationIndex);\r\n\r\n const body = container.GetBackendBodyPrograms(permutationIndex);\r\n const selectedStageKeys = (body?.passes ?? [])\r\n .flatMap((pass) => pass.shaders.map((shader) => shader.key));\r\n const passKeys = (body?.passes ?? []).map((pass) => pass.passKey);\r\n\r\n return {\r\n effectName: source,\r\n sourcePath: source,\r\n bodyIndex: permutationIndex,\r\n selectedOptions,\r\n ...(passKeys.length === 1\r\n ? {\r\n wgslSelection: {\r\n mode: \"explicit\",\r\n completePasses: true,\r\n techniqueName: passKeys[0].slice(0, passKeys[0].lastIndexOf(\".pass\")),\r\n passIndex: Number(/\\.pass([0-9]+)$/u.exec(passKeys[0])?.[1] ?? 0),\r\n requestedStageNames: Array.from(new Set(\r\n (body?.passes ?? []).flatMap((pass) => pass.shaders.map((shader) => shader.stageName))\r\n )),\r\n selectedStageKeys\r\n }\r\n }\r\n : {})\r\n };\r\n}\r\n\r\n/**\r\n * Derives the `INFO`-shaped summary the chunk package used to store.\r\n *\r\n * Everything here is counted from the records rather than trusted from a stored\r\n * field, which is why no digest accompanies it: a count derived from the thing\r\n * it counts cannot disagree with it.\r\n *\r\n * @param {object} container Loaded container.\r\n * @param {object} [options] View options.\r\n * @param {string} [options.source] Source label.\r\n * @returns {object} Info document.\r\n */\r\nexport function deriveInfo(container, options = {})\r\n{\r\n const source = options.source || container.sourcePath || \"memory\";\r\n const graph = container.permutationGraph;\r\n return {\r\n format: \"CARBON_WEBGPU\",\r\n packageKind: \"tr2-effect-webgpu\",\r\n sourcePath: source,\r\n effectVersion: container.carbon.version,\r\n compilerVersion: [ ...container.carbon.compilerVersion ],\r\n permutationCount: graph.variants.length,\r\n uniqueBodyCount: graph.bodies.length\r\n };\r\n}\r\n\r\nexport default deriveAnalysis;\r\n"],"names":["defaultPermutationIndex","container","multiplier","index","axis","carbon","permutations","defaultOption","options","length","records","describeRuntime","permutationIndex","source","runtimeDescriptionFromCarbon","GetDescription","effectName","version","bytecodeFor","stage","stageType","HlslShaderBytecode","stageName","hlslShaderStageName","bytes","shaderData","shaderSize","size","stringTableOffset","offset","SelectedOptions","variant","permutationGraph","variants","map","axisIndex","optionIndex","optionIndices","name","value","defaultValue","deriveAnalysis","sourcePath","resolvedPermutationIndex","effectDescription","buildEffectAnalysis","bindingManifest","HlslEffectBindingManifest","fromEffectDescription","effectRes","m_compilerVersion","selection","bodyIndex","selectedOptions","decodeBytecode","decodeInstructions","deriveWgsl","body","GetBackendBodyPrograms","shaders","layouts","resourceTransforms","pass","passes","shader","push","key","techniqueName","passIndex","entryPoint","code","threadGroupSize","layout","transform","format","formatVersion","WGSL_SET_VERSION","deriveBackendBodySet","bodyKeys","bodyKeyByOffset","passUnits","bodies","seen","Set","has","add","bodyKey","get","status","representativePermutationIndex","error","passCount","unit","sha256","sha256Utf8","JSON","stringify","wgslSetVersion","passKey","unitKey","bodyCount","translatedBodyCount","filter","passUnitCount","translated","deriveMetadata","selectedStageKeys","flatMap","passKeys","wgslSelection","mode","completePasses","slice","lastIndexOf","Number","exec","requestedStageNames","Array","from","deriveInfo","graph","packageKind","effectVersion","compilerVersion","permutationCount","uniqueBodyCount"],"mappings":";;;;;;;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,uBAAuBA,CAACC,SAAS,EACjD;EACI,IAAIC,UAAU,GAAG,CAAC;EAClB,IAAIC,KAAK,GAAG,CAAC;EACb,KAAK,MAAMC,IAAI,IAAIH,SAAS,CAACI,MAAM,CAACC,YAAY,EAChD;AACIH,IAAAA,KAAK,IAAIC,IAAI,CAACG,aAAa,GAAGL,UAAU;AACxCA,IAAAA,UAAU,IAAIE,IAAI,CAACI,OAAO,CAACC,MAAM,IAAI,CAAC;AAC1C,EAAA;AACA,EAAA,OAAON,KAAK,GAAGF,SAAS,CAACI,MAAM,CAACK,OAAO,CAACD,MAAM,GAAGN,KAAK,GAAG,CAAC;AAC9D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,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,EAAE8C,MAAM,CAAC,kBAAkB,CAACC,IAAI,CAACP,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;AACjEQ,QAAAA,mBAAmB,EAAEC,KAAK,CAACC,IAAI,CAAC,IAAInC,GAAG,CACnC,CAAC1B,IAAI,EAAEM,MAAM,IAAI,EAAE,EAAE4C,OAAO,CAAE7C,IAAI,IAAKA,IAAI,CAACH,OAAO,CAACzB,GAAG,CAAE8B,MAAM,IAAKA,MAAM,CAAC1C,SAAS,CAAC,CACzF,CAAC,CAAC;AACFoF,QAAAA;AACJ;KACH,GACC,EAAE;GACX;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASa,UAAUA,CAACtH,SAAS,EAAEO,OAAO,GAAG,EAAE,EAClD;EACI,MAAMK,MAAM,GAAGL,OAAO,CAACK,MAAM,IAAIZ,SAAS,CAACyC,UAAU,IAAI,QAAQ;AACjE,EAAA,MAAM8E,KAAK,GAAGvH,SAAS,CAAC+B,gBAAgB;EACxC,OAAO;AACH0C,IAAAA,MAAM,EAAE,eAAe;AACvB+C,IAAAA,WAAW,EAAE,mBAAmB;AAChC/E,IAAAA,UAAU,EAAE7B,MAAM;AAClB6G,IAAAA,aAAa,EAAEzH,SAAS,CAACI,MAAM,CAACY,OAAO;IACvC0G,eAAe,EAAE,CAAE,GAAG1H,SAAS,CAACI,MAAM,CAACsH,eAAe,CAAE;AACxDC,IAAAA,gBAAgB,EAAEJ,KAAK,CAACvF,QAAQ,CAACxB,MAAM;AACvCoH,IAAAA,eAAe,EAAEL,KAAK,CAACvC,MAAM,CAACxE;GACjC;AACL;;;;"}
@@ -12,7 +12,6 @@ import { selectEffectStages } from './packageEffectSelection.js';
12
12
  import { compareUtf8 } from '../../../format/compareUtf8.js';
13
13
  import { isParticleClearEffectCandidate, preflightParticleClearEffectProfile, particleClearEffectProofFor } from './wgsl/lowerParticleClearComputePrograms.js';
14
14
 
15
- const EFFECT_BACKEND_BODY_SET_CHUNK = "WGSB";
16
15
  const EFFECT_BACKEND_BODY_SET_FORMAT = "CJS_WGSL_BODY_SET";
17
16
  const EFFECT_BACKEND_BODY_SET_VERSION = 1;
18
17
 
@@ -167,7 +166,7 @@ function translatePassUnit(pass, programForKey, source, bindingPolicy) {
167
166
  * separately from the same effect; this body-set document does not store it.
168
167
  *
169
168
  * @param {object} effectRes Loaded version-15 `Tr2EffectRes`.
170
- * @param {object} permutationGraph Validated `PGRF` document.
169
+ * @param {object} permutationGraph Validated derived `CJS_EFFECT_PERMUTATION_GRAPH` document (no chunk is stored).
171
170
  * @param {object} [options] Source label, stage selection, and binding policy.
172
171
  * @returns {object} Frozen `CJS_WGSL_BODY_SET` document.
173
172
  */
@@ -302,5 +301,5 @@ function buildEffectBackendBodySet(effectRes, permutationGraph, options = {}) {
302
301
  });
303
302
  }
304
303
 
305
- export { EFFECT_BACKEND_BODY_SET_CHUNK, EFFECT_BACKEND_BODY_SET_FORMAT, EFFECT_BACKEND_BODY_SET_VERSION, buildEffectBackendBodySet };
304
+ export { EFFECT_BACKEND_BODY_SET_FORMAT, EFFECT_BACKEND_BODY_SET_VERSION, buildEffectBackendBodySet };
306
305
  //# sourceMappingURL=effectBackendBodySet.js.map