@carbonenginejs/runtime-resource 0.17.0 → 0.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/format/carbonEffect/CjsCarbonEffectWriter.js +16 -4
  2. package/dist/format/carbonEffect/CjsCarbonEffectWriter.js.map +1 -1
  3. package/dist/format/carbonEffect/backendEngineId.js +1 -3
  4. package/dist/format/carbonEffect/backendEngineId.js.map +1 -1
  5. package/dist/format/carbonEffect/buildCarbonEffectContainer.js +11 -1
  6. package/dist/format/carbonEffect/buildCarbonEffectContainer.js.map +1 -1
  7. package/dist/format/carbonEffect/carbonEffectBackendBlock.js +38 -1
  8. package/dist/format/carbonEffect/carbonEffectBackendBlock.js.map +1 -1
  9. package/dist/format/carbonEffect/carbonEffectRecords.js +45 -1
  10. package/dist/format/carbonEffect/carbonEffectRecords.js.map +1 -1
  11. package/dist/format/carbonEffect/carbonEffectResourceTransform.js +120 -60
  12. package/dist/format/carbonEffect/carbonEffectResourceTransform.js.map +1 -1
  13. package/dist/format/effect/effectPermutationGraph.js +46 -29
  14. package/dist/format/effect/effectPermutationGraph.js.map +1 -1
  15. package/dist/format/index.js +1 -1
  16. package/dist/formats/dds/core/helpers.js +35 -6
  17. package/dist/formats/dds/core/helpers.js.map +1 -1
  18. package/dist/formats/hlsl/core/carbonDescriptionToRuntime.js +53 -1
  19. package/dist/formats/hlsl/core/carbonDescriptionToRuntime.js.map +1 -1
  20. package/dist/formats/hlsl/core/detailMapFamily.js +1 -1
  21. package/dist/formats/hlsl/core/detailMapFamily.js.map +1 -1
  22. package/dist/formats/hlsl/core/localLightFamily.js +1 -1
  23. package/dist/formats/hlsl/core/localLightFamily.js.map +1 -1
  24. package/dist/formats/hlsl/core/tr2/shader/HlslEffectBindingManifest.js +10 -1
  25. package/dist/formats/hlsl/core/tr2/shader/HlslEffectBindingManifest.js.map +1 -1
  26. package/dist/formats/index.js +3 -0
  27. package/dist/formats/index.js.map +1 -1
  28. package/dist/formats/schemabound/CjsSchemaBoundFormat.js +236 -0
  29. package/dist/formats/schemabound/CjsSchemaBoundFormat.js.map +1 -0
  30. package/dist/formats/schemabound/core/schemaBoundErrors.js +9 -0
  31. package/dist/formats/schemabound/core/schemaBoundErrors.js.map +1 -0
  32. package/dist/formats/schemabound/core/schemaBoundValues.js +307 -0
  33. package/dist/formats/schemabound/core/schemaBoundValues.js.map +1 -0
  34. package/dist/formats/schemabound/index.js +2 -0
  35. package/dist/formats/schemabound/index.js.map +1 -0
  36. package/dist/formats/sqlite/CjsSqliteFormat.js +244 -0
  37. package/dist/formats/sqlite/CjsSqliteFormat.js.map +1 -0
  38. package/dist/formats/sqlite/core/sqlitePages.js +159 -0
  39. package/dist/formats/sqlite/core/sqlitePages.js.map +1 -0
  40. package/dist/formats/sqlite/core/sqliteRecords.js +174 -0
  41. package/dist/formats/sqlite/core/sqliteRecords.js.map +1 -0
  42. package/dist/formats/sqlite/core/sqliteSchema.js +100 -0
  43. package/dist/formats/sqlite/core/sqliteSchema.js.map +1 -0
  44. package/dist/formats/sqlite/index.js +2 -0
  45. package/dist/formats/sqlite/index.js.map +1 -0
  46. package/dist/formats/static/CjsStaticFormat.js +220 -0
  47. package/dist/formats/static/CjsStaticFormat.js.map +1 -0
  48. package/dist/formats/static/index.js +2 -0
  49. package/dist/formats/static/index.js.map +1 -0
  50. package/dist/formats/webgl/core/buildGlslEffectContainer.js +3 -1
  51. package/dist/formats/webgl/core/buildGlslEffectContainer.js.map +1 -1
  52. package/dist/formats/webgl/core/effectPackage.js +13 -5
  53. package/dist/formats/webgl/core/effectPackage.js.map +1 -1
  54. package/dist/formats/webgl/core/glsl/DxbcGlslEmitter.js +10 -2
  55. package/dist/formats/webgl/core/glsl/DxbcGlslEmitter.js.map +1 -1
  56. package/dist/formats/webgl/core/glslBackendBlock.js +6 -5
  57. package/dist/formats/webgl/core/glslBackendBlock.js.map +1 -1
  58. package/dist/formats/webgl/core/glslBackendBodySet.js +0 -1
  59. package/dist/formats/webgl/core/glslBackendBodySet.js.map +1 -1
  60. package/dist/formats/webgpu/CjsWebgpuFormat.js +161 -163
  61. package/dist/formats/webgpu/CjsWebgpuFormat.js.map +1 -1
  62. package/dist/formats/webgpu/core/buildCarbonEffectContainer.js +3 -1
  63. package/dist/formats/webgpu/core/buildCarbonEffectContainer.js.map +1 -1
  64. package/dist/formats/webgpu/core/carbonWebgpu/containerViews.js +179 -131
  65. package/dist/formats/webgpu/core/carbonWebgpu/containerViews.js.map +1 -1
  66. package/dist/formats/webgpu/core/effectBackendBodySet.js +2 -3
  67. package/dist/formats/webgpu/core/effectBackendBodySet.js.map +1 -1
  68. package/dist/formats/webgpu/core/helpers.js +111 -99
  69. package/dist/formats/webgpu/core/helpers.js.map +1 -1
  70. package/dist/formats/webgpu/core/packageEffect.js +44 -33
  71. package/dist/formats/webgpu/core/packageEffect.js.map +1 -1
  72. package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js +9 -1
  73. package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js.map +1 -1
  74. package/dist/resource/shader/reflection/Tr2EffectStageInput.js +14 -0
  75. package/dist/resource/shader/reflection/Tr2EffectStageInput.js.map +1 -1
  76. package/docs/concepts/shader-resource-model.md +34 -1
  77. package/docs/formats/README.md +21 -0
  78. package/docs/formats/carbon-effect-container.md +54 -27
  79. package/docs/formats/schemabound.md +112 -0
  80. package/docs/formats/static.md +119 -0
  81. package/docs/formats/webgl/README.md +5 -3
  82. package/docs/formats/webgpu/README.md +2 -2
  83. package/docs/formats/webgpu/architecture.md +2 -2
  84. package/docs/formats/webgpu/formats/carbon-webgpu.md +24 -6
  85. package/docs/formats/webgpu/guides/effect-packaging.md +1 -2
  86. package/docs/formats/webgpu/reference/api.md +7 -6
  87. package/docs/formats/webgpu/reference/wgsl-compatibility.md +2 -2
  88. package/docs/reference/classes/formats.md +33 -0
  89. package/package.json +5 -2
@@ -25,9 +25,9 @@ import { DxbcResourceDimensionNames } from '../../dxbc/core/decoder.js';
25
25
  *
26
26
  * ## Why identifiers are on the wire
27
27
  *
28
- * `docs/contracts/constant-buffer-slots.md` establishes that a constant buffer's
29
- * register index is its meaning, and that identifiers are positional. That is
30
- * true of the *contract* but not sufficient to derive a name here: the pixel
28
+ * A constant buffer's register index is its meaning, and identifiers are
29
+ * positional. That is true of the *contract* but not sufficient to derive a
30
+ * name here: the pixel
31
31
  * stage remaps slot 0 to `cb7` (`DxbcGlslEmitter.js`, `pixelConstantBufferRemap`),
32
32
  * so an identifier is a function of register **and stage**, through a profile
33
33
  * table. A reader deriving names would be re-implementing the emitter's naming
@@ -82,8 +82,9 @@ import { DxbcResourceDimensionNames } from '../../dxbc/core/decoder.js';
82
82
  * Why the pairing is here at all: D3D pairs a texture with a sampler at each
83
83
  * sample site, GLSL merges the two into one uniform, and Carbon's reflection
84
84
  * relates them nowhere. A consumer without this field can only match `t#`
85
- * against `s#` by number, which is coincidence see
86
- * `/docs/contracts/texture-sampler-pairing.md`.
85
+ * against `s#` by number, which is coincidence: with two pattern samplers
86
+ * declared, `NormalMap` at t3 collides with the clamp sampler at s3 and every
87
+ * hull reads its normal map clamped instead of wrapped.
87
88
  */
88
89
 
