@carbonenginejs/runtime-resource 0.18.0 → 0.19.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 (81) hide show
  1. package/dist/format/carbonEffect/CjsCarbonEffectWriter.js +16 -4
  2. package/dist/format/carbonEffect/CjsCarbonEffectWriter.js.map +1 -1
  3. package/dist/format/carbonEffect/buildCarbonEffectContainer.js +11 -1
  4. package/dist/format/carbonEffect/buildCarbonEffectContainer.js.map +1 -1
  5. package/dist/format/carbonEffect/carbonEffectBackendBlock.js +36 -0
  6. package/dist/format/carbonEffect/carbonEffectBackendBlock.js.map +1 -1
  7. package/dist/format/carbonEffect/carbonEffectRecords.js +45 -1
  8. package/dist/format/carbonEffect/carbonEffectRecords.js.map +1 -1
  9. package/dist/format/carbonEffect/carbonEffectResourceTransform.js +120 -60
  10. package/dist/format/carbonEffect/carbonEffectResourceTransform.js.map +1 -1
  11. package/dist/format/index.js +1 -1
  12. package/dist/formats/dds/core/helpers.js +35 -6
  13. package/dist/formats/dds/core/helpers.js.map +1 -1
  14. package/dist/formats/fbx/core/helpers.js +1 -1
  15. package/dist/formats/fbx/core/helpers.js.map +1 -1
  16. package/dist/formats/hlsl/core/carbonDescriptionToRuntime.js +53 -1
  17. package/dist/formats/hlsl/core/carbonDescriptionToRuntime.js.map +1 -1
  18. package/dist/formats/hlsl/core/tr2/shader/HlslEffectBindingManifest.js +10 -1
  19. package/dist/formats/hlsl/core/tr2/shader/HlslEffectBindingManifest.js.map +1 -1
  20. package/dist/formats/index.js +3 -0
  21. package/dist/formats/index.js.map +1 -1
  22. package/dist/formats/jpeg/core/helpers.js +1 -1
  23. package/dist/formats/jpeg/core/helpers.js.map +1 -1
  24. package/dist/formats/pickle/core/CjsPickleProtocol0Reader.js +205 -44
  25. package/dist/formats/pickle/core/CjsPickleProtocol0Reader.js.map +1 -1
  26. package/dist/formats/schemabound/CjsSchemaBoundFormat.js +236 -0
  27. package/dist/formats/schemabound/CjsSchemaBoundFormat.js.map +1 -0
  28. package/dist/formats/schemabound/core/schemaBoundErrors.js +9 -0
  29. package/dist/formats/schemabound/core/schemaBoundErrors.js.map +1 -0
  30. package/dist/formats/schemabound/core/schemaBoundValues.js +336 -0
  31. package/dist/formats/schemabound/core/schemaBoundValues.js.map +1 -0
  32. package/dist/formats/schemabound/index.js +2 -0
  33. package/dist/formats/schemabound/index.js.map +1 -0
  34. package/dist/formats/sqlite/CjsSqliteFormat.js +244 -0
  35. package/dist/formats/sqlite/CjsSqliteFormat.js.map +1 -0
  36. package/dist/formats/sqlite/core/sqlitePages.js +159 -0
  37. package/dist/formats/sqlite/core/sqlitePages.js.map +1 -0
  38. package/dist/formats/sqlite/core/sqliteRecords.js +174 -0
  39. package/dist/formats/sqlite/core/sqliteRecords.js.map +1 -0
  40. package/dist/formats/sqlite/core/sqliteSchema.js +100 -0
  41. package/dist/formats/sqlite/core/sqliteSchema.js.map +1 -0
  42. package/dist/formats/sqlite/index.js +2 -0
  43. package/dist/formats/sqlite/index.js.map +1 -0
  44. package/dist/formats/static/CjsStaticFormat.js +222 -0
  45. package/dist/formats/static/CjsStaticFormat.js.map +1 -0
  46. package/dist/formats/static/index.js +3 -0
  47. package/dist/formats/static/index.js.map +1 -0
  48. package/dist/formats/static/staticContainers.js +157 -0
  49. package/dist/formats/static/staticContainers.js.map +1 -0
  50. package/dist/formats/webgl/core/buildGlslEffectContainer.js +3 -1
  51. package/dist/formats/webgl/core/buildGlslEffectContainer.js.map +1 -1
  52. package/dist/formats/webgl/core/effectPackage.js +11 -2
  53. package/dist/formats/webgl/core/effectPackage.js.map +1 -1
  54. package/dist/formats/webgl/core/glsl/DxbcGlslEmitter.js +10 -2
  55. package/dist/formats/webgl/core/glsl/DxbcGlslEmitter.js.map +1 -1
  56. package/dist/formats/webgpu/core/buildCarbonEffectContainer.js +3 -1
  57. package/dist/formats/webgpu/core/buildCarbonEffectContainer.js.map +1 -1
  58. package/dist/formats/webgpu/core/carbonWebgpu/containerViews.js +179 -131
  59. package/dist/formats/webgpu/core/carbonWebgpu/containerViews.js.map +1 -1
  60. package/dist/formats/webgpu/core/effectBackendBodySet.js +20 -20
  61. package/dist/formats/webgpu/core/effectBackendBodySet.js.map +1 -1
  62. package/dist/formats/webgpu/core/packageEffect.js +14 -1
  63. package/dist/formats/webgpu/core/packageEffect.js.map +1 -1
  64. package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js +9 -1
  65. package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js.map +1 -1
  66. package/dist/resource/shader/reflection/Tr2EffectStageInput.js +14 -0
  67. package/dist/resource/shader/reflection/Tr2EffectStageInput.js.map +1 -1
  68. package/docs/concepts/shader-resource-model.md +34 -1
  69. package/docs/formats/README.md +21 -0
  70. package/docs/formats/carbon-effect-container.md +54 -27
  71. package/docs/formats/pickle.md +36 -0
  72. package/docs/formats/schemabound.md +123 -0
  73. package/docs/formats/static.md +166 -0
  74. package/docs/formats/webgl/README.md +5 -3
  75. package/docs/formats/webgpu/README.md +2 -2
  76. package/docs/formats/webgpu/architecture.md +2 -2
  77. package/docs/formats/webgpu/formats/carbon-webgpu.md +13 -2
  78. package/docs/formats/webgpu/guides/effect-packaging.md +1 -2
  79. package/docs/formats/webgpu/reference/wgsl-compatibility.md +2 -2
  80. package/docs/reference/classes/formats.md +33 -0
  81. package/package.json +4 -1
