@carbonenginejs/runtime 0.1.0-alpha.1 → 0.1.0-alpha.2

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.
@@ -33,8 +33,9 @@ const SPECIAL_OPERAND_NAMES = {
33
33
  /**
34
34
  * Formats decoded DXBC operands as GLSL ES 3.00 expressions and assignments.
35
35
  *
36
- * Type policy: register files use float `vec4`s. Packed-light shaders also
37
- * retain uint companions for temporary registers; integer reads use those
36
+ * Type policy: register files use float `vec4`s. Packed-light shaders and
37
+ * shaders reading SV_VertexID/SV_InstanceID also retain uint companions for
38
+ * temporary registers; integer reads use those
38
39
  * companions to avoid losing packed bits through float storage. Other integer and
39
40
  * unsigned reads/writes bitcast at the use site (`floatBitsToInt` family),
40
41
  * mirroring HLSLcc's lowering when reflection-driven type analysis is
@@ -58,6 +59,10 @@ class DxbcGlslOperandFormatter {
58
59
  // bitcast (floatBitsToInt(attr)) - ccpwgl uploads them as plain float
59
60
  // values, not integer bit patterns (see DxbcGlslEmitter._declareVertexInput).
60
61
  this.integerInputs = options.integerInputs || null;
62
+ // Map of input register index -> GLSL integer built-in (`gl_VertexID`).
63
+ // Integer reads use the built-in directly instead of bitcasting its
64
+ // float bit-pattern register, which ANGLE/D3D11 does not preserve.
65
+ this.systemIntegerInputs = options.systemIntegerInputs || null;
61
66
  this.names = {
62
67
  temp: index => `r${index}`,
63
68
  indexableTemp: index => `x${index}`,
@@ -127,7 +132,11 @@ class DxbcGlslOperandFormatter {
127
132
  }
128
133
  if (as !== "float") {
129
134
  const integerInputKind = operand.type === 1 && this.integerInputs ? this.integerInputs.get(operand.registerIndex) : undefined;
130
- if (operand.type === 0 && this.integerTemps && !floatSpaceModifier) {
135
+ const systemInteger = operand.type === 1 && this.systemIntegerInputs ? this.systemIntegerInputs.get(operand.registerIndex) : undefined;
136
+ if (systemInteger && !floatSpaceModifier) {
137
+ const width = suffix ? suffix.length - 1 : 4;
138
+ expression = `${VEC_TYPE_BY_KIND[as][width - 1]}(${systemInteger})`;
139
+ } else if (operand.type === 0 && this.integerTemps && !floatSpaceModifier) {
131
140
  // Raw integer companion. An integer `neg` applies to it
132
141
  // directly below; a float-space abs forces the float register
133
142
  // through the bitcast branch instead.
@@ -1 +1 @@
1
- {"version":3,"file":"DxbcGlslOperandFormatter.js","sources":["../../../../../../../src/resource/formats/webgl/core/glsl/DxbcGlslOperandFormatter.js"],"sourcesContent":["import { WebglReadError } from \"../errors.js\";\r\n\r\nconst COMPONENTS = [ \"x\", \"y\", \"z\", \"w\" ];\r\nconst COMPONENT_INDEX = { x: 0, y: 1, z: 2, w: 3 };\r\nconst VEC_TYPE_BY_KIND = {\r\n float: [ \"float\", \"vec2\", \"vec3\", \"vec4\" ],\r\n int: [ \"int\", \"ivec2\", \"ivec3\", \"ivec4\" ],\r\n uint: [ \"uint\", \"uvec2\", \"uvec3\", \"uvec4\" ]\r\n};\r\nconst BITCAST_FROM_FLOAT = { int: \"floatBitsToInt\", uint: \"floatBitsToUint\" };\r\nconst BITCAST_TO_FLOAT = { int: \"intBitsToFloat\", uint: \"uintBitsToFloat\" };\r\n\r\n/**\r\n * Operand types that resolve to a special GLSL built-in instead of a register.\r\n */\r\nconst SPECIAL_OPERAND_NAMES = {\r\n 12: \"gl_FragDepth\",\r\n 38: \"gl_FragDepth\",\r\n 39: \"gl_FragDepth\"\r\n};\r\n\r\n/**\r\n * Formats decoded DXBC operands as GLSL ES 3.00 expressions and assignments.\r\n *\r\n * Type policy: register files use float `vec4`s. Packed-light shaders also\r\n * retain uint companions for temporary registers; integer reads use those\r\n * companions to avoid losing packed bits through float storage. Other integer and\r\n * unsigned reads/writes bitcast at the use site (`floatBitsToInt` family),\r\n * mirroring HLSLcc's lowering when reflection-driven type analysis is\r\n * unavailable — which is always true for this stripped-DXBC corpus.\r\n *\r\n * Register naming defaults to the fork's register-stable ABI: `r#` temps,\r\n * `v#`/`o#` stage IO, `cb#.data[i]` constant buffers, `t#`/`s#` resources.\r\n */\r\nexport class DxbcGlslOperandFormatter\r\n{\r\n /**\r\n * @param {object} [options] Naming overrides.\r\n * @param {object} [options.names] Partial override of the register-name builders.\r\n * @param {boolean} [options.integerTemps] Read temporary integer lanes from uint companions.\r\n */\r\n constructor(options = {})\r\n {\r\n this.componentMap = options.componentMap || null;\r\n this.integerTemps = options.integerTemps === true;\r\n // Map of vertex-input register index -> \"int\"|\"uint\" for inputs whose\r\n // ISGN component type is integer but whose GLSL declaration was\r\n // float-lowered. Integer reads of these VALUE-convert (int(attr)), not\r\n // bitcast (floatBitsToInt(attr)) - ccpwgl uploads them as plain float\r\n // values, not integer bit patterns (see DxbcGlslEmitter._declareVertexInput).\r\n this.integerInputs = options.integerInputs || null;\r\n this.names = {\r\n temp: (index) => `r${index}`,\r\n indexableTemp: (index) => `x${index}`,\r\n input: (index) => `v${index}`,\r\n output: (index) => `o${index}`,\r\n constantBuffer: (slot) => `cb${slot}`,\r\n constantBufferMember: \"data\",\r\n resource: (index) => `t${index}`,\r\n sampler: (index) => `s${index}`,\r\n uav: (index) => `u${index}`,\r\n // Compute-stage pseudo-registers (map-style lowering): fixed names, one\r\n // instance per shader, independent of any register index.\r\n threadId: () => \"vThreadID\",\r\n threadGroupId: () => \"vThreadGroupID\",\r\n threadIdInGroup: () => \"vThreadIDInGroup\",\r\n threadIdInGroupFlattened: () => \"vThreadIDInGroupFlattened\",\r\n immediateConstantBuffer: \"icb\",\r\n ...options.names\r\n };\r\n }\r\n\r\n /**\r\n * Formats a source operand as a typed GLSL expression.\r\n *\r\n * @param {object} operand Decoded operand.\r\n * @param {object} [options] Formatting context.\r\n * @param {string} [options.destMask] Destination write mask driving swizzle selection.\r\n * @param {\"float\"|\"int\"|\"uint\"} [options.as] Type the consuming instruction reads.\r\n * @returns {string} GLSL expression.\r\n */\r\n sourceExpression(operand, options = {})\r\n {\r\n const destMask = options.destMask || \"xyzw\";\r\n const as = options.as || \"float\";\r\n\r\n if (operand.type === 4)\r\n {\r\n return this._immediateExpression(operand, destMask, as);\r\n }\r\n if (operand.type === 5)\r\n {\r\n throw new WebglReadError(\"64-bit immediates are not supported by the WebGL2 emitter\", {\r\n operandType: operand.typeName\r\n });\r\n }\r\n\r\n const suffix = this._swizzleSuffix(operand, destMask);\r\n let expression = this.registerReference(operand) + suffix;\r\n\r\n // Modifier placement is PER MODIFIER on a typed read, and getting it\r\n // wrong has broken shipped shaders in both directions:\r\n //\r\n // - `neg` on an integer read is DXBC's integer negation - two's\r\n // complement AFTER the reinterpret (`iadd r, -a, b` emits\r\n // `(-floatBitsToInt(a)) + ...`). Applying it in float space merely\r\n // flips the sign bit and broke every lines3d instance offset.\r\n // - `abs`/`absneg` have no integer form in DXBC; they appear on\r\n // typed reads only as FLOAT modifiers (condition tests, f16tof32\r\n // sources) and must wrap the float expression INSIDE the bitcast:\r\n // `abs(floatBitsToUint(x))` is invalid GLSL ES 3.00 (abs is\r\n // undefined for genUType) and failed the whole effect at compile.\r\n const modifierName = operand.modifierName;\r\n const floatSpaceModifier = as === \"float\" || modifierName === \"abs\" || modifierName === \"absneg\";\r\n if (floatSpaceModifier)\r\n {\r\n if (modifierName === \"neg\")\r\n {\r\n expression = `(-${expression})`;\r\n }\r\n else if (modifierName === \"abs\")\r\n {\r\n expression = `abs(${expression})`;\r\n }\r\n else if (modifierName === \"absneg\")\r\n {\r\n expression = `(-abs(${expression}))`;\r\n }\r\n }\r\n\r\n if (as !== \"float\")\r\n {\r\n const integerInputKind = operand.type === 1 && this.integerInputs\r\n ? this.integerInputs.get(operand.registerIndex)\r\n : undefined;\r\n\r\n if (operand.type === 0 && this.integerTemps && !floatSpaceModifier)\r\n {\r\n // Raw integer companion. An integer `neg` applies to it\r\n // directly below; a float-space abs forces the float register\r\n // through the bitcast branch instead.\r\n const raw = `cjsBitsR${operand.registerIndex}${suffix}`;\r\n const width = suffix ? suffix.length - 1 : 4;\r\n expression = as === \"uint\" ? raw : `${VEC_TYPE_BY_KIND.int[width - 1]}(${raw})`;\r\n }\r\n else if (integerInputKind)\r\n {\r\n // Float-lowered integer vertex attribute (e.g. BLENDINDICES):\r\n // the register holds the value (3.0), not the bit pattern of 3,\r\n // so convert rather than bitcast (which would read garbage).\r\n const width = suffix ? suffix.length - 1 : 4;\r\n expression = `${VEC_TYPE_BY_KIND[as][width - 1]}(${expression})`;\r\n }\r\n else\r\n {\r\n expression = `${BITCAST_FROM_FLOAT[as]}(${expression})`;\r\n }\r\n\r\n if (modifierName === \"neg\")\r\n {\r\n // Integer negation of the typed read (two's complement).\r\n expression = `(-${expression})`;\r\n }\r\n }\r\n return expression;\r\n }\r\n\r\n /**\r\n * Remaps register-space component letters into an operand's declared-variable\r\n * component space (an input packed at `.z` of its register but declared as a\r\n * scalar `float` reads without any suffix; one packed at `.zw` and declared\r\n * `vec2` reads `.xy`).\r\n *\r\n * @param {object} operand Decoded operand.\r\n * @param {string} chars Register-space component letters.\r\n * @returns {string} Declared-space component letters (\"\" for scalar variables).\r\n */\r\n remapComponents(operand, chars)\r\n {\r\n const declared = this.componentMap ? this.componentMap(operand) : null;\r\n if (!declared || declared === \"xyzw\")\r\n {\r\n return chars;\r\n }\r\n if (declared.length === 1)\r\n {\r\n return \"\";\r\n }\r\n return [ ...chars ]\r\n .map((component) =>\r\n {\r\n const index = declared.indexOf(component);\r\n return COMPONENTS[index >= 0 ? index : 0];\r\n })\r\n .join(\"\");\r\n }\r\n\r\n /**\r\n * Computes how many components a formatted source expression yields, after\r\n * declared-variable remapping (a swizzle over a scalar-declared input reads\r\n * as width 1 regardless of the requested mask width).\r\n *\r\n * @param {object} operand Decoded operand.\r\n * @param {string} [destMask] Destination write mask driving swizzle selection.\r\n * @returns {number} Component count of the emitted expression.\r\n */\r\n expressionWidth(operand, destMask = \"xyzw\")\r\n {\r\n if (operand.type === 4)\r\n {\r\n return operand.componentCount === 1 ? 1 : destMask.length;\r\n }\r\n if (operand.componentCount < 4 || operand.selectionModeName === \"select1\")\r\n {\r\n return 1;\r\n }\r\n let selected = destMask;\r\n if (operand.selectionModeName === \"swizzle\")\r\n {\r\n selected = [ ...destMask ].map((component) => operand.swizzle[COMPONENT_INDEX[component]]).join(\"\");\r\n }\r\n else if (operand.selectionModeName === \"mask\" && operand.mask && operand.mask !== \"xyzw\")\r\n {\r\n selected = operand.mask;\r\n }\r\n const remapped = this.remapComponents(operand, selected);\r\n return remapped === \"\" ? 1 : remapped.length;\r\n }\r\n\r\n /**\r\n * Resolves a destination operand to its register reference and write masks.\r\n *\r\n * @param {object} operand Decoded destination operand.\r\n * @returns {{ref:string,mask:string,registerMask:string}|null} Target with the\r\n * declared-space display mask and the register-space mask, or null for the\r\n * `null` register.\r\n */\r\n destination(operand)\r\n {\r\n if (operand.type === 13)\r\n {\r\n return null;\r\n }\r\n if (SPECIAL_OPERAND_NAMES[operand.type])\r\n {\r\n return { ref: SPECIAL_OPERAND_NAMES[operand.type], mask: \"\", registerMask: operand.mask || \"xyzw\" };\r\n }\r\n const registerMask = operand.mask || \"\";\r\n return {\r\n ref: this.registerReference(operand),\r\n mask: this.remapComponents(operand, registerMask),\r\n registerMask\r\n };\r\n }\r\n\r\n /**\r\n * Builds a full assignment statement for a destination operand.\r\n *\r\n * @param {object} destOperand Decoded destination operand.\r\n * @param {string} valueExpression GLSL expression producing the value.\r\n * @param {object} [options] Assignment context.\r\n * @param {boolean} [options.saturate] Wrap the value in `clamp(v, 0.0, 1.0)`.\r\n * @param {\"float\"|\"int\"|\"uint\"} [options.as] Type of `valueExpression`; non-float\r\n * values are bitcast back into the float register storage.\r\n * @returns {string|null} GLSL statement, or null when the destination is `null`.\r\n */\r\n assignment(destOperand, valueExpression, options = {})\r\n {\r\n const target = this.destination(destOperand);\r\n if (!target)\r\n {\r\n return null;\r\n }\r\n let value = valueExpression;\r\n const as = options.as || \"float\";\r\n if (as !== \"float\")\r\n {\r\n value = `${BITCAST_TO_FLOAT[as]}(${value})`;\r\n }\r\n if (options.saturate)\r\n {\r\n value = `clamp(${value}, 0.0, 1.0)`;\r\n }\r\n const mask = target.mask ? `.${target.mask}` : \"\";\r\n return `${target.ref}${mask} = ${value};`;\r\n }\r\n\r\n /**\r\n * Resolves an operand's register reference without swizzle or casts.\r\n *\r\n * @param {object} operand Decoded operand.\r\n * @returns {string} GLSL lvalue such as `r0`, `cb3.data[26]`, or `t0`.\r\n */\r\n registerReference(operand)\r\n {\r\n const indices = operand.indices;\r\n switch (operand.type)\r\n {\r\n case 0:\r\n return this.names.temp(this._immediateIndex(operand, 0));\r\n case 1:\r\n if (indices.length !== 1)\r\n {\r\n throw new WebglReadError(\"Multi-dimensional inputs are not supported by the WebGL2 emitter\", {\r\n operandType: operand.typeName,\r\n dimensions: indices.length\r\n });\r\n }\r\n return this.names.input(this._immediateIndex(operand, 0));\r\n case 2:\r\n return this.names.output(this._immediateIndex(operand, 0));\r\n case 3:\r\n return `${this.names.indexableTemp(this._immediateIndex(operand, 0))}[${this._indexExpression(operand, 1)}]`;\r\n case 6:\r\n return this.names.sampler(this._registerIndex(operand));\r\n case 7:\r\n return this.names.resource(this._registerIndex(operand));\r\n case 8: {\r\n // A constant-buffer operand is indexed either 2D or 3D, and both\r\n // appear in the shipped corpus - 1,660 two-dimensional against\r\n // 1,747 three-dimensional across 152 shaders.\r\n //\r\n // 2D: (register, row) - shader model 5.0\r\n // 3D: (range id, register, row) - shader model 5.1\r\n //\r\n // Reading a 3D operand as if it were 2D takes the range id for\r\n // the register and the register for the row. The range id is the\r\n // ordinal of the `dcl_constant_buffer` that introduced the\r\n // binding, so it equals the register only while a shader declares\r\n // its buffers contiguously from zero. A shader declaring b0, b1,\r\n // b3 emits `cb2` for every b3 reference - a slot it never\r\n // declared, which fails to compile - and every shader that does\r\n // compile reads its rows from the register number.\r\n const dimension = operand.indices.length - 2;\r\n const member = this.names.constantBufferMember;\r\n const base = this.names.constantBuffer(\r\n this._immediateIndex(operand, dimension)\r\n );\r\n return `${base}${member ? `.${member}` : \"\"}[${this._indexExpression(operand, dimension + 1)}]`;\r\n }\r\n case 9:\r\n return `${this.names.immediateConstantBuffer}[${this._indexExpression(operand, 0)}]`;\r\n case 30:\r\n return this.names.uav(this._registerIndex(operand));\r\n case 32:\r\n return this.names.threadId();\r\n case 33:\r\n return this.names.threadGroupId();\r\n case 34:\r\n return this.names.threadIdInGroup();\r\n case 36:\r\n return this.names.threadIdInGroupFlattened();\r\n default:\r\n if (SPECIAL_OPERAND_NAMES[operand.type])\r\n {\r\n return SPECIAL_OPERAND_NAMES[operand.type];\r\n }\r\n throw new WebglReadError(\"Operand type is not supported by the WebGL2 emitter\", {\r\n operandType: operand.typeName\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Formats an immediate32 operand as a scalar or vector literal.\r\n *\r\n * @param {object} operand Decoded immediate operand.\r\n * @param {string} destMask Destination write mask.\r\n * @param {\"float\"|\"int\"|\"uint\"} as Literal type.\r\n * @returns {string} GLSL literal expression.\r\n * @private\r\n */\r\n _immediateExpression(operand, destMask, as)\r\n {\r\n const literals = operand.immediateValues.map((value) => this._literal(value, as));\r\n if (operand.componentCount === 1)\r\n {\r\n return literals[0];\r\n }\r\n const selected = [ ...destMask ].map((component) =>\r\n {\r\n const slot = COMPONENT_INDEX[component];\r\n if (slot === undefined || slot >= literals.length)\r\n {\r\n throw new WebglReadError(\"Immediate component selection is out of range\", {\r\n destMask,\r\n component\r\n });\r\n }\r\n return literals[slot];\r\n });\r\n if (selected.length === 1)\r\n {\r\n return selected[0];\r\n }\r\n return `${VEC_TYPE_BY_KIND[as][selected.length - 1]}(${selected.join(\", \")})`;\r\n }\r\n\r\n /**\r\n * Formats one immediate dword as a GLSL literal.\r\n *\r\n * @param {{uint32:number,float32:number|null}} value Immediate value views.\r\n * @param {\"float\"|\"int\"|\"uint\"} as Literal type.\r\n * @returns {string} GLSL literal.\r\n * @private\r\n */\r\n _literal(value, as)\r\n {\r\n if (as === \"uint\")\r\n {\r\n return `${value.uint32 >>> 0}u`;\r\n }\r\n if (as === \"int\")\r\n {\r\n return `${value.uint32 | 0}`;\r\n }\r\n const float = value.float32;\r\n if (!Number.isFinite(float))\r\n {\r\n return `uintBitsToFloat(${value.uint32 >>> 0}u)`;\r\n }\r\n if (Object.is(float, -0))\r\n {\r\n return \"-0.0\";\r\n }\r\n const text = String(float);\r\n return /[.e]/.test(text) ? text : `${text}.0`;\r\n }\r\n\r\n /**\r\n * Applies the operand's component selection against a destination mask.\r\n *\r\n * @param {object} operand Decoded operand.\r\n * @param {string} destMask Destination write mask.\r\n * @returns {string} Swizzle suffix including the leading dot, or empty.\r\n * @private\r\n */\r\n _swizzleSuffix(operand, destMask)\r\n {\r\n if (operand.componentCount < 4)\r\n {\r\n return \"\";\r\n }\r\n let selected = \"\";\r\n if (operand.selectionModeName === \"select1\")\r\n {\r\n selected = operand.selected;\r\n }\r\n else if (operand.selectionModeName === \"swizzle\")\r\n {\r\n selected = [ ...destMask ]\r\n .map((component) => operand.swizzle[COMPONENT_INDEX[component]])\r\n .join(\"\");\r\n }\r\n else if (operand.selectionModeName === \"mask\" && operand.mask && operand.mask !== \"xyzw\")\r\n {\r\n selected = operand.mask;\r\n }\r\n else\r\n {\r\n return \"\";\r\n }\r\n const remapped = this.remapComponents(operand, selected);\r\n return remapped ? `.${remapped}` : \"\";\r\n }\r\n\r\n /**\r\n * Reads a purely immediate operand index.\r\n *\r\n * @param {object} operand Decoded operand.\r\n * @param {number} dimension Index dimension.\r\n * @returns {number} Immediate index value.\r\n * @private\r\n */\r\n /**\r\n * The bound register of a resource-like operand.\r\n *\r\n * Shader model 5.1 prepends a range id to every register-bearing operand, so\r\n * a resource that is 1D at 5.0 is 2D at 5.1 and a constant buffer that is 2D\r\n * becomes 3D. The register is what trails: reading dimension 0 unconditionally\r\n * takes the range id instead, which is the ordinal of the declaration that\r\n * introduced the binding and equals the register only while a shader declares\r\n * its bindings contiguously from zero.\r\n *\r\n * Measured across 40 shipped effects: 56 of 161 two-dimensional resource\r\n * operands and 4 of 145 sampler operands carry a range id that differs from\r\n * their register. Those named the wrong binding entirely - a texel fetch\r\n * landing on a samplerCube, which GLSL ES 3.00 has no overload for.\r\n *\r\n * @param {object} operand Decoded operand.\r\n * @returns {number} Bound register index.\r\n */\r\n _registerIndex(operand)\r\n {\r\n const dimension = operand.indices.length - 1;\r\n const index = operand.indices[dimension];\r\n if (index?.relative)\r\n {\r\n // A dynamically indexed binding. GLSL ES 3.00 has no dynamic sampler\r\n // indexing, so there is nothing to emit. Reading dimension 0 instead\r\n // would find the range id - an immediate - and quietly emit a fixed\r\n // binding that is simply the wrong one.\r\n throw new WebglReadError(\r\n \"Resource operand uses a relative register index; GLSL ES 3.00 has no dynamic binding indexing\",\r\n { operandType: operand.typeName, dimension }\r\n );\r\n }\r\n return this._immediateIndex(operand, dimension);\r\n }\r\n\r\n /**\r\n * Return one required immediate operand index.\r\n *\r\n * @param {object} operand Decoded operand.\r\n * @param {number} dimension Index dimension.\r\n * @returns {number} Immediate index value.\r\n * @private\r\n */\r\n _immediateIndex(operand, dimension)\r\n {\r\n const index = operand.indices[dimension];\r\n if (!index || index.values.length === 0 || index.relative)\r\n {\r\n throw new WebglReadError(\"Expected an immediate register index\", {\r\n operandType: operand.typeName,\r\n dimension\r\n });\r\n }\r\n return index.values[0];\r\n }\r\n\r\n /**\r\n * Formats an operand index that may combine an immediate offset with a\r\n * relative register (for example `cb3[r1.y + 26]`).\r\n *\r\n * @param {object} operand Decoded operand.\r\n * @param {number} dimension Index dimension.\r\n * @returns {string} GLSL index expression.\r\n * @private\r\n */\r\n _indexExpression(operand, dimension)\r\n {\r\n const index = operand.indices[dimension];\r\n if (!index)\r\n {\r\n throw new WebglReadError(\"Missing operand index dimension\", {\r\n operandType: operand.typeName,\r\n dimension\r\n });\r\n }\r\n if (index.representation === 1 || index.representation === 4)\r\n {\r\n throw new WebglReadError(\"64-bit register indices are not supported by the WebGL2 emitter\", {\r\n operandType: operand.typeName,\r\n dimension\r\n });\r\n }\r\n\r\n const immediate = index.values.length ? index.values[0] : null;\r\n const relative = index.relative\r\n ? this.sourceExpression(index.relative, { destMask: \"x\", as: \"int\" })\r\n : null;\r\n\r\n if (relative && immediate)\r\n {\r\n return `${relative} + ${immediate}`;\r\n }\r\n if (relative)\r\n {\r\n return relative;\r\n }\r\n if (immediate === null)\r\n {\r\n throw new WebglReadError(\"Operand index has neither immediate nor relative part\", {\r\n operandType: operand.typeName,\r\n dimension\r\n });\r\n }\r\n return String(immediate);\r\n }\r\n}\r\n"],"names":["COMPONENTS","COMPONENT_INDEX","x","y","z","w","VEC_TYPE_BY_KIND","float","int","uint","BITCAST_FROM_FLOAT","BITCAST_TO_FLOAT","SPECIAL_OPERAND_NAMES","DxbcGlslOperandFormatter","constructor","options","componentMap","integerTemps","integerInputs","names","temp","index","indexableTemp","input","output","constantBuffer","slot","constantBufferMember","resource","sampler","uav","threadId","threadGroupId","threadIdInGroup","threadIdInGroupFlattened","immediateConstantBuffer","sourceExpression","operand","destMask","as","type","_immediateExpression","WebglReadError","operandType","typeName","suffix","_swizzleSuffix","expression","registerReference","modifierName","floatSpaceModifier","integerInputKind","get","registerIndex","undefined","raw","width","length","remapComponents","chars","declared","map","component","indexOf","join","expressionWidth","componentCount","selectionModeName","selected","swizzle","mask","remapped","destination","ref","registerMask","assignment","destOperand","valueExpression","target","value","saturate","indices","_immediateIndex","dimensions","_indexExpression","_registerIndex","dimension","member","base","literals","immediateValues","_literal","uint32","float32","Number","isFinite","Object","is","text","String","test","relative","values","representation","immediate"],"mappings":";;AAEA,MAAMA,UAAU,GAAG,CAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAE;AACzC,MAAMC,eAAe,GAAG;AAAEC,EAAAA,CAAC,EAAE,CAAC;AAAEC,EAAAA,CAAC,EAAE,CAAC;AAAEC,EAAAA,CAAC,EAAE,CAAC;AAAEC,EAAAA,CAAC,EAAE;AAAE,CAAC;AAClD,MAAMC,gBAAgB,GAAG;EACrBC,KAAK,EAAE,CAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAE;EAC1CC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EAAiE,EAAE;QACxFC,WAAW,EAAEN,OAAO,CAACO,QAAQ;AAC7B0C,QAAAA;AACJ,OAAC,CAAC;AACN,IAAA;AAEA,IAAA,MAAMkB,SAAS,GAAGnF,KAAK,CAACiF,MAAM,CAAC7C,MAAM,GAAGpC,KAAK,CAACiF,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI;AAC9D,IAAA,MAAMD,QAAQ,GAAGhF,KAAK,CAACgF,QAAQ,GACzB,IAAI,CAACjE,gBAAgB,CAACf,KAAK,CAACgF,QAAQ,EAAE;AAAE/D,MAAAA,QAAQ,EAAE,GAAG;AAAEC,MAAAA,EAAE,EAAE;KAAO,CAAC,GACnE,IAAI;IAEV,IAAI8D,QAAQ,IAAIG,SAAS,EACzB;AACI,MAAA,OAAO,CAAA,EAAGH,QAAQ,CAAA,GAAA,EAAMG,SAAS,CAAA,CAAE;AACvC,IAAA;AACA,IAAA,IAAIH,QAAQ,EACZ;AACI,MAAA,OAAOA,QAAQ;AACnB,IAAA;IACA,IAAIG,SAAS,KAAK,IAAI,EACtB;AACI,MAAA,MAAM,IAAI9D,cAAc,CAAC,uDAAuD,EAAE;QAC9EC,WAAW,EAAEN,OAAO,CAACO,QAAQ;AAC7B0C,QAAAA;AACJ,OAAC,CAAC;AACN,IAAA;IACA,OAAOa,MAAM,CAACK,SAAS,CAAC;AAC5B,EAAA;AACJ;;;;"}
1
+ {"version":3,"file":"DxbcGlslOperandFormatter.js","sources":["../../../../../../../src/resource/formats/webgl/core/glsl/DxbcGlslOperandFormatter.js"],"sourcesContent":["import { WebglReadError } from \"../errors.js\";\r\n\r\nconst COMPONENTS = [ \"x\", \"y\", \"z\", \"w\" ];\r\nconst COMPONENT_INDEX = { x: 0, y: 1, z: 2, w: 3 };\r\nconst VEC_TYPE_BY_KIND = {\r\n float: [ \"float\", \"vec2\", \"vec3\", \"vec4\" ],\r\n int: [ \"int\", \"ivec2\", \"ivec3\", \"ivec4\" ],\r\n uint: [ \"uint\", \"uvec2\", \"uvec3\", \"uvec4\" ]\r\n};\r\nconst BITCAST_FROM_FLOAT = { int: \"floatBitsToInt\", uint: \"floatBitsToUint\" };\r\nconst BITCAST_TO_FLOAT = { int: \"intBitsToFloat\", uint: \"uintBitsToFloat\" };\r\n\r\n/**\r\n * Operand types that resolve to a special GLSL built-in instead of a register.\r\n */\r\nconst SPECIAL_OPERAND_NAMES = {\r\n 12: \"gl_FragDepth\",\r\n 38: \"gl_FragDepth\",\r\n 39: \"gl_FragDepth\"\r\n};\r\n\r\n/**\r\n * Formats decoded DXBC operands as GLSL ES 3.00 expressions and assignments.\r\n *\r\n * Type policy: register files use float `vec4`s. Packed-light shaders and\r\n * shaders reading SV_VertexID/SV_InstanceID also retain uint companions for\r\n * temporary registers; integer reads use those\r\n * companions to avoid losing packed bits through float storage. Other integer and\r\n * unsigned reads/writes bitcast at the use site (`floatBitsToInt` family),\r\n * mirroring HLSLcc's lowering when reflection-driven type analysis is\r\n * unavailable — which is always true for this stripped-DXBC corpus.\r\n *\r\n * Register naming defaults to the fork's register-stable ABI: `r#` temps,\r\n * `v#`/`o#` stage IO, `cb#.data[i]` constant buffers, `t#`/`s#` resources.\r\n */\r\nexport class DxbcGlslOperandFormatter\r\n{\r\n /**\r\n * @param {object} [options] Naming overrides.\r\n * @param {object} [options.names] Partial override of the register-name builders.\r\n * @param {boolean} [options.integerTemps] Read temporary integer lanes from uint companions.\r\n */\r\n constructor(options = {})\r\n {\r\n this.componentMap = options.componentMap || null;\r\n this.integerTemps = options.integerTemps === true;\r\n // Map of vertex-input register index -> \"int\"|\"uint\" for inputs whose\r\n // ISGN component type is integer but whose GLSL declaration was\r\n // float-lowered. Integer reads of these VALUE-convert (int(attr)), not\r\n // bitcast (floatBitsToInt(attr)) - ccpwgl uploads them as plain float\r\n // values, not integer bit patterns (see DxbcGlslEmitter._declareVertexInput).\r\n this.integerInputs = options.integerInputs || null;\r\n // Map of input register index -> GLSL integer built-in (`gl_VertexID`).\r\n // Integer reads use the built-in directly instead of bitcasting its\r\n // float bit-pattern register, which ANGLE/D3D11 does not preserve.\r\n this.systemIntegerInputs = options.systemIntegerInputs || null;\r\n this.names = {\r\n temp: (index) => `r${index}`,\r\n indexableTemp: (index) => `x${index}`,\r\n input: (index) => `v${index}`,\r\n output: (index) => `o${index}`,\r\n constantBuffer: (slot) => `cb${slot}`,\r\n constantBufferMember: \"data\",\r\n resource: (index) => `t${index}`,\r\n sampler: (index) => `s${index}`,\r\n uav: (index) => `u${index}`,\r\n // Compute-stage pseudo-registers (map-style lowering): fixed names, one\r\n // instance per shader, independent of any register index.\r\n threadId: () => \"vThreadID\",\r\n threadGroupId: () => \"vThreadGroupID\",\r\n threadIdInGroup: () => \"vThreadIDInGroup\",\r\n threadIdInGroupFlattened: () => \"vThreadIDInGroupFlattened\",\r\n immediateConstantBuffer: \"icb\",\r\n ...options.names\r\n };\r\n }\r\n\r\n /**\r\n * Formats a source operand as a typed GLSL expression.\r\n *\r\n * @param {object} operand Decoded operand.\r\n * @param {object} [options] Formatting context.\r\n * @param {string} [options.destMask] Destination write mask driving swizzle selection.\r\n * @param {\"float\"|\"int\"|\"uint\"} [options.as] Type the consuming instruction reads.\r\n * @returns {string} GLSL expression.\r\n */\r\n sourceExpression(operand, options = {})\r\n {\r\n const destMask = options.destMask || \"xyzw\";\r\n const as = options.as || \"float\";\r\n\r\n if (operand.type === 4)\r\n {\r\n return this._immediateExpression(operand, destMask, as);\r\n }\r\n if (operand.type === 5)\r\n {\r\n throw new WebglReadError(\"64-bit immediates are not supported by the WebGL2 emitter\", {\r\n operandType: operand.typeName\r\n });\r\n }\r\n\r\n const suffix = this._swizzleSuffix(operand, destMask);\r\n let expression = this.registerReference(operand) + suffix;\r\n\r\n // Modifier placement is PER MODIFIER on a typed read, and getting it\r\n // wrong has broken shipped shaders in both directions:\r\n //\r\n // - `neg` on an integer read is DXBC's integer negation - two's\r\n // complement AFTER the reinterpret (`iadd r, -a, b` emits\r\n // `(-floatBitsToInt(a)) + ...`). Applying it in float space merely\r\n // flips the sign bit and broke every lines3d instance offset.\r\n // - `abs`/`absneg` have no integer form in DXBC; they appear on\r\n // typed reads only as FLOAT modifiers (condition tests, f16tof32\r\n // sources) and must wrap the float expression INSIDE the bitcast:\r\n // `abs(floatBitsToUint(x))` is invalid GLSL ES 3.00 (abs is\r\n // undefined for genUType) and failed the whole effect at compile.\r\n const modifierName = operand.modifierName;\r\n const floatSpaceModifier = as === \"float\" || modifierName === \"abs\" || modifierName === \"absneg\";\r\n if (floatSpaceModifier)\r\n {\r\n if (modifierName === \"neg\")\r\n {\r\n expression = `(-${expression})`;\r\n }\r\n else if (modifierName === \"abs\")\r\n {\r\n expression = `abs(${expression})`;\r\n }\r\n else if (modifierName === \"absneg\")\r\n {\r\n expression = `(-abs(${expression}))`;\r\n }\r\n }\r\n\r\n if (as !== \"float\")\r\n {\r\n const integerInputKind = operand.type === 1 && this.integerInputs\r\n ? this.integerInputs.get(operand.registerIndex)\r\n : undefined;\r\n const systemInteger = operand.type === 1 && this.systemIntegerInputs\r\n ? this.systemIntegerInputs.get(operand.registerIndex)\r\n : undefined;\r\n\r\n if (systemInteger && !floatSpaceModifier)\r\n {\r\n const width = suffix ? suffix.length - 1 : 4;\r\n expression = `${VEC_TYPE_BY_KIND[as][width - 1]}(${systemInteger})`;\r\n }\r\n else if (operand.type === 0 && this.integerTemps && !floatSpaceModifier)\r\n {\r\n // Raw integer companion. An integer `neg` applies to it\r\n // directly below; a float-space abs forces the float register\r\n // through the bitcast branch instead.\r\n const raw = `cjsBitsR${operand.registerIndex}${suffix}`;\r\n const width = suffix ? suffix.length - 1 : 4;\r\n expression = as === \"uint\" ? raw : `${VEC_TYPE_BY_KIND.int[width - 1]}(${raw})`;\r\n }\r\n else if (integerInputKind)\r\n {\r\n // Float-lowered integer vertex attribute (e.g. BLENDINDICES):\r\n // the register holds the value (3.0), not the bit pattern of 3,\r\n // so convert rather than bitcast (which would read garbage).\r\n const width = suffix ? suffix.length - 1 : 4;\r\n expression = `${VEC_TYPE_BY_KIND[as][width - 1]}(${expression})`;\r\n }\r\n else\r\n {\r\n expression = `${BITCAST_FROM_FLOAT[as]}(${expression})`;\r\n }\r\n\r\n if (modifierName === \"neg\")\r\n {\r\n // Integer negation of the typed read (two's complement).\r\n expression = `(-${expression})`;\r\n }\r\n }\r\n return expression;\r\n }\r\n\r\n /**\r\n * Remaps register-space component letters into an operand's declared-variable\r\n * component space (an input packed at `.z` of its register but declared as a\r\n * scalar `float` reads without any suffix; one packed at `.zw` and declared\r\n * `vec2` reads `.xy`).\r\n *\r\n * @param {object} operand Decoded operand.\r\n * @param {string} chars Register-space component letters.\r\n * @returns {string} Declared-space component letters (\"\" for scalar variables).\r\n */\r\n remapComponents(operand, chars)\r\n {\r\n const declared = this.componentMap ? this.componentMap(operand) : null;\r\n if (!declared || declared === \"xyzw\")\r\n {\r\n return chars;\r\n }\r\n if (declared.length === 1)\r\n {\r\n return \"\";\r\n }\r\n return [ ...chars ]\r\n .map((component) =>\r\n {\r\n const index = declared.indexOf(component);\r\n return COMPONENTS[index >= 0 ? index : 0];\r\n })\r\n .join(\"\");\r\n }\r\n\r\n /**\r\n * Computes how many components a formatted source expression yields, after\r\n * declared-variable remapping (a swizzle over a scalar-declared input reads\r\n * as width 1 regardless of the requested mask width).\r\n *\r\n * @param {object} operand Decoded operand.\r\n * @param {string} [destMask] Destination write mask driving swizzle selection.\r\n * @returns {number} Component count of the emitted expression.\r\n */\r\n expressionWidth(operand, destMask = \"xyzw\")\r\n {\r\n if (operand.type === 4)\r\n {\r\n return operand.componentCount === 1 ? 1 : destMask.length;\r\n }\r\n if (operand.componentCount < 4 || operand.selectionModeName === \"select1\")\r\n {\r\n return 1;\r\n }\r\n let selected = destMask;\r\n if (operand.selectionModeName === \"swizzle\")\r\n {\r\n selected = [ ...destMask ].map((component) => operand.swizzle[COMPONENT_INDEX[component]]).join(\"\");\r\n }\r\n else if (operand.selectionModeName === \"mask\" && operand.mask && operand.mask !== \"xyzw\")\r\n {\r\n selected = operand.mask;\r\n }\r\n const remapped = this.remapComponents(operand, selected);\r\n return remapped === \"\" ? 1 : remapped.length;\r\n }\r\n\r\n /**\r\n * Resolves a destination operand to its register reference and write masks.\r\n *\r\n * @param {object} operand Decoded destination operand.\r\n * @returns {{ref:string,mask:string,registerMask:string}|null} Target with the\r\n * declared-space display mask and the register-space mask, or null for the\r\n * `null` register.\r\n */\r\n destination(operand)\r\n {\r\n if (operand.type === 13)\r\n {\r\n return null;\r\n }\r\n if (SPECIAL_OPERAND_NAMES[operand.type])\r\n {\r\n return { ref: SPECIAL_OPERAND_NAMES[operand.type], mask: \"\", registerMask: operand.mask || \"xyzw\" };\r\n }\r\n const registerMask = operand.mask || \"\";\r\n return {\r\n ref: this.registerReference(operand),\r\n mask: this.remapComponents(operand, registerMask),\r\n registerMask\r\n };\r\n }\r\n\r\n /**\r\n * Builds a full assignment statement for a destination operand.\r\n *\r\n * @param {object} destOperand Decoded destination operand.\r\n * @param {string} valueExpression GLSL expression producing the value.\r\n * @param {object} [options] Assignment context.\r\n * @param {boolean} [options.saturate] Wrap the value in `clamp(v, 0.0, 1.0)`.\r\n * @param {\"float\"|\"int\"|\"uint\"} [options.as] Type of `valueExpression`; non-float\r\n * values are bitcast back into the float register storage.\r\n * @returns {string|null} GLSL statement, or null when the destination is `null`.\r\n */\r\n assignment(destOperand, valueExpression, options = {})\r\n {\r\n const target = this.destination(destOperand);\r\n if (!target)\r\n {\r\n return null;\r\n }\r\n let value = valueExpression;\r\n const as = options.as || \"float\";\r\n if (as !== \"float\")\r\n {\r\n value = `${BITCAST_TO_FLOAT[as]}(${value})`;\r\n }\r\n if (options.saturate)\r\n {\r\n value = `clamp(${value}, 0.0, 1.0)`;\r\n }\r\n const mask = target.mask ? `.${target.mask}` : \"\";\r\n return `${target.ref}${mask} = ${value};`;\r\n }\r\n\r\n /**\r\n * Resolves an operand's register reference without swizzle or casts.\r\n *\r\n * @param {object} operand Decoded operand.\r\n * @returns {string} GLSL lvalue such as `r0`, `cb3.data[26]`, or `t0`.\r\n */\r\n registerReference(operand)\r\n {\r\n const indices = operand.indices;\r\n switch (operand.type)\r\n {\r\n case 0:\r\n return this.names.temp(this._immediateIndex(operand, 0));\r\n case 1:\r\n if (indices.length !== 1)\r\n {\r\n throw new WebglReadError(\"Multi-dimensional inputs are not supported by the WebGL2 emitter\", {\r\n operandType: operand.typeName,\r\n dimensions: indices.length\r\n });\r\n }\r\n return this.names.input(this._immediateIndex(operand, 0));\r\n case 2:\r\n return this.names.output(this._immediateIndex(operand, 0));\r\n case 3:\r\n return `${this.names.indexableTemp(this._immediateIndex(operand, 0))}[${this._indexExpression(operand, 1)}]`;\r\n case 6:\r\n return this.names.sampler(this._registerIndex(operand));\r\n case 7:\r\n return this.names.resource(this._registerIndex(operand));\r\n case 8: {\r\n // A constant-buffer operand is indexed either 2D or 3D, and both\r\n // appear in the shipped corpus - 1,660 two-dimensional against\r\n // 1,747 three-dimensional across 152 shaders.\r\n //\r\n // 2D: (register, row) - shader model 5.0\r\n // 3D: (range id, register, row) - shader model 5.1\r\n //\r\n // Reading a 3D operand as if it were 2D takes the range id for\r\n // the register and the register for the row. The range id is the\r\n // ordinal of the `dcl_constant_buffer` that introduced the\r\n // binding, so it equals the register only while a shader declares\r\n // its buffers contiguously from zero. A shader declaring b0, b1,\r\n // b3 emits `cb2` for every b3 reference - a slot it never\r\n // declared, which fails to compile - and every shader that does\r\n // compile reads its rows from the register number.\r\n const dimension = operand.indices.length - 2;\r\n const member = this.names.constantBufferMember;\r\n const base = this.names.constantBuffer(\r\n this._immediateIndex(operand, dimension)\r\n );\r\n return `${base}${member ? `.${member}` : \"\"}[${this._indexExpression(operand, dimension + 1)}]`;\r\n }\r\n case 9:\r\n return `${this.names.immediateConstantBuffer}[${this._indexExpression(operand, 0)}]`;\r\n case 30:\r\n return this.names.uav(this._registerIndex(operand));\r\n case 32:\r\n return this.names.threadId();\r\n case 33:\r\n return this.names.threadGroupId();\r\n case 34:\r\n return this.names.threadIdInGroup();\r\n case 36:\r\n return this.names.threadIdInGroupFlattened();\r\n default:\r\n if (SPECIAL_OPERAND_NAMES[operand.type])\r\n {\r\n return SPECIAL_OPERAND_NAMES[operand.type];\r\n }\r\n throw new WebglReadError(\"Operand type is not supported by the WebGL2 emitter\", {\r\n operandType: operand.typeName\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Formats an immediate32 operand as a scalar or vector literal.\r\n *\r\n * @param {object} operand Decoded immediate operand.\r\n * @param {string} destMask Destination write mask.\r\n * @param {\"float\"|\"int\"|\"uint\"} as Literal type.\r\n * @returns {string} GLSL literal expression.\r\n * @private\r\n */\r\n _immediateExpression(operand, destMask, as)\r\n {\r\n const literals = operand.immediateValues.map((value) => this._literal(value, as));\r\n if (operand.componentCount === 1)\r\n {\r\n return literals[0];\r\n }\r\n const selected = [ ...destMask ].map((component) =>\r\n {\r\n const slot = COMPONENT_INDEX[component];\r\n if (slot === undefined || slot >= literals.length)\r\n {\r\n throw new WebglReadError(\"Immediate component selection is out of range\", {\r\n destMask,\r\n component\r\n });\r\n }\r\n return literals[slot];\r\n });\r\n if (selected.length === 1)\r\n {\r\n return selected[0];\r\n }\r\n return `${VEC_TYPE_BY_KIND[as][selected.length - 1]}(${selected.join(\", \")})`;\r\n }\r\n\r\n /**\r\n * Formats one immediate dword as a GLSL literal.\r\n *\r\n * @param {{uint32:number,float32:number|null}} value Immediate value views.\r\n * @param {\"float\"|\"int\"|\"uint\"} as Literal type.\r\n * @returns {string} GLSL literal.\r\n * @private\r\n */\r\n _literal(value, as)\r\n {\r\n if (as === \"uint\")\r\n {\r\n return `${value.uint32 >>> 0}u`;\r\n }\r\n if (as === \"int\")\r\n {\r\n return `${value.uint32 | 0}`;\r\n }\r\n const float = value.float32;\r\n if (!Number.isFinite(float))\r\n {\r\n return `uintBitsToFloat(${value.uint32 >>> 0}u)`;\r\n }\r\n if (Object.is(float, -0))\r\n {\r\n return \"-0.0\";\r\n }\r\n const text = String(float);\r\n return /[.e]/.test(text) ? text : `${text}.0`;\r\n }\r\n\r\n /**\r\n * Applies the operand's component selection against a destination mask.\r\n *\r\n * @param {object} operand Decoded operand.\r\n * @param {string} destMask Destination write mask.\r\n * @returns {string} Swizzle suffix including the leading dot, or empty.\r\n * @private\r\n */\r\n _swizzleSuffix(operand, destMask)\r\n {\r\n if (operand.componentCount < 4)\r\n {\r\n return \"\";\r\n }\r\n let selected = \"\";\r\n if (operand.selectionModeName === \"select1\")\r\n {\r\n selected = operand.selected;\r\n }\r\n else if (operand.selectionModeName === \"swizzle\")\r\n {\r\n selected = [ ...destMask ]\r\n .map((component) => operand.swizzle[COMPONENT_INDEX[component]])\r\n .join(\"\");\r\n }\r\n else if (operand.selectionModeName === \"mask\" && operand.mask && operand.mask !== \"xyzw\")\r\n {\r\n selected = operand.mask;\r\n }\r\n else\r\n {\r\n return \"\";\r\n }\r\n const remapped = this.remapComponents(operand, selected);\r\n return remapped ? `.${remapped}` : \"\";\r\n }\r\n\r\n /**\r\n * Reads a purely immediate operand index.\r\n *\r\n * @param {object} operand Decoded operand.\r\n * @param {number} dimension Index dimension.\r\n * @returns {number} Immediate index value.\r\n * @private\r\n */\r\n /**\r\n * The bound register of a resource-like operand.\r\n *\r\n * Shader model 5.1 prepends a range id to every register-bearing operand, so\r\n * a resource that is 1D at 5.0 is 2D at 5.1 and a constant buffer that is 2D\r\n * becomes 3D. The register is what trails: reading dimension 0 unconditionally\r\n * takes the range id instead, which is the ordinal of the declaration that\r\n * introduced the binding and equals the register only while a shader declares\r\n * its bindings contiguously from zero.\r\n *\r\n * Measured across 40 shipped effects: 56 of 161 two-dimensional resource\r\n * operands and 4 of 145 sampler operands carry a range id that differs from\r\n * their register. Those named the wrong binding entirely - a texel fetch\r\n * landing on a samplerCube, which GLSL ES 3.00 has no overload for.\r\n *\r\n * @param {object} operand Decoded operand.\r\n * @returns {number} Bound register index.\r\n */\r\n _registerIndex(operand)\r\n {\r\n const dimension = operand.indices.length - 1;\r\n const index = operand.indices[dimension];\r\n if (index?.relative)\r\n {\r\n // A dynamically indexed binding. GLSL ES 3.00 has no dynamic sampler\r\n // indexing, so there is nothing to emit. Reading dimension 0 instead\r\n // would find the range id - an immediate - and quietly emit a fixed\r\n // binding that is simply the wrong one.\r\n throw new WebglReadError(\r\n \"Resource operand uses a relative register index; GLSL ES 3.00 has no dynamic binding indexing\",\r\n { operandType: operand.typeName, dimension }\r\n );\r\n }\r\n return this._immediateIndex(operand, dimension);\r\n }\r\n\r\n /**\r\n * Return one required immediate operand index.\r\n *\r\n * @param {object} operand Decoded operand.\r\n * @param {number} dimension Index dimension.\r\n * @returns {number} Immediate index value.\r\n * @private\r\n */\r\n _immediateIndex(operand, dimension)\r\n {\r\n const index = operand.indices[dimension];\r\n if (!index || index.values.length === 0 || index.relative)\r\n {\r\n throw new WebglReadError(\"Expected an immediate register index\", {\r\n operandType: operand.typeName,\r\n dimension\r\n });\r\n }\r\n return index.values[0];\r\n }\r\n\r\n /**\r\n * Formats an operand index that may combine an immediate offset with a\r\n * relative register (for example `cb3[r1.y + 26]`).\r\n *\r\n * @param {object} operand Decoded operand.\r\n * @param {number} dimension Index dimension.\r\n * @returns {string} GLSL index expression.\r\n * @private\r\n */\r\n _indexExpression(operand, dimension)\r\n {\r\n const index = operand.indices[dimension];\r\n if (!index)\r\n {\r\n throw new WebglReadError(\"Missing operand index dimension\", {\r\n operandType: operand.typeName,\r\n dimension\r\n });\r\n }\r\n if (index.representation === 1 || index.representation === 4)\r\n {\r\n throw new WebglReadError(\"64-bit register indices are not supported by the WebGL2 emitter\", {\r\n operandType: operand.typeName,\r\n dimension\r\n });\r\n }\r\n\r\n const immediate = index.values.length ? index.values[0] : null;\r\n const relative = index.relative\r\n ? this.sourceExpression(index.relative, { destMask: \"x\", as: \"int\" })\r\n : null;\r\n\r\n if (relative && immediate)\r\n {\r\n return `${relative} + ${immediate}`;\r\n }\r\n if (relative)\r\n {\r\n return relative;\r\n }\r\n if (immediate === null)\r\n {\r\n throw new WebglReadError(\"Operand index has neither immediate nor relative part\", {\r\n operandType: operand.typeName,\r\n dimension\r\n });\r\n }\r\n return String(immediate);\r\n }\r\n}\r\n"],"names":["COMPONENTS","COMPONENT_INDEX","x","y","z","w","VEC_TYPE_BY_KIND","float","int","uint","BITCAST_FROM_FLOAT","BITCAST_TO_FLOAT","SPECIAL_OPERAND_NAMES","DxbcGlslOperandFormatter","constructor","options","componentMap","integerTemps","integerInputs","systemIntegerInputs","names","temp","index","indexableTemp","input","output","constantBuffer","slot","constantBufferMember","resource","sampler","uav","threadId","threadGroupId","threadIdInGroup","threadIdInGroupFlattened","immediateConstantBuffer","sourceExpression","operand","destMask","as","type","_immediateExpression","WebglReadError","operandType","typeName","suffix","_swizzleSuffix","expression","registerReference","modifierName","floatSpaceModifier","integerInputKind","get","registerIndex","undefined","systemInteger","width","length","raw","remapComponents","chars","declared","map","component","indexOf","join","expressionWidth","componentCount","selectionModeName","selected","swizzle","mask","remapped","destination","ref","registerMask","assignment","destOperand","valueExpression","target","value","saturate","indices","_immediateIndex","dimensions","_indexExpression","_registerIndex","dimension","member","base","literals","immediateValues","_literal","uint32","float32","Number","isFinite","Object","is","text","String","test","relative","values","representation","immediate"],"mappings":";;AAEA,MAAMA,UAAU,GAAG,CAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAE;AACzC,MAAMC,eAAe,GAAG;AAAEC,EAAAA,CAAC,EAAE,CAAC;AAAEC,EAAAA,CAAC,EAAE,CAAC;AAAEC,EAAAA,CAAC,EAAE,CAAC;AAAEC,EAAAA,CAAC,EAAE;AAAE,CAAC;AAClD,MAAMC,gBAAgB,GAAG;EACrBC,KAAK,EAAE,CAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAE;EAC1CC,GAAG,EAAE,CAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAE;EACzCC,IAAI,EAAE,CAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO;AAC7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AM,CAACK,SAAS,CAAC;AAC5B,EAAA;AACJ;;;;"}
@@ -1282,93 +1282,62 @@ the all-body path initially omitted the particle-clear effect-profile
1282
1282
  preflight. The synthetic fixtures cannot express either condition, so an