89
90
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"glslBackendBlock.js","sources":["../../../../../src/formats/webgl/core/glslBackendBlock.js"],"sourcesContent":["import { CjsByteWriter } from \"../../../format/CjsByteWriter.js\";\nimport { CjsByteReader } from \"../../../format/CjsByteReader.js\";\nimport { CjsFormatReadError, CjsFormatWriteError } from \"../../../format/CjsFormatError.js\";\nimport {\n readInlineString,\n readTransformSection,\n writeInlineString,\n writeTransformSection\n} from \"../../../format/carbonEffect/carbonEffectResourceTransform.js\";\nimport {\n CARBON_BACKEND_ENGINE_ID,\n readBackendEngineId\n} from \"../../../format/carbonEffect/backendEngineId.js\";\nimport { DxbcComponentTypeNames } from \"../../dxbc/core/signature.js\";\nimport { DxbcResourceDimensionNames } from \"../../dxbc/core/decoder.js\";\n\n/**\n * The WebGL 2 pass block: what the GLSL text declares but cannot say how to\n * build or bind.\n *\n * This is the GLSL counterpart of `carbonEffectBackendBlock.js`, occupying the\n * same one optional trailing block per pass, and it shares that file's\n * resource-transform section verbatim. Everything else differs, because the two\n * backends' lowering decisions are genuinely different documents: WebGPU records\n * bind-group topology, while WebGL 2 records sampler and uniform declarations,\n * synthesised data textures and UBOs, the vertex attribute ABI, and the recipe\n * for running a compute shader as a fragment pass.\n *\n * Which one parses a given block is decided by the resource path the file came\n * from, the same way the backend itself is chosen — so nothing has to sniff.\n * The leading engine identifier then confirms that decision rather than\n * replacing it, and disagreement is a hard error.\n *\n * ## Why identifiers are on the wire\n *\n * `docs/contracts/constant-buffer-slots.md` establishes that a constant buffer's\n * register index is its meaning, and that identifiers are positional. That is\n * true of the *contract* but not sufficient to derive a name here: the pixel\n * stage remaps slot 0 to `cb7` (`DxbcGlslEmitter.js`, `pixelConstantBufferRemap`),\n * so an identifier is a function of register **and stage**, through a profile\n * table. A reader deriving names would be re-implementing the emitter's naming\n * policy, and a divergence would surface as a uniform that silently never binds\n * rather than as an error. The name is the actual link between this block and\n * the GLSL text, so it is stored and the text stays checkable against it.\n *\n * What is genuinely derived: the sampler type (a total function of the DXBC\n * resource dimension and whether comparison sampling is used) and the data\n * texture formats (constant per binding kind).\n *\n * ## What this block deliberately does not carry\n *\n * **Resource names.** The enclosing Carbon description already lists every\n * texture with its name and register, interned in the string table exactly as a\n * shipped Carbon file does. That is the name authority, and duplicating it here\n * would create two places to disagree.\n *\n * **Merge layer counts.** A merged detail-map array's layer count is the number\n * of inputs on its transform in the section below. The emitter also reports\n * `arrayLayerCount` and `mergedFrom` on the binding for standalone callers with\n * no container around them, and those are intentionally not stored: inside a\n * container the transform is the single source of truth for what merged.\n */\n\n/**\n * ## This block identifies itself, and carries no version of its own\n *\n * The first byte is `CARBON_BACKEND_ENGINE_ID.webgl2`. Until it existed, this\n * writer and the WebGPU one both led with a `1` meaning unrelated things, so a\n * block could not say what it was and identification relied on the caller\n * already knowing.\n *\n * **Carbon's container version is the only version.** An independent counter\n * here would be a second versioning axis over the same bytes, and the two would\n * have to be reasoned about together at every change — while describing a block\n * that is only ever written and read by the same build, because every consumer\n * calls `buildEffect` and then `read` on its result in-process.\n *\n * A shape change is therefore not a compatibility event, it is a rebuild. Stale\n * artifacts are deleted and regenerated rather than parsed by an older path, and\n * the trailing-byte check at the end of the read is what catches a mismatch: a\n * record that does not land exactly on its declared size is a hard error, not a\n * degraded read.\n *\n * This replaced a private version byte whose v1 wrote sampler registers only for\n * comparison sampling and recovered `comparison` as \"that list is non-empty\".\n * Carrying the texture-to-sampler pairing for ordinary textures under that\n * encoding would have marked every one of them a shadow sampler, so the two are\n * now independent fields — as they always were independent facts.\n *\n * Why the pairing is here at all: D3D pairs a texture with a sampler at each\n * sample site, GLSL merges the two into one uniform, and Carbon's reflection\n * relates them nowhere. A consumer without this field can only match `t#`\n * against `s#` by number, which is coincidence — see\n * `/docs/contracts/texture-sampler-pairing.md`.\n */\n\n/**\n * Stage names, as a wire index.\n *\n * These are the emitter's own names, which are Carbon's and D3D's: the pixel\n * stage is `pixel`, not `fragment`. The WebGPU block's visibility enum says\n * `fragment` because that is WGSL's word. Neither is translated into the other -\n * each block speaks its own backend's vocabulary, and the stage a record belongs\n * to is never inferred across the two.\n */\nexport const GLSL_BACKEND_STAGE = Object.freeze([ \"vertex\", \"pixel\", \"compute\" ]);\n\n/**\n * Binding kinds, ordered so the wire value is stable. These are the emitter's\n * own `binding.kind` values (`DxbcGlslEmitter.js`).\n */\nexport const GLSL_BACKEND_BINDING_KIND = Object.freeze([\n \"constantBuffer\",\n \"resource\",\n \"bufferTexture\",\n \"structuredTexture\",\n \"structuredUbo\",\n \"uavTexture\",\n \"dispatchUniform\"\n]);\n\n/** Constant-buffer declaration styles. */\nexport const GLSL_BACKEND_CONSTANT_BUFFER_STYLE = Object.freeze([ \"array\", \"std140\" ]);\n\n/** Sampler type per WebGL2-supported DXBC resource dimension. */\nconst SAMPLER_TYPE_BY_DIMENSION = Object.freeze({\n 2: \"sampler2D\",\n 3: \"sampler2D\",\n 5: \"sampler3D\",\n 6: \"samplerCube\",\n 8: \"sampler2DArray\"\n});\n\n/** Shadow-sampler type per WebGL2-supported DXBC resource dimension. */\nconst SHADOW_SAMPLER_TYPE_BY_DIMENSION = Object.freeze({\n 3: \"sampler2DShadow\",\n 6: \"samplerCubeShadow\",\n 8: \"sampler2DArrayShadow\"\n});\n\n/** Texel formats a synthesised data texture always uses, by binding kind. */\nconst DATA_TEXTURE_FORMAT = Object.freeze({\n bufferTexture: \"RGBA32F\",\n structuredTexture: \"RGBA32UI\"\n});\n\n/** Marks an absent optional `u8`. */\nconst ABSENT_U8 = 0xff;\n\n/**\n * Local-light lowering roles, as a wire index.\n *\n * Carbon puts local lights in two structured buffers plus a profile texture.\n * WebGL 2 has no structured buffers at all, so they have to be re-expressed —\n * this is a *storage* change, not a shading one, and without it the affected\n * shaders cannot bind their lights.\n *\n * The emitter still spells the role `cjsSemantic` on its binding records. That\n * name is not carried onto the wire: it names a defunct package format rather\n * than the thing it describes. Renaming it at the emitter is a separate change.\n */\nexport const GLSL_LOCAL_LIGHT_ROLE = Object.freeze([ \"packed-texture\", \"constant-buffer\" ]);\n\n/** Emitter `cjsSemantic` values, in the same order as the roles above. */\nconst EMITTER_LIGHT_SEMANTIC = Object.freeze([ \"packedLocalLights\", \"localLights\" ]);\n\n/**\n * Writes the optional local-light lowering record.\n *\n * Carries the source registers so a consumer can tie the synthesised resource\n * back to the Carbon resources it replaced, which is otherwise unrecoverable:\n * the shader no longer declares them.\n *\n * @param {CjsByteWriter} writer Target writer.\n * @param {object} binding Emitter binding record.\n */\nfunction writeLocalLightRecord(writer, binding)\n{\n const role = EMITTER_LIGHT_SEMANTIC.indexOf(binding.cjsSemantic);\n\n if (!binding.cjsSemantic)\n {\n writer.u8(0);\n return;\n }\n\n if (role < 0)\n {\n throw new CjsFormatWriteError(\n `Binding \"${binding.name}\" carries unknown local-light role \"${binding.cjsSemantic}\"`,\n { name: binding.name, semantic: binding.cjsSemantic }\n );\n }\n\n writer.u8(1);\n writer.u8(role);\n writer.u8(binding.lightIndexRegister);\n writer.u8(binding.lightDataRegister);\n // The profile array is optional: some permutations never sample it, and the\n // lowering replaces it with neutral attenuation when it is absent.\n writer.u8(binding.lightProfileRegister ?? ABSENT_U8);\n writer.u32(binding.dataTexelBase ?? 0);\n writer.u16(binding.capacityLights ?? 0);\n}\n\n/**\n * Reads the optional local-light lowering record.\n *\n * @param {CjsByteReader} reader Source reader.\n * @returns {object|null} Local-light fields, or null when the binding is ordinary.\n */\nfunction readLocalLightRecord(reader)\n{\n if (!reader.readUint8()) return null;\n\n const role = GLSL_LOCAL_LIGHT_ROLE[reader.readUint8()];\n const lightIndexRegister = reader.readUint8();\n const lightDataRegister = reader.readUint8();\n const profile = reader.readUint8();\n const dataTexelBase = reader.readUint32();\n const capacityLights = reader.readUint16();\n\n return {\n localLightRole: role,\n lightIndexRegister,\n lightDataRegister,\n lightProfileRegister: profile === ABSENT_U8 ? null : profile,\n ...(role === \"packed-texture\" ? { dataTexelBase } : {}),\n ...(role === \"constant-buffer\" ? { capacityLights } : {})\n };\n}\n\n/**\n * Writes one binding's kind-specific payload.\n *\n * @param {CjsByteWriter} writer Target writer.\n * @param {object} binding Emitter binding record.\n */\nfunction writeBindingBody(writer, binding)\n{\n switch (binding.kind)\n {\n case \"constantBuffer\": {\n const style = GLSL_BACKEND_CONSTANT_BUFFER_STYLE.indexOf(binding.style ?? \"array\");\n if (style < 0)\n {\n throw new CjsFormatWriteError(\n `Unknown constant-buffer style \"${binding.style}\"`, { style: binding.style }\n );\n }\n writer.u16(binding.sizeInVec4);\n writer.u8(style);\n writeLocalLightRecord(writer, binding);\n break;\n }\n case \"resource\": {\n const dimension = DxbcResourceDimensionNames.indexOf(binding.dimensionName);\n if (dimension < 0)\n {\n throw new CjsFormatWriteError(\n `Unknown resource dimension \"${binding.dimensionName}\"`,\n { dimensionName: binding.dimensionName }\n );\n }\n writer.u8(dimension);\n const samplers = binding.comparison ? binding.samplerRegisterIndices ?? [] : [];\n writer.u8(samplers.length);\n for (const register of samplers) writer.u8(register);\n // v2: comparison is its own fact, not \"the list above is non-empty\",\n // so the pairing below can be written for ordinary textures too.\n writer.u8(binding.comparison ? 1 : 0);\n const paired = binding.pairedSamplerRegisters ?? [];\n writer.u8(paired.length);\n for (const register of paired) writer.u8(register);\n break;\n }\n case \"bufferTexture\":\n writer.u16(binding.width);\n writeStringList(writer, binding.returnTypes);\n break;\n case \"structuredTexture\":\n writer.u32(binding.strideBytes ?? 0);\n writer.u16(binding.width);\n writeLocalLightRecord(writer, binding);\n break;\n case \"structuredUbo\":\n writer.u32(binding.strideBytes ?? 0);\n writer.u16(binding.capacityElements);\n break;\n case \"uavTexture\":\n writer.u8(binding.slice ?? ABSENT_U8);\n writer.u8(binding.location);\n writeStringList(writer, binding.returnTypes);\n break;\n case \"dispatchUniform\":\n break;\n default:\n throw new CjsFormatWriteError(`Unknown binding kind \"${binding.kind}\"`, {\n kind: binding.kind\n });\n }\n}\n\n/**\n * Reads one binding's kind-specific payload, restoring derived fields.\n *\n * @param {CjsByteReader} reader Source reader.\n * @param {string} kind Binding kind.\n * @returns {object} Kind-specific fields.\n */\nfunction readBindingBody(reader, kind)\n{\n switch (kind)\n {\n case \"constantBuffer\": {\n const sizeInVec4 = reader.readUint16();\n const style = GLSL_BACKEND_CONSTANT_BUFFER_STYLE[reader.readUint8()];\n return { sizeInVec4, style, ...(readLocalLightRecord(reader) ?? {}) };\n }\n case \"resource\": {\n const dimension = reader.readUint8();\n const samplerCount = reader.readUint8();\n const samplerRegisterIndices = [];\n for (let index = 0; index < samplerCount; index += 1)\n {\n samplerRegisterIndices.push(reader.readUint8());\n }\n // Comparison is its own fact rather than \"the register list above is\n // non-empty\", which is what frees the pairing below to be written\n // for ordinary textures too.\n const comparison = reader.readUint8() === 1;\n const pairedSamplerRegisters = [];\n const pairedCount = reader.readUint8();\n for (let index = 0; index < pairedCount; index += 1)\n {\n pairedSamplerRegisters.push(reader.readUint8());\n }\n const samplerType = comparison\n ? SHADOW_SAMPLER_TYPE_BY_DIMENSION[dimension]\n : SAMPLER_TYPE_BY_DIMENSION[dimension];\n\n if (!samplerType)\n {\n throw new CjsFormatReadError(\n `Resource dimension ${dimension} has no ${comparison ? \"shadow \" : \"\"}sampler type`,\n { dimension, comparison }\n );\n }\n\n return {\n samplerType,\n dimensionName: DxbcResourceDimensionNames[dimension] ?? `dimension_${dimension}`,\n ...(pairedSamplerRegisters.length ? { pairedSamplerRegisters } : {}),\n ...(comparison ? { comparison: true, samplerRegisterIndices } : {})\n };\n }\n case \"bufferTexture\":\n return {\n format: DATA_TEXTURE_FORMAT.bufferTexture,\n width: reader.readUint16(),\n returnTypes: readStringList(reader)\n };\n case \"structuredTexture\": {\n const strideBytes = reader.readUint32();\n const width = reader.readUint16();\n return {\n strideBytes,\n format: DATA_TEXTURE_FORMAT.structuredTexture,\n width,\n ...(readLocalLightRecord(reader) ?? {})\n };\n }\n case \"structuredUbo\":\n return {\n strideBytes: reader.readUint32(),\n capacityElements: reader.readUint16()\n };\n case \"uavTexture\": {\n const slice = reader.readUint8();\n return {\n slice: slice === ABSENT_U8 ? null : slice,\n location: reader.readUint8(),\n returnTypes: readStringList(reader)\n };\n }\n case \"dispatchUniform\":\n return {};\n default:\n throw new CjsFormatReadError(`Unknown binding kind \"${kind}\"`, { kind });\n }\n}\n\n/**\n * Writes an optional count-prefixed string list.\n *\n * @param {CjsByteWriter} writer Target writer.\n * @param {string[]|null} values String list, or null.\n */\nfunction writeStringList(writer, values)\n{\n const list = Array.isArray(values) ? values : [];\n writer.u8(list.length);\n for (const value of list) writeInlineString(writer, value);\n}\n\n/**\n * Reads an optional count-prefixed string list.\n *\n * @param {CjsByteReader} reader Source reader.\n * @returns {string[]|null} String list, or null when empty.\n */\nfunction readStringList(reader)\n{\n const count = reader.readUint8();\n if (!count) return null;\n\n const values = [];\n for (let index = 0; index < count; index += 1) values.push(readInlineString(reader));\n return values;\n}\n\n/**\n * Writes the compute-as-fragment section.\n *\n * @param {CjsByteWriter} writer Target writer.\n * @param {object|null} computeFragment Compute-fragment contract, or null.\n */\nfunction writeComputeFragment(writer, computeFragment)\n{\n if (!computeFragment)\n {\n writer.u8(0);\n return;\n }\n\n writer.u8(1);\n const threadGroup = computeFragment.threadGroup;\n writer.u8(threadGroup ? 1 : 0);\n if (threadGroup) for (const extent of threadGroup) writer.u16(extent);\n writeInlineString(writer, computeFragment.dispatchOriginUniform ?? \"\");\n\n const outputs = computeFragment.uavOutputs ?? [];\n writer.u8(outputs.length);\n for (const output of outputs)\n {\n writer.u8(output.register);\n writer.u8(output.slice ?? ABSENT_U8);\n writer.u8(output.location);\n writeInlineString(writer, output.glslName);\n }\n}\n\n/**\n * Reads the compute-as-fragment section.\n *\n * @param {CjsByteReader} reader Source reader.\n * @returns {object|null} Compute-fragment contract, or null.\n */\nfunction readComputeFragment(reader)\n{\n if (!reader.readUint8()) return null;\n\n const threadGroup = reader.readUint8()\n ? [ reader.readUint16(), reader.readUint16(), reader.readUint16() ]\n : null;\n const dispatchOriginUniform = readInlineString(reader);\n\n const uavOutputs = [];\n const outputCount = reader.readUint8();\n for (let index = 0; index < outputCount; index += 1)\n {\n const register = reader.readUint8();\n const slice = reader.readUint8();\n uavOutputs.push({\n register,\n slice: slice === ABSENT_U8 ? null : slice,\n location: reader.readUint8(),\n glslName: readInlineString(reader)\n });\n }\n\n return {\n threadGroup,\n dispatchOriginUniform: dispatchOriginUniform === \"\" ? null : dispatchOriginUniform,\n uavOutputs\n };\n}\n\n/**\n * Serialises one pass's GLSL backend block.\n *\n * @param {object} block Block contents.\n * @param {object} [block.stages] Per-stage lowering data, keyed by stage name.\n * @param {object[]} [block.transforms] Resource transforms.\n * @returns {Uint8Array} Self-contained block bytes.\n */\nexport function writeGlslBackendBlock(block)\n{\n const stages = block.stages ?? {};\n const writer = new CjsByteWriter(256);\n\n writer.u8(CARBON_BACKEND_ENGINE_ID.webgl2);\n\n // Canonical stage order, not object insertion order: two passes with the\n // same lowering must produce the same bytes so the arena dedupes them.\n const present = GLSL_BACKEND_STAGE.filter((name) => stages[name]);\n writer.u8(present.length);\n\n for (const stageName of present)\n {\n const stage = stages[stageName];\n writer.u8(GLSL_BACKEND_STAGE.indexOf(stageName));\n\n const bindings = stage.bindings ?? [];\n writer.u8(bindings.length);\n for (const binding of bindings)\n {\n const kind = GLSL_BACKEND_BINDING_KIND.indexOf(binding.kind);\n if (kind < 0)\n {\n throw new CjsFormatWriteError(`Unknown binding kind \"${binding.kind}\"`, {\n kind: binding.kind\n });\n }\n writer.u8(kind);\n writer.u8(binding.registerIndex ?? ABSENT_U8);\n writeInlineString(writer, binding.name);\n writeBindingBody(writer, binding);\n }\n\n const stageInputs = stage.stageInputs ?? [];\n writer.u8(stageInputs.length);\n for (const input of stageInputs)\n {\n const componentType = DxbcComponentTypeNames.indexOf(input.componentTypeName);\n if (componentType < 0)\n {\n throw new CjsFormatWriteError(\n `Unknown component type \"${input.componentTypeName}\"`,\n { componentTypeName: input.componentTypeName }\n );\n }\n writer.u8(input.register);\n writeInlineString(writer, input.name);\n writeInlineString(writer, input.semanticName);\n writer.u8(input.semanticIndex);\n writer.u8(componentType);\n writer.u8(input.mask);\n }\n\n writeComputeFragment(writer, stage.computeFragment ?? null);\n }\n\n writeTransformSection(writer, block.transforms ?? []);\n\n return writer.toBytes();\n}\n\n/**\n * Parses one pass's GLSL 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 readGlslBackendBlock(bytes, options = {})\n{\n const reader = new CjsByteReader(bytes, { source: options.source ?? \"glsl backend block\" });\n const layoutKey = options.layoutKey ?? null;\n\n // Identity, then straight into the payload: no version byte is read because\n // none is written. Carbon's container version is the only version, and a\n // block whose shape does not match this build fails on the trailing-byte\n // check below - the fix for which is to rebuild the package, never to add a\n // branch.\n readBackendEngineId(reader, CARBON_BACKEND_ENGINE_ID.webgl2, options.source ?? \"glsl backend block\");\n\n const stages = {};\n const stageCount = reader.readUint8();\n\n for (let index = 0; index < stageCount; index += 1)\n {\n const stageName = GLSL_BACKEND_STAGE[reader.readUint8()];\n\n const bindings = [];\n const bindingCount = reader.readUint8();\n for (let bindingIndex = 0; bindingIndex < bindingCount; bindingIndex += 1)\n {\n const kind = GLSL_BACKEND_BINDING_KIND[reader.readUint8()];\n const registerIndex = reader.readUint8();\n const name = readInlineString(reader);\n bindings.push({\n kind,\n ...(registerIndex === ABSENT_U8 ? {} : { registerIndex }),\n name,\n ...readBindingBody(reader, kind)\n });\n }\n\n const stageInputs = [];\n const stageInputCount = reader.readUint8();\n for (let inputIndex = 0; inputIndex < stageInputCount; inputIndex += 1)\n {\n stageInputs.push({\n register: reader.readUint8(),\n name: readInlineString(reader),\n semanticName: readInlineString(reader),\n semanticIndex: reader.readUint8(),\n componentTypeName: DxbcComponentTypeNames[reader.readUint8()],\n mask: reader.readUint8()\n });\n }\n\n const computeFragment = readComputeFragment(reader);\n\n stages[stageName] = {\n bindings,\n stageInputs,\n ...(computeFragment ? { computeFragment } : {})\n };\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 without a version byte\n // is the ONLY signal that a block came from a different build - so this is\n // load-bearing rather than defensive, and it is why removing the version is\n // safe. The fix is always to rebuild the package.\n if (reader.remaining !== 0)\n {\n throw new CjsFormatReadError(\n `GLSL backend block has ${reader.remaining} unparsed trailing byte(s); rebuild the effect package`,\n {\n source: options.source ?? \"glsl backend block\",\n trailingBytes: reader.remaining\n }\n );\n }\n\n return { layoutKey, stages, transforms, trailingBytes: 0 };\n}\n"],"names":["GLSL_BACKEND_STAGE","Object","freeze","GLSL_BACKEND_BINDING_KIND","GLSL_BACKEND_CONSTANT_BUFFER_STYLE","SAMPLER_TYPE_BY_DIMENSION","SHADOW_SAMPLER_TYPE_BY_DIMENSION","DATA_TEXTURE_FORMAT","bufferTexture","structuredTexture","ABSENT_U8","GLSL_LOCAL_LIGHT_ROLE","EMITTER_LIGHT_SEMANTIC","writeLocalLightRecord","writer","binding","role","indexOf","cjsSemantic","u8","CjsFormatWriteError","name","semantic","lightIndexRegister","lightDataRegister","lightProfileRegister","u32","dataTexelBase","u16","capacityLights","readLocalLightRecord","reader","readUint8","profile","readUint32","readUint16","localLightRole","writeBindingBody","kind","style","sizeInVec4","dimension","DxbcResourceDimensionNames","dimensionName","samplers","comparison","samplerRegisterIndices","length","register","paired","pairedSamplerRegisters","width","writeStringList","returnTypes","strideBytes","capacityElements","slice","location","readBindingBody","samplerCount","index","push","pairedCount","samplerType","CjsFormatReadError","format","readStringList","values","list","Array","isArray","value","writeInlineString","count","readInlineString","writeComputeFragment","computeFragment","threadGroup","extent","dispatchOriginUniform","outputs","uavOutputs","output","glslName","readComputeFragment","outputCount","writeGlslBackendBlock","block","stages","CjsByteWriter","CARBON_BACKEND_ENGINE_ID","webgl2","present","filter","stageName","stage","bindings","registerIndex","stageInputs","input","componentType","DxbcComponentTypeNames","componentTypeName","semanticName","semanticIndex","mask","writeTransformSection","transforms","toBytes","readGlslBackendBlock","bytes","options","CjsByteReader","source","layoutKey","readBackendEngineId","stageCount","bindingCount","bindingIndex","stageInputCount","inputIndex","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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AAC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QAAQ;MACRE,WAAW;AACX,MAAA,IAAItB,eAAe,GAAG;AAAEA,QAAAA;OAAiB,GAAG,EAAE;KACjD;AACL,EAAA;AAEA,EAAA,MAAM+B,UAAU,GAAGc,oBAAoB,CAAC1F,MAAM,EAAEmF,SAAS,CAAC;;AAE1D;AACA;AACA;AACA;AACA;AACA,EAAA,IAAInF,MAAM,CAAC2F,SAAS,KAAK,CAAC,EAC1B;IACI,MAAM,IAAI1D,kBAAkB,CACxB,CAAA,uBAAA,EAA0BjC,MAAM,CAAC2F,SAAS,wDAAwD,EAClG;AACIT,MAAAA,MAAM,EAAEF,OAAO,CAACE,MAAM,IAAI,oBAAoB;MAC9CU,aAAa,EAAE5F,MAAM,CAAC2F;AAC1B,KACJ,CAAC;AACL,EAAA;EAEA,OAAO;IAAER,SAAS;IAAE1B,MAAM;IAAEmB,UAAU;AAAEgB,IAAAA,aAAa,EAAE;GAAG;AAC9D;;;;"}
1
+ {"version":3,"file":"glslBackendBlock.js","sources":["../../../../../src/formats/webgl/core/glslBackendBlock.js"],"sourcesContent":["import { CjsByteWriter } from \"../../../format/CjsByteWriter.js\";\nimport { CjsByteReader } from \"../../../format/CjsByteReader.js\";\nimport { CjsFormatReadError, CjsFormatWriteError } from \"../../../format/CjsFormatError.js\";\nimport {\n readInlineString,\n readTransformSection,\n writeInlineString,\n writeTransformSection\n} from \"../../../format/carbonEffect/carbonEffectResourceTransform.js\";\nimport {\n CARBON_BACKEND_ENGINE_ID,\n readBackendEngineId\n} from \"../../../format/carbonEffect/backendEngineId.js\";\nimport { DxbcComponentTypeNames } from \"../../dxbc/core/signature.js\";\nimport { DxbcResourceDimensionNames } from \"../../dxbc/core/decoder.js\";\n\n/**\n * The WebGL 2 pass block: what the GLSL text declares but cannot say how to\n * build or bind.\n *\n * This is the GLSL counterpart of `carbonEffectBackendBlock.js`, occupying the\n * same one optional trailing block per pass, and it shares that file's\n * resource-transform section verbatim. Everything else differs, because the two\n * backends' lowering decisions are genuinely different documents: WebGPU records\n * bind-group topology, while WebGL 2 records sampler and uniform declarations,\n * synthesised data textures and UBOs, the vertex attribute ABI, and the recipe\n * for running a compute shader as a fragment pass.\n *\n * Which one parses a given block is decided by the resource path the file came\n * from, the same way the backend itself is chosen — so nothing has to sniff.\n * The leading engine identifier then confirms that decision rather than\n * replacing it, and disagreement is a hard error.\n *\n * ## Why identifiers are on the wire\n *\n * A constant buffer's register index is its meaning, and identifiers are\n * positional. That is true of the *contract* but not sufficient to derive a\n * name here: the pixel\n * stage remaps slot 0 to `cb7` (`DxbcGlslEmitter.js`, `pixelConstantBufferRemap`),\n * so an identifier is a function of register **and stage**, through a profile\n * table. A reader deriving names would be re-implementing the emitter's naming\n * policy, and a divergence would surface as a uniform that silently never binds\n * rather than as an error. The name is the actual link between this block and\n * the GLSL text, so it is stored and the text stays checkable against it.\n *\n * What is genuinely derived: the sampler type (a total function of the DXBC\n * resource dimension and whether comparison sampling is used) and the data\n * texture formats (constant per binding kind).\n *\n * ## What this block deliberately does not carry\n *\n * **Resource names.** The enclosing Carbon description already lists every\n * texture with its name and register, interned in the string table exactly as a\n * shipped Carbon file does. That is the name authority, and duplicating it here\n * would create two places to disagree.\n *\n * **Merge layer counts.** A merged detail-map array's layer count is the number\n * of inputs on its transform in the section below. The emitter also reports\n * `arrayLayerCount` and `mergedFrom` on the binding for standalone callers with\n * no container around them, and those are intentionally not stored: inside a\n * container the transform is the single source of truth for what merged.\n */\n\n/**\n * ## This block identifies itself, and carries no version of its own\n *\n * The first byte is `CARBON_BACKEND_ENGINE_ID.webgl2`. Until it existed, this\n * writer and the WebGPU one both led with a `1` meaning unrelated things, so a\n * block could not say what it was and identification relied on the caller\n * already knowing.\n *\n * **Carbon's container version is the only version.** An independent counter\n * here would be a second versioning axis over the same bytes, and the two would\n * have to be reasoned about together at every change — while describing a block\n * that is only ever written and read by the same build, because every consumer\n * calls `buildEffect` and then `read` on its result in-process.\n *\n * A shape change is therefore not a compatibility event, it is a rebuild. Stale\n * artifacts are deleted and regenerated rather than parsed by an older path, and\n * the trailing-byte check at the end of the read is what catches a mismatch: a\n * record that does not land exactly on its declared size is a hard error, not a\n * degraded read.\n *\n * This replaced a private version byte whose v1 wrote sampler registers only for\n * comparison sampling and recovered `comparison` as \"that list is non-empty\".\n * Carrying the texture-to-sampler pairing for ordinary textures under that\n * encoding would have marked every one of them a shadow sampler, so the two are\n * now independent fields — as they always were independent facts.\n *\n * Why the pairing is here at all: D3D pairs a texture with a sampler at each\n * sample site, GLSL merges the two into one uniform, and Carbon's reflection\n * relates them nowhere. A consumer without this field can only match `t#`\n * against `s#` by number, which is coincidence: with two pattern samplers\n * declared, `NormalMap` at t3 collides with the clamp sampler at s3 and every\n * hull reads its normal map clamped instead of wrapped.\n */\n\n/**\n * Stage names, as a wire index.\n *\n * These are the emitter's own names, which are Carbon's and D3D's: the pixel\n * stage is `pixel`, not `fragment`. The WebGPU block's visibility enum says\n * `fragment` because that is WGSL's word. Neither is translated into the other -\n * each block speaks its own backend's vocabulary, and the stage a record belongs\n * to is never inferred across the two.\n */\nexport const GLSL_BACKEND_STAGE = Object.freeze([ \"vertex\", \"pixel\", \"compute\" ]);\n\n/**\n * Binding kinds, ordered so the wire value is stable. These are the emitter's\n * own `binding.kind` values (`DxbcGlslEmitter.js`).\n */\nexport const GLSL_BACKEND_BINDING_KIND = Object.freeze([\n \"constantBuffer\",\n \"resource\",\n \"bufferTexture\",\n \"structuredTexture\",\n \"structuredUbo\",\n \"uavTexture\",\n \"dispatchUniform\"\n]);\n\n/** Constant-buffer declaration styles. */\nexport const GLSL_BACKEND_CONSTANT_BUFFER_STYLE = Object.freeze([ \"array\", \"std140\" ]);\n\n/** Sampler type per WebGL2-supported DXBC resource dimension. */\nconst SAMPLER_TYPE_BY_DIMENSION = Object.freeze({\n 2: \"sampler2D\",\n 3: \"sampler2D\",\n 5: \"sampler3D\",\n 6: \"samplerCube\",\n 8: \"sampler2DArray\"\n});\n\n/** Shadow-sampler type per WebGL2-supported DXBC resource dimension. */\nconst SHADOW_SAMPLER_TYPE_BY_DIMENSION = Object.freeze({\n 3: \"sampler2DShadow\",\n 6: \"samplerCubeShadow\",\n 8: \"sampler2DArrayShadow\"\n});\n\n/** Texel formats a synthesised data texture always uses, by binding kind. */\nconst DATA_TEXTURE_FORMAT = Object.freeze({\n bufferTexture: \"RGBA32F\",\n structuredTexture: \"RGBA32UI\"\n});\n\n/** Marks an absent optional `u8`. */\nconst ABSENT_U8 = 0xff;\n\n/**\n * Local-light lowering roles, as a wire index.\n *\n * Carbon puts local lights in two structured buffers plus a profile texture.\n * WebGL 2 has no structured buffers at all, so they have to be re-expressed —\n * this is a *storage* change, not a shading one, and without it the affected\n * shaders cannot bind their lights.\n *\n * The emitter still spells the role `cjsSemantic` on its binding records. That\n * name is not carried onto the wire: it names a defunct package format rather\n * than the thing it describes. Renaming it at the emitter is a separate change.\n */\nexport const GLSL_LOCAL_LIGHT_ROLE = Object.freeze([ \"packed-texture\", \"constant-buffer\" ]);\n\n/** Emitter `cjsSemantic` values, in the same order as the roles above. */\nconst EMITTER_LIGHT_SEMANTIC = Object.freeze([ \"packedLocalLights\", \"localLights\" ]);\n\n/**\n * Writes the optional local-light lowering record.\n *\n * Carries the source registers so a consumer can tie the synthesised resource\n * back to the Carbon resources it replaced, which is otherwise unrecoverable:\n * the shader no longer declares them.\n *\n * @param {CjsByteWriter} writer Target writer.\n * @param {object} binding Emitter binding record.\n */\nfunction writeLocalLightRecord(writer, binding)\n{\n const role = EMITTER_LIGHT_SEMANTIC.indexOf(binding.cjsSemantic);\n\n if (!binding.cjsSemantic)\n {\n writer.u8(0);\n return;\n }\n\n if (role < 0)\n {\n throw new CjsFormatWriteError(\n `Binding \"${binding.name}\" carries unknown local-light role \"${binding.cjsSemantic}\"`,\n { name: binding.name, semantic: binding.cjsSemantic }\n );\n }\n\n writer.u8(1);\n writer.u8(role);\n writer.u8(binding.lightIndexRegister);\n writer.u8(binding.lightDataRegister);\n // The profile array is optional: some permutations never sample it, and the\n // lowering replaces it with neutral attenuation when it is absent.\n writer.u8(binding.lightProfileRegister ?? ABSENT_U8);\n writer.u32(binding.dataTexelBase ?? 0);\n writer.u16(binding.capacityLights ?? 0);\n}\n\n/**\n * Reads the optional local-light lowering record.\n *\n * @param {CjsByteReader} reader Source reader.\n * @returns {object|null} Local-light fields, or null when the binding is ordinary.\n */\nfunction readLocalLightRecord(reader)\n{\n if (!reader.readUint8()) return null;\n\n const role = GLSL_LOCAL_LIGHT_ROLE[reader.readUint8()];\n const lightIndexRegister = reader.readUint8();\n const lightDataRegister = reader.readUint8();\n const profile = reader.readUint8();\n const dataTexelBase = reader.readUint32();\n const capacityLights = reader.readUint16();\n\n return {\n localLightRole: role,\n lightIndexRegister,\n lightDataRegister,\n lightProfileRegister: profile === ABSENT_U8 ? null : profile,\n ...(role === \"packed-texture\" ? { dataTexelBase } : {}),\n ...(role === \"constant-buffer\" ? { capacityLights } : {})\n };\n}\n\n/**\n * Writes one binding's kind-specific payload.\n *\n * @param {CjsByteWriter} writer Target writer.\n * @param {object} binding Emitter binding record.\n */\nfunction writeBindingBody(writer, binding)\n{\n switch (binding.kind)\n {\n case \"constantBuffer\": {\n const style = GLSL_BACKEND_CONSTANT_BUFFER_STYLE.indexOf(binding.style ?? \"array\");\n if (style < 0)\n {\n throw new CjsFormatWriteError(\n `Unknown constant-buffer style \"${binding.style}\"`, { style: binding.style }\n );\n }\n writer.u16(binding.sizeInVec4);\n writer.u8(style);\n writeLocalLightRecord(writer, binding);\n break;\n }\n case \"resource\": {\n const dimension = DxbcResourceDimensionNames.indexOf(binding.dimensionName);\n if (dimension < 0)\n {\n throw new CjsFormatWriteError(\n `Unknown resource dimension \"${binding.dimensionName}\"`,\n { dimensionName: binding.dimensionName }\n );\n }\n writer.u8(dimension);\n const samplers = binding.comparison ? binding.samplerRegisterIndices ?? [] : [];\n writer.u8(samplers.length);\n for (const register of samplers) writer.u8(register);\n // v2: comparison is its own fact, not \"the list above is non-empty\",\n // so the pairing below can be written for ordinary textures too.\n writer.u8(binding.comparison ? 1 : 0);\n const paired = binding.pairedSamplerRegisters ?? [];\n writer.u8(paired.length);\n for (const register of paired) writer.u8(register);\n break;\n }\n case \"bufferTexture\":\n writer.u16(binding.width);\n writeStringList(writer, binding.returnTypes);\n break;\n case \"structuredTexture\":\n writer.u32(binding.strideBytes ?? 0);\n writer.u16(binding.width);\n writeLocalLightRecord(writer, binding);\n break;\n case \"structuredUbo\":\n writer.u32(binding.strideBytes ?? 0);\n writer.u16(binding.capacityElements);\n break;\n case \"uavTexture\":\n writer.u8(binding.slice ?? ABSENT_U8);\n writer.u8(binding.location);\n writeStringList(writer, binding.returnTypes);\n break;\n case \"dispatchUniform\":\n break;\n default:\n throw new CjsFormatWriteError(`Unknown binding kind \"${binding.kind}\"`, {\n kind: binding.kind\n });\n }\n}\n\n/**\n * Reads one binding's kind-specific payload, restoring derived fields.\n *\n * @param {CjsByteReader} reader Source reader.\n * @param {string} kind Binding kind.\n * @returns {object} Kind-specific fields.\n */\nfunction readBindingBody(reader, kind)\n{\n switch (kind)\n {\n case \"constantBuffer\": {\n const sizeInVec4 = reader.readUint16();\n const style = GLSL_BACKEND_CONSTANT_BUFFER_STYLE[reader.readUint8()];\n return { sizeInVec4, style, ...(readLocalLightRecord(reader) ?? {}) };\n }\n case \"resource\": {\n const dimension = reader.readUint8();\n const samplerCount = reader.readUint8();\n const samplerRegisterIndices = [];\n for (let index = 0; index < samplerCount; index += 1)\n {\n samplerRegisterIndices.push(reader.readUint8());\n }\n // Comparison is its own fact rather than \"the register list above is\n // non-empty\", which is what frees the pairing below to be written\n // for ordinary textures too.\n const comparison = reader.readUint8() === 1;\n const pairedSamplerRegisters = [];\n const pairedCount = reader.readUint8();\n for (let index = 0; index < pairedCount; index += 1)\n {\n pairedSamplerRegisters.push(reader.readUint8());\n }\n const samplerType = comparison\n ? SHADOW_SAMPLER_TYPE_BY_DIMENSION[dimension]\n : SAMPLER_TYPE_BY_DIMENSION[dimension];\n\n if (!samplerType)\n {\n throw new CjsFormatReadError(\n `Resource dimension ${dimension} has no ${comparison ? \"shadow \" : \"\"}sampler type`,\n { dimension, comparison }\n );\n }\n\n return {\n samplerType,\n dimensionName: DxbcResourceDimensionNames[dimension] ?? `dimension_${dimension}`,\n ...(pairedSamplerRegisters.length ? { pairedSamplerRegisters } : {}),\n ...(comparison ? { comparison: true, samplerRegisterIndices } : {})\n };\n }\n case \"bufferTexture\":\n return {\n format: DATA_TEXTURE_FORMAT.bufferTexture,\n width: reader.readUint16(),\n returnTypes: readStringList(reader)\n };\n case \"structuredTexture\": {\n const strideBytes = reader.readUint32();\n const width = reader.readUint16();\n return {\n strideBytes,\n format: DATA_TEXTURE_FORMAT.structuredTexture,\n width,\n ...(readLocalLightRecord(reader) ?? {})\n };\n }\n case \"structuredUbo\":\n return {\n strideBytes: reader.readUint32(),\n capacityElements: reader.readUint16()\n };\n case \"uavTexture\": {\n const slice = reader.readUint8();\n return {\n slice: slice === ABSENT_U8 ? null : slice,\n location: reader.readUint8(),\n returnTypes: readStringList(reader)\n };\n }\n case \"dispatchUniform\":\n return {};\n default:\n throw new CjsFormatReadError(`Unknown binding kind \"${kind}\"`, { kind });\n }\n}\n\n/**\n * Writes an optional count-prefixed string list.\n *\n * @param {CjsByteWriter} writer Target writer.\n * @param {string[]|null} values String list, or null.\n */\nfunction writeStringList(writer, values)\n{\n const list = Array.isArray(values) ? values : [];\n writer.u8(list.length);\n for (const value of list) writeInlineString(writer, value);\n}\n\n/**\n * Reads an optional count-prefixed string list.\n *\n * @param {CjsByteReader} reader Source reader.\n * @returns {string[]|null} String list, or null when empty.\n */\nfunction readStringList(reader)\n{\n const count = reader.readUint8();\n if (!count) return null;\n\n const values = [];\n for (let index = 0; index < count; index += 1) values.push(readInlineString(reader));\n return values;\n}\n\n/**\n * Writes the compute-as-fragment section.\n *\n * @param {CjsByteWriter} writer Target writer.\n * @param {object|null} computeFragment Compute-fragment contract, or null.\n */\nfunction writeComputeFragment(writer, computeFragment)\n{\n if (!computeFragment)\n {\n writer.u8(0);\n return;\n }\n\n writer.u8(1);\n const threadGroup = computeFragment.threadGroup;\n writer.u8(threadGroup ? 1 : 0);\n if (threadGroup) for (const extent of threadGroup) writer.u16(extent);\n writeInlineString(writer, computeFragment.dispatchOriginUniform ?? \"\");\n\n const outputs = computeFragment.uavOutputs ?? [];\n writer.u8(outputs.length);\n for (const output of outputs)\n {\n writer.u8(output.register);\n writer.u8(output.slice ?? ABSENT_U8);\n writer.u8(output.location);\n writeInlineString(writer, output.glslName);\n }\n}\n\n/**\n * Reads the compute-as-fragment section.\n *\n * @param {CjsByteReader} reader Source reader.\n * @returns {object|null} Compute-fragment contract, or null.\n */\nfunction readComputeFragment(reader)\n{\n if (!reader.readUint8()) return null;\n\n const threadGroup = reader.readUint8()\n ? [ reader.readUint16(), reader.readUint16(), reader.readUint16() ]\n : null;\n const dispatchOriginUniform = readInlineString(reader);\n\n const uavOutputs = [];\n const outputCount = reader.readUint8();\n for (let index = 0; index < outputCount; index += 1)\n {\n const register = reader.readUint8();\n const slice = reader.readUint8();\n uavOutputs.push({\n register,\n slice: slice === ABSENT_U8 ? null : slice,\n location: reader.readUint8(),\n glslName: readInlineString(reader)\n });\n }\n\n return {\n threadGroup,\n dispatchOriginUniform: dispatchOriginUniform === \"\" ? null : dispatchOriginUniform,\n uavOutputs\n };\n}\n\n/**\n * Serialises one pass's GLSL backend block.\n *\n * @param {object} block Block contents.\n * @param {object} [block.stages] Per-stage lowering data, keyed by stage name.\n * @param {object[]} [block.transforms] Resource transforms.\n * @returns {Uint8Array} Self-contained block bytes.\n */\nexport function writeGlslBackendBlock(block)\n{\n const stages = block.stages ?? {};\n const writer = new CjsByteWriter(256);\n\n writer.u8(CARBON_BACKEND_ENGINE_ID.webgl2);\n\n // Canonical stage order, not object insertion order: two passes with the\n // same lowering must produce the same bytes so the arena dedupes them.\n const present = GLSL_BACKEND_STAGE.filter((name) => stages[name]);\n writer.u8(present.length);\n\n for (const stageName of present)\n {\n const stage = stages[stageName];\n writer.u8(GLSL_BACKEND_STAGE.indexOf(stageName));\n\n const bindings = stage.bindings ?? [];\n writer.u8(bindings.length);\n for (const binding of bindings)\n {\n const kind = GLSL_BACKEND_BINDING_KIND.indexOf(binding.kind);\n if (kind < 0)\n {\n throw new CjsFormatWriteError(`Unknown binding kind \"${binding.kind}\"`, {\n kind: binding.kind\n });\n }\n writer.u8(kind);\n writer.u8(binding.registerIndex ?? ABSENT_U8);\n writeInlineString(writer, binding.name);\n writeBindingBody(writer, binding);\n }\n\n const stageInputs = stage.stageInputs ?? [];\n writer.u8(stageInputs.length);\n for (const input of stageInputs)\n {\n const componentType = DxbcComponentTypeNames.indexOf(input.componentTypeName);\n if (componentType < 0)\n {\n throw new CjsFormatWriteError(\n `Unknown component type \"${input.componentTypeName}\"`,\n { componentTypeName: input.componentTypeName }\n );\n }\n writer.u8(input.register);\n writeInlineString(writer, input.name);\n writeInlineString(writer, input.semanticName);\n writer.u8(input.semanticIndex);\n writer.u8(componentType);\n writer.u8(input.mask);\n }\n\n writeComputeFragment(writer, stage.computeFragment ?? null);\n }\n\n writeTransformSection(writer, block.transforms ?? []);\n\n return writer.toBytes();\n}\n\n/**\n * Parses one pass's GLSL 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 readGlslBackendBlock(bytes, options = {})\n{\n const reader = new CjsByteReader(bytes, { source: options.source ?? \"glsl backend block\" });\n const layoutKey = options.layoutKey ?? null;\n\n // Identity, then straight into the payload: no version byte is read because\n // none is written. Carbon's container version is the only version, and a\n // block whose shape does not match this build fails on the trailing-byte\n // check below - the fix for which is to rebuild the package, never to add a\n // branch.\n readBackendEngineId(reader, CARBON_BACKEND_ENGINE_ID.webgl2, options.source ?? \"glsl backend block\");\n\n const stages = {};\n const stageCount = reader.readUint8();\n\n for (let index = 0; index < stageCount; index += 1)\n {\n const stageName = GLSL_BACKEND_STAGE[reader.readUint8()];\n\n const bindings = [];\n const bindingCount = reader.readUint8();\n for (let bindingIndex = 0; bindingIndex < bindingCount; bindingIndex += 1)\n {\n const kind = GLSL_BACKEND_BINDING_KIND[reader.readUint8()];\n const registerIndex = reader.readUint8();\n const name = readInlineString(reader);\n bindings.push({\n kind,\n ...(registerIndex === ABSENT_U8 ? {} : { registerIndex }),\n name,\n ...readBindingBody(reader, kind)\n });\n }\n\n const stageInputs = [];\n const stageInputCount = reader.readUint8();\n for (let inputIndex = 0; inputIndex < stageInputCount; inputIndex += 1)\n {\n stageInputs.push({\n register: reader.readUint8(),\n name: readInlineString(reader),\n semanticName: readInlineString(reader),\n semanticIndex: reader.readUint8(),\n componentTypeName: DxbcComponentTypeNames[reader.readUint8()],\n mask: reader.readUint8()\n });\n }\n\n const computeFragment = readComputeFragment(reader);\n\n stages[stageName] = {\n bindings,\n stageInputs,\n ...(computeFragment ? { computeFragment } : {})\n };\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 without a version byte\n // is the ONLY signal that a block came from a different build - so this is\n // load-bearing rather than defensive, and it is why removing the version is\n // safe. The fix is always to rebuild the package.\n if (reader.remaining !== 0)\n {\n throw new CjsFormatReadError(\n `GLSL backend block has ${reader.remaining} unparsed trailing byte(s); rebuild the effect package`,\n {\n source: options.source ?? \"glsl backend block\",\n trailingBytes: reader.remaining\n }\n );\n }\n\n return { layoutKey, stages, transforms, trailingBytes: 0 };\n}\n"],"names":["GLSL_BACKEND_STAGE","Object","freeze","GLSL_BACKEND_BINDING_KIND","GLSL_BACKEND_CONSTANT_BUFFER_STYLE","SAMPLER_TYPE_BY_DIMENSION","SHADOW_SAMPLER_TYPE_BY_DIMENSION","DATA_TEXTURE_FORMAT","bufferTexture","structuredTexture","ABSENT_U8","GLSL_LOCAL_LIGHT_ROLE","EMITTER_LIGHT_SEMANTIC","writeLocalLightRecord","writer","binding","role","indexOf","cjsSemantic","u8","CjsFormatWriteError","name","semantic","lightIndexRegister","lightDataRegister","lightProfileRegister","u32","dataTexelBase","u16","capacityLights","readLocalLightRecord","reader","readUint8","profile","readUint32","readUint16","localLightRole","writeBindingBody","kind","style","sizeInVec4","dimension","DxbcResourceDimensionNames","dimensionName","samplers","comparison","samplerRegisterIndices","length","register","paired","pairedSamplerRegisters","width","writeStringList","returnTypes","strideBytes","capacityElements","slice","location","readBindingBody","samplerCount","index","push","pairedCount","samplerType","CjsFormatReadError","format","readStringList","values","list","Array","isArray","value","writeInlineString","count","readInlineString","writeComputeFragment","computeFragment","threadGroup","extent","dispatchOriginUniform","outputs","uavOutputs","output","glslName","readComputeFragment","outputCount","writeGlslBackendBlock","block","stages","CjsByteWriter","CARBON_BACKEND_ENGINE_ID","webgl2","present","filter","stageName","stage","bindings","registerIndex","stageInputs","input","componentType","DxbcComponentTypeNames","componentTypeName","semanticName","semanticIndex","mask","writeTransformSection","transforms","toBytes","readGlslBackendBlock","bytes","options","CjsByteReader","source","layoutKey","readBackendEngineId","stageCount","bindingCount","bindingIndex","stageInputCount","inputIndex","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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,M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C;;AAE1D;AACA;AACA;AACA;AACA;AACA,EAAA,IAAInF,MAAM,CAAC2F,SAAS,KAAK,CAAC,EAC1B;IACI,MAAM,IAAI1D,kBAAkB,CACxB,CAAA,uBAAA,EAA0BjC,MAAM,CAAC2F,SAAS,wDAAwD,EAClG;AACIT,MAAAA,MAAM,EAAEF,OAAO,CAACE,MAAM,IAAI,oBAAoB;MAC9CU,aAAa,EAAE5F,MAAM,CAAC2F;AAC1B,KACJ,CAAC;AACL,EAAA;EAEA,OAAO;IAAER,SAAS;IAAE1B,MAAM;IAAEmB,UAAU;AAAEgB,IAAAA,aAAa,EAAE;GAAG;AAC9D;;;;"}
@@ -74,7 +74,6 @@ function unitSignature(unit) {
74
74
  * depends on the register *and* the stage, through a profile table. Deriving it
75
75
  * downstream would re-implement that policy, and a divergence would show up as a
76
76
  * uniform that never binds rather than as an error.
77
- * See docs/contracts/constant-buffer-slots.md.
78
77
  *
79
78
  * @param {object} shader Translated shader record.
80
79
  * @returns {object|null} Stage block data, or null when the stage adds nothing.
@@ -1 +1 @@
1
- {"version":3,"file":"glslBackendBodySet.js","sources":["../../../../../src/formats/webgl/core/glslBackendBodySet.js"],"sourcesContent":["import { detailMapTransformFor } from \"../../hlsl/core/detailMapFamily.js\";\nimport { localLightProfileNeutralTransformFor } from \"../../hlsl/core/localLightFamily.js\";\n\n/**\n * Reshapes translated GLSL into the backend body set the Carbon container\n * writer consumes.\n *\n * This is the WebGL counterpart of `formats/webgpu/core/effectBackendBodySet.js`\n * and deliberately emits the same envelope, because `buildCarbonEffectContainer`\n * is backend-neutral and should stay that way: it wants bodies, passes and\n * translation units, and does not care what language the programs are in.\n *\n * Two facts drive the shape here, and neither is obvious:\n *\n * 1. **Body keys must be the permutation graph's, not this package's.** The\n * effect walk mints `body_${offset}_${size}` while the graph mints\n * `body${N}`. The container writer drives off graph variants, so a package\n * key reaching it would silently match nothing. The bridge is the\n * permutation index, not string surgery on either spelling.\n *\n * 2. **A translation unit is per pass, never per shader.** One DXBC vertex body\n * can lower to several different GLSL programs, because `pairVaryings`\n * zero-fills the varyings a paired pixel stage reads but the vertex stage\n * never writes - and that set differs per pass. Deduplicating programs by\n * bytecode would therefore collapse two genuinely different programs into\n * one. The unit signature includes the pass key for exactly this reason.\n */\n\n/**\n * Carbon's pass identity, matching the WebGPU emitter so both backends key\n * passes identically.\n *\n * @param {string} techniqueName Technique name.\n * @param {number} passIndex Pass index within the technique.\n * @returns {string} Pass key.\n */\nfunction passKeyFor(techniqueName, passIndex)\n{\n return `${techniqueName}.pass${passIndex}`;\n}\n\n/**\n * Stable signature for one pass translation unit.\n *\n * Includes `passKey` because pass-scoped varying pairing can make two units\n * differ while their source bytecode is identical. Excludes diagnostics\n * (`emitWarnings`, `hlsl2webgl`) because they describe the build, not the\n * program, and would split otherwise-identical units.\n *\n * @param {object} unit Candidate unit.\n * @returns {string} Signature.\n */\nfunction unitSignature(unit)\n{\n return JSON.stringify({\n passKey: unit.passKey,\n shaders: unit.shaders,\n block: unit.block,\n resourceTransforms: unit.resourceTransforms\n });\n}\n\n/**\n * Collect the per-stage data that has no home in Carbon reflection.\n *\n * Carbon records the logical resource and its register; these are the lowering\n * decisions taken on top of that - fused sampler pairs, synthesised data\n * textures and UBOs, dropped stub registers, and integer attributes lowered to\n * float. The GLSL text declares them but does not say how to build or bind\n * them, and reflection does not know they happened.\n *\n * Identifiers are kept. An earlier version of this comment claimed `cb{n}`,\n * `s{n}` and `attr{n}` are functions of the register index alone and so need not\n * be stored. They are not: the pixel stage remaps constant-buffer slot 0 to\n * `cb7` (`DxbcGlslEmitter.js`, `pixelConstantBufferRemap`), so an identifier\n * depends on the register *and* the stage, through a profile table. Deriving it\n * downstream would re-implement that policy, and a divergence would show up as a\n * uniform that never binds rather than as an error.\n * See docs/contracts/constant-buffer-slots.md.\n *\n * @param {object} shader Translated shader record.\n * @returns {object|null} Stage block data, or null when the stage adds nothing.\n */\nfunction stageBlockFor(shader)\n{\n const block = {};\n\n if (Array.isArray(shader.bindings) && shader.bindings.length)\n {\n block.bindings = shader.bindings;\n }\n if (Array.isArray(shader.stageInputs) && shader.stageInputs.length)\n {\n block.stageInputs = shader.stageInputs;\n }\n if (shader.computeFragment)\n {\n block.computeFragment = shader.computeFragment;\n }\n\n return Object.keys(block).length ? block : null;\n}\n\n/**\n * Build the backend body set for a translated WebGL effect.\n *\n * @param {object} input Translation results.\n * @param {Array<object>} input.bodies Body records from the effect walk.\n * @param {Array<object>} input.stages Stage records from the effect walk.\n * @param {Array<object>} input.shaders Translated shader records.\n * @param {Array<object>} input.variants Export variants, carrying permutation indices.\n * @param {object} input.permutationGraph Validated permutation graph.\n * @returns {object} Backend body set in the container writer's shape.\n */\nexport function buildGlslBackendBodySet(input)\n{\n const { bodies, stages, shaders, variants, permutationGraph } = input;\n\n const shadersByKey = new Map(shaders.map((shader) => [ shader.key, shader ]));\n const stagesByBody = new Map();\n for (const stage of stages)\n {\n if (!stagesByBody.has(stage.bodyKey)) stagesByBody.set(stage.bodyKey, []);\n stagesByBody.get(stage.bodyKey).push(stage);\n }\n\n // Package body key -> the graph's own key, bridged through the permutation\n // index rather than by reformatting either spelling.\n const graphKeyByPackageKey = new Map();\n const permutationIndexByPackageKey = new Map();\n for (const variant of variants)\n {\n if (graphKeyByPackageKey.has(variant.bodyKey)) continue;\n const graphVariant = permutationGraph.variants[variant.permutationIndex];\n if (!graphVariant) continue;\n graphKeyByPackageKey.set(variant.bodyKey, graphVariant.bodyKey);\n permutationIndexByPackageKey.set(variant.bodyKey, variant.permutationIndex);\n }\n\n const passUnits = [];\n const unitKeyBySignature = new Map();\n const emittedBodies = [];\n\n for (const body of bodies)\n {\n const graphBodyKey = graphKeyByPackageKey.get(body.key);\n if (!graphBodyKey) continue;\n\n const representativePermutationIndex =\n permutationIndexByPackageKey.get(body.key) ?? 0;\n\n if (body.error)\n {\n emittedBodies.push(Object.freeze({\n bodyKey: graphBodyKey,\n representativePermutationIndex,\n status: \"unsupported\",\n error: body.error,\n passes: Object.freeze([])\n }));\n continue;\n }\n\n const passes = new Map();\n for (const stage of stagesByBody.get(body.key) ?? [])\n {\n const key = passKeyFor(stage.techniqueName, stage.passIndex);\n if (!passes.has(key))\n {\n passes.set(key, { passKey: key, shaders: [], block: {}, transforms: [] });\n }\n\n const shader = shadersByKey.get(stage.shaderKey);\n // A stage the translator could not lower carries no program. The\n // body still emits, with reflection intact and an empty slot, so\n // the offset table stays dense and the failure is visible rather\n // than absent.\n if (!shader?.source) continue;\n\n const entry = passes.get(key);\n\n // The merge is a property of the pass, not of one stage: the block's\n // transform section says how to build the array the GLSL samples.\n // Built here rather than at translation time because the transform's\n // identity includes the pass key, which the translator does not know.\n if (shader.detailMapArray && !entry.hasDetailMapTransform)\n {\n entry.hasDetailMapTransform = true;\n entry.transforms.push(detailMapTransformFor(shader.detailMapArray, key));\n }\n\n // Same reasoning, different statement: this one records that the\n // light profile array was dropped for a constant, so the resource\n // the description still lists is accounted for rather than missing.\n if (shader.lightProfileNeutral && !entry.hasLightProfileTransform)\n {\n const transform = localLightProfileNeutralTransformFor(shader.lightProfileNeutral, key);\n if (transform)\n {\n entry.hasLightProfileTransform = true;\n entry.transforms.push(transform);\n }\n }\n\n entry.shaders.push({\n key: `${key}.${stage.stageName}`,\n stageName: stage.stageName,\n stageType: stage.stageType,\n code: shader.source\n });\n\n const stageBlock = stageBlockFor(shader);\n if (stageBlock) entry.block[stage.stageName] = stageBlock;\n }\n\n const bodyPasses = [];\n let translatedPassCount = 0;\n\n for (const pass of passes.values())\n {\n if (!pass.shaders.length) continue;\n translatedPassCount += 1;\n\n const unit = {\n passKey: pass.passKey,\n shaders: pass.shaders,\n block: Object.keys(pass.block).length ? pass.block : null,\n resourceTransforms: pass.transforms\n };\n const signature = unitSignature(unit);\n let unitKey = unitKeyBySignature.get(signature);\n\n if (!unitKey)\n {\n unitKey = `unit${passUnits.length}`;\n unitKeyBySignature.set(signature, unitKey);\n passUnits.push(Object.freeze({ key: unitKey, ...unit }));\n }\n\n bodyPasses.push(Object.freeze({ passKey: pass.passKey, unitKey }));\n }\n\n emittedBodies.push(Object.freeze({\n bodyKey: graphBodyKey,\n representativePermutationIndex,\n status: translatedPassCount ? \"translated\" : \"unsupported\",\n error: translatedPassCount ? null : \"no pass produced a translated program\",\n passes: Object.freeze(bodyPasses)\n }));\n }\n\n return Object.freeze({\n format: \"CJS_GLSL_BODY_SET\",\n formatVersion: 1,\n bodyCount: emittedBodies.length,\n translatedBodyCount: emittedBodies.filter((body) => body.status === \"translated\").length,\n passUnitCount: passUnits.length,\n passUnits: Object.freeze(passUnits),\n bodies: Object.freeze(emittedBodies)\n });\n}\n\nexport default buildGlslBackendBodySet;\n"],"names":["passKeyFor","techniqueName","passIndex","unitSignature","unit","JSON","stringify","passKey","shaders","block","resourceTransforms","stageBlockFor","shader","Array","isArray","bindings","length","stageInputs","computeFragment","Object","keys","buildGlslBackendBodySet","input","bodies","stages","variants","permutationGraph","shadersByKey","Map","map","key","stagesByBody","stage","has","bodyKey","set","get","push","graphKeyByPackageKey","permutationIndexByPackageKey","variant","graphVariant","permutationIndex","passUnits","unitKeyBySignature","emittedBodies","body","graphBodyKey","representativePermutationIndex","error","freeze","status","passes","transforms","shaderKey","source","entry","detailMapArray","hasDetailMapTransform","detailMapTransformFor","lightProfileNeutral","hasLightProfileTransform","transform","localLightProfileNeutralTransformFor","stageName","stageType","code","stageBlock","bodyPasses","translatedPassCount","pass","values","signature","unitKey","format","formatVersion","bodyCount","translatedBodyCount","filter","passUnitCount"],"mappings":";;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,UAAUA,CAACC,aAAa,EAAEC,SAAS,EAC5C;AACI,EAAA,OAAO,CAAA,EAAGD,aAAa,CAAA,KAAA,EAAQC,SAAS,CAAA,CAAE;AAC9C;;AAEA;A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uC;AAC3EjB,MAAAA,MAAM,EAAEjC,MAAM,CAAC+B,MAAM,CAACkB,UAAU;AACpC,KAAC,CAAC,CAAC;AACP,EAAA;EAEA,OAAOjD,MAAM,CAAC+B,MAAM,CAAC;AACjBwB,IAAAA,MAAM,EAAE,mBAAmB;AAC3BC,IAAAA,aAAa,EAAE,CAAC;IAChBC,SAAS,EAAE/B,aAAa,CAAC7B,MAAM;AAC/B6D,IAAAA,mBAAmB,EAAEhC,aAAa,CAACiC,MAAM,CAAEhC,IAAI,IAAKA,IAAI,CAACK,MAAM,KAAK,YAAY,CAAC,CAACnC,MAAM;IACxF+D,aAAa,EAAEpC,SAAS,CAAC3B,MAAM;AAC/B2B,IAAAA,SAAS,EAAExB,MAAM,CAAC+B,MAAM,CAACP,SAAS,CAAC;AACnCpB,IAAAA,MAAM,EAAEJ,MAAM,CAAC+B,MAAM,CAACL,aAAa;AACvC,GAAC,CAAC;AACN;;;;"}
1
+ {"version":3,"file":"glslBackendBodySet.js","sources":["../../../../../src/formats/webgl/core/glslBackendBodySet.js"],"sourcesContent":["import { detailMapTransformFor } from \"../../hlsl/core/detailMapFamily.js\";\nimport { localLightProfileNeutralTransformFor } from \"../../hlsl/core/localLightFamily.js\";\n\n/**\n * Reshapes translated GLSL into the backend body set the Carbon container\n * writer consumes.\n *\n * This is the WebGL counterpart of `formats/webgpu/core/effectBackendBodySet.js`\n * and deliberately emits the same envelope, because `buildCarbonEffectContainer`\n * is backend-neutral and should stay that way: it wants bodies, passes and\n * translation units, and does not care what language the programs are in.\n *\n * Two facts drive the shape here, and neither is obvious:\n *\n * 1. **Body keys must be the permutation graph's, not this package's.** The\n * effect walk mints `body_${offset}_${size}` while the graph mints\n * `body${N}`. The container writer drives off graph variants, so a package\n * key reaching it would silently match nothing. The bridge is the\n * permutation index, not string surgery on either spelling.\n *\n * 2. **A translation unit is per pass, never per shader.** One DXBC vertex body\n * can lower to several different GLSL programs, because `pairVaryings`\n * zero-fills the varyings a paired pixel stage reads but the vertex stage\n * never writes - and that set differs per pass. Deduplicating programs by\n * bytecode would therefore collapse two genuinely different programs into\n * one. The unit signature includes the pass key for exactly this reason.\n */\n\n/**\n * Carbon's pass identity, matching the WebGPU emitter so both backends key\n * passes identically.\n *\n * @param {string} techniqueName Technique name.\n * @param {number} passIndex Pass index within the technique.\n * @returns {string} Pass key.\n */\nfunction passKeyFor(techniqueName, passIndex)\n{\n return `${techniqueName}.pass${passIndex}`;\n}\n\n/**\n * Stable signature for one pass translation unit.\n *\n * Includes `passKey` because pass-scoped varying pairing can make two units\n * differ while their source bytecode is identical. Excludes diagnostics\n * (`emitWarnings`, `hlsl2webgl`) because they describe the build, not the\n * program, and would split otherwise-identical units.\n *\n * @param {object} unit Candidate unit.\n * @returns {string} Signature.\n */\nfunction unitSignature(unit)\n{\n return JSON.stringify({\n passKey: unit.passKey,\n shaders: unit.shaders,\n block: unit.block,\n resourceTransforms: unit.resourceTransforms\n });\n}\n\n/**\n * Collect the per-stage data that has no home in Carbon reflection.\n *\n * Carbon records the logical resource and its register; these are the lowering\n * decisions taken on top of that - fused sampler pairs, synthesised data\n * textures and UBOs, dropped stub registers, and integer attributes lowered to\n * float. The GLSL text declares them but does not say how to build or bind\n * them, and reflection does not know they happened.\n *\n * Identifiers are kept. An earlier version of this comment claimed `cb{n}`,\n * `s{n}` and `attr{n}` are functions of the register index alone and so need not\n * be stored. They are not: the pixel stage remaps constant-buffer slot 0 to\n * `cb7` (`DxbcGlslEmitter.js`, `pixelConstantBufferRemap`), so an identifier\n * depends on the register *and* the stage, through a profile table. Deriving it\n * downstream would re-implement that policy, and a divergence would show up as a\n * uniform that never binds rather than as an error.\n *\n * @param {object} shader Translated shader record.\n * @returns {object|null} Stage block data, or null when the stage adds nothing.\n */\nfunction stageBlockFor(shader)\n{\n const block = {};\n\n if (Array.isArray(shader.bindings) && shader.bindings.length)\n {\n block.bindings = shader.bindings;\n }\n if (Array.isArray(shader.stageInputs) && shader.stageInputs.length)\n {\n block.stageInputs = shader.stageInputs;\n }\n if (shader.computeFragment)\n {\n block.computeFragment = shader.computeFragment;\n }\n\n return Object.keys(block).length ? block : null;\n}\n\n/**\n * Build the backend body set for a translated WebGL effect.\n *\n * @param {object} input Translation results.\n * @param {Array<object>} input.bodies Body records from the effect walk.\n * @param {Array<object>} input.stages Stage records from the effect walk.\n * @param {Array<object>} input.shaders Translated shader records.\n * @param {Array<object>} input.variants Export variants, carrying permutation indices.\n * @param {object} input.permutationGraph Validated permutation graph.\n * @returns {object} Backend body set in the container writer's shape.\n */\nexport function buildGlslBackendBodySet(input)\n{\n const { bodies, stages, shaders, variants, permutationGraph } = input;\n\n const shadersByKey = new Map(shaders.map((shader) => [ shader.key, shader ]));\n const stagesByBody = new Map();\n for (const stage of stages)\n {\n if (!stagesByBody.has(stage.bodyKey)) stagesByBody.set(stage.bodyKey, []);\n stagesByBody.get(stage.bodyKey).push(stage);\n }\n\n // Package body key -> the graph's own key, bridged through the permutation\n // index rather than by reformatting either spelling.\n const graphKeyByPackageKey = new Map();\n const permutationIndexByPackageKey = new Map();\n for (const variant of variants)\n {\n if (graphKeyByPackageKey.has(variant.bodyKey)) continue;\n const graphVariant = permutationGraph.variants[variant.permutationIndex];\n if (!graphVariant) continue;\n graphKeyByPackageKey.set(variant.bodyKey, graphVariant.bodyKey);\n permutationIndexByPackageKey.set(variant.bodyKey, variant.permutationIndex);\n }\n\n const passUnits = [];\n const unitKeyBySignature = new Map();\n const emittedBodies = [];\n\n for (const body of bodies)\n {\n const graphBodyKey = graphKeyByPackageKey.get(body.key);\n if (!graphBodyKey) continue;\n\n const representativePermutationIndex =\n permutationIndexByPackageKey.get(body.key) ?? 0;\n\n if (body.error)\n {\n emittedBodies.push(Object.freeze({\n bodyKey: graphBodyKey,\n representativePermutationIndex,\n status: \"unsupported\",\n error: body.error,\n passes: Object.freeze([])\n }));\n continue;\n }\n\n const passes = new Map();\n for (const stage of stagesByBody.get(body.key) ?? [])\n {\n const key = passKeyFor(stage.techniqueName, stage.passIndex);\n if (!passes.has(key))\n {\n passes.set(key, { passKey: key, shaders: [], block: {}, transforms: [] });\n }\n\n const shader = shadersByKey.get(stage.shaderKey);\n // A stage the translator could not lower carries no program. The\n // body still emits, with reflection intact and an empty slot, so\n // the offset table stays dense and the failure is visible rather\n // than absent.\n if (!shader?.source) continue;\n\n const entry = passes.get(key);\n\n // The merge is a property of the pass, not of one stage: the block's\n // transform section says how to build the array the GLSL samples.\n // Built here rather than at translation time because the transform's\n // identity includes the pass key, which the translator does not know.\n if (shader.detailMapArray && !entry.hasDetailMapTransform)\n {\n entry.hasDetailMapTransform = true;\n entry.transforms.push(detailMapTransformFor(shader.detailMapArray, key));\n }\n\n // Same reasoning, different statement: this one records that the\n // light profile array was dropped for a constant, so the resource\n // the description still lists is accounted for rather than missing.\n if (shader.lightProfileNeutral && !entry.hasLightProfileTransform)\n {\n const transform = localLightProfileNeutralTransformFor(shader.lightProfileNeutral, key);\n if (transform)\n {\n entry.hasLightProfileTransform = true;\n entry.transforms.push(transform);\n }\n }\n\n entry.shaders.push({\n key: `${key}.${stage.stageName}`,\n stageName: stage.stageName,\n stageType: stage.stageType,\n code: shader.source\n });\n\n const stageBlock = stageBlockFor(shader);\n if (stageBlock) entry.block[stage.stageName] = stageBlock;\n }\n\n const bodyPasses = [];\n let translatedPassCount = 0;\n\n for (const pass of passes.values())\n {\n if (!pass.shaders.length) continue;\n translatedPassCount += 1;\n\n const unit = {\n passKey: pass.passKey,\n shaders: pass.shaders,\n block: Object.keys(pass.block).length ? pass.block : null,\n resourceTransforms: pass.transforms\n };\n const signature = unitSignature(unit);\n let unitKey = unitKeyBySignature.get(signature);\n\n if (!unitKey)\n {\n unitKey = `unit${passUnits.length}`;\n unitKeyBySignature.set(signature, unitKey);\n passUnits.push(Object.freeze({ key: unitKey, ...unit }));\n }\n\n bodyPasses.push(Object.freeze({ passKey: pass.passKey, unitKey }));\n }\n\n emittedBodies.push(Object.freeze({\n bodyKey: graphBodyKey,\n representativePermutationIndex,\n status: translatedPassCount ? \"translated\" : \"unsupported\",\n error: translatedPassCount ? null : \"no pass produced a translated program\",\n passes: Object.freeze(bodyPasses)\n }));\n }\n\n return Object.freeze({\n format: \"CJS_GLSL_BODY_SET\",\n formatVersion: 1,\n bodyCount: emittedBodies.length,\n translatedBodyCount: emittedBodies.filter((body) => body.status === \"translated\").length,\n passUnitCount: passUnits.length,\n passUnits: Object.freeze(passUnits),\n bodies: Object.freeze(emittedBodies)\n });\n}\n\nexport default buildGlslBackendBodySet;\n"],"names":["passKeyFor","techniqueName","passIndex","unitSignature","unit","JSON","stringify","passKey","shaders","block","resourceTransforms","stageBlockFor","shader","Array","isArray","bindings","length","stageInputs","computeFragment","Object","keys","buildGlslBackendBodySet","input","bodies","stages","variants","permutationGraph","shadersByKey","Map","map","key","stagesByBody","stage","has","bodyKey","set","get","push","graphKeyByPackageKey","permutationIndexByPackageKey","variant","graphVariant","permutationIndex","passUnits","unitKeyBySignature","emittedBodies","body","graphBodyKey","representativePermutationIndex","error","freeze","status","passes","transforms","shaderKey","source","entry","detailMapArray","hasDetailMapTransform","detailMapTransformFor","lightProfileNeutral","hasLightProfileTransform","transform","localLightProfileNeutralTransformFor","stageName","stageType","code","stageBlock","bodyPasses","translatedPassCount","pass","values","signature","unitKey","format","formatVersion","bodyCount","translatedBodyCount","filter","passUnitCount"],"mappings":";;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,UAAUA,CAACC,aAAa,EAAEC,SAAS,EAC5C;AACI,EAAA,OAAO,CAAA,EAAGD,aAAa,CAAA,KAAA,EAAQC,SAAS,CAAA,CAAE;AAC9C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,aAAaA,CAACC,IAAI,EAC3B;EACI,OAAOC,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