@carbonenginejs/runtime-resource 0.17.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.
Files changed (29) hide show
  1. package/dist/format/carbonEffect/backendEngineId.js +1 -3
  2. package/dist/format/carbonEffect/backendEngineId.js.map +1 -1
  3. package/dist/format/carbonEffect/carbonEffectBackendBlock.js +2 -1
  4. package/dist/format/carbonEffect/carbonEffectBackendBlock.js.map +1 -1
  5. package/dist/format/carbonEffect/carbonEffectResourceTransform.js +1 -1
  6. package/dist/format/carbonEffect/carbonEffectResourceTransform.js.map +1 -1
  7. package/dist/format/effect/effectPermutationGraph.js +46 -29
  8. package/dist/format/effect/effectPermutationGraph.js.map +1 -1
  9. package/dist/formats/hlsl/core/detailMapFamily.js +1 -1
  10. package/dist/formats/hlsl/core/detailMapFamily.js.map +1 -1
  11. package/dist/formats/hlsl/core/localLightFamily.js +1 -1
  12. package/dist/formats/hlsl/core/localLightFamily.js.map +1 -1
  13. package/dist/formats/webgl/core/effectPackage.js +2 -3
  14. package/dist/formats/webgl/core/effectPackage.js.map +1 -1
  15. package/dist/formats/webgl/core/glslBackendBlock.js +6 -5
  16. package/dist/formats/webgl/core/glslBackendBlock.js.map +1 -1
  17. package/dist/formats/webgl/core/glslBackendBodySet.js +0 -1
  18. package/dist/formats/webgl/core/glslBackendBodySet.js.map +1 -1
  19. package/dist/formats/webgpu/CjsWebgpuFormat.js +161 -163
  20. package/dist/formats/webgpu/CjsWebgpuFormat.js.map +1 -1
  21. package/dist/formats/webgpu/core/effectBackendBodySet.js +21 -22
  22. package/dist/formats/webgpu/core/effectBackendBodySet.js.map +1 -1
  23. package/dist/formats/webgpu/core/helpers.js +111 -99
  24. package/dist/formats/webgpu/core/helpers.js.map +1 -1
  25. package/dist/formats/webgpu/core/packageEffect.js +30 -32
  26. package/dist/formats/webgpu/core/packageEffect.js.map +1 -1
  27. package/docs/formats/webgpu/formats/carbon-webgpu.md +11 -4
  28. package/docs/formats/webgpu/reference/api.md +7 -6
  29. package/package.json +2 -2
@@ -21,9 +21,7 @@ import { CjsFormatReadError } from '../CjsFormatError.js';
21
21
  * varies per effect — which resources became data textures, which detail maps
22
22
  * merged into which array layer, whether local lights were packed or dropped —
23
23
  * and none of that is derivable from the shader.
24
- *
25
- * Authority: `/docs/architecture/effect-read-path.md` § *The block identifies
26
- * itself*.
24
+
27
25
  */