@@ -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.\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;A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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
+ {"version":3,"file":"carbonEffectResourceTransform.js","sources":["../../../../src/format/carbonEffect/carbonEffectResourceTransform.js"],"sourcesContent":["import { CjsFormatWriteError, CjsFormatReadError } from \"../CjsFormatError.js\";\r\nimport { DETAIL_MAP_ARRAY_NAME } from \"../../formats/hlsl/core/detailMapFamily.js\";\r\n\r\n/**\r\n * The resource-transform section, shared by every backend's per-pass block.\r\n *\r\n * A resource transform is a recipe for building one backend resource out of\r\n * several Carbon ones. It is deliberately backend-neutral: `detail-map-array`\r\n * merges `Detail1Map`, `Detail2Map` and `Detail3Map` into one array texture, and\r\n * that decision is about the *resources*, not about WGSL or GLSL. Both backends\r\n * want the identical merge, for different reasons - WebGPU to reduce binding\r\n * churn, WebGL 2 because the family otherwise needs 17 texture units against a\r\n * limit of 16.\r\n *\r\n * So the section lives here rather than in either backend's block codec, and the\r\n * two codecs compose it. A transform written by one backend decodes identically\r\n * under the other.\r\n */\r\n\r\n/**\r\n * Resource-transform families. The discriminator exists so `kind`,\r\n * `representation`, `missingLayer` and the output name stay derivable without\r\n * pinning the format to one recognizer: a second family costs an enum value\r\n * rather than a format version bump.\r\n */\r\nexport const CARBON_BACKEND_TRANSFORM_FAMILY = Object.freeze([\r\n \"detail-map-array\",\r\n \"local-light-profile-neutral\"\r\n]);\r\n\r\n/** Constants a `detail-map-array` transform restores rather than storing. */\r\nexport const DETAIL_MAP_ARRAY_DEFAULTS = Object.freeze({\r\n version: 1,\r\n kind: \"texture-2d-array\",\r\n stage: \"fragment\",\r\n representation: \"native-or-rgba8\",\r\n missingLayer: \"reject\",\r\n viewDimension: \"2d-array\",\r\n // The merged array's name is owned by the detail-map family, not restated\r\n // here. It has been renamed once already (DetailMapArray -> DetailArrayMap),\r\n // and a second literal is a second place for the next rename to miss.\r\n outputName: DETAIL_MAP_ARRAY_NAME\r\n});\r\n\r\n/**\r\n * Constants a `local-light-profile-neutral` transform restores rather than\r\n * storing.\r\n *\r\n * Unlike `detail-map-array` this transform has no output resource: its whole\r\n * content is that an input resource was replaced by a constant. It exists so a\r\n * described Carbon resource that the backend deliberately dropped is still\r\n * accounted for - a resource that simply disappears is indistinguishable from\r\n * one that was lost, and the integrity rules reject that on purpose.\r\n *\r\n * `LightProfileArray` is multiplied into a light's attenuation, so the constant\r\n * is one, not zero. That is the same value the shader's own no-profile path\r\n * produces, which is why dropping it is neutral rather than dark.\r\n */\r\nexport const LOCAL_LIGHT_PROFILE_NEUTRAL_DEFAULTS = Object.freeze({\r\n version: 1,\r\n kind: \"constant\",\r\n stage: \"fragment\",\r\n representation: \"constant-one\",\r\n missingLayer: \"ignore\",\r\n viewDimension: null,\r\n outputName: null\r\n});\r\n\r\n/**\r\n * Per-family constant sets, keyed by family name.\r\n *\r\n * The reader restores these rather than storing them, so a family that omitted\r\n * its entry here would silently inherit another family's constants.\r\n */\r\nconst TRANSFORM_DEFAULTS_BY_FAMILY = Object.freeze({\r\n \"detail-map-array\": DETAIL_MAP_ARRAY_DEFAULTS,\r\n \"local-light-profile-neutral\": LOCAL_LIGHT_PROFILE_NEUTRAL_DEFAULTS\r\n});\r\n\r\n/**\r\n * Refuses a transform whose restored fields disagree with its family.\r\n *\r\n * Every field below is dropped on write and rebuilt from the family constants\r\n * on read, so a document that disagrees does not fail - it round-trips into a\r\n * *different* document, which is the failure shape that produced both the\r\n * `selectedOptions` and the register-pair bugs. A caller may supply its own\r\n * transform plan, so agreement is checked here rather than assumed from the\r\n * one producer that happens to emit constants.\r\n *\r\n * An absent field is not a disagreement: omitting it is the normal way to say\r\n * \"restore the family value\".\r\n *\r\n * @param {object} transform Resource transform.\r\n * @param {string} family Resolved family name.\r\n * @param {object} defaults Family constants the reader restores.\r\n */\r\nfunction assertRestoredFieldsAgree(transform, family, defaults)\r\n{\r\n const restored = [\r\n [ \"version\", transform.version, defaults.version ],\r\n [ \"kind\", transform.kind, defaults.kind ],\r\n [ \"stage\", transform.stage, defaults.stage ],\r\n [ \"representation\", transform.representation, defaults.representation ],\r\n [ \"missingLayer\", transform.missingLayer, defaults.missingLayer ],\r\n [ \"output.name\", transform.output?.name, defaults.outputName ],\r\n [ \"output.viewDimension\", transform.output?.viewDimension, defaults.viewDimension ]\r\n ];\r\n\r\n for (const [ field, actual, expected ] of restored)\r\n {\r\n if (actual === undefined || actual === null) continue;\r\n if (actual === expected) continue;\r\n\r\n throw new CjsFormatWriteError(\r\n `Resource transform \"${transform.id}\" sets ${field} to ${JSON.stringify(actual)}, but the`\r\n + ` \"${family}\" family restores ${JSON.stringify(expected)} on read. The value is not`\r\n + ` stored, so writing this would silently change the document.`,\r\n { transform: transform.id, family, field, actual, expected }\r\n );\r\n }\r\n\r\n // Layer count is positional on the wire: the reader counts the inputs it\r\n // read. A document claiming a different count is claiming something the\r\n // bytes cannot carry.\r\n const layerCount = transform.output?.layerCount;\r\n\r\n if (layerCount !== undefined && layerCount !== null && layerCount !== transform.inputs.length)\r\n {\r\n throw new CjsFormatWriteError(\r\n `Resource transform \"${transform.id}\" declares ${layerCount} output layers but carries`\r\n + ` ${transform.inputs.length} inputs; the reader derives the count from the inputs.`,\r\n { transform: transform.id, family, declared: layerCount, inputs: transform.inputs.length }\r\n );\r\n }\r\n}\r\n\r\n/**\r\n * Writes a length-prefixed UTF-8 string.\r\n *\r\n * @param {object} writer Target byte writer.\r\n * @param {string} value Text value.\r\n */\r\nexport function writeInlineString(writer, value)\r\n{\r\n const bytes = new TextEncoder().encode(String(value ?? \"\"));\r\n if (bytes.length > 0xffff)\r\n {\r\n throw new CjsFormatWriteError(\"Backend block string exceeds 65535 bytes\", {\r\n byteLength: bytes.length\r\n });\r\n }\r\n writer.u16(bytes.length);\r\n writer.bytes(bytes);\r\n}\r\n\r\n/**\r\n * Reads a length-prefixed UTF-8 string.\r\n *\r\n * @param {object} reader Source byte reader.\r\n * @returns {string} Decoded text.\r\n */\r\nexport function readInlineString(reader)\r\n{\r\n const length = reader.readUint16();\r\n return new TextDecoder(\"utf-8\", { fatal: false }).decode(reader.readRaw(length));\r\n}\r\n\r\n/**\r\n * Writes the count-prefixed resource-transform section.\r\n *\r\n * @param {object} writer Target byte writer.\r\n * @param {object[]} transforms Resource transforms.\r\n */\r\nexport function writeTransformSection(writer, transforms)\r\n{\r\n writer.u8(transforms.length);\r\n\r\n for (const transform of transforms)\r\n {\r\n const familyName = transform.family ?? \"detail-map-array\";\r\n const family = CARBON_BACKEND_TRANSFORM_FAMILY.indexOf(familyName);\r\n if (family < 0)\r\n {\r\n throw new CjsFormatWriteError(`Unknown transform family \"${transform.family}\"`, {\r\n family: transform.family\r\n });\r\n }\r\n assertRestoredFieldsAgree(transform, familyName, TRANSFORM_DEFAULTS_BY_FAMILY[familyName]);\r\n writer.u8(family);\r\n // `id` stays on the wire: a caller may supply it, and it propagates into\r\n // the engine binding as `transformId`. Deriving it would foreclose the\r\n // caller-supplied plan path to save four bytes.\r\n writeInlineString(writer, transform.id);\r\n writer.u8(transform.inputs.length);\r\n for (const input of transform.inputs)\r\n {\r\n // Array position is the layer. Safe because `parameter` stays on the\r\n // wire, so layer identity remains cross-checkable rather than\r\n // asserted by position.\r\n //\r\n // Checked rather than trusted: the reader rebuilds each input's\r\n // identity from this pair, so a producer that omits it does not fail\r\n // here -- it writes two zero bytes and every layer reads back as\r\n // register 0. That is a wrong package that loads, which is worse\r\n // than one that throws.\r\n if (!Number.isInteger(input.registerSpace) || !Number.isInteger(input.registerIndex))\r\n {\r\n throw new TypeError(\r\n `Resource transform input ${input.parameter} needs integer registerSpace and`\r\n + ` registerIndex; the reader rebuilds its identity from them`\r\n );\r\n }\r\n writer.u8(input.registerSpace);\r\n writer.u8(input.registerIndex);\r\n writeInlineString(writer, input.parameter);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Reads the count-prefixed resource-transform section, restoring derived fields.\r\n *\r\n * @param {object} reader Source byte reader.\r\n * @param {string|null} layoutKey Enclosing pass key, restored onto records.\r\n * @returns {object[]} Resource transforms.\r\n */\r\nexport function readTransformSection(reader, layoutKey)\r\n{\r\n const transforms = [];\r\n const transformCount = reader.readUint8();\r\n\r\n for (let index = 0; index < transformCount; index += 1)\r\n {\r\n const family = CARBON_BACKEND_TRANSFORM_FAMILY[reader.readUint8()];\r\n const defaults = TRANSFORM_DEFAULTS_BY_FAMILY[family];\r\n if (!defaults)\r\n {\r\n throw new CjsFormatReadError(`Transform family \"${family}\" has no restored constants`, {\r\n family\r\n });\r\n }\r\n const id = readInlineString(reader);\r\n const inputs = [];\r\n const inputCount = reader.readUint8();\r\n for (let layer = 0; layer < inputCount; layer += 1)\r\n {\r\n const registerSpace = reader.readUint8();\r\n const registerIndex = reader.readUint8();\r\n const parameter = readInlineString(reader);\r\n const identity = `sampled-resource:${registerSpace}:${registerIndex}`;\r\n inputs.push({\r\n parameter,\r\n layer,\r\n // Kept alongside the identity they compose: a consumer checking\r\n // the transform against a binding set compares registers, and\r\n // re-parsing them back out of the identity string is a second\r\n // place for the format of that string to matter.\r\n registerSpace,\r\n registerIndex,\r\n identity,\r\n scopeIdentity: `${identity}@${defaults.stage}`\r\n });\r\n }\r\n\r\n transforms.push({\r\n id,\r\n family,\r\n version: defaults.version,\r\n kind: defaults.kind,\r\n stage: defaults.stage,\r\n representation: defaults.representation,\r\n missingLayer: defaults.missingLayer,\r\n layoutKey,\r\n inputs,\r\n output: {\r\n name: defaults.outputName,\r\n viewDimension: defaults.viewDimension,\r\n layerCount: inputs.length,\r\n identity: inputs[0]?.identity ?? null,\r\n scopeIdentity: inputs[0]?.scopeIdentity ?? null\r\n }\r\n });\r\n }\r\n\r\n return transforms;\r\n}\r\n"],"names":["CARBON_BACKEND_TRANSFORM_FAMILY","Object","freeze","DETAIL_MAP_ARRAY_DEFAULTS","version","kind","stage","representation","missingLayer","viewDimension","outputName","DETAIL_MAP_ARRAY_NAME","LOCAL_LIGHT_PROFILE_NEUTRAL_DEFAULTS","TRANSFORM_DEFAULTS_BY_FAMILY","assertRestoredFieldsAgree","transform","family","defaults","restored","output","name","field","actual","expected","undefined","CjsFormatWriteError","id","JSON","stringify","layerCount","inputs","length","declared","writeInlineString","writer","value","bytes","TextEncoder","encode","String","byteLength","u16","readInlineString","reader","readUint16","TextDecoder","fatal","decode","readRaw","writeTransformSection","transforms","u8","familyName","indexOf","input","Number","isInteger","registerSpace","registerIndex","TypeError","parameter","readTransformSection","layoutKey","transformCount","readUint8","index","CjsFormatReadError","inputCount","layer","identity","push","scopeIdentity"],"mappings":";;;AAGA;AACA;A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A,iBAAA,EAAoBZ,aAAa,CAAA,CAAA,EAAIC,aAAa,CAAA,CAAE;MACrE5B,MAAM,CAACwC,IAAI,CAAC;QACRV,SAAS;QACTQ,KAAK;AACL;AACA;AACA;AACA;QACAX,aAAa;QACbC,aAAa;QACbW,QAAQ;AACRE,QAAAA,aAAa,EAAE,CAAA,EAAGF,QAAQ,CAAA,CAAA,EAAIpD,QAAQ,CAACX,KAAK,CAAA;AAChD,OAAC,CAAC;AACN,IAAA;IAEA4C,UAAU,CAACoB,IAAI,CAAC;MACZ5C,EAAE;MACFV,MAAM;MACNZ,OAAO,EAAEa,QAAQ,CAACb,OAAO;MACzBC,IAAI,EAAEY,QAAQ,CAACZ,IAAI;MACnBC,KAAK,EAAEW,QAAQ,CAACX,KAAK;MACrBC,cAAc,EAAEU,QAAQ,CAACV,cAAc;MACvCC,YAAY,EAAES,QAAQ,CAACT,YAAY;MACnCsD,SAAS;MACThC,MAAM;AACNX,MAAAA,MAAM,EAAE;QACJC,IAAI,EAAEH,QAAQ,CAACP,UAAU;QACzBD,aAAa,EAAEQ,QAAQ,CAACR,aAAa;QACrCoB,UAAU,EAAEC,MAAM,CAACC,MAAM;QACzBsC,QAAQ,EAAEvC,MAAM,CAAC,CAAC,CAAC,EAAEuC,QAAQ,IAAI,IAAI;AACrCE,QAAAA,aAAa,EAAEzC,MAAM,CAAC,CAAC,CAAC,EAAEyC,aAAa,IAAI;AAC/C;AACJ,KAAC,CAAC;AACN,EAAA;AAEA,EAAA,OAAOrB,UAAU;AACrB;;;;"}
@@ -3,7 +3,7 @@ export { CjsFormatReadError, CjsFormatWriteError } from './CjsFormatError.js';
3
3
  export { CjsByteReader } from './CjsByteReader.js';