1283
1283
  all-body corpus sweep is part of this feature's verification, not an optional
1284
1284
  extra.
1285
-
1286
- ## Consumer boundary: resource transforms
1287
-
1288
- The `trinityal/webgpu` layer accepts `CJS_WGSL_SET` versions 1, 2 and 3, and realizes
1289
- `texture-2d-array` resource transforms. The discriminator is the **feature**,
1290
- never the document version and never `texture.viewDimension`:
1291
-
1292
- - a **source-declared** `texture_2d_array` keeps every one of its bindings and
1293
- needs no assembly. Gating on `viewDimension` would reject the very packages
1294
- the exact draw gate renders — the selected Quad V5 body binds a plain
1295
- `texture_2d_array<f32>` with no transform, and both Quad families carry
1296
- `cube` bindings.
1297
- - a **transformed** binding carries `transformId` and `arrayLayerCount`, and its
1298
- merged-away inputs are absent from the layout. It cannot be fed from one
1299
- source texture, so the consumer assembles the layers.
1300
-
1301
- Only `kind: texture-2d-array`, `version: 1`,
1302
- `representation: native-or-rgba8`, and `missingLayer: reject` are realized.
1303
- Anything else throws a diagnostic naming the offending field, because the
1304
- failure mode of guessing is WGSL a device accepts and pixels that are quietly
1305
- wrong.
1306
-
1307
- Both halves of the claim are validated, not just the record: exactly one binding
1308
- must carry each declared transform, at the declared output identity, with a
1309
- matching `arrayLayerCount`, a `texture_2d_array<f32>` type, visibility to the
1310
- transform's stage, and **no surviving binding for any merged-away input**. A
1311
- survivor would still be bindable and would silently receive a texture the shader
1312
- never reads. Symmetrically, a binding claiming an undeclared transform, or
1313
- declaring array layers without one, is rejected.
1314
-
1315
- ### The analysis is pre-transform; the layout is post-transform
1316
-
1317
- This asymmetry is the one thing a consumer must not get wrong. The reflection
1318
- still lists every declared resource under its own register, including inputs the
1319
- producer merged away; the layout is shorter by exactly those inputs. Checking
1320
- one against the other reports the merge as drift. The merged array occupies the
1321
- **layer-0 input's slot**, which is required rather than assumed, so the binding a
1322
- consumer must fill is unambiguous.
1323
-
1324
- Layers are written in declared order, layer *i* from `inputs[i]`, and must agree
1325
- on size and format because one texture cannot hold layers that do not. A missing
1326
- input is rejected rather than substituted: any stand-in layer would change the
1327
- rendered result while still validating.
1328
-
1329
- Realized and drawn, all with zero WGSL warnings:
1330
-
1331
- | Family | Layers | Merged into | Evidence |
1285
+
1286
+ ## Consumer boundary: resource transforms
1287
+
1288
+ The [version-3 contract](../formats/carbon-webgpu.md#version-3-resource-transforms)
1289
+ owns supported recipes and record/layout validation; the
1290
+ [device API](../../../../trinityal/webgpu/reference/api.md#device-boundary)
1291
+ owns caller-supplied layer assembly. Unsupported fields fail with a diagnostic
1292
+ naming the field. Validation rejects undeclared transforms, orphan layer-count
1293
+ claims, and surviving bindings for merged-away inputs.
1294
+
1295
+ Discriminate by **feature**, not document version or `texture.viewDimension`:
1296
+
1297
+ - **Source-declared** arrays retain their bindings and need no assembly. The
1298
+ selected Quad V5 body binds `texture_2d_array<f32>` without a transform;
1299
+ both Quad families also carry `cube` bindings.
1300
+ - **Transformed** bindings carry `transformId` and `arrayLayerCount`; their
1301
+ merged-away inputs are absent. Supply the assembled layers, not one source.
1302
+
1303
+ ### The analysis is pre-transform; the layout is post-transform
1304
+
1305
+ Reflection retains each declared register, including merged-away inputs;
1306
+ physical layout omits those inputs. Comparing them as identical would report
1307
+ the intended merge as drift. The contract requires the array to reuse layer
1308
+ zero's slot, preserve declared input order, and reject missing or incompatible
1309
+ layers.
1310
+
1311
+ Realized and drawn, all with zero WGSL warnings:
1312
+
1313
+ | Family | Layers | Merged into | Evidence |
1332
1314
  | --- | --- | --- | --- |
1333
1315
  | `unpackedskinned_quadheatdetailv5` | 2 | `Detail1Map` slot | 22 over 22 bindings, 3 cases, detail changed 570/635 covered pixels |
1334
- | `unpacked_quaddetailv5` | 3 | `Detail1Map` slot | both detail controls changed 1116/1116 covered pixels |
1335
- | `unpackedskinned_quaddetailv5` | 3 | `Detail1Map` slot | 634/635 and 635/635, indexed non-identity bones observed |
1336
-
1337
- The `Detail1` and `Detail2` delta maps were **distinct** in every case. That is
1338
- the assertion that matters: a collapsed or misordered assembly would produce
1339
- identical deltas while still rendering and still validating.
1340
-
1341
- Source-declared array textures are now realized rather than merely accepted:
1342
- the engine creates a layered 2D texture with a `2d-array` view and binds it
1343
- through the same adapter, gated by a synthetic two-layer draw that asserts each
1344
- layer's pixels exactly. A single-layer array view is legal and distinct from a
1345
- plain 2D view, because a shader declaring `texture_2d_array<f32>` needs the
1346
- array view whatever its layer count. A layout asking for the dimension the view
1347
- was not created with fails closed, since a view's dimension is fixed at
1348
- creation and cannot be reinterpreted.
1349
-
1350
- This matters beyond the transform case: the High `.sm_depth` Quad V5 `Main`
1351
- pass binds `LightProfileArray` as a plain `texture_2d_array<f32>` with no
1352
- transform at all, so array-texture realization is a prerequisite for any
1353
- High-tier draw gate, not a detail of transform support.
1354
-
1355
- Array-texture realization is what made transform support possible: the engine
1356
- allocates the array itself and fills layer *i* from `inputs[i]`, which is the
1357
- only way a binding whose other inputs were removed can be filled at all. The
1358
- Detail and HeatDetail family gates draw under this contract. The Environment
1359
- family has not been exercised and should be treated as unverified rather than
1360
- working.
1361
-
1362
- Accepting version 3 also tightened three structural checks that were written
1363
- `=== 2` and would otherwise have silently downgraded every version-3 package to
1364
- version-1 semantics: shared binding identities must span at least two stages,
1365
- and explicit D3D and scope identities are both required. That downgrade would
1366
- have been invisible to the exact draw gate, because DX11 and DX12 downgrade
1367
- identically and the bit-exact comparison would have stayed green.
1368
-
1369
- ## Verification contract
1370
-
1371
- Every shader-emission, layout, or transform compatibility change requires the
1316
+ | `unpacked_quaddetailv5` | 3 | `Detail1Map` slot | both detail controls changed 1116/1116 covered pixels |
1317
+ | `unpackedskinned_quaddetailv5` | 3 | `Detail1Map` slot | 634/635 and 635/635, indexed non-identity bones observed |
1318
+
1319
+ `Detail1` and `Detail2` delta maps were **distinct** in every case: collapsed
1320
+ or misordered assembly could render and validate but produce identical deltas.
1321
+
1322
+ Source-declared arrays are also realized: a synthetic two-layer draw checks
1323
+ each layer's pixels exactly through the same adapter. A single-layer
1324
+ `2d-array` view remains distinct from plain 2D; a layout requesting a dimension
1325
+ other than the view's fixed creation dimension fails closed. High `.sm_depth`
1326
+ Quad V5 `Main` binds `LightProfileArray` without a transform, so this support
1327
+ is a prerequisite for High-tier draw gates.
1328
+
1329
+ The Detail and HeatDetail gates exercise layer assembly under this contract;
1330
+ **Environment remains unverified**.
1331
+
1332
+ Version 3 exposed three checks incorrectly gated by `=== 2`: shared identities
1333
+ must span at least two stages, and explicit D3D and scope identities are both
1334
+ required. Otherwise version 3 would silently acquire version-1 semantics. Exact
1335
+ DX11/DX12 draw comparison would miss that regression because both would downgrade
1336
+ identically.
1337
+
1338
+ ## Verification contract
1339
+
1340
+ Every shader-emission, layout, or transform compatibility change requires the
1372
1341
  package suite and a representative `trinityal/webgpu` browser gate on a real
1373
1342
  WebGPU device with zero WGSL warnings. Format-level qualification cannot detect
1374
1343
  every WGSL scoping or validator failure, so browser validation remains part of
@@ -7,7 +7,7 @@ Summary: Provides one-sentence purpose descriptors for abstraction-layer donor c
7
7
 
8
8
  Every class here comes from a backend Carbon compiles instead of ours. That is
9
9
  not on its own a reason to ignore one: `MetalWorkQueue` is the declared model
10
- for `CjsWebgpuWorkQueue`, and of the seven below, five describe behaviour this
10
+ for `CjsWebgpuWorkQueue`, and of the eight below, six describe behaviour this
11
11
  package already ports under different names. They are written so the
12
12
  correspondence is checkable rather than assumed.
13
13
 
@@ -71,6 +71,16 @@ Carbon's deferred render-pass attachment record, whose behaviour this package po
71
71
  - Visibility: Internal
72
72
  - Kind: Faithful Carbon port
73
73
 
74
+ <!-- class:MetalWorkQueue -->
75
+ ## `MetalWorkQueue`
76
+
77
+ Carbon's Metal command recorder, whose encoder-lifetime half this package ports as `CjsWebgpuWorkQueue` while the pipeline, resource sets and render context's draw verbs take the rest of its surface.
78
+
79
+ - Export: None
80
+ - Source: `src/trinityal/dropped/MetalWorkQueue.js`
81
+ - Visibility: Internal
82
+ - Kind: Faithful Carbon port
83
+
74
84
  <!-- class:ShaderResourceMask -->
75
85
  ## `ShaderResourceMask`
76
86
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carbonenginejs/runtime",
3
- "version": "0.1.0-alpha.1",
3
+ "version": "0.1.0-alpha.2",
4
4
  "private": false,
5
5
  "description": "Browser-safe CarbonEngineJS runtime: resource and format readers, the Trinity/EVE object graph, SOF, audio, character, and the WebGPU renderer.",
6
6
  "type": "module",