28
26
  const CARBON_BACKEND_ENGINE_ID = Object.freeze({
29
27
  invalid: 0,
@@ -1 +1 @@
1
- {"version":3,"file":"backendEngineId.js","sources":["../../../../src/format/carbonEffect/backendEngineId.js"],"sourcesContent":["import { CjsFormatReadError } from \"../CjsFormatError.js\";\n\n/**\n * Which backend a per-pass block belongs to.\n *\n * The container diverges by backend at exactly one place — the optional\n * per-pass backend block — and until this byte existed a block could not say\n * what it was. Both writers emitted a leading `1` meaning unrelated things, so\n * telling a WebGL2 block from a WebGPU one relied on the caller already knowing,\n * which is not identification.\n *\n * **`0` is deliberately not a backend.** Absent, truncated, or zero-filled data\n * must not read as a valid one; that is the failure mode this byte exists to\n * make impossible.\n *\n * Reserved numbers cost nothing, so they are assigned now rather than argued\n * about later. `webgl1` and `opengl` will most likely never emit a block at\n * all: a backend records one only where its lowering is NOT purely\n * conventional. OpenGL lowered without any such block because the same rule\n * applied to every shader, so the runtime applied it without being told. Ours\n * varies per effect — which resources became data textures, which detail maps\n * merged into which array layer, whether local lights were packed or dropped —\n * and none of that is derivable from the shader.\n *\n * Authority: `/docs/architecture/effect-read-path.md` § *The block identifies\n * itself*.\n */\nexport const CARBON_BACKEND_ENGINE_ID = Object.freeze({\n invalid: 0,\n webgl2: 1,\n webgpu: 2,\n webgl1: 3,\n opengl: 4\n});\n\n/** Wire value to name, for error messages. */\nconst TYPE_NAMES = Object.freeze(\n Object.fromEntries(Object.entries(CARBON_BACKEND_ENGINE_ID).map(([ name, value ]) => [ value, name ]))\n);\n\n/**\n * Reads a block's engine id without consuming it or validating it.\n *\n * This is how a CONTAINER reader stays tolerant. Loading a container must never\n * depend on being able to use its backend blocks: CCP's own dx11, dx12 and metal\n * containers are Carbon-shaped and carry no block at all, and a dx11 container\n * must load here even though nothing in this library can execute its programs.\n * The same must hold for a block belonging to a sibling backend — a WebGPU block\n * met by the WebGL2 reader means \"not for this engine\", not \"corrupt file\".\n *\n * So the container peeks, and only calls the matching parser. The hard failure\n * in `readBackendEngineId` then applies exactly where it should: to a caller\n * that has already committed to parsing this block as a specific backend.\n *\n * @param {Uint8Array} bytes Block bytes.\n * @returns {number} The declared engine id, or `invalid` when unreadable.\n */\nexport function peekBackendEngineId(bytes)\n{\n return bytes && bytes.length ? bytes[0] : CARBON_BACKEND_ENGINE_ID.invalid;\n}\n\n/**\n * Reads and validates a block's leading type byte.\n *\n * A block that does not identify as the backend the caller is parsing is a hard\n * error, never a skip. The caller has already decided which parser to run from\n * the resource path, so a mismatch means the two disagree about what the file\n * is — and continuing would misparse structurally valid bytes into plausible\n * nonsense.\n *\n * No version byte follows. Carbon's container version is the only version.\n *\n * Consumers split two ways, and neither wants one. ccpwgl builds a container and\n * reads it back in the same process (`Tw2EffectRes` calls `buildEffect` then\n * `read` on the result), so writer and reader are always the same build.\n * engine-webgpu's harness does consume a stored file — `--draw-cewgpu <path>` —\n * but that file is a disposable operator-built input regenerated on demand, not\n * a shipped asset, and a skew there already fails at the CONTAINER magic long\n * before any block is parsed. A per-block version would not have caught it.\n *\n * A block from a different build is caught by the trailing-byte check at the end\n * of each reader, and the remedy is to rebuild the package.\n *\n * @param {object} reader Byte reader positioned at the start of the block.\n * @param {number} expected Expected `CARBON_BACKEND_ENGINE_ID` value.\n * @param {string} source Source name for error details.\n * @returns {number} The type that was read.\n */\nexport function readBackendEngineId(reader, expected, source)\n{\n const type = reader.readUint8();\n\n if (type !== expected)\n {\n throw new CjsFormatReadError(\n `Backend block declares type ${type} (${TYPE_NAMES[type] ?? \"unknown\"}) `\n + `but was parsed as ${TYPE_NAMES[expected]}`,\n { source, type, expected }\n );\n }\n\n return type;\n}\n"],"names":["CARBON_BACKEND_ENGINE_ID","Object","freeze","invalid","webgl2","webgpu","webgl1","opengl","TYPE_NAMES","fromEntries","entries","map","name","value","peekBackendEngineId","bytes","length","readBackendEngineId","reader","expected","source","type","readUint8","CjsFormatReadError"],"mappings":";;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACaA,wBAAwB,GAAGC,MAAM,CAACC,MAAM,CAAC;AAClDC,EAAAA,OAAO,EAAE,CAAC;AACVC,EAAAA,MAAM,EAAE,CAAC;AACTC,EAAAA,MAAM,EAAE,CAAC;AACTC,EAAAA,MAAM,EAAE,CAAC;AACTC,EAAAA,MAAM,EAAE;AACZ,CAAC;;AAED;AACA,MAAMC,UAAU,GAAGP,MAAM,CAACC,MAAM,CAC5BD,MAAM,CAACQ,WAAW,CAACR,MAAM,CAACS,OAAO,CAACV,wBAAwB,CAAC,CAACW,GAAG,CAAC,CAAC,CAAEC,IAAI,EAAEC,KAAK,CAAE,KAAK,CAAEA,KAAK,EAAED,IAAI,CAAE,CAAC,CACzG,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,mBAAmBA,CAACC,KAAK,EACzC;AACI,EAAA,OAAOA,KAAK,IAAIA,KAAK,CAACC,MAAM,GAAGD,KAAK,CAAC,CAAC,CAAC,GAAGf,wBAAwB,CAACG,OAAO;AAC9E;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASc,mBAAmBA,CAACC,MAAM,EAAEC,QAAQ,EAAEC,MAAM,EAC5D;AACI,EAAA,MAAMC,IAAI,GAAGH,MAAM,CAACI,SAAS,EAAE;EAE/B,IAAID,IAAI,KAAKF,QAAQ,EACrB;IACI,MAAM,IAAII,kBAAkB,CACxB,CAAA,4BAAA,EAA+BF,IAAI,CAAA,EAAA,EAAKb,UAAU,CAACa,IAAI,CAAC,IAAI,SAAS,CAAA,EAAA,CAAI,GACvE,CAAA,kBAAA,EAAqBb,UAAU,CAACW,QAAQ,CAAC,EAAE,EAC7C;MAAEC,MAAM;MAAEC,IAAI;AAAEF,MAAAA;AAAS,KAC7B,CAAC;AACL,EAAA;AAEA,EAAA,OAAOE,IAAI;AACf;;;;"}
1
+ {"version":3,"file":"backendEngineId.js","sources":["../../../../src/format/carbonEffect/backendEngineId.js"],"sourcesContent":["import { CjsFormatReadError } from \"../CjsFormatError.js\";\n\n/**\n * Which backend a per-pass block belongs to.\n *\n * The container diverges by backend at exactly one place — the optional\n * per-pass backend block — and until this byte existed a block could not say\n * what it was. Both writers emitted a leading `1` meaning unrelated things, so\n * telling a WebGL2 block from a WebGPU one relied on the caller already knowing,\n * which is not identification.\n *\n * **`0` is deliberately not a backend.** Absent, truncated, or zero-filled data\n * must not read as a valid one; that is the failure mode this byte exists to\n * make impossible.\n *\n * Reserved numbers cost nothing, so they are assigned now rather than argued\n * about later. `webgl1` and `opengl` will most likely never emit a block at\n * all: a backend records one only where its lowering is NOT purely\n * conventional. OpenGL lowered without any such block because the same rule\n * applied to every shader, so the runtime applied it without being told. Ours\n * varies per effect — which resources became data textures, which detail maps\n * merged into which array layer, whether local lights were packed or dropped —\n * and none of that is derivable from the shader.\n\n */\nexport const CARBON_BACKEND_ENGINE_ID = Object.freeze({\n invalid: 0,\n webgl2: 1,\n webgpu: 2,\n webgl1: 3,\n opengl: 4\n});\n\n/** Wire value to name, for error messages. */\nconst TYPE_NAMES = Object.freeze(\n Object.fromEntries(Object.entries(CARBON_BACKEND_ENGINE_ID).map(([ name, value ]) => [ value, name ]))\n);\n\n/**\n * Reads a block's engine id without consuming it or validating it.\n *\n * This is how a CONTAINER reader stays tolerant. Loading a container must never\n * depend on being able to use its backend blocks: CCP's own dx11, dx12 and metal\n * containers are Carbon-shaped and carry no block at all, and a dx11 container\n * must load here even though nothing in this library can execute its programs.\n * The same must hold for a block belonging to a sibling backend — a WebGPU block\n * met by the WebGL2 reader means \"not for this engine\", not \"corrupt file\".\n *\n * So the container peeks, and only calls the matching parser. The hard failure\n * in `readBackendEngineId` then applies exactly where it should: to a caller\n * that has already committed to parsing this block as a specific backend.\n *\n * @param {Uint8Array} bytes Block bytes.\n * @returns {number} The declared engine id, or `invalid` when unreadable.\n */\nexport function peekBackendEngineId(bytes)\n{\n return bytes && bytes.length ? bytes[0] : CARBON_BACKEND_ENGINE_ID.invalid;\n}\n\n/**\n * Reads and validates a block's leading type byte.\n *\n * A block that does not identify as the backend the caller is parsing is a hard\n * error, never a skip. The caller has already decided which parser to run from\n * the resource path, so a mismatch means the two disagree about what the file\n * is — and continuing would misparse structurally valid bytes into plausible\n * nonsense.\n *\n * No version byte follows. Carbon's container version is the only version.\n *\n * Consumers split two ways, and neither wants one. ccpwgl builds a container and\n * reads it back in the same process (`Tw2EffectRes` calls `buildEffect` then\n * `read` on the result), so writer and reader are always the same build.\n * engine-webgpu's harness does consume a stored file — `--draw-cewgpu <path>` —\n * but that file is a disposable operator-built input regenerated on demand, not\n * a shipped asset, and a skew there already fails at the CONTAINER magic long\n * before any block is parsed. A per-block version would not have caught it.\n *\n * A block from a different build is caught by the trailing-byte check at the end\n * of each reader, and the remedy is to rebuild the package.\n *\n * @param {object} reader Byte reader positioned at the start of the block.\n * @param {number} expected Expected `CARBON_BACKEND_ENGINE_ID` value.\n * @param {string} source Source name for error details.\n * @returns {number} The type that was read.\n */\nexport function readBackendEngineId(reader, expected, source)\n{\n const type = reader.readUint8();\n\n if (type !== expected)\n {\n throw new CjsFormatReadError(\n `Backend block declares type ${type} (${TYPE_NAMES[type] ?? \"unknown\"}) `\n + `but was parsed as ${TYPE_NAMES[expected]}`,\n { source, type, expected }\n );\n }\n\n return type;\n}\n"],"names":["CARBON_BACKEND_ENGINE_ID","Object","freeze","invalid","webgl2","webgpu","webgl1","opengl","TYPE_NAMES","fromEntries","entries","map","name","value","peekBackendEngineId","bytes","length","readBackendEngineId","reader","expected","source","type","readUint8","CjsFormatReadError"],"mappings":";;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;MACaA,wBAAwB,GAAGC,MAAM,CAACC,MAAM,CAAC;AAClDC,EAAAA,OAAO,EAAE,CAAC;AACVC,EAAAA,MAAM,EAAE,CAAC;AACTC,EAAAA,MAAM,EAAE,CAAC;AACTC,EAAAA,MAAM,EAAE,CAAC;AACTC,EAAAA,MAAM,EAAE;AACZ,CAAC;;AAED;AACA,MAAMC,UAAU,GAAGP,MAAM,CAACC,MAAM,CAC5BD,MAAM,CAACQ,WAAW,CAACR,MAAM,CAACS,OAAO,CAACV,wBAAwB,CAAC,CAACW,GAAG,CAAC,CAAC,CAAEC,IAAI,EAAEC,KAAK,CAAE,KAAK,CAAEA,KAAK,EAAED,IAAI,CAAE,CAAC,CACzG,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,mBAAmBA,CAACC,KAAK,EACzC;AACI,EAAA,OAAOA,KAAK,IAAIA,KAAK,CAACC,MAAM,GAAGD,KAAK,CAAC,CAAC,CAAC,GAAGf,wBAAwB,CAACG,OAAO;AAC9E;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASc,mBAAmBA,CAACC,MAAM,EAAEC,QAAQ,EAAEC,MAAM,EAC5D;AACI,EAAA,MAAMC,IAAI,GAAGH,MAAM,CAACI,SAAS,EAAE;EAE/B,IAAID,IAAI,KAAKF,QAAQ,EACrB;IACI,MAAM,IAAII,kBAAkB,CACxB,CAAA,4BAAA,EAA+BF,IAAI,CAAA,EAAA,EAAKb,UAAU,CAACa,IAAI,CAAC,IAAI,SAAS,CAAA,EAAA,CAAI,GACvE,CAAA,kBAAA,EAAqBb,UAAU,CAACW,QAAQ,CAAC,EAAE,EAC7C;MAAEC,MAAM;MAAEC,IAAI;AAAEF,MAAAA;AAAS,KAC7B,CAAC;AACL,EAAA;AAEA,EAAA,OAAOE,IAAI;AACf;;;;"}
@@ -51,7 +51,8 @@ export { CARBON_BACKEND_TRANSFORM_FAMILY, DETAIL_MAP_ARRAY_DEFAULTS } from './ca
51
51
  * a consumer builds one and reads it back in the same process, so a block from
52
52
  * a different build is caught by the trailing-byte check at the end of the read.
53
53
  *
54
- * Authority: /docs/architecture/effect-read-path.md, the block identifies itself.
54
+ * The identifier is shared with the WebGL2 block rather than duplicated, so the
55
+ * two cannot drift into meaning the same number again.
55
56
  */
56
57
 
57
58
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"carbonEffectBackendBlock.js","sources":["../../../../src/format/carbonEffect/carbonEffectBackendBlock.js"],"sourcesContent":["import { CjsByteWriter } from \"../CjsByteWriter.js\";\nimport { CjsByteReader } from \"../CjsByteReader.js\";\nimport { CjsFormatReadError, CjsFormatWriteError } from \"../CjsFormatError.js\";\nimport {\n CARBON_BACKEND_ENGINE_ID,\n readBackendEngineId\n} from \"./backendEngineId.js\";\nimport {\n CARBON_BACKEND_TRANSFORM_FAMILY,\n DETAIL_MAP_ARRAY_DEFAULTS,\n readInlineString,\n readTransformSection,\n writeInlineString,\n writeTransformSection\n} from \"./carbonEffectResourceTransform.js\";\n\n/**\n * The WebGPU pass block: bind-group layouts plus the shared resource-transform\n * section.\n *\n * Neither is derivable from Carbon reflection. Carbon's `registers[]` is the D3D\n * binding model, while `(group, binding, visibility, generatedSymbol)` comes from\n * the *lowered IR's* bindings. So this is the port's only genuine invention, and\n * it is built entirely from Carbon's own techniques: count-prefixed fixed-width\n * records inside a blob referenced by `{u32 size, u32 offset}`, exactly like\n * program source.\n *\n * Both sections share **one** block rather than occupying two, because the\n * invariant worth keeping is \"the Carbon region is backend-invariant, with\n * exactly one optional trailing block\". They are also mutually required — a\n * transform needs a carrier binding in the same pass's layout and a transformed\n * binding needs a recipe — so one unit is the honest shape.\n *\n * ## Why the block is self-contained\n *\n * The block lives in the arena so that identical layouts dedupe across bodies the\n * way program source does; measured sharing is 30.5:1 at `(body, pass)`\n * granularity, 22 distinct blocks across 672 pairs.\n *\n * That forces one design consequence: **the block cannot contain arena offsets.**\n * An offset is only known after the arena's content sort, and the sort depends on\n * every blob's bytes — including this one. A block referencing the arena would\n * have to be interned before its own contents could be computed. Carbon never\n * meets this because no Carbon arena blob refers to the arena.\n *\n * So strings are inline here, length-prefixed, not interned. The cost is real but\n * small: a repeated `\"t11\"` inside 22 distinct blocks rather than one shared copy.\n * The block itself is what dedupes, and it dedupes 30x.\n */\n\n/**\n * The leading byte is the TARGET ENGINE IDENTIFIER, not a version.\n *\n * It was called CARBON_EFFECT_BACKEND_BLOCK_VERSION and emitted 1, while the\n * WebGL2 writer also emitted 1 meaning something unrelated - so the byte could\n * not do the one job it was there for. Renamed to what it is, and given a\n * distinct value per backend, it identifies the block.\n *\n * Carbon container version remains the only version. Nothing stores this block:\n * a consumer builds one and reads it back in the same process, so a block from\n * a different build is caught by the trailing-byte check at the end of the read.\n *\n * Authority: /docs/architecture/effect-read-path.md, the block identifies itself.\n */\n\n/**\n * Resource kinds, ordered so the wire value is stable\n * (`buildWgslSet.js:117-122`).\n */\nexport const CARBON_BACKEND_RESOURCE_KIND = Object.freeze([\n \"uniform-buffer\",\n \"sampled-resource\",\n \"sampler\",\n \"storage-resource\"\n]);\n\n/** Shader stages, as a bit position in the visibility mask. */\nexport const CARBON_BACKEND_VISIBILITY = Object.freeze([ \"vertex\", \"fragment\", \"compute\" ]);\n\n// The transform section is shared with the GLSL block; both re-export the\n// family enum and defaults so a consumer of either codec sees them.\nexport { CARBON_BACKEND_TRANSFORM_FAMILY, DETAIL_MAP_ARRAY_DEFAULTS };\n\n/** Marks an absent optional `u32`. Carbon's null-reference value. */\nconst ABSENT = 0xffffffff;\n\n/**\n * Encodes a visibility list as a bit mask.\n *\n * @param {string[]} visibility Stage names.\n * @returns {number} Bit mask.\n */\nfunction packVisibility(visibility)\n{\n let mask = 0;\n for (const stage of visibility ?? [])\n {\n const bit = CARBON_BACKEND_VISIBILITY.indexOf(stage);\n if (bit < 0)\n {\n throw new CjsFormatWriteError(`Unknown binding visibility \"${stage}\"`, { stage });\n }\n mask |= 1 << bit;\n }\n return mask;\n}\n\n/**\n * Decodes a visibility bit mask, in the canonical stage order.\n *\n * @param {number} mask Bit mask.\n * @returns {string[]} Stage names.\n */\nfunction unpackVisibility(mask)\n{\n const stages = [];\n for (let bit = 0; bit < CARBON_BACKEND_VISIBILITY.length; bit += 1)\n {\n if (mask & (1 << bit)) stages.push(CARBON_BACKEND_VISIBILITY[bit]);\n }\n return stages;\n}\n\n/**\n * Rebuilds a binding's WebGPU descriptor from what the block does store.\n *\n * The descriptor — `buffer`, `texture` or `sampler` — is not on the wire because\n * it is a pure function of the WGSL type, the resource kind and the structure\n * stride, all three of which are. `lowerBindingLayout.js` derives it from the\n * same three inputs on the way out; this derives it back on the way in.\n *\n * The pairs that could collide do not. `array<u32>` reaches both a structured\n * buffer and a compute typed buffer, and the structure stride separates them:\n * structured always carries one, typed never does.\n *\n * @param {object} binding Decoded binding record.\n * @returns {object} The descriptor fragment, as one `{buffer|texture|sampler}` key.\n */\nfunction deriveBindingDescriptor(binding)\n{\n const stride = binding.structureStride;\n\n if (binding.resourceKind === \"sampler\")\n {\n return { sampler: { type: \"filtering\" } };\n }\n\n if (binding.resourceKind === \"uniform-buffer\")\n {\n const vec4Count = /^array<vec4<f32>, (\\d+)>$/u.exec(binding.type)?.[1];\n if (!vec4Count)\n {\n throw new CjsFormatReadError(\n `Backend block uniform binding has untranslatable type \"${binding.type}\"`,\n { type: binding.type }\n );\n }\n return {\n buffer: {\n type: \"uniform\",\n hasDynamicOffset: false,\n minBindingSize: Number(vec4Count) * 16\n }\n };\n }\n\n if (binding.resourceKind === \"sampled-resource\")\n {\n const texture = TEXTURE_DESCRIPTORS[binding.type];\n if (texture) return { texture: { ...texture } };\n\n return {\n buffer: {\n type: \"read-only-storage\",\n hasDynamicOffset: false,\n minBindingSize: stride === undefined ? 4 : stride\n }\n };\n }\n\n return {\n buffer: {\n type: \"storage\",\n hasDynamicOffset: false,\n minBindingSize: stride === undefined ? 4 : stride\n }\n };\n}\n\n/** Texture descriptors by WGSL type (`lowerBindingLayout.js:90-95`). */\nconst TEXTURE_DESCRIPTORS = Object.freeze({\n \"texture_2d<f32>\": Object.freeze({ sampleType: \"float\", viewDimension: \"2d\", multisampled: false }),\n \"texture_cube<f32>\": Object.freeze({ sampleType: \"float\", viewDimension: \"cube\", multisampled: false }),\n \"texture_3d<f32>\": Object.freeze({ sampleType: \"float\", viewDimension: \"3d\", multisampled: false }),\n \"texture_2d_array<f32>\": Object.freeze({ sampleType: \"float\", viewDimension: \"2d-array\", multisampled: false })\n});\n\n/**\n * Serialises one pass's backend block.\n *\n * @param {object} block Block contents.\n * @param {object[]} [block.bindGroups] Bind groups with their bindings.\n * @param {object[]} [block.transforms] Resource transforms.\n * @returns {Uint8Array} Self-contained block bytes.\n */\nexport function writeBackendBlock(block)\n{\n const bindGroups = block.bindGroups ?? [];\n const transforms = block.transforms ?? [];\n const writer = new CjsByteWriter(256);\n\n writer.u8(CARBON_BACKEND_ENGINE_ID.webgpu);\n\n writer.u8(bindGroups.length);\n for (const group of bindGroups)\n {\n writer.u8(group.group);\n writer.u8(group.bindings.length);\n for (const binding of group.bindings)\n {\n const kind = CARBON_BACKEND_RESOURCE_KIND.indexOf(binding.resourceKind);\n if (kind < 0)\n {\n throw new CjsFormatWriteError(`Unknown resource kind \"${binding.resourceKind}\"`, {\n resourceKind: binding.resourceKind\n });\n }\n writer.u8(kind);\n writer.u8(binding.registerSpace);\n writer.u8(binding.binding);\n writer.u8(packVisibility(binding.visibility));\n writer.u32(binding.registerIndex);\n writer.u32(binding.structureStride ?? ABSENT);\n writer.u8(binding.arrayLayerCount ?? 0);\n writeInlineString(writer, binding.type);\n writeInlineString(writer, binding.generatedSymbol);\n // A binding either carries a transform id or it does not; an empty\n // string is not a legal id, so length zero encodes absence.\n writeInlineString(writer, binding.transformId ?? \"\");\n }\n }\n\n writeTransformSection(writer, transforms);\n\n return writer.toBytes();\n}\n\n/**\n * Parses one pass's backend block, restoring every derived field.\n *\n * @param {ArrayBuffer|ArrayBufferView|Uint8Array} bytes Block bytes.\n * @param {object} [options] Read options.\n * @param {string} [options.layoutKey] Enclosing pass key, restored onto records.\n * @param {string} [options.source] Source name for error details.\n * @returns {object} Block contents with derived fields restored.\n */\nexport function readBackendBlock(bytes, options = {})\n{\n const reader = new CjsByteReader(bytes, { source: options.source ?? \"backend block\" });\n const layoutKey = options.layoutKey ?? null;\n\n readBackendEngineId(reader, CARBON_BACKEND_ENGINE_ID.webgpu, options.source ?? \"backend block\");\n\n const bindGroups = [];\n const groupCount = reader.readUint8();\n for (let groupIndex = 0; groupIndex < groupCount; groupIndex += 1)\n {\n const group = reader.readUint8();\n const bindings = [];\n const bindingCount = reader.readUint8();\n for (let index = 0; index < bindingCount; index += 1)\n {\n const resourceKind = CARBON_BACKEND_RESOURCE_KIND[reader.readUint8()];\n const registerSpace = reader.readUint8();\n const binding = reader.readUint8();\n const visibility = unpackVisibility(reader.readUint8());\n const registerIndex = reader.readUint32();\n const structureStride = reader.readUint32();\n const arrayLayerCount = reader.readUint8();\n const type = readInlineString(reader);\n const generatedSymbol = readInlineString(reader);\n const transformId = readInlineString(reader);\n\n const identity = `${resourceKind}:${registerSpace}:${registerIndex}`;\n const record = {\n group,\n binding,\n resourceKind,\n registerSpace,\n registerIndex,\n visibility,\n type,\n generatedSymbol,\n identity,\n scopeIdentity: `${identity}@${visibility[0]}`,\n ...(structureStride === ABSENT ? {} : { structureStride }),\n ...(arrayLayerCount === 0 ? {} : { arrayLayerCount }),\n ...(transformId === \"\" ? {} : { transformId })\n };\n bindings.push({ ...record, ...deriveBindingDescriptor(record) });\n }\n bindGroups.push({ group, bindings });\n }\n\n const transforms = readTransformSection(reader, layoutKey);\n\n // A sized record must land exactly on its declared end. Trailing bytes mean\n // the writer knew fields this reader does not, which with no version byte is\n // the ONLY signal that a block came from a different build - so this check is\n // load-bearing rather than defensive.\n // This is the only surviving form of a closed-schema check: under a record\n // layout a field either exists at its offset or the read fails, so there is\n // nothing per-field left to assert, but exhaustiveness is still checkable and\n // is exactly what a silently-discarded tail would violate.\n if (reader.remaining !== 0)\n {\n throw new CjsFormatReadError(\n `Backend block has ${reader.remaining} unparsed trailing byte(s); rebuild the effect package`,\n { source: options.source ?? \"backend block\", trailingBytes: reader.remaining }\n );\n }\n\n return {\n layoutKey,\n bindGroups,\n transforms,\n trailingBytes: 0\n };\n}\n"],"names":["CARBON_BACKEND_RESOURCE_KIND","Object","freeze","CARBON_BACKEND_VISIBILITY","ABSENT","packVisibility","visibility","mask","stage","bit","indexOf","CjsFormatWriteError","unpackVisibility","stages","length","push","deriveBindingDescriptor","binding","stride","structureStride","resourceKind","sampler","type","vec4Count","exec","CjsFormatReadError","buffer","hasDynamicOffset","minBindingSize","Number","texture","TEXTURE_DESCRIPTORS","undefined","sampleType","viewDimension","multisampled","writeBackendBlock","block","bindGroups","transforms","writer","CjsByteWriter","u8","CARBON_BACKEND_ENGINE_ID","webgpu","group","bindings","kind","registerSpace","u32","registerIndex","arrayLayerCount","writeInlineString","generatedSymbol","transformId","writeTransformSection","toBytes","readBackendBlock","bytes","options","reader","CjsByteReader","source","layoutKey","readBackendEngineId","groupCount","readUint8","groupIndex","bindingCount","index","readUint32","readInlineString","identity","record","scopeIdentity","readTransformSection","remaining","trailingBytes"],"mappings":";;;;;;;AAgBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,CAACvB,IAAI,CAAC;MAAE8B,KAAK;AAAEC,MAAAA;AAAS,KAAC,CAAC;AACxC,EAAA;AAEA,EAAA,MAAMP,UAAU,GAAGoC,oBAAoB,CAACf,MAAM,EAAEG,SAAS,CAAC;;AAE1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAA,IAAIH,MAAM,CAACgB,SAAS,KAAK,CAAC,EAC1B;IACI,MAAM,IAAInD,kBAAkB,CACxB,CAAA,kBAAA,EAAqBmC,MAAM,CAACgB,SAAS,wDAAwD,EAC7F;AAAEd,MAAAA,MAAM,EAAEH,OAAO,CAACG,MAAM,IAAI,eAAe;MAAEe,aAAa,EAAEjB,MAAM,CAACgB;AAAU,KACjF,CAAC;AACL,EAAA;EAEA,OAAO;IACHb,SAAS;IACTzB,UAAU;IACVC,UAAU;AACVsC,IAAAA,aAAa,EAAE;GAClB;AACL;;;;"}
1
+ {"version":3,"file":"carbonEffectBackendBlock.js","sources":["../../../../src/format/carbonEffect/carbonEffectBackendBlock.js"],"sourcesContent":["import { CjsByteWriter } from \"../CjsByteWriter.js\";\nimport { CjsByteReader } from \"../CjsByteReader.js\";\nimport { CjsFormatReadError, CjsFormatWriteError } from \"../CjsFormatError.js\";\nimport {\n CARBON_BACKEND_ENGINE_ID,\n readBackendEngineId\n} from \"./backendEngineId.js\";\nimport {\n CARBON_BACKEND_TRANSFORM_FAMILY,\n DETAIL_MAP_ARRAY_DEFAULTS,\n readInlineString,\n readTransformSection,\n writeInlineString,\n writeTransformSection\n} from \"./carbonEffectResourceTransform.js\";\n\n/**\n * The WebGPU pass block: bind-group layouts plus the shared resource-transform\n * section.\n *\n * Neither is derivable from Carbon reflection. Carbon's `registers[]` is the D3D\n * binding model, while `(group, binding, visibility, generatedSymbol)` comes from\n * the *lowered IR's* bindings. So this is the port's only genuine invention, and\n * it is built entirely from Carbon's own techniques: count-prefixed fixed-width\n * records inside a blob referenced by `{u32 size, u32 offset}`, exactly like\n * program source.\n *\n * Both sections share **one** block rather than occupying two, because the\n * invariant worth keeping is \"the Carbon region is backend-invariant, with\n * exactly one optional trailing block\". They are also mutually required — a\n * transform needs a carrier binding in the same pass's layout and a transformed\n * binding needs a recipe — so one unit is the honest shape.\n *\n * ## Why the block is self-contained\n *\n * The block lives in the arena so that identical layouts dedupe across bodies the\n * way program source does; measured sharing is 30.5:1 at `(body, pass)`\n * granularity, 22 distinct blocks across 672 pairs.\n *\n * That forces one design consequence: **the block cannot contain arena offsets.**\n * An offset is only known after the arena's content sort, and the sort depends on\n * every blob's bytes — including this one. A block referencing the arena would\n * have to be interned before its own contents could be computed. Carbon never\n * meets this because no Carbon arena blob refers to the arena.\n *\n * So strings are inline here, length-prefixed, not interned. The cost is real but\n * small: a repeated `\"t11\"` inside 22 distinct blocks rather than one shared copy.\n * The block itself is what dedupes, and it dedupes 30x.\n */\n\n/**\n * The leading byte is the TARGET ENGINE IDENTIFIER, not a version.\n *\n * It was called CARBON_EFFECT_BACKEND_BLOCK_VERSION and emitted 1, while the\n * WebGL2 writer also emitted 1 meaning something unrelated - so the byte could\n * not do the one job it was there for. Renamed to what it is, and given a\n * distinct value per backend, it identifies the block.\n *\n * Carbon container version remains the only version. Nothing stores this block:\n * a consumer builds one and reads it back in the same process, so a block from\n * a different build is caught by the trailing-byte check at the end of the read.\n *\n * The identifier is shared with the WebGL2 block rather than duplicated, so the\n * two cannot drift into meaning the same number again.\n */\n\n/**\n * Resource kinds, ordered so the wire value is stable\n * (`buildWgslSet.js:117-122`).\n */\nexport const CARBON_BACKEND_RESOURCE_KIND = Object.freeze([\n \"uniform-buffer\",\n \"sampled-resource\",\n \"sampler\",\n \"storage-resource\"\n]);\n\n/** Shader stages, as a bit position in the visibility mask. */\nexport const CARBON_BACKEND_VISIBILITY = Object.freeze([ \"vertex\", \"fragment\", \"compute\" ]);\n\n// The transform section is shared with the GLSL block; both re-export the\n// family enum and defaults so a consumer of either codec sees them.\nexport { CARBON_BACKEND_TRANSFORM_FAMILY, DETAIL_MAP_ARRAY_DEFAULTS };\n\n/** Marks an absent optional `u32`. Carbon's null-reference value. */\nconst ABSENT = 0xffffffff;\n\n/**\n * Encodes a visibility list as a bit mask.\n *\n * @param {string[]} visibility Stage names.\n * @returns {number} Bit mask.\n */\nfunction packVisibility(visibility)\n{\n let mask = 0;\n for (const stage of visibility ?? [])\n {\n const bit = CARBON_BACKEND_VISIBILITY.indexOf(stage);\n if (bit < 0)\n {\n throw new CjsFormatWriteError(`Unknown binding visibility \"${stage}\"`, { stage });\n }\n mask |= 1 << bit;\n }\n return mask;\n}\n\n/**\n * Decodes a visibility bit mask, in the canonical stage order.\n *\n * @param {number} mask Bit mask.\n * @returns {string[]} Stage names.\n */\nfunction unpackVisibility(mask)\n{\n const stages = [];\n for (let bit = 0; bit < CARBON_BACKEND_VISIBILITY.length; bit += 1)\n {\n if (mask & (1 << bit)) stages.push(CARBON_BACKEND_VISIBILITY[bit]);\n }\n return stages;\n}\n\n/**\n * Rebuilds a binding's WebGPU descriptor from what the block does store.\n *\n * The descriptor — `buffer`, `texture` or `sampler` — is not on the wire because\n * it is a pure function of the WGSL type, the resource kind and the structure\n * stride, all three of which are. `lowerBindingLayout.js` derives it from the\n * same three inputs on the way out; this derives it back on the way in.\n *\n * The pairs that could collide do not. `array<u32>` reaches both a structured\n * buffer and a compute typed buffer, and the structure stride separates them:\n * structured always carries one, typed never does.\n *\n * @param {object} binding Decoded binding record.\n * @returns {object} The descriptor fragment, as one `{buffer|texture|sampler}` key.\n */\nfunction deriveBindingDescriptor(binding)\n{\n const stride = binding.structureStride;\n\n if (binding.resourceKind === \"sampler\")\n {\n return { sampler: { type: \"filtering\" } };\n }\n\n if (binding.resourceKind === \"uniform-buffer\")\n {\n const vec4Count = /^array<vec4<f32>, (\\d+)>$/u.exec(binding.type)?.[1];\n if (!vec4Count)\n {\n throw new CjsFormatReadError(\n `Backend block uniform binding has untranslatable type \"${binding.type}\"`,\n { type: binding.type }\n );\n }\n return {\n buffer: {\n type: \"uniform\",\n hasDynamicOffset: false,\n minBindingSize: Number(vec4Count) * 16\n }\n };\n }\n\n if (binding.resourceKind === \"sampled-resource\")\n {\n const texture = TEXTURE_DESCRIPTORS[binding.type];\n if (texture) return { texture: { ...texture } };\n\n return {\n buffer: {\n type: \"read-only-storage\",\n hasDynamicOffset: false,\n minBindingSize: stride === undefined ? 4 : stride\n }\n };\n }\n\n return {\n buffer: {\n type: \"storage\",\n hasDynamicOffset: false,\n minBindingSize: stride === undefined ? 4 : stride\n }\n };\n}\n\n/** Texture descriptors by WGSL type (`lowerBindingLayout.js:90-95`). */\nconst TEXTURE_DESCRIPTORS = Object.freeze({\n \"texture_2d<f32>\": Object.freeze({ sampleType: \"float\", viewDimension: \"2d\", multisampled: false }),\n \"texture_cube<f32>\": Object.freeze({ sampleType: \"float\", viewDimension: \"cube\", multisampled: false }),\n \"texture_3d<f32>\": Object.freeze({ sampleType: \"float\", viewDimension: \"3d\", multisampled: false }),\n \"texture_2d_array<f32>\": Object.freeze({ sampleType: \"float\", viewDimension: \"2d-array\", multisampled: false })\n});\n\n/**\n * Serialises one pass's backend block.\n *\n * @param {object} block Block contents.\n * @param {object[]} [block.bindGroups] Bind groups with their bindings.\n * @param {object[]} [block.transforms] Resource transforms.\n * @returns {Uint8Array} Self-contained block bytes.\n */\nexport function writeBackendBlock(block)\n{\n const bindGroups = block.bindGroups ?? [];\n const transforms = block.transforms ?? [];\n const writer = new CjsByteWriter(256);\n\n writer.u8(CARBON_BACKEND_ENGINE_ID.webgpu);\n\n writer.u8(bindGroups.length);\n for (const group of bindGroups)\n {\n writer.u8(group.group);\n writer.u8(group.bindings.length);\n for (const binding of group.bindings)\n {\n const kind = CARBON_BACKEND_RESOURCE_KIND.indexOf(binding.resourceKind);\n if (kind < 0)\n {\n throw new CjsFormatWriteError(`Unknown resource kind \"${binding.resourceKind}\"`, {\n resourceKind: binding.resourceKind\n });\n }\n writer.u8(kind);\n writer.u8(binding.registerSpace);\n writer.u8(binding.binding);\n writer.u8(packVisibility(binding.visibility));\n writer.u32(binding.registerIndex);\n writer.u32(binding.structureStride ?? ABSENT);\n writer.u8(binding.arrayLayerCount ?? 0);\n writeInlineString(writer, binding.type);\n writeInlineString(writer, binding.generatedSymbol);\n // A binding either carries a transform id or it does not; an empty\n // string is not a legal id, so length zero encodes absence.\n writeInlineString(writer, binding.transformId ?? \"\");\n }\n }\n\n writeTransformSection(writer, transforms);\n\n return writer.toBytes();\n}\n\n/**\n * Parses one pass's backend block, restoring every derived field.\n *\n * @param {ArrayBuffer|ArrayBufferView|Uint8Array} bytes Block bytes.\n * @param {object} [options] Read options.\n * @param {string} [options.layoutKey] Enclosing pass key, restored onto records.\n * @param {string} [options.source] Source name for error details.\n * @returns {object} Block contents with derived fields restored.\n */\nexport function readBackendBlock(bytes, options = {})\n{\n const reader = new CjsByteReader(bytes, { source: options.source ?? \"backend block\" });\n const layoutKey = options.layoutKey ?? null;\n\n readBackendEngineId(reader, CARBON_BACKEND_ENGINE_ID.webgpu, options.source ?? \"backend block\");\n\n const bindGroups = [];\n const groupCount = reader.readUint8();\n for (let groupIndex = 0; groupIndex < groupCount; groupIndex += 1)\n {\n const group = reader.readUint8();\n const bindings = [];\n const bindingCount = reader.readUint8();\n for (let index = 0; index < bindingCount; index += 1)\n {\n const resourceKind = CARBON_BACKEND_RESOURCE_KIND[reader.readUint8()];\n const registerSpace = reader.readUint8();\n const binding = reader.readUint8();\n const visibility = unpackVisibility(reader.readUint8());\n const registerIndex = reader.readUint32();\n const structureStride = reader.readUint32();\n const arrayLayerCount = reader.readUint8();\n const type = readInlineString(reader);\n const generatedSymbol = readInlineString(reader);\n const transformId = readInlineString(reader);\n\n const identity = `${resourceKind}:${registerSpace}:${registerIndex}`;\n const record = {\n group,\n binding,\n resourceKind,\n registerSpace,\n registerIndex,\n visibility,\n type,\n generatedSymbol,\n identity,\n scopeIdentity: `${identity}@${visibility[0]}`,\n ...(structureStride === ABSENT ? {} : { structureStride }),\n ...(arrayLayerCount === 0 ? {} : { arrayLayerCount }),\n ...(transformId === \"\" ? {} : { transformId })\n };\n bindings.push({ ...record, ...deriveBindingDescriptor(record) });\n }\n bindGroups.push({ group, bindings });\n }\n\n const transforms = readTransformSection(reader, layoutKey);\n\n // A sized record must land exactly on its declared end. Trailing bytes mean\n // the writer knew fields this reader does not, which with no version byte is\n // the ONLY signal that a block came from a different build - so this check is\n // load-bearing rather than defensive.\n // This is the only surviving form of a closed-schema check: under a record\n // layout a field either exists at its offset or the read fails, so there is\n // nothing per-field left to assert, but exhaustiveness is still checkable and\n // is exactly what a silently-discarded tail would violate.\n if (reader.remaining !== 0)\n {\n throw new CjsFormatReadError(\n `Backend block has ${reader.remaining} unparsed trailing byte(s); rebuild the effect package`,\n { source: options.source ?? \"backend block\", trailingBytes: reader.remaining }\n );\n }\n\n return {\n layoutKey,\n bindGroups,\n transforms,\n trailingBytes: 0\n };\n}\n"],"names":["CARBON_BACKEND_RESOURCE_KIND","Object","freeze","CARBON_BACKEND_VISIBILITY","ABSENT","packVisibility","visibility","mask","stage","bit","indexOf","CjsFormatWriteError","unpackVisibility","stages","length","push","deriveBindingDescriptor","binding","stride","structureStride","resourceKind","sampler","type","vec4Count","exec","CjsFormatReadError","buffer","hasDynamicOffset","minBindingSize","Number","texture","TEXTURE_DESCRIPTORS","undefined","sampleType","viewDimension","multisampled","writeBackendBlock","block","bindGroups","transforms","writer","CjsByteWriter","u8","CARBON_BACKEND_ENGINE_ID","webgpu","group","bindings","kind","registerSpace","u32","registerIndex","arrayLayerCount","writeInlineString","generatedSymbol","transformId","writeTransformSection","toBytes","readBackendBlock","bytes","options","reader","CjsByteReader","source","layoutKey","readBackendEngineId","groupCount","readUint8","groupIndex","bindingCount","index","readUint32","readInlineString","identity","record","scopeIdentity","readTransformSection","remaining","trailingBytes"],"mappings":";;;;;;;AAgBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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ACxC,EAAA;AAEA,EAAA,MAAMP,UAAU,GAAGoC,oBAAoB,CAACf,MAAM,EAAEG,SAAS,CAAC;;AAE1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAA,IAAIH,MAAM,CAACgB,SAAS,KAAK,CAAC,EAC1B;IACI,MAAM,IAAInD,kBAAkB,CACxB,CAAA,kBAAA,EAAqBmC,MAAM,CAACgB,SAAS,wDAAwD,EAC7F;AAAEd,MAAAA,MAAM,EAAEH,OAAO,CAACG,MAAM,IAAI,eAAe;MAAEe,aAAa,EAAEjB,MAAM,CAACgB;AAAU,KACjF,CAAC;AACL,EAAA;EAEA,OAAO;IACHb,SAAS;IACTzB,UAAU;IACVC,UAAU;AACVsC,IAAAA,aAAa,EAAE;GAClB;AACL;;;;"}
@@ -9,7 +9,7 @@ import { CjsFormatReadError, CjsFormatWriteError } from '../CjsFormatError.js';
9
9
  * that decision is about the *resources*, not about WGSL or GLSL. Both backends
10
10
  * want the identical merge, for different reasons - WebGPU to reduce binding
11
11
  * churn, WebGL 2 because the family otherwise needs 17 texture units against a
12
- * limit of 16 (docs/contracts/webgl2-texture-budget.md).
12
+ * limit of 16.
13
13
  *
14
14
  * So the section lives here rather than in either backend's block codec, and the
15
15
  * two codecs compose it. A transform written by one backend decodes identically
@@ -1 +1 @@
1
- {"version":3,"file":"carbonEffectResourceTransform.js","sources":["../../../../src/format/carbonEffect/carbonEffectResourceTransform.js"],"sourcesContent":["import { CjsFormatWriteError, CjsFormatReadError } from \"../CjsFormatError.js\";\n\n/**\n * The resource-transform section, shared by every backend's per-pass block.\n *\n * A resource transform is a recipe for building one backend resource out of\n * several Carbon ones. It is deliberately backend-neutral: `detail-map-array`\n * merges `Detail1Map`, `Detail2Map` and `Detail3Map` into one array texture, and\n * that decision is about the *resources*, not about WGSL or GLSL. Both backends\n * want the identical merge, for different reasons - WebGPU to reduce binding\n * churn, WebGL 2 because the family otherwise needs 17 texture units against a\n * limit of 16 (docs/contracts/webgl2-texture-budget.md).\n *\n * So the section lives here rather than in either backend's block codec, and the\n * two codecs compose it. A transform written by one backend decodes identically\n * under the other.\n */\n\n/**\n * Resource-transform families. The discriminator exists so `kind`,\n * `representation`, `missingLayer` and the output name stay derivable without\n * pinning the format to one recognizer: a second family costs an enum value\n * rather than a format version bump.\n */\nexport const CARBON_BACKEND_TRANSFORM_FAMILY = Object.freeze([\n \"detail-map-array\",\n \"local-light-profile-neutral\"\n]);\n\n/** Constants a `detail-map-array` transform restores rather than storing. */\nexport const DETAIL_MAP_ARRAY_DEFAULTS = Object.freeze({\n version: 1,\n kind: \"texture-2d-array\",\n stage: \"fragment\",\n representation: \"native-or-rgba8\",\n missingLayer: \"reject\",\n viewDimension: \"2d-array\",\n outputName: \"DetailArrayMap\"\n});\n\n/**\n * Constants a `local-light-profile-neutral` transform restores rather than\n * storing.\n *\n * Unlike `detail-map-array` this transform has no output resource: its whole\n * content is that an input resource was replaced by a constant. It exists so a\n * described Carbon resource that the backend deliberately dropped is still\n * accounted for - a resource that simply disappears is indistinguishable from\n * one that was lost, and the integrity rules reject that on purpose.\n *\n * `LightProfileArray` is multiplied into a light's attenuation, so the constant\n * is one, not zero. That is the same value the shader's own no-profile path\n * produces, which is why dropping it is neutral rather than dark.\n */\nexport const LOCAL_LIGHT_PROFILE_NEUTRAL_DEFAULTS = Object.freeze({\n version: 1,\n kind: \"constant\",\n stage: \"fragment\",\n representation: \"constant-one\",\n missingLayer: \"ignore\",\n viewDimension: null,\n outputName: null\n});\n\n/**\n * Per-family constant sets, keyed by family name.\n *\n * The reader restores these rather than storing them, so a family that omitted\n * its entry here would silently inherit another family's constants.\n */\nconst TRANSFORM_DEFAULTS_BY_FAMILY = Object.freeze({\n \"detail-map-array\": DETAIL_MAP_ARRAY_DEFAULTS,\n \"local-light-profile-neutral\": LOCAL_LIGHT_PROFILE_NEUTRAL_DEFAULTS\n});\n\n/**\n * Writes a length-prefixed UTF-8 string.\n *\n * @param {object} writer Target byte writer.\n * @param {string} value Text value.\n */\nexport function writeInlineString(writer, value)\n{\n const bytes = new TextEncoder().encode(String(value ?? \"\"));\n if (bytes.length > 0xffff)\n {\n throw new CjsFormatWriteError(\"Backend block string exceeds 65535 bytes\", {\n byteLength: bytes.length\n });\n }\n writer.u16(bytes.length);\n writer.bytes(bytes);\n}\n\n/**\n * Reads a length-prefixed UTF-8 string.\n *\n * @param {object} reader Source byte reader.\n * @returns {string} Decoded text.\n */\nexport function readInlineString(reader)\n{\n const length = reader.readUint16();\n return new TextDecoder(\"utf-8\", { fatal: false }).decode(reader.readRaw(length));\n}\n\n/**\n * Writes the count-prefixed resource-transform section.\n *\n * @param {object} writer Target byte writer.\n * @param {object[]} transforms Resource transforms.\n */\nexport function writeTransformSection(writer, transforms)\n{\n writer.u8(transforms.length);\n\n for (const transform of transforms)\n {\n const family = CARBON_BACKEND_TRANSFORM_FAMILY.indexOf(transform.family ?? \"detail-map-array\");\n if (family < 0)\n {\n throw new CjsFormatWriteError(`Unknown transform family \"${transform.family}\"`, {\n family: transform.family\n });\n }\n writer.u8(family);\n // `id` stays on the wire: a caller may supply it, and it propagates into\n // the engine binding as `transformId`. Deriving it would foreclose the\n // caller-supplied plan path to save four bytes.\n writeInlineString(writer, transform.id);\n writer.u8(transform.inputs.length);\n for (const input of transform.inputs)\n {\n // Array position is the layer. Safe because `parameter` stays on the\n // wire, so layer identity remains cross-checkable rather than\n // asserted by position.\n writer.u8(input.registerSpace);\n writer.u8(input.registerIndex);\n writeInlineString(writer, input.parameter);\n }\n }\n}\n\n/**\n * Reads the count-prefixed resource-transform section, restoring derived fields.\n *\n * @param {object} reader Source byte reader.\n * @param {string|null} layoutKey Enclosing pass key, restored onto records.\n * @returns {object[]} Resource transforms.\n */\nexport function readTransformSection(reader, layoutKey)\n{\n const transforms = [];\n const transformCount = reader.readUint8();\n\n for (let index = 0; index < transformCount; index += 1)\n {\n const family = CARBON_BACKEND_TRANSFORM_FAMILY[reader.readUint8()];\n const defaults = TRANSFORM_DEFAULTS_BY_FAMILY[family];\n if (!defaults)\n {\n throw new CjsFormatReadError(`Transform family \"${family}\" has no restored constants`, {\n family\n });\n }\n const id = readInlineString(reader);\n const inputs = [];\n const inputCount = reader.readUint8();\n for (let layer = 0; layer < inputCount; layer += 1)\n {\n const registerSpace = reader.readUint8();\n const registerIndex = reader.readUint8();\n const parameter = readInlineString(reader);\n const identity = `sampled-resource:${registerSpace}:${registerIndex}`;\n inputs.push({\n parameter,\n layer,\n // Kept alongside the identity they compose: a consumer checking\n // the transform against a binding set compares registers, and\n // re-parsing them back out of the identity string is a second\n // place for the format of that string to matter.\n registerSpace,\n registerIndex,\n identity,\n scopeIdentity: `${identity}@${defaults.stage}`\n });\n }\n\n transforms.push({\n id,\n family,\n version: defaults.version,\n kind: defaults.kind,\n stage: defaults.stage,\n representation: defaults.representation,\n missingLayer: defaults.missingLayer,\n layoutKey,\n inputs,\n output: {\n name: defaults.outputName,\n viewDimension: defaults.viewDimension,\n layerCount: inputs.length,\n identity: inputs[0]?.identity ?? null,\n scopeIdentity: inputs[0]?.scopeIdentity ?? null\n }\n });\n }\n\n return transforms;\n}\n"],"names":["CARBON_BACKEND_TRANSFORM_FAMILY","Object","freeze","DETAIL_MAP_ARRAY_DEFAULTS","version","kind","stage","representation","missingLayer","viewDimension","outputName","LOCAL_LIGHT_PROFILE_NEUTRAL_DEFAULTS","TRANSFORM_DEFAULTS_BY_FAMILY","writeInlineString","writer","value","bytes","TextEncoder","encode","String","length","CjsFormatWriteError","byteLength","u16","readInlineString","reader","readUint16","TextDecoder","fatal","decode","readRaw","writeTransformSection","transforms","u8","transform","family","indexOf","id","inputs","input","registerSpace","registerIndex","parameter","readTransformSection","layoutKey","transformCount","readUint8","index","defaults","CjsFormatReadError","inputCount","layer","identity","push","scopeIdentity","output","name","layerCount"],"mappings":";;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM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a,CAAA,CAAA,EAAIC,aAAa,CAAA,CAAE;MACrEH,MAAM,CAACe,IAAI,CAAC;QACRX,SAAS;QACTS,KAAK;AACL;AACA;AACA;AACA;QACAX,aAAa;QACbC,aAAa;QACbW,QAAQ;AACRE,QAAAA,aAAa,EAAE,CAAA,EAAGF,QAAQ,CAAA,CAAA,EAAIJ,QAAQ,CAAC1C,KAAK,CAAA;AAChD,OAAC,CAAC;AACN,IAAA;IAEA0B,UAAU,CAACqB,IAAI,CAAC;MACZhB,EAAE;MACFF,MAAM;MACN/B,OAAO,EAAE4C,QAAQ,CAAC5C,OAAO;MACzBC,IAAI,EAAE2C,QAAQ,CAAC3C,IAAI;MACnBC,KAAK,EAAE0C,QAAQ,CAAC1C,KAAK;MACrBC,cAAc,EAAEyC,QAAQ,CAACzC,cAAc;MACvCC,YAAY,EAAEwC,QAAQ,CAACxC,YAAY;MACnCoC,SAAS;MACTN,MAAM;AACNiB,MAAAA,MAAM,EAAE;QACJC,IAAI,EAAER,QAAQ,CAACtC,UAAU;QACzBD,aAAa,EAAEuC,QAAQ,CAACvC,aAAa;QACrCgD,UAAU,EAAEnB,MAAM,CAAClB,MAAM;QACzBgC,QAAQ,EAAEd,MAAM,CAAC,CAAC,CAAC,EAAEc,QAAQ,IAAI,IAAI;AACrCE,QAAAA,aAAa,EAAEhB,MAAM,CAAC,CAAC,CAAC,EAAEgB,aAAa,IAAI;AAC/C;AACJ,KAAC,CAAC;AACN,EAAA;AAEA,EAAA,OAAOtB,UAAU;AACrB;;;;"}
1
+ {"version":3,"file":"carbonEffectResourceTransform.js","sources":["../../../../src/format/carbonEffect/carbonEffectResourceTransform.js"],"sourcesContent":["import { CjsFormatWriteError, CjsFormatReadError } from \"../CjsFormatError.js\";\n\n/**\n * The resource-transform section, shared by every backend's per-pass block.\n *\n * A resource transform is a recipe for building one backend resource out of\n * several Carbon ones. It is deliberately backend-neutral: `detail-map-array`\n * merges `Detail1Map`, `Detail2Map` and `Detail3Map` into one array texture, and\n * that decision is about the *resources*, not about WGSL or GLSL. Both backends\n * want the identical merge, for different reasons - WebGPU to reduce binding\n * churn, WebGL 2 because the family otherwise needs 17 texture units against a\n * limit of 16.\n *\n * So the section lives here rather than in either backend's block codec, and the\n * two codecs compose it. A transform written by one backend decodes identically\n * under the other.\n */\n\n/**\n * Resource-transform families. The discriminator exists so `kind`,\n * `representation`, `missingLayer` and the output name stay derivable without\n * pinning the format to one recognizer: a second family costs an enum value\n * rather than a format version bump.\n */\nexport const CARBON_BACKEND_TRANSFORM_FAMILY = Object.freeze([\n \"detail-map-array\",\n \"local-light-profile-neutral\"\n]);\n\n/** Constants a `detail-map-array` transform restores rather than storing. */\nexport const DETAIL_MAP_ARRAY_DEFAULTS = Object.freeze({\n version: 1,\n kind: \"texture-2d-array\",\n stage: \"fragment\",\n representation: \"native-or-rgba8\",\n missingLayer: \"reject\",\n viewDimension: \"2d-array\",\n outputName: \"DetailArrayMap\"\n});\n\n/**\n * Constants a `local-light-profile-neutral` transform restores rather than\n * storing.\n *\n * Unlike `detail-map-array` this transform has no output resource: its whole\n * content is that an input resource was replaced by a constant. It exists so a\n * described Carbon resource that the backend deliberately dropped is still\n * accounted for - a resource that simply disappears is indistinguishable from\n * one that was lost, and the integrity rules reject that on purpose.\n *\n * `LightProfileArray` is multiplied into a light's attenuation, so the constant\n * is one, not zero. That is the same value the shader's own no-profile path\n * produces, which is why dropping it is neutral rather than dark.\n */\nexport const LOCAL_LIGHT_PROFILE_NEUTRAL_DEFAULTS = Object.freeze({\n version: 1,\n kind: \"constant\",\n stage: \"fragment\",\n representation: \"constant-one\",\n missingLayer: \"ignore\",\n viewDimension: null,\n outputName: null\n});\n\n/**\n * Per-family constant sets, keyed by family name.\n *\n * The reader restores these rather than storing them, so a family that omitted\n * its entry here would silently inherit another family's constants.\n */\nconst TRANSFORM_DEFAULTS_BY_FAMILY = Object.freeze({\n \"detail-map-array\": DETAIL_MAP_ARRAY_DEFAULTS,\n \"local-light-profile-neutral\": LOCAL_LIGHT_PROFILE_NEUTRAL_DEFAULTS\n});\n\n/**\n * Writes a length-prefixed UTF-8 string.\n *\n * @param {object} writer Target byte writer.\n * @param {string} value Text value.\n */\nexport function writeInlineString(writer, value)\n{\n const bytes = new TextEncoder().encode(String(value ?? \"\"));\n if (bytes.length > 0xffff)\n {\n throw new CjsFormatWriteError(\"Backend block string exceeds 65535 bytes\", {\n byteLength: bytes.length\n });\n }\n writer.u16(bytes.length);\n writer.bytes(bytes);\n}\n\n/**\n * Reads a length-prefixed UTF-8 string.\n *\n * @param {object} reader Source byte reader.\n * @returns {string} Decoded text.\n */\nexport function readInlineString(reader)\n{\n const length = reader.readUint16();\n return new TextDecoder(\"utf-8\", { fatal: false }).decode(reader.readRaw(length));\n}\n\n/**\n * Writes the count-prefixed resource-transform section.\n *\n * @param {object} writer Target byte writer.\n * @param {object[]} transforms Resource transforms.\n */\nexport function writeTransformSection(writer, transforms)\n{\n writer.u8(transforms.length);\n\n for (const transform of transforms)\n {\n const family = CARBON_BACKEND_TRANSFORM_FAMILY.indexOf(transform.family ?? \"detail-map-array\");\n if (family < 0)\n {\n throw new CjsFormatWriteError(`Unknown transform family \"${transform.family}\"`, {\n family: transform.family\n });\n }\n writer.u8(family);\n // `id` stays on the wire: a caller may supply it, and it propagates into\n // the engine binding as `transformId`. Deriving it would foreclose the\n // caller-supplied plan path to save four bytes.\n writeInlineString(writer, transform.id);\n writer.u8(transform.inputs.length);\n for (const input of transform.inputs)\n {\n // Array position is the layer. Safe because `parameter` stays on the\n // wire, so layer identity remains cross-checkable rather than\n // asserted by position.\n writer.u8(input.registerSpace);\n writer.u8(input.registerIndex);\n writeInlineString(writer, input.parameter);\n }\n }\n}\n\n/**\n * Reads the count-prefixed resource-transform section, restoring derived fields.\n *\n * @param {object} reader Source byte reader.\n * @param {string|null} layoutKey Enclosing pass key, restored onto records.\n * @returns {object[]} Resource transforms.\n */\nexport function readTransformSection(reader, layoutKey)\n{\n const transforms = [];\n const transformCount = reader.readUint8();\n\n for (let index = 0; index < transformCount; index += 1)\n {\n const family = CARBON_BACKEND_TRANSFORM_FAMILY[reader.readUint8()];\n const defaults = TRANSFORM_DEFAULTS_BY_FAMILY[family];\n if (!defaults)\n {\n throw new CjsFormatReadError(`Transform family \"${family}\" has no restored constants`, {\n family\n });\n }\n const id = readInlineString(reader);\n const inputs = [];\n const inputCount = reader.readUint8();\n for (let layer = 0; layer < inputCount; layer += 1)\n {\n const registerSpace = reader.readUint8();\n const registerIndex = reader.readUint8();\n const parameter = readInlineString(reader);\n const identity = `sampled-resource:${registerSpace}:${registerIndex}`;\n inputs.push({\n parameter,\n layer,\n // Kept alongside the identity they compose: a consumer checking\n // the transform against a binding set compares registers, and\n // re-parsing them back out of the identity string is a second\n // place for the format of that string to matter.\n registerSpace,\n registerIndex,\n identity,\n scopeIdentity: `${identity}@${defaults.stage}`\n });\n }\n\n transforms.push({\n id,\n family,\n version: defaults.version,\n kind: defaults.kind,\n stage: defaults.stage,\n representation: defaults.representation,\n missingLayer: defaults.missingLayer,\n layoutKey,\n inputs,\n output: {\n name: defaults.outputName,\n viewDimension: defaults.viewDimension,\n layerCount: inputs.length,\n identity: inputs[0]?.identity ?? null,\n scopeIdentity: inputs[0]?.scopeIdentity ?? null\n }\n });\n }\n\n return transforms;\n}\n"],"names":["CARBON_BACKEND_TRANSFORM_FAMILY","Object","freeze","DETAIL_MAP_ARRAY_DEFAULTS","version","kind","stage","representation","missingLayer","viewDimension","outputName","LOCAL_LIGHT_PROFILE_NEUTRAL_DEFAULTS","TRANSFORM_DEFAULTS_BY_FAMILY","writeInlineString","writer","value","bytes","TextEncoder","encode","String","length","CjsFormatWriteError","byteLength","u16","readInlineString","reader","readUint16","TextDecoder","fatal","decode","readRaw","writeTransformSection","transforms","u8","transform","family","indexOf","id","inputs","input","registerSpace","registerIndex","parameter","readTransformSection","layoutKey","transformCount","readUint8","index","defaults","CjsFormatReadError","inputCount","layer","identity","push","scopeIdentity","output","name","layerCount"],"mappings":";;AAEA;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AMJ,SAAS,GAAGlB,gBAAgB,CAACC,MAAM,CAAC;AAC1C,MAAA,MAAM2B,QAAQ,GAAG,CAAA,iBAAA,EAAoBZ,aAAa,CAAA,CAAA,EAAIC,aAAa,CAAA,CAAE;MACrEH,MAAM,CAACe,IAAI,CAAC;QACRX,SAAS;QACTS,KAAK;AACL;AACA;AACA;AACA;QACAX,aAAa;QACbC,aAAa;QACbW,QAAQ;AACRE,QAAAA,aAAa,EAAE,CAAA,EAAGF,QAAQ,CAAA,CAAA,EAAIJ,QAAQ,CAAC1C,KAAK,CAAA;AAChD,OAAC,CAAC;AACN,IAAA;IAEA0B,UAAU,CAACqB,IAAI,CAAC;MACZhB,EAAE;MACFF,MAAM;MACN/B,OAAO,EAAE4C,QAAQ,CAAC5C,OAAO;MACzBC,IAAI,EAAE2C,QAAQ,CAAC3C,IAAI;MACnBC,KAAK,EAAE0C,QAAQ,CAAC1C,KAAK;MACrBC,cAAc,EAAEyC,QAAQ,CAACzC,cAAc;MACvCC,YAAY,EAAEwC,QAAQ,CAACxC,YAAY;MACnCoC,SAAS;MACTN,MAAM;AACNiB,MAAAA,MAAM,EAAE;QACJC,IAAI,EAAER,QAAQ,CAACtC,UAAU;QACzBD,aAAa,EAAEuC,QAAQ,CAACvC,aAAa;QACrCgD,UAAU,EAAEnB,MAAM,CAAClB,MAAM;QACzBgC,QAAQ,EAAEd,MAAM,CAAC,CAAC,CAAC,EAAEc,QAAQ,IAAI,IAAI;AACrCE,QAAAA,aAAa,EAAEhB,MAAM,CAAC,CAAC,CAAC,EAAEgB,aAAa,IAAI;AAC/C;AACJ,KAAC,CAAC;AACN,EAAA;AAEA,EAAA,OAAOtB,UAAU;AACrB;;;;"}
@@ -1,19 +1,36 @@
1
1
  import { sha256Bytes } from './sha256.js';
2
2
 
3
+ /**
4
+ * The source permutation topology: which permutations exist, and which of them
5
+ * share one body.
6
+ *
7
+ * This module used to model that as the `PGRF` **chunk** - it exported the tag,
8
+ * and every error it raised named it. There are no chunks. A `.carbonwebgpu` or
9
+ * `.carbonwebgl` file is one Carbon v15 record container, and the graph the
10
+ * container publishes is a *view* over the header's own permutation records and
11
+ * offset table, not a stored document beside them. The chunk vocabulary outlived
12
+ * the reader beneath it by weeks precisely because nothing was broken: packages
13
+ * built, ccpwgl rendered, and the only cost was that every error message named a
14
+ * container the file no longer had.
15
+ *
16
+ * The graph is still built here, from the decoded effect resource, because that
17
+ * is where the source topology is known. What is gone is the claim that it is
18
+ * stored anywhere.
19
+ */
20
+
3
21
  const EFFECT_PERMUTATION_GRAPH_FORMAT = "CJS_EFFECT_PERMUTATION_GRAPH";
4
22
  const EFFECT_PERMUTATION_GRAPH_VERSION = 1;
5
- const EFFECT_PERMUTATION_GRAPH_CHUNK = "PGRF";
6
23
  const SHA256 = /^[0-9a-f]{64}$/u;
7
24
  const UINT8_MAX = 0xff;
8
25
  const UINT32_MAX = 0xffffffff;
9
26
  const MAX_EFFECT_PERMUTATIONS = 0x10000;
10
27
 
11
- /**
12
- * Build a complete source permutation topology without claiming that every
13
- * body has portable reflection or backend programs.
14
- *
15
- * @param {object} effectRes Raw format-hlsl effect resource.
16
- * @returns {object} JSON-safe permutation graph.
28
+ /**
29
+ * Build a complete source permutation topology without claiming that every
30
+ * body has portable reflection or backend programs.
31
+ *
32
+ * @param {object} effectRes Raw format-hlsl effect resource.
33
+ * @returns {object} JSON-safe permutation graph.
17
34
  */
18
35
  function buildEffectPermutationGraph(effectRes) {
19
36
  if (!effectRes || typeof effectRes !== "object") {
@@ -83,32 +100,32 @@ function buildEffectPermutationGraph(effectRes) {
83
100
  return graph;
84
101
  }
85
102
 
86
- /**
87
- * Validate a source permutation graph independently of the original effect
88
- * bytes.
89
- *
90
- * @param {object} graph Candidate graph.
91
- * @param {object} [options] Optional source-envelope limits.
92
- * @param {number} [options.sourceByteLength] Exact enclosing source byte length.
93
- * @returns {{permutationCount:number,uniqueBodyCount:number}} Validated counts.
103
+ /**
104
+ * Validate a source permutation graph independently of the original effect
105
+ * bytes.
106
+ *
107
+ * @param {object} graph Candidate graph.
108
+ * @param {object} [options] Optional source-envelope limits.
109
+ * @param {number} [options.sourceByteLength] Exact enclosing source byte length.
110
+ * @returns {{permutationCount:number,uniqueBodyCount:number}} Validated counts.
94
111
  */
95
112
  function validateEffectPermutationGraph(graph, options = {}) {
96
113
  if (!graph || typeof graph !== "object" || Array.isArray(graph) || graph.format !== EFFECT_PERMUTATION_GRAPH_FORMAT || graph.formatVersion !== EFFECT_PERMUTATION_GRAPH_VERSION || !graph.coverage || typeof graph.coverage !== "object" || Array.isArray(graph.coverage) || graph.coverage.permutations !== "complete" || graph.coverage.bodies !== "identity-only" || graph.coverage.reflection !== "absent") {
97
- throw new Error("PGRF schema or coverage is unsupported");
114
+ throw new Error("Effect permutation graph schema or coverage is unsupported");
98
115
  }
99
116
  const axes = validateGraphAxes(graph.axes);
100
117
  const permutationCount = permutationProduct(axes);
101
118
  if (!Array.isArray(graph.variants) || graph.variants.length !== permutationCount) {
102
- throw new Error("PGRF must contain one variant per Cartesian permutation");
119
+ throw new Error("Effect permutation graph must contain one variant per Cartesian permutation");
103
120
  }
104
121
  if (!Array.isArray(graph.bodies) || !graph.bodies.length || graph.bodies.length > graph.variants.length) {
105
- throw new Error("PGRF bodies are malformed");
122
+ throw new Error("Effect permutation graph bodies are malformed");
106
123
  }
107
124
  const bodies = new Map();
108
125
  const bodyDigests = new Set();
109
126
  for (const [bodyIndex, body] of graph.bodies.entries()) {
110
127
  if (!body || typeof body !== "object" || Array.isArray(body) || typeof body.key !== "string" || !body.key || body.key !== body.key.trim() || !Number.isSafeInteger(body.byteLength) || body.byteLength < 1 || body.byteLength > UINT32_MAX || typeof body.sha256 !== "string" || !SHA256.test(body.sha256) || bodies.has(body.key) || bodyDigests.has(body.sha256)) {
111
- throw new Error(`PGRF body ${bodyIndex} is malformed or duplicated`);
128
+ throw new Error(`Effect permutation graph body ${bodyIndex} is malformed or duplicated`);
112
129
  }
113
130
  bodyDigests.add(body.sha256);
114
131
  bodies.set(body.key, {
@@ -121,26 +138,26 @@ function validateEffectPermutationGraph(graph, options = {}) {
121
138
  for (const [permutationIndex, variant] of graph.variants.entries()) {
122
139
  const expectedOptionIndices = decodeOptionIndices(permutationIndex, axes);
123
140
  if (!variant || typeof variant !== "object" || Array.isArray(variant) || variant.permutationIndex !== permutationIndex || !Array.isArray(variant.optionIndices) || variant.optionIndices.length !== expectedOptionIndices.length || variant.optionIndices.some((value, index) => value !== expectedOptionIndices[index]) || typeof variant.bodyKey !== "string" || !bodies.has(variant.bodyKey)) {
124
- throw new Error(`PGRF variant ${permutationIndex} is malformed`);
141
+ throw new Error(`Effect permutation graph variant ${permutationIndex} is malformed`);
125
142
  }
126
143
  const sourceRecord = validateGraphSourceRecord(variant.sourceRecord, permutationIndex, options.sourceByteLength);
127
144
  const body = bodies.get(variant.bodyKey);
128
145
  if (sourceRecord.byteLength !== body.byteLength) {
129
- throw new Error(`PGRF variant ${permutationIndex} body length disagrees`);
146
+ throw new Error(`Effect permutation graph variant ${permutationIndex} body length disagrees`);
130
147
  }
131
148
  const recordKey = `${sourceRecord.offset}:${sourceRecord.byteLength}`;
132
149
  const existingBodyKey = bodyKeyBySourceRecord.get(recordKey);
133
150
  if (existingBodyKey && existingBodyKey !== variant.bodyKey) {
134
- throw new Error(`PGRF source record ${recordKey} maps to multiple bodies`);
151
+ throw new Error(`Effect permutation graph source record ${recordKey} maps to multiple bodies`);
135
152
  }
136
153
  bodyKeyBySourceRecord.set(recordKey, variant.bodyKey);
137
154
  sourceRecords.push(sourceRecord);
138
155
  body.references += 1;
139
156
  }
140
- validateDisjointSourceRecords(sourceRecords, "PGRF source body records partially overlap");
157
+ validateDisjointSourceRecords(sourceRecords, "Effect permutation graph source body records partially overlap");
141
158
  for (const [bodyKey, body] of bodies) {
142
159
  if (!body.references) {
143
- throw new Error(`PGRF body ${bodyKey} is unreferenced`);
160
+ throw new Error(`Effect permutation graph body ${bodyKey} is unreferenced`);
144
161
  }
145
162
  }
146
163
  return Object.freeze({
@@ -177,18 +194,18 @@ function normalizeAxes(value) {
177
194
  }
178
195
  function validateGraphAxes(value) {
179
196
  if (!Array.isArray(value) || value.length > UINT8_MAX) {
180
- throw new Error("PGRF axes must be an array");
197
+ throw new Error("Effect permutation graph axes must be an array");
181
198
  }
182
199
  const names = new Set();
183
200
  return value.map((axis, index) => {
184
201
  if (!axis || typeof axis !== "object" || Array.isArray(axis) || axis.index !== index || typeof axis.name !== "string" || !axis.name || axis.name !== axis.name.trim() || names.has(axis.name) || !Array.isArray(axis.options) || !axis.options.length || axis.options.length > UINT8_MAX || !Number.isSafeInteger(axis.defaultOption) || axis.defaultOption < 0 || axis.defaultOption >= axis.options.length || typeof axis.description !== "string" || !Number.isSafeInteger(axis.type) || axis.type < 0 || axis.type > UINT8_MAX) {
185
- throw new Error(`PGRF axis ${index} is malformed or duplicated`);
202
+ throw new Error(`Effect permutation graph axis ${index} is malformed or duplicated`);
186
203
  }
187
204
  names.add(axis.name);
188
205
  const options = new Set();
189
206
  for (const option of axis.options) {
190
207
  if (typeof option !== "string" || !option || option !== option.trim() || options.has(option)) {
191
- throw new Error(`PGRF axis ${index} options are malformed`);
208
+ throw new Error(`Effect permutation graph axis ${index} options are malformed`);
192
209
  }
193
210
  options.add(option);
194
211
  }
@@ -227,7 +244,7 @@ function validateGraphSourceRecord(record, permutationIndex, sourceByteLength) {
227
244
  const byteLength = record?.byteLength;
228
245
  const end = offset + byteLength;
229
246
  if (!record || typeof record !== "object" || Array.isArray(record) || !Number.isSafeInteger(offset) || offset < 0 || offset > UINT32_MAX || !Number.isSafeInteger(byteLength) || byteLength < 1 || byteLength > UINT32_MAX || !Number.isSafeInteger(end) || sourceByteLength !== undefined && (!Number.isSafeInteger(sourceByteLength) || sourceByteLength < 1 || end > sourceByteLength)) {
230
- throw new Error(`PGRF variant ${permutationIndex} source record is malformed`);
247
+ throw new Error(`Effect permutation graph variant ${permutationIndex} source record is malformed`);
231
248
  }
232
249
  return record;
233
250
  }
@@ -253,5 +270,5 @@ function bytesEqual(left, right) {
253
270
  return left.byteLength === right.byteLength && left.every((value, index) => value === right[index]);
254
271
  }
255
272
 
256
- export { EFFECT_PERMUTATION_GRAPH_CHUNK, EFFECT_PERMUTATION_GRAPH_FORMAT, EFFECT_PERMUTATION_GRAPH_VERSION, buildEffectPermutationGraph, validateEffectPermutationGraph };
273
+ export { EFFECT_PERMUTATION_GRAPH_FORMAT, EFFECT_PERMUTATION_GRAPH_VERSION, buildEffectPermutationGraph, validateEffectPermutationGraph };
257
274
  //# sourceMappingURL=effectPermutationGraph.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"effectPermutationGraph.js","sources":["../../../../src/format/effect/effectPermutationGraph.js"],"sourcesContent":["import { sha256Bytes } from \"./sha256.js\";\n\nexport const EFFECT_PERMUTATION_GRAPH_FORMAT = \"CJS_EFFECT_PERMUTATION_GRAPH\";\nexport const EFFECT_PERMUTATION_GRAPH_VERSION = 1;\nexport const EFFECT_PERMUTATION_GRAPH_CHUNK = \"PGRF\";\n\nconst SHA256 = /^[0-9a-f]{64}$/u;\nconst UINT8_MAX = 0xff;\nconst UINT32_MAX = 0xffffffff;\nconst MAX_EFFECT_PERMUTATIONS = 0x10000;\n\n/**\n * Build a complete source permutation topology without claiming that every\n * body has portable reflection or backend programs.\n *\n * @param {object} effectRes Raw format-hlsl effect resource.\n * @returns {object} JSON-safe permutation graph.\n */\nexport function buildEffectPermutationGraph(effectRes)\n{\n if (!effectRes || typeof effectRes !== \"object\")\n {\n throw new TypeError(\"Effect permutation graph requires a decoded effect resource\");\n }\n\n const sourceBytes = effectRes.m_data;\n if (!(sourceBytes instanceof Uint8Array))\n {\n throw new TypeError(\"Effect permutation graph requires exact source bytes\");\n }\n\n const axes = normalizeAxes(effectRes.m_permutations);\n const permutationCount = permutationProduct(axes);\n const offsets = effectRes.m_offsets;\n if (!Array.isArray(offsets) || offsets.length !== permutationCount\n || effectRes.m_offsetCount !== offsets.length)\n {\n throw new Error(\n \"Effect permutation graph requires one source body record per permutation\"\n );\n }\n\n const sourceRecords = offsets.map((record, permutationIndex) =>\n normalizeSourceRecord(\n record,\n permutationIndex,\n sourceBytes.byteLength\n ));\n validateDisjointSourceRecords(\n sourceRecords,\n \"Effect permutation source body records partially overlap\"\n );\n\n const bodies = [];\n const bodyCandidatesByDigest = new Map();\n const bodyBySourceRecord = new Map();\n const variants = sourceRecords.map((sourceRecord, permutationIndex) =>\n {\n const sourceRecordKey = `${sourceRecord.offset}:${sourceRecord.byteLength}`;\n let body = bodyBySourceRecord.get(sourceRecordKey);\n if (!body)\n {\n const bodyBytes = sourceBytes.subarray(\n sourceRecord.offset,\n sourceRecord.offset + sourceRecord.byteLength\n );\n const digest = sha256Bytes(bodyBytes);\n body = (bodyCandidatesByDigest.get(digest) || [])\n .find((candidate) => bytesEqual(candidate.bytes, bodyBytes));\n if (!body && bodyCandidatesByDigest.has(digest))\n {\n throw new Error(\n \"Effect permutation graph body SHA-256 collision detected\"\n );\n }\n if (!body)\n {\n body = {\n bytes: bodyBytes,\n record: Object.freeze({\n key: `body${bodies.length}`,\n byteLength: bodyBytes.byteLength,\n sha256: digest\n })\n };\n bodyCandidatesByDigest.set(digest, [ body ]);\n bodies.push(body.record);\n }\n bodyBySourceRecord.set(sourceRecordKey, body);\n }\n\n return Object.freeze({\n permutationIndex,\n optionIndices: Object.freeze(decodeOptionIndices(\n permutationIndex,\n axes\n )),\n bodyKey: body.record.key,\n sourceRecord\n });\n });\n\n const graph = Object.freeze({\n format: EFFECT_PERMUTATION_GRAPH_FORMAT,\n formatVersion: EFFECT_PERMUTATION_GRAPH_VERSION,\n coverage: Object.freeze({\n permutations: \"complete\",\n bodies: \"identity-only\",\n reflection: \"absent\"\n }),\n axes: Object.freeze(axes),\n variants: Object.freeze(variants),\n bodies: Object.freeze(bodies)\n });\n\n validateEffectPermutationGraph(graph, {\n sourceByteLength: sourceBytes.byteLength\n });\n return graph;\n}\n\n/**\n * Validate a source permutation graph independently of the original effect\n * bytes.\n *\n * @param {object} graph Candidate graph.\n * @param {object} [options] Optional source-envelope limits.\n * @param {number} [options.sourceByteLength] Exact enclosing source byte length.\n * @returns {{permutationCount:number,uniqueBodyCount:number}} Validated counts.\n */\nexport function validateEffectPermutationGraph(graph, options = {})\n{\n if (!graph || typeof graph !== \"object\" || Array.isArray(graph)\n || graph.format !== EFFECT_PERMUTATION_GRAPH_FORMAT\n || graph.formatVersion !== EFFECT_PERMUTATION_GRAPH_VERSION\n || !graph.coverage || typeof graph.coverage !== \"object\"\n || Array.isArray(graph.coverage)\n || graph.coverage.permutations !== \"complete\"\n || graph.coverage.bodies !== \"identity-only\"\n || graph.coverage.reflection !== \"absent\")\n {\n throw new Error(\"PGRF schema or coverage is unsupported\");\n }\n\n const axes = validateGraphAxes(graph.axes);\n const permutationCount = permutationProduct(axes);\n if (!Array.isArray(graph.variants)\n || graph.variants.length !== permutationCount)\n {\n throw new Error(\n \"PGRF must contain one variant per Cartesian permutation\"\n );\n }\n if (!Array.isArray(graph.bodies)\n || !graph.bodies.length\n || graph.bodies.length > graph.variants.length)\n {\n throw new Error(\"PGRF bodies are malformed\");\n }\n\n const bodies = new Map();\n const bodyDigests = new Set();\n for (const [ bodyIndex, body ] of graph.bodies.entries())\n {\n if (!body || typeof body !== \"object\" || Array.isArray(body)\n || typeof body.key !== \"string\" || !body.key\n || body.key !== body.key.trim()\n || !Number.isSafeInteger(body.byteLength) || body.byteLength < 1\n || body.byteLength > UINT32_MAX\n || typeof body.sha256 !== \"string\" || !SHA256.test(body.sha256)\n || bodies.has(body.key)\n || bodyDigests.has(body.sha256))\n {\n throw new Error(`PGRF body ${bodyIndex} is malformed or duplicated`);\n }\n bodyDigests.add(body.sha256);\n bodies.set(body.key, {\n byteLength: body.byteLength,\n references: 0\n });\n }\n\n const bodyKeyBySourceRecord = new Map();\n const sourceRecords = [];\n for (const [ permutationIndex, variant ] of graph.variants.entries())\n {\n const expectedOptionIndices = decodeOptionIndices(permutationIndex, axes);\n if (!variant || typeof variant !== \"object\" || Array.isArray(variant)\n || variant.permutationIndex !== permutationIndex\n || !Array.isArray(variant.optionIndices)\n || variant.optionIndices.length !== expectedOptionIndices.length\n || variant.optionIndices.some((value, index) =>\n value !== expectedOptionIndices[index])\n || typeof variant.bodyKey !== \"string\"\n || !bodies.has(variant.bodyKey))\n {\n throw new Error(`PGRF variant ${permutationIndex} is malformed`);\n }\n\n const sourceRecord = validateGraphSourceRecord(\n variant.sourceRecord,\n permutationIndex,\n options.sourceByteLength\n );\n const body = bodies.get(variant.bodyKey);\n if (sourceRecord.byteLength !== body.byteLength)\n {\n throw new Error(\n `PGRF variant ${permutationIndex} body length disagrees`\n );\n }\n\n const recordKey = `${sourceRecord.offset}:${sourceRecord.byteLength}`;\n const existingBodyKey = bodyKeyBySourceRecord.get(recordKey);\n if (existingBodyKey && existingBodyKey !== variant.bodyKey)\n {\n throw new Error(\n `PGRF source record ${recordKey} maps to multiple bodies`\n );\n }\n bodyKeyBySourceRecord.set(recordKey, variant.bodyKey);\n sourceRecords.push(sourceRecord);\n body.references += 1;\n }\n\n validateDisjointSourceRecords(\n sourceRecords,\n \"PGRF source body records partially overlap\"\n );\n\n for (const [ bodyKey, body ] of bodies)\n {\n if (!body.references)\n {\n throw new Error(`PGRF body ${bodyKey} is unreferenced`);\n }\n }\n\n return Object.freeze({\n permutationCount,\n uniqueBodyCount: bodies.size\n });\n}\n\nfunction normalizeAxes(value)\n{\n if (!Array.isArray(value) || value.length > UINT8_MAX)\n {\n throw new TypeError(\"Effect permutation axes must be an array\");\n }\n\n const names = new Set();\n return value.map((axis, index) =>\n {\n if (!axis || typeof axis !== \"object\"\n || typeof axis.name !== \"string\" || !axis.name\n || axis.name !== axis.name.trim()\n || names.has(axis.name)\n || !Array.isArray(axis.options) || !axis.options.length\n || axis.options.length > UINT8_MAX\n || !Number.isSafeInteger(axis.defaultOption)\n || axis.defaultOption < 0\n || axis.defaultOption >= axis.options.length\n || typeof axis.description !== \"string\"\n || !Number.isSafeInteger(axis.type)\n || axis.type < 0 || axis.type > UINT8_MAX)\n {\n throw new Error(`Effect permutation axis ${index} is malformed`);\n }\n names.add(axis.name);\n\n const options = new Set();\n for (const option of axis.options)\n {\n if (typeof option !== \"string\" || !option\n || option !== option.trim() || options.has(option))\n {\n throw new Error(\n `Effect permutation axis ${axis.name} has malformed options`\n );\n }\n options.add(option);\n }\n\n return Object.freeze({\n index,\n name: axis.name,\n options: Object.freeze(axis.options.slice()),\n defaultOption: axis.defaultOption,\n description: axis.description,\n type: axis.type\n });\n });\n}\n\nfunction validateGraphAxes(value)\n{\n if (!Array.isArray(value) || value.length > UINT8_MAX)\n {\n throw new Error(\"PGRF axes must be an array\");\n }\n\n const names = new Set();\n return value.map((axis, index) =>\n {\n if (!axis || typeof axis !== \"object\" || Array.isArray(axis)\n || axis.index !== index\n || typeof axis.name !== \"string\" || !axis.name\n || axis.name !== axis.name.trim() || names.has(axis.name)\n || !Array.isArray(axis.options) || !axis.options.length\n || axis.options.length > UINT8_MAX\n || !Number.isSafeInteger(axis.defaultOption)\n || axis.defaultOption < 0\n || axis.defaultOption >= axis.options.length\n || typeof axis.description !== \"string\"\n || !Number.isSafeInteger(axis.type)\n || axis.type < 0 || axis.type > UINT8_MAX)\n {\n throw new Error(`PGRF axis ${index} is malformed or duplicated`);\n }\n names.add(axis.name);\n\n const options = new Set();\n for (const option of axis.options)\n {\n if (typeof option !== \"string\" || !option\n || option !== option.trim() || options.has(option))\n {\n throw new Error(`PGRF axis ${index} options are malformed`);\n }\n options.add(option);\n }\n return axis;\n });\n}\n\nfunction permutationProduct(axes)\n{\n let product = 1;\n for (const axis of axes)\n {\n product *= axis.options.length;\n if (!Number.isSafeInteger(product) || product < 1\n || product > MAX_EFFECT_PERMUTATIONS)\n {\n throw new Error(\n `Effect permutation count above the implementation limit `\n + `${MAX_EFFECT_PERMUTATIONS} is not supported`\n );\n }\n }\n return product;\n}\n\nfunction decodeOptionIndices(permutationIndex, axes)\n{\n let value = permutationIndex;\n return axes.map((axis) =>\n {\n const optionIndex = value % axis.options.length;\n value = Math.floor(value / axis.options.length);\n return optionIndex;\n });\n}\n\nfunction normalizeSourceRecord(record, permutationIndex, sourceByteLength)\n{\n if (!record || typeof record !== \"object\"\n || record.index !== permutationIndex\n || !Number.isSafeInteger(record.offset) || record.offset < 0\n || record.offset > UINT32_MAX\n || !Number.isSafeInteger(record.size) || record.size < 1\n || record.size > UINT32_MAX\n || !Number.isSafeInteger(record.end)\n || record.end !== record.offset + record.size\n || record.end > sourceByteLength)\n {\n throw new Error(\n `Effect permutation ${permutationIndex} has an invalid source body record`\n );\n }\n\n return Object.freeze({\n offset: record.offset,\n byteLength: record.size\n });\n}\n\nfunction validateGraphSourceRecord(record, permutationIndex, sourceByteLength)\n{\n const offset = record?.offset;\n const byteLength = record?.byteLength;\n const end = offset + byteLength;\n if (!record || typeof record !== \"object\" || Array.isArray(record)\n || !Number.isSafeInteger(offset) || offset < 0 || offset > UINT32_MAX\n || !Number.isSafeInteger(byteLength) || byteLength < 1\n || byteLength > UINT32_MAX\n || !Number.isSafeInteger(end)\n || (sourceByteLength !== undefined\n && (!Number.isSafeInteger(sourceByteLength)\n || sourceByteLength < 1\n || end > sourceByteLength)))\n {\n throw new Error(\n `PGRF variant ${permutationIndex} source record is malformed`\n );\n }\n return record;\n}\n\nfunction validateDisjointSourceRecords(records, message)\n{\n const uniqueRanges = new Map();\n for (const record of records)\n {\n const key = `${record.offset}:${record.byteLength}`;\n if (!uniqueRanges.has(key))\n {\n uniqueRanges.set(key, {\n offset: record.offset,\n end: record.offset + record.byteLength\n });\n }\n }\n\n const orderedRanges = Array.from(uniqueRanges.values())\n .sort((left, right) => left.offset - right.offset || left.end - right.end);\n for (let index = 1; index < orderedRanges.length; index += 1)\n {\n if (orderedRanges[index].offset < orderedRanges[index - 1].end)\n {\n throw new Error(message);\n }\n }\n}\n\nfunction bytesEqual(left, right)\n{\n return left.byteLength === right.byteLength\n && left.every((value, index) => value === right[index]);\n}\n"],"names":["EFFECT_PERMUTATION_GRAPH_FORMAT","EFFECT_PERMUTATION_GRAPH_VERSION","EFFECT_PERMUTATION_GRAPH_CHUNK","SHA256","UINT8_MAX","UINT32_MAX","MAX_EFFECT_PERMUTATIONS","buildEffectPermutationGraph","effectRes","TypeError","sourceBytes","m_data","Uint8Array","axes","normalizeAxes","m_permutations","permutationCount","permutationProduct","offsets","m_offsets","Array","isArray","length","m_offsetCount","Error","sourceRecords","map","record","permutationIndex","normalizeSourceRecord","byteLength","validateDisjointSourceRecords","bodies","bodyCandidatesByDigest","Map","bodyBySourceRecord","variants","sourceRecord","sourceRecordKey","offset","body","get","bodyBytes","subarray","digest","sha256Bytes","find","candidate","bytesEqual","bytes","has","Object","freeze","key","sha256","set","push","optionIndices","decodeOptionIndices","bodyKey","graph","format","formatVersion","coverage","permutations","reflection","validateEffectPermutationGraph","sourceByteLength","options","validateGraphAxes","bodyDigests","Set","bodyIndex","entries","trim","Number","isSafeInteger","test","add","references","bodyKeyBySourceRecord","variant","expectedOptionIndices","some","value","index","validateGraphSourceRecord","recordKey","existingBodyKey","uniqueBodyCount","size","names","axis","name","defaultOption","description","type","option","slice","product","optionIndex","Math","floor","end","undefined","records","message","uniqueRanges","orderedRanges","from","values","sort","left","right","every"],"mappings":";;AAEO,MAAMA,+BAA+B,GAAG;AACxC,MAAMC,gCAAgC,GAAG;AACzC,MAAMC,8BAA8B,GAAG;AAE9C,MAAMC,MAAM,GAAG,iBAAiB;AAChC,MAAMC,SAAS,GAAG,IAAI;AACtB,MAAMC,UAAU,GAAG,UAAU;AAC7B,MAAMC,uBAAuB,GAAG,OAAO;;AAEvC;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,2BAA2BA,CAACC,SAAS,EACrD;AACI,EAAA,IAAI,CAACA,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ,EAC/C;AACI,IAAA,MAAM,IAAIC,SAAS,CAAC,6DAA6D,CAAC;AACtF,EAAA;AAEA,EAAA,MAAMC,WAA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AAM,CAACG;AAChC,OAAC,CAAC;AACN,IAAA;AACJ,EAAA;AAEA,EAAA,MAAM8E,aAAa,GAAGxF,KAAK,CAACyF,IAAI,CAACF,YAAY,CAACG,MAAM,EAAE,CAAC,CAClDC,IAAI,CAAC,CAACC,IAAI,EAAEC,KAAK,KAAKD,IAAI,CAACzE,MAAM,GAAG0E,KAAK,CAAC1E,MAAM,IAAIyE,IAAI,CAACT,GAAG,GAAGU,KAAK,CAACV,GAAG,CAAC;AAC9E,EAAA,KAAK,IAAIlB,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAGuB,aAAa,CAACtF,MAAM,EAAE+D,KAAK,IAAI,CAAC,EAC5D;AACI,IAAA,IAAIuB,aAAa,CAACvB,KAAK,CAAC,CAAC9C,MAAM,GAAGqE,aAAa,CAACvB,KAAK,GAAG,CAAC,CAAC,CAACkB,GAAG,EAC9D;AACI,MAAA,MAAM,IAAI/E,KAAK,CAACkF,OAAO,CAAC;AAC5B,IAAA;AACJ,EAAA;AACJ;AAEA,SAAS1D,UAAUA,CAACgE,IAAI,EAAEC,KAAK,EAC/B;EACI,OAAOD,IAAI,CAAClF,UAAU,KAAKmF,KAAK,CAACnF,UAAU,IACpCkF,IAAI,CAACE,KAAK,CAAC,CAAC9B,KAAK,EAAEC,KAAK,KAAKD,KAAK,KAAK6B,KAAK,CAAC5B,KAAK,CAAC,CAAC;AAC/D;;;;"}
1
+ {"version":3,"file":"effectPermutationGraph.js","sources":["../../../../src/format/effect/effectPermutationGraph.js"],"sourcesContent":["import { sha256Bytes } from \"./sha256.js\";\r\n\r\n/**\r\n * The source permutation topology: which permutations exist, and which of them\r\n * share one body.\r\n *\r\n * This module used to model that as the `PGRF` **chunk** - it exported the tag,\r\n * and every error it raised named it. There are no chunks. A `.carbonwebgpu` or\r\n * `.carbonwebgl` file is one Carbon v15 record container, and the graph the\r\n * container publishes is a *view* over the header's own permutation records and\r\n * offset table, not a stored document beside them. The chunk vocabulary outlived\r\n * the reader beneath it by weeks precisely because nothing was broken: packages\r\n * built, ccpwgl rendered, and the only cost was that every error message named a\r\n * container the file no longer had.\r\n *\r\n * The graph is still built here, from the decoded effect resource, because that\r\n * is where the source topology is known. What is gone is the claim that it is\r\n * stored anywhere.\r\n */\r\n\r\nexport const EFFECT_PERMUTATION_GRAPH_FORMAT = \"CJS_EFFECT_PERMUTATION_GRAPH\";\r\nexport const EFFECT_PERMUTATION_GRAPH_VERSION = 1;\r\n\r\nconst SHA256 = /^[0-9a-f]{64}$/u;\r\nconst UINT8_MAX = 0xff;\r\nconst UINT32_MAX = 0xffffffff;\r\nconst MAX_EFFECT_PERMUTATIONS = 0x10000;\r\n\r\n/**\r\n * Build a complete source permutation topology without claiming that every\r\n * body has portable reflection or backend programs.\r\n *\r\n * @param {object} effectRes Raw format-hlsl effect resource.\r\n * @returns {object} JSON-safe permutation graph.\r\n */\r\nexport function buildEffectPermutationGraph(effectRes)\r\n{\r\n if (!effectRes || typeof effectRes !== \"object\")\r\n {\r\n throw new TypeError(\"Effect permutation graph requires a decoded effect resource\");\r\n }\r\n\r\n const sourceBytes = effectRes.m_data;\r\n if (!(sourceBytes instanceof Uint8Array))\r\n {\r\n throw new TypeError(\"Effect permutation graph requires exact source bytes\");\r\n }\r\n\r\n const axes = normalizeAxes(effectRes.m_permutations);\r\n const permutationCount = permutationProduct(axes);\r\n const offsets = effectRes.m_offsets;\r\n if (!Array.isArray(offsets) || offsets.length !== permutationCount\r\n || effectRes.m_offsetCount !== offsets.length)\r\n {\r\n throw new Error(\r\n \"Effect permutation graph requires one source body record per permutation\"\r\n );\r\n }\r\n\r\n const sourceRecords = offsets.map((record, permutationIndex) =>\r\n normalizeSourceRecord(\r\n record,\r\n permutationIndex,\r\n sourceBytes.byteLength\r\n ));\r\n validateDisjointSourceRecords(\r\n sourceRecords,\r\n \"Effect permutation source body records partially overlap\"\r\n );\r\n\r\n const bodies = [];\r\n const bodyCandidatesByDigest = new Map();\r\n const bodyBySourceRecord = new Map();\r\n const variants = sourceRecords.map((sourceRecord, permutationIndex) =>\r\n {\r\n const sourceRecordKey = `${sourceRecord.offset}:${sourceRecord.byteLength}`;\r\n let body = bodyBySourceRecord.get(sourceRecordKey);\r\n if (!body)\r\n {\r\n const bodyBytes = sourceBytes.subarray(\r\n sourceRecord.offset,\r\n sourceRecord.offset + sourceRecord.byteLength\r\n );\r\n const digest = sha256Bytes(bodyBytes);\r\n body = (bodyCandidatesByDigest.get(digest) || [])\r\n .find((candidate) => bytesEqual(candidate.bytes, bodyBytes));\r\n if (!body && bodyCandidatesByDigest.has(digest))\r\n {\r\n throw new Error(\r\n \"Effect permutation graph body SHA-256 collision detected\"\r\n );\r\n }\r\n if (!body)\r\n {\r\n body = {\r\n bytes: bodyBytes,\r\n record: Object.freeze({\r\n key: `body${bodies.length}`,\r\n byteLength: bodyBytes.byteLength,\r\n sha256: digest\r\n })\r\n };\r\n bodyCandidatesByDigest.set(digest, [ body ]);\r\n bodies.push(body.record);\r\n }\r\n bodyBySourceRecord.set(sourceRecordKey, body);\r\n }\r\n\r\n return Object.freeze({\r\n permutationIndex,\r\n optionIndices: Object.freeze(decodeOptionIndices(\r\n permutationIndex,\r\n axes\r\n )),\r\n bodyKey: body.record.key,\r\n sourceRecord\r\n });\r\n });\r\n\r\n const graph = Object.freeze({\r\n format: EFFECT_PERMUTATION_GRAPH_FORMAT,\r\n formatVersion: EFFECT_PERMUTATION_GRAPH_VERSION,\r\n coverage: Object.freeze({\r\n permutations: \"complete\",\r\n bodies: \"identity-only\",\r\n reflection: \"absent\"\r\n }),\r\n axes: Object.freeze(axes),\r\n variants: Object.freeze(variants),\r\n bodies: Object.freeze(bodies)\r\n });\r\n\r\n validateEffectPermutationGraph(graph, {\r\n sourceByteLength: sourceBytes.byteLength\r\n });\r\n return graph;\r\n}\r\n\r\n/**\r\n * Validate a source permutation graph independently of the original effect\r\n * bytes.\r\n *\r\n * @param {object} graph Candidate graph.\r\n * @param {object} [options] Optional source-envelope limits.\r\n * @param {number} [options.sourceByteLength] Exact enclosing source byte length.\r\n * @returns {{permutationCount:number,uniqueBodyCount:number}} Validated counts.\r\n */\r\nexport function validateEffectPermutationGraph(graph, options = {})\r\n{\r\n if (!graph || typeof graph !== \"object\" || Array.isArray(graph)\r\n || graph.format !== EFFECT_PERMUTATION_GRAPH_FORMAT\r\n || graph.formatVersion !== EFFECT_PERMUTATION_GRAPH_VERSION\r\n || !graph.coverage || typeof graph.coverage !== \"object\"\r\n || Array.isArray(graph.coverage)\r\n || graph.coverage.permutations !== \"complete\"\r\n || graph.coverage.bodies !== \"identity-only\"\r\n || graph.coverage.reflection !== \"absent\")\r\n {\r\n throw new Error(\"Effect permutation graph schema or coverage is unsupported\");\r\n }\r\n\r\n const axes = validateGraphAxes(graph.axes);\r\n const permutationCount = permutationProduct(axes);\r\n if (!Array.isArray(graph.variants)\r\n || graph.variants.length !== permutationCount)\r\n {\r\n throw new Error(\r\n \"Effect permutation graph must contain one variant per Cartesian permutation\"\r\n );\r\n }\r\n if (!Array.isArray(graph.bodies)\r\n || !graph.bodies.length\r\n || graph.bodies.length > graph.variants.length)\r\n {\r\n throw new Error(\"Effect permutation graph bodies are malformed\");\r\n }\r\n\r\n const bodies = new Map();\r\n const bodyDigests = new Set();\r\n for (const [ bodyIndex, body ] of graph.bodies.entries())\r\n {\r\n if (!body || typeof body !== \"object\" || Array.isArray(body)\r\n || typeof body.key !== \"string\" || !body.key\r\n || body.key !== body.key.trim()\r\n || !Number.isSafeInteger(body.byteLength) || body.byteLength < 1\r\n || body.byteLength > UINT32_MAX\r\n || typeof body.sha256 !== \"string\" || !SHA256.test(body.sha256)\r\n || bodies.has(body.key)\r\n || bodyDigests.has(body.sha256))\r\n {\r\n throw new Error(`Effect permutation graph body ${bodyIndex} is malformed or duplicated`);\r\n }\r\n bodyDigests.add(body.sha256);\r\n bodies.set(body.key, {\r\n byteLength: body.byteLength,\r\n references: 0\r\n });\r\n }\r\n\r\n const bodyKeyBySourceRecord = new Map();\r\n const sourceRecords = [];\r\n for (const [ permutationIndex, variant ] of graph.variants.entries())\r\n {\r\n const expectedOptionIndices = decodeOptionIndices(permutationIndex, axes);\r\n if (!variant || typeof variant !== \"object\" || Array.isArray(variant)\r\n || variant.permutationIndex !== permutationIndex\r\n || !Array.isArray(variant.optionIndices)\r\n || variant.optionIndices.length !== expectedOptionIndices.length\r\n || variant.optionIndices.some((value, index) =>\r\n value !== expectedOptionIndices[index])\r\n || typeof variant.bodyKey !== \"string\"\r\n || !bodies.has(variant.bodyKey))\r\n {\r\n throw new Error(`Effect permutation graph variant ${permutationIndex} is malformed`);\r\n }\r\n\r\n const sourceRecord = validateGraphSourceRecord(\r\n variant.sourceRecord,\r\n permutationIndex,\r\n options.sourceByteLength\r\n );\r\n const body = bodies.get(variant.bodyKey);\r\n if (sourceRecord.byteLength !== body.byteLength)\r\n {\r\n throw new Error(\r\n `Effect permutation graph variant ${permutationIndex} body length disagrees`\r\n );\r\n }\r\n\r\n const recordKey = `${sourceRecord.offset}:${sourceRecord.byteLength}`;\r\n const existingBodyKey = bodyKeyBySourceRecord.get(recordKey);\r\n if (existingBodyKey && existingBodyKey !== variant.bodyKey)\r\n {\r\n throw new Error(\r\n `Effect permutation graph source record ${recordKey} maps to multiple bodies`\r\n );\r\n }\r\n bodyKeyBySourceRecord.set(recordKey, variant.bodyKey);\r\n sourceRecords.push(sourceRecord);\r\n body.references += 1;\r\n }\r\n\r\n validateDisjointSourceRecords(\r\n sourceRecords,\r\n \"Effect permutation graph source body records partially overlap\"\r\n );\r\n\r\n for (const [ bodyKey, body ] of bodies)\r\n {\r\n if (!body.references)\r\n {\r\n throw new Error(`Effect permutation graph body ${bodyKey} is unreferenced`);\r\n }\r\n }\r\n\r\n return Object.freeze({\r\n permutationCount,\r\n uniqueBodyCount: bodies.size\r\n });\r\n}\r\n\r\nfunction normalizeAxes(value)\r\n{\r\n if (!Array.isArray(value) || value.length > UINT8_MAX)\r\n {\r\n throw new TypeError(\"Effect permutation axes must be an array\");\r\n }\r\n\r\n const names = new Set();\r\n return value.map((axis, index) =>\r\n {\r\n if (!axis || typeof axis !== \"object\"\r\n || typeof axis.name !== \"string\" || !axis.name\r\n || axis.name !== axis.name.trim()\r\n || names.has(axis.name)\r\n || !Array.isArray(axis.options) || !axis.options.length\r\n || axis.options.length > UINT8_MAX\r\n || !Number.isSafeInteger(axis.defaultOption)\r\n || axis.defaultOption < 0\r\n || axis.defaultOption >= axis.options.length\r\n || typeof axis.description !== \"string\"\r\n || !Number.isSafeInteger(axis.type)\r\n || axis.type < 0 || axis.type > UINT8_MAX)\r\n {\r\n throw new Error(`Effect permutation axis ${index} is malformed`);\r\n }\r\n names.add(axis.name);\r\n\r\n const options = new Set();\r\n for (const option of axis.options)\r\n {\r\n if (typeof option !== \"string\" || !option\r\n || option !== option.trim() || options.has(option))\r\n {\r\n throw new Error(\r\n `Effect permutation axis ${axis.name} has malformed options`\r\n );\r\n }\r\n options.add(option);\r\n }\r\n\r\n return Object.freeze({\r\n index,\r\n name: axis.name,\r\n options: Object.freeze(axis.options.slice()),\r\n defaultOption: axis.defaultOption,\r\n description: axis.description,\r\n type: axis.type\r\n });\r\n });\r\n}\r\n\r\nfunction validateGraphAxes(value)\r\n{\r\n if (!Array.isArray(value) || value.length > UINT8_MAX)\r\n {\r\n throw new Error(\"Effect permutation graph axes must be an array\");\r\n }\r\n\r\n const names = new Set();\r\n return value.map((axis, index) =>\r\n {\r\n if (!axis || typeof axis !== \"object\" || Array.isArray(axis)\r\n || axis.index !== index\r\n || typeof axis.name !== \"string\" || !axis.name\r\n || axis.name !== axis.name.trim() || names.has(axis.name)\r\n || !Array.isArray(axis.options) || !axis.options.length\r\n || axis.options.length > UINT8_MAX\r\n || !Number.isSafeInteger(axis.defaultOption)\r\n || axis.defaultOption < 0\r\n || axis.defaultOption >= axis.options.length\r\n || typeof axis.description !== \"string\"\r\n || !Number.isSafeInteger(axis.type)\r\n || axis.type < 0 || axis.type > UINT8_MAX)\r\n {\r\n throw new Error(`Effect permutation graph axis ${index} is malformed or duplicated`);\r\n }\r\n names.add(axis.name);\r\n\r\n const options = new Set();\r\n for (const option of axis.options)\r\n {\r\n if (typeof option !== \"string\" || !option\r\n || option !== option.trim() || options.has(option))\r\n {\r\n throw new Error(`Effect permutation graph axis ${index} options are malformed`);\r\n }\r\n options.add(option);\r\n }\r\n return axis;\r\n });\r\n}\r\n\r\nfunction permutationProduct(axes)\r\n{\r\n let product = 1;\r\n for (const axis of axes)\r\n {\r\n product *= axis.options.length;\r\n if (!Number.isSafeInteger(product) || product < 1\r\n || product > MAX_EFFECT_PERMUTATIONS)\r\n {\r\n throw new Error(\r\n `Effect permutation count above the implementation limit `\r\n + `${MAX_EFFECT_PERMUTATIONS} is not supported`\r\n );\r\n }\r\n }\r\n return product;\r\n}\r\n\r\nfunction decodeOptionIndices(permutationIndex, axes)\r\n{\r\n let value = permutationIndex;\r\n return axes.map((axis) =>\r\n {\r\n const optionIndex = value % axis.options.length;\r\n value = Math.floor(value / axis.options.length);\r\n return optionIndex;\r\n });\r\n}\r\n\r\nfunction normalizeSourceRecord(record, permutationIndex, sourceByteLength)\r\n{\r\n if (!record || typeof record !== \"object\"\r\n || record.index !== permutationIndex\r\n || !Number.isSafeInteger(record.offset) || record.offset < 0\r\n || record.offset > UINT32_MAX\r\n || !Number.isSafeInteger(record.size) || record.size < 1\r\n || record.size > UINT32_MAX\r\n || !Number.isSafeInteger(record.end)\r\n || record.end !== record.offset + record.size\r\n || record.end > sourceByteLength)\r\n {\r\n throw new Error(\r\n `Effect permutation ${permutationIndex} has an invalid source body record`\r\n );\r\n }\r\n\r\n return Object.freeze({\r\n offset: record.offset,\r\n byteLength: record.size\r\n });\r\n}\r\n\r\nfunction validateGraphSourceRecord(record, permutationIndex, sourceByteLength)\r\n{\r\n const offset = record?.offset;\r\n const byteLength = record?.byteLength;\r\n const end = offset + byteLength;\r\n if (!record || typeof record !== \"object\" || Array.isArray(record)\r\n || !Number.isSafeInteger(offset) || offset < 0 || offset > UINT32_MAX\r\n || !Number.isSafeInteger(byteLength) || byteLength < 1\r\n || byteLength > UINT32_MAX\r\n || !Number.isSafeInteger(end)\r\n || (sourceByteLength !== undefined\r\n && (!Number.isSafeInteger(sourceByteLength)\r\n || sourceByteLength < 1\r\n || end > sourceByteLength)))\r\n {\r\n throw new Error(\r\n `Effect permutation graph variant ${permutationIndex} source record is malformed`\r\n );\r\n }\r\n return record;\r\n}\r\n\r\nfunction validateDisjointSourceRecords(records, message)\r\n{\r\n const uniqueRanges = new Map();\r\n for (const record of records)\r\n {\r\n const key = `${record.offset}:${record.byteLength}`;\r\n if (!uniqueRanges.has(key))\r\n {\r\n uniqueRanges.set(key, {\r\n offset: record.offset,\r\n end: record.offset + record.byteLength\r\n });\r\n }\r\n }\r\n\r\n const orderedRanges = Array.from(uniqueRanges.values())\r\n .sort((left, right) => left.offset - right.offset || left.end - right.end);\r\n for (let index = 1; index < orderedRanges.length; index += 1)\r\n {\r\n if (orderedRanges[index].offset < orderedRanges[index - 1].end)\r\n {\r\n throw new Error(message);\r\n }\r\n }\r\n}\r\n\r\nfunction bytesEqual(left, right)\r\n{\r\n return left.byteLength === right.byteLength\r\n && left.every((value, index) => value === right[index]);\r\n}\r\n"],"names":["EFFECT_PERMUTATION_GRAPH_FORMAT","EFFECT_PERMUTATION_GRAPH_VERSION","SHA256","UINT8_MAX","UINT32_MAX","MAX_EFFECT_PERMUTATIONS","buildEffectPermutationGraph","effectRes","TypeError","sourceBytes","m_data","Uint8Array","axes","normalizeAxes","m_permutations","permutationCount","permutationProduct","offsets","m_offsets","Array","isArray","length","m_offsetCount","Error","sourceRecords","map","record","permutationIndex","normalizeSourceRecord","byteLength","validateDisjointSourceRecords","bodies","bodyCandidatesByDigest","Map","bodyBySourceRecord","variants","sourceRecord","sourceRecordKey","offset","body","get","bodyBytes","subarray","digest","sha256Bytes","find","candidate","bytesEqual","bytes","has","Object","freeze","key","sha256","set","push","optionIndices","decodeOptionIndices","bodyKey","graph","format","formatVersion","coverage","permutations","reflection","validateEffectPermutationGraph","sourceByteLength","options","validateGraphAxes","bodyDigests","Set","bodyIndex","entries","trim","Number","isSafeInteger","test","add","references","bodyKeyBySourceRecord","variant","expectedOptionIndices","some","value","index","validateGraphSourceRecord","recordKey","existingBodyKey","uniqueBodyCount","size","names","axis","name","defaultOption","description","type","option","slice","product","optionIndex","Math","floor","end","undefined","records","message","uniqueRanges","orderedRanges","from","values","sort","left","right","every"],"mappings":";;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEO,MAAMA,+BAA+B,GAAG;AACxC,MAAMC,gCAAgC,GAAG;AAEhD,MAAMC,MAAM,GAAG,iBAAiB;AAChC,MAAMC,SAAS,GAAG,IAAI;AACtB,MAAMC,UAAU,GAAG,UAAU;AAC7B,MAAMC,uBAAuB,GAAG,OAAO;;AAEvC;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,2BAA2BA,CAACC,SAAS,EACrD;AACI,EAAA,IAAI,CAACA,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ,EAC/C;AACI,IAAA,MAAM,IAAIC,SAAS,CAAC,6DAA6D,CAAC;AACtF,EAAA;AAEA,EAAA,MAAMC,WAAW,GAAGF,SAAS,CAACG,MAAM;AACpC,EAAA,IAAI,EAAED,WAAW,YAAYE,UAAU,CAAC,EACxC;AACI,IAAA,MAAM,IAAIH,SAAS,CAAC,sDAAsD,CAAC;AAC/E,EAAA;AAEA,EAAA,MAAMI,IAAI,GAAGC,aAAa,CAACN,SAAS,CAACO,cAAc,CAAC;AACpD,EAAA,MAAMC,gBAAgB,GAAGC,kBAAkB,CAACJ,IAAI,CAAC;AACjD,EAAA,MAAMK,OAAO,GAAGV,SAAS,CAACW,SAAS;EACnC,IAAI,CAACC,KAAK,CAACC,OAAO,CAACH,OAAO,CAAC,IAAIA,OAAO,CAACI,MAAM,KAAKN,gBAAgB,IAC3DR,SAAS,CAACe,aAAa,KAAKL,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a,CAACvB,KAAK,CAAC,CAAC9C,MAAM,GAAGqE,aAAa,CAACvB,KAAK,GAAG,CAAC,CAAC,CAACkB,GAAG,EAC9D;AACI,MAAA,MAAM,IAAI/E,KAAK,CAACkF,OAAO,CAAC;AAC5B,IAAA;AACJ,EAAA;AACJ;AAEA,SAAS1D,UAAUA,CAACgE,IAAI,EAAEC,KAAK,EAC/B;EACI,OAAOD,IAAI,CAAClF,UAAU,KAAKmF,KAAK,CAACnF,UAAU,IACpCkF,IAAI,CAACE,KAAK,CAAC,CAAC9B,KAAK,EAAEC,KAAK,KAAKD,KAAK,KAAK6B,KAAK,CAAC5B,KAAK,CAAC,CAAC;AAC/D;;;;"}
@@ -17,7 +17,7 @@
17
17
  * The WebGL 2 motivation is a hard limit rather than tidiness: the affected
18
18
  * shaders sit at exactly 16 textures against a 16-unit guarantee, so merging
19
19
  * three maps into one is what creates the headroom lighting needs. See
20
- * docs/contracts/webgl2-texture-budget.md.
20
+ * the WebGL2 sampler-unit limit of 16.
21
21
  */
22
22
 
23
23
  /** Resource names that make up the family, in layer order. */