4
4
  export { CjsByteWriter } from './CjsByteWriter.js';
5
5
  export { CJS_STRING_TABLE_NULL_REFERENCE, CjsStringTable, compareTableBlobs } from './CjsStringTable.js';
6
- export { CARBON_ANNOTATION_TYPE, CARBON_EFFECT_COUNT_CAPS, CARBON_EFFECT_DATA_VERSION, CARBON_EFFECT_MIN_DATA_VERSION, CARBON_SHADER_CONSTANTS_MAX, collectArena, compareAnnotationNames, internArena, passthroughArena, readEffectDescription, writeEffectDescription } from './carbonEffect/carbonEffectRecords.js';
6
+ export { CARBON_ANNOTATION_TYPE, CARBON_EFFECT_COUNT_CAPS, CARBON_EFFECT_DATA_VERSION, CARBON_EFFECT_MIN_DATA_VERSION, CARBON_EFFECT_WRITE_VERSIONS, CARBON_SHADER_CONSTANTS_MAX, collectArena, compareAnnotationNames, internArena, passthroughArena, readEffectDescription, resolveWriteVersion, writeEffectDescription } from './carbonEffect/carbonEffectRecords.js';
7
7
  export { CARBON_BACKEND_RESOURCE_KIND, CARBON_BACKEND_VISIBILITY, readBackendBlock, writeBackendBlock } from './carbonEffect/carbonEffectBackendBlock.js';
8
8
  export { CARBON_EFFECT_RECORD_BYTES, CARBON_EFFECT_SOURCE_HASH_BYTES, CjsCarbonEffectBodyReader, CjsCarbonEffectReader, looksLikeCarbonEffectContainer } from './carbonEffect/CjsCarbonEffectReader.js';
9
9
  export { CjsCarbonEffectWriter, writeCarbonEffectFile } from './carbonEffect/CjsCarbonEffectWriter.js';
@@ -37,6 +37,7 @@ const DXGI_PIXEL_FORMATS = Object.freeze({
37
37
  6: "rgb32float",
38
38
  10: "rgba16float",
39
39
  16: "rg32float",
40
+ 34: "rg16float",
40
41
  41: "r32float",
41
42
  54: "r16float",
42
43
  28: "rgba8unorm",
@@ -460,7 +461,7 @@ function readDdsTexture(bytes, metadata) {
460
461
  };
461
462
  }
462
463
  function canDecodeDdsToRgba(metadata) {
463
- return ["rgba32float", "rgb32float", "rgba16float", "rg32float", "r32float", "r16float", "rgba8unorm", "rgba8unorm-srgb", "bgra8unorm", "bgra8unorm-srgb", "bgrx8unorm", "bgrx8unorm-srgb", "rgbx8unorm", "bgr8unorm", "l8unorm", "l8a8unorm", "a8unorm", "rg8unorm", "r8unorm", "bc1-rgba-unorm", "bc1-rgba-unorm-srgb", "bc2-rgba-unorm", "bc2-rgba-unorm-srgb", "bc3-rgba-unorm", "bc3-rgba-unorm-srgb", "bc4-r-unorm", "bc4-r-snorm", "bc5-rg-unorm", "bc5-rg-snorm", "bc6h-rgb-ufloat", "bc6h-rgb-float", "bc7-rgba-unorm", "bc7-rgba-unorm-srgb"].includes(metadata.pixelFormat);
464
+ return ["rgba32float", "rgb32float", "rgba16float", "rg32float", "rg16float", "r32float", "r16float", "rgba8unorm", "rgba8unorm-srgb", "bgra8unorm", "bgra8unorm-srgb", "bgrx8unorm", "bgrx8unorm-srgb", "rgbx8unorm", "bgr8unorm", "l8unorm", "l8a8unorm", "a8unorm", "rg8unorm", "r8unorm", "bc1-rgba-unorm", "bc1-rgba-unorm-srgb", "bc2-rgba-unorm", "bc2-rgba-unorm-srgb", "bc3-rgba-unorm", "bc3-rgba-unorm-srgb", "bc4-r-unorm", "bc4-r-snorm", "bc5-rg-unorm", "bc5-rg-snorm", "bc6h-rgb-ufloat", "bc6h-rgb-float", "bc7-rgba-unorm", "bc7-rgba-unorm-srgb"].includes(metadata.pixelFormat);
464
465
  }
465
466
  function readDdsToRgba(bytes, metadata) {
466
467
  if (!canDecodeDdsToRgba(metadata)) {
@@ -563,6 +564,7 @@ function getDdsLevelLayout(pixelFormat, width, height, depth) {
563
564
  "rgb32float": 12,
564
565
  "rgba16float": 8,
565
566
  "rg32float": 8,
567
+ "rg16float": 4,
566
568
  "r32float": 4,
567
569
  "r16float": 2,
568
570
  "rgba8unorm": 4,
@@ -648,6 +650,7 @@ function decodeFloatUncompressed(source, metadata) {
648
650
  "rgb32float": 12,
649
651
  "rgba16float": 8,
650
652
  "rg32float": 8,
653
+ "rg16float": 4,
651
654
  "r32float": 4,
652
655
  "r16float": 2
653
656
  }[metadata.pixelFormat];
@@ -675,6 +678,11 @@ function decodeFloatUncompressed(source, metadata) {
675
678
  green = view.getFloat32(sourceOffset + 4, true);
676
679
  blue = 0;
677
680
  alpha = 1;
681
+ } else if (metadata.pixelFormat === "rg16float") {
682
+ red = halfToFloat(view.getUint16(sourceOffset, true));
683
+ green = halfToFloat(view.getUint16(sourceOffset + 2, true));
684
+ blue = 0;
685
+ alpha = 1;
678
686
  } else {
679
687
  red = metadata.pixelFormat === "r16float" ? halfToFloat(view.getUint16(sourceOffset, true)) : view.getFloat32(sourceOffset, true);
680
688
  green = red;
@@ -689,7 +697,7 @@ function decodeFloatUncompressed(source, metadata) {
689
697
  return rgba;
690
698
  }
691
699
  function isFloatPixelFormat(pixelFormat) {
692
- return typeof pixelFormat === "string" && (pixelFormat.startsWith("bc6h-") || ["rgba32float", "rgb32float", "rgba16float", "rg32float", "r32float", "r16float"].includes(pixelFormat));
700
+ return typeof pixelFormat === "string" && (pixelFormat.startsWith("bc6h-") || ["rgba32float", "rgb32float", "rgba16float", "rg32float", "rg16float", "r32float", "r16float"].includes(pixelFormat));
693
701
  }
694
702
  function halfToFloat(value) {
695
703
  const sign = value & 0x8000 ? -1 : 1;
@@ -832,13 +840,34 @@ function decodeBc1Colors(c0, c1, forceFourColor = false) {
832
840
  function decode565(value) {
833
841
  return [Math.round((value >>> 11 & 0x1f) * 255 / 31), Math.round((value >>> 5 & 0x3f) * 255 / 63), Math.round((value & 0x1f) * 255 / 31), 255];
834
842
  }
843
+
844
+ /**
845
+ * The floating-point `D3DFORMAT` enumerators, which a legacy DDS stores as a
846
+ * NUMBER in the four-character-code field rather than as four characters.
847
+ *
848
+ * That is the whole trap. `DDPF_FOURCC` is set and the field reads `114`, which
849
+ * as text is `"r\0\0\0"` and matches nothing, so a reader that only compares
850
+ * character codes reports an unrecognized format for a file whose format is
851
+ * perfectly ordinary. Every one of these six is a plain uncompressed surface.
852
+ *
853
+ * Two were mapped when BC6H support landed and the other four were not, so
854
+ * `A16B16G16R16F` and `A32B32G32R32F` loaded while their one- and two-channel
855
+ * siblings did not. Found 2026-08-16 on
856
+ * `res:/dx9/model/ship/amarr/battleship/ab3/effects/ab3_traffic.dds`, a 256x9
857
+ * `R32F` gradient.
858
+ */
859
+ const LEGACY_D3DFMT_PIXEL_FORMATS = {
860
+ 111: "r16float",
861
+ 112: "rg16float",
862
+ 113: "rgba16float",
863
+ 114: "r32float",
864
+ 115: "rg32float",
865
+ 116: "rgba32float"
866
+ };
835
867
  function getDdsPixelFormat(format) {
836
868
  if (format.dxgiFormat) return DXGI_PIXEL_FORMATS[format.dxgiFormat] || "";
837
869
  if (format.pfFlags & DDS_FOURCC && format.fourCc) {
838
- return FOURCC_PIXEL_FORMATS[format.fourCc] || {
839
- 113: "rgba16float",
840
- 116: "rgba32float"
841
- }[format.fourCcCode] || "";
870
+ return FOURCC_PIXEL_FORMATS[format.fourCc] || LEGACY_D3DFMT_PIXEL_FORMATS[format.fourCcCode] || "";
842
871
  }
843
872
  if (format.pfFlags & DDS_RGB) {
844
873
  if (format.rgbBitCount === 32 && format.rBitMask === 0x000000ff && format.gBitMask === 0x0000ff00 && format.bBitMask === 0x00ff0000 && format.aBitMask === 0xff000000) return "rgba8unorm";