@carbonenginejs/runtime-resource 0.11.1 → 0.12.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.
- package/dist/CjsResMan.js +4 -4
- package/dist/CjsResMan.js.map +1 -1
- package/dist/_virtual/_rollupPluginBabelHelpers.js +1 -4
- package/dist/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
- package/dist/format/CjsByteReader.js +310 -0
- package/dist/format/CjsByteReader.js.map +1 -0
- package/dist/format/CjsByteWriter.js +242 -0
- package/dist/format/CjsByteWriter.js.map +1 -0
- package/dist/format/CjsFormatError.js +41 -0
- package/dist/format/CjsFormatError.js.map +1 -0
- package/dist/format/CjsStringTable.js +268 -0
- package/dist/format/CjsStringTable.js.map +1 -0
- package/dist/format/carbonEffect/CjsCarbonEffectReader.js +361 -0
- package/dist/format/carbonEffect/CjsCarbonEffectReader.js.map +1 -0
- package/dist/format/carbonEffect/CjsCarbonEffectWriter.js +373 -0
- package/dist/format/carbonEffect/CjsCarbonEffectWriter.js.map +1 -0
- package/dist/format/carbonEffect/carbonDescriptionFromPortable.js +372 -0
- package/dist/format/carbonEffect/carbonDescriptionFromPortable.js.map +1 -0
- package/dist/format/carbonEffect/carbonEffectBackendBlock.js +427 -0
- package/dist/format/carbonEffect/carbonEffectBackendBlock.js.map +1 -0
- package/dist/format/carbonEffect/carbonEffectRecords.js +955 -0
- package/dist/format/carbonEffect/carbonEffectRecords.js.map +1 -0
- package/dist/format/compareUtf8.js +36 -0
- package/dist/format/compareUtf8.js.map +1 -0
- package/dist/format/index.js +11 -0
- package/dist/format/index.js.map +1 -0
- package/dist/formats/bnk/CjsBnkFormat.js +18 -2
- package/dist/formats/bnk/CjsBnkFormat.js.map +1 -1
- package/dist/formats/bnk/core/eventAction.js +305 -0
- package/dist/formats/bnk/core/eventAction.js.map +1 -0
- package/dist/formats/bnk/core/graph.js +3 -6
- package/dist/formats/bnk/core/graph.js.map +1 -1
- package/dist/formats/bnk/core/helpers.js +62 -11
- package/dist/formats/bnk/core/helpers.js.map +1 -1
- package/dist/formats/bnk/core/nodeBase.js +532 -0
- package/dist/formats/bnk/core/nodeBase.js.map +1 -0
- package/dist/formats/bnk/core/sfxNodes.js +632 -0
- package/dist/formats/bnk/core/sfxNodes.js.map +1 -0
- package/dist/formats/bnk/core/soundbanksInfo.js +59 -51
- package/dist/formats/bnk/core/soundbanksInfo.js.map +1 -1
- package/dist/formats/gr2/CjsGr2Format.js +256 -13
- package/dist/formats/gr2/CjsGr2Format.js.map +1 -1
- package/dist/formats/gr2/core/helpers.js +15 -15
- package/dist/formats/gr2/core/helpers.js.map +1 -1
- package/dist/formats/gr2/core/json.js +1 -1
- package/dist/formats/gr2/core/json.js.map +1 -1
- package/dist/formats/gr2/core/targets.js +1 -1
- package/dist/formats/gr2/core/targets.js.map +1 -1
- package/dist/formats/gr2/index.js +0 -1
- package/dist/formats/gr2/index.js.map +1 -1
- package/dist/formats/hlsl/core/HlslReader.js +7 -257
- package/dist/formats/hlsl/core/HlslReader.js.map +1 -1
- package/dist/formats/hlsl/core/analysis.js +1 -1
- package/dist/formats/hlsl/core/carbonDescriptionToRuntime.js +781 -0
- package/dist/formats/hlsl/core/carbonDescriptionToRuntime.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/resources/HlslEffectRes.js +21 -1
- package/dist/formats/hlsl/core/tr2/resources/HlslEffectRes.js.map +1 -1
- package/dist/formats/hlsl/index.js +1 -0
- package/dist/formats/hlsl/index.js.map +1 -1
- package/dist/formats/index.js +3 -6
- package/dist/formats/index.js.map +1 -1
- package/dist/formats/webgl/core/cewg/CewgPackage.js +2 -1
- package/dist/formats/webgl/core/cewg/CewgPackage.js.map +1 -1
- package/dist/formats/webgl/core/cewg/binary.js +11 -93
- package/dist/formats/webgl/core/cewg/binary.js.map +1 -1
- package/dist/formats/webgl/core/effectPackage.js +4 -1
- package/dist/formats/webgl/core/effectPackage.js.map +1 -1
- package/dist/formats/webgl/core/errors.js +3 -3
- package/dist/formats/webgl/core/errors.js.map +1 -1
- package/dist/formats/webgpu/CjsWebgpuFormat.js +4 -23
- package/dist/formats/webgpu/CjsWebgpuFormat.js.map +1 -1
- package/dist/formats/webgpu/core/buildCarbonEffectContainer.js +197 -0
- package/dist/formats/webgpu/core/buildCarbonEffectContainer.js.map +1 -0
- package/dist/formats/webgpu/core/cewgpu/CewgpuContainer.js +368 -0
- package/dist/formats/webgpu/core/cewgpu/CewgpuContainer.js.map +1 -0
- package/dist/formats/webgpu/core/cewgpu/containerViews.js +355 -0
- package/dist/formats/webgpu/core/cewgpu/containerViews.js.map +1 -0
- package/dist/formats/webgpu/core/cewgpu/validateContainer.js +90 -0
- package/dist/formats/webgpu/core/cewgpu/validateContainer.js.map +1 -0
- package/dist/formats/webgpu/core/effectBackendBodySet.js +21 -20
- package/dist/formats/webgpu/core/effectBackendBodySet.js.map +1 -1
- package/dist/formats/webgpu/core/helpers.js +87 -92
- package/dist/formats/webgpu/core/helpers.js.map +1 -1
- package/dist/formats/webgpu/core/ir/analyzeRegisterValues.js +14 -13
- package/dist/formats/webgpu/core/ir/analyzeRegisterValues.js.map +1 -1
- package/dist/formats/webgpu/core/ir/inferValueTypes.js +10 -8
- package/dist/formats/webgpu/core/ir/inferValueTypes.js.map +1 -1
- package/dist/formats/webgpu/core/packageEffect.js +94 -9
- package/dist/formats/webgpu/core/packageEffect.js.map +1 -1
- package/dist/formats/webgpu/core/packageMetadata.js +10 -1
- package/dist/formats/webgpu/core/packageMetadata.js.map +1 -1
- package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js +17 -15
- package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js.map +1 -1
- package/dist/formats/webgpu/core/wgsl/buildWgslBindingPlan.js +13 -12
- package/dist/formats/webgpu/core/wgsl/buildWgslBindingPlan.js.map +1 -1
- package/dist/formats/webgpu/core/wgsl/buildWgslSet.js +9 -8
- package/dist/formats/webgpu/core/wgsl/buildWgslSet.js.map +1 -1
- package/dist/formats/webgpu/core/wgsl/lowerComputeProgram.js +23 -22
- package/dist/formats/webgpu/core/wgsl/lowerComputeProgram.js.map +1 -1
- package/dist/formats/webgpu/core/wgsl/selectionPlans.js +46 -44
- package/dist/formats/webgpu/core/wgsl/selectionPlans.js.map +1 -1
- package/dist/resource/CjsResource.js +700 -684
- package/dist/resource/CjsResource.js.map +1 -1
- package/dist/resource/Tr2LightProfileRes.js +18 -27
- package/dist/resource/Tr2LightProfileRes.js.map +1 -1
- package/dist/resource/audio/CjsAudioBufferRes.js +2 -2
- package/dist/resource/audio/CjsAudioBufferRes.js.map +1 -1
- package/dist/resource/audio/CjsAudioRes.js +2 -2
- package/dist/resource/audio/CjsAudioRes.js.map +1 -1
- package/dist/resource/geometry/TriGeometryRes.js +605 -586
- package/dist/resource/geometry/TriGeometryRes.js.map +1 -1
- package/dist/resource/geometry/granny/Tr2GrannyStateRes.js +21 -30
- package/dist/resource/geometry/granny/Tr2GrannyStateRes.js.map +1 -1
- package/dist/resource/geometry/granny/TriGrannyRes.js +21 -30
- package/dist/resource/geometry/granny/TriGrannyRes.js.map +1 -1
- package/dist/resource/shader/Tr2EffectRes.js +9 -7
- package/dist/resource/shader/Tr2EffectRes.js.map +1 -1
- package/dist/resource/shader/Tr2MaterialArea.js +5 -3
- package/dist/resource/shader/Tr2MaterialArea.js.map +1 -1
- package/dist/resource/shader/Tr2MaterialMesh.js +4 -2
- package/dist/resource/shader/Tr2MaterialMesh.js.map +1 -1
- package/dist/resource/shader/Tr2MaterialRes.js +5 -3
- package/dist/resource/shader/Tr2MaterialRes.js.map +1 -1
- package/dist/resource/shader/Tr2Shader.js +26 -21
- package/dist/resource/shader/Tr2Shader.js.map +1 -1
- package/dist/resource/shader/Tr2ShaderPermutation.js +8 -6
- package/dist/resource/shader/Tr2ShaderPermutation.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectDefine.js +5 -3
- package/dist/resource/shader/reflection/Tr2EffectDefine.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectDescription.js +5 -3
- package/dist/resource/shader/reflection/Tr2EffectDescription.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectLibrary.js +17 -15
- package/dist/resource/shader/reflection/Tr2EffectLibrary.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js +11 -9
- package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectResource.js +8 -6
- package/dist/resource/shader/reflection/Tr2EffectResource.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectStageInput.js +15 -13
- package/dist/resource/shader/reflection/Tr2EffectStageInput.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectTechnique.js +7 -5
- package/dist/resource/shader/reflection/Tr2EffectTechnique.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2Pass.js +11 -9
- package/dist/resource/shader/reflection/Tr2Pass.js.map +1 -1
- package/dist/resource/shader/sampler/Tr2SamplerSetup.js +8 -6
- package/dist/resource/shader/sampler/Tr2SamplerSetup.js.map +1 -1
- package/dist/resource/texture/CjsTextureArrayRes.js +400 -411
- package/dist/resource/texture/CjsTextureArrayRes.js.map +1 -1
- package/dist/resource/texture/Tr2ImageRes.js +99 -95
- package/dist/resource/texture/Tr2ImageRes.js.map +1 -1
- package/dist/resource/texture/TriTextureRes.js +312 -273
- package/dist/resource/texture/TriTextureRes.js.map +1 -1
- package/docs/README.md +13 -1
- package/docs/architecture.md +3 -3
- package/docs/concepts/resource-lifecycle.md +9 -2
- package/docs/concepts/shader-resource-model.md +114 -0
- package/docs/concepts/writing-an-engine-adapter.md +115 -0
- package/docs/formats/README.md +24 -1
- package/docs/formats/carbon-effect-container.md +452 -0
- package/docs/formats/dxbc/README.md +68 -0
- package/docs/formats/dxbc/architecture.md +80 -0
- package/docs/formats/dxbc/reference/api.md +77 -0
- package/docs/formats/dxbc/reference/classes/README.md +9 -0
- package/docs/formats/dxbc/reference/decoded-output.md +122 -0
- package/docs/formats/gr2.md +3 -4
- package/docs/formats/hlsl/README.md +54 -0
- package/docs/formats/hlsl/architecture.md +67 -0
- package/docs/formats/hlsl/guides/hydrating-json-output.md +62 -0
- package/docs/formats/hlsl/guides/reading-effects.md +64 -0
- package/docs/formats/hlsl/reference/advanced-analysis.md +66 -0
- package/docs/formats/hlsl/reference/api.md +98 -0
- package/docs/formats/hlsl/reference/classes/README.md +11 -0
- package/docs/formats/hlsl/reference/json-graph.md +100 -0
- package/docs/formats/hlsl/reference/portable-reflection.md +141 -0
- package/docs/formats/provenance.md +32 -17
- package/docs/formats/webgl/README.md +57 -0
- package/docs/formats/webgl/architecture.md +70 -0
- package/docs/formats/webgl/carbon-constant-layouts.md +326 -0
- package/docs/formats/webgl/decl-io.md +1234 -0
- package/docs/formats/webgl/effect-reflection.md +127 -0
- package/docs/formats/webgl/memory-structured.md +871 -0
- package/docs/formats/webgl/reference/classes/README.md +9 -0
- package/docs/formats/webgl/texture-sample.md +964 -0
- package/docs/formats/webgpu/README.md +84 -0
- package/docs/formats/webgpu/architecture.md +96 -0
- package/docs/formats/webgpu/formats/cewgpu.md +216 -0
- package/docs/formats/webgpu/guides/effect-packaging.md +191 -0
- package/docs/formats/webgpu/reference/api.md +197 -0
- package/docs/formats/webgpu/reference/classes/README.md +9 -0
- package/docs/formats/webgpu/reference/wgsl-compatibility.md +1543 -0
- package/docs/formats/wwise.md +45 -4
- package/docs/reference/classes/core.md +80 -0
- package/docs/reference/classes/formats.md +24 -34
- package/docs/reference/events.md +25 -0
- package/docs/reference/motherlode-cache.md +22 -8
- package/docs/reference/workers.md +5 -5
- package/docs/roadmap.md +61 -41
- package/format-notices/bnk/NOTICE +5 -4
- package/format-notices/webgl/NOTICE +1 -1
- package/package.json +2 -1
- package/dist/formats/gr2/core/CjsFormatGr2.js +0 -273
- package/dist/formats/gr2/core/CjsFormatGr2.js.map +0 -1
- package/dist/formats/webgpu/core/cewgpu/CewgpuPackage.js +0 -415
- package/dist/formats/webgpu/core/cewgpu/CewgpuPackage.js.map +0 -1
- package/dist/formats/webgpu/core/cewgpu/CewgpuPackageBuilder.js +0 -100
- package/dist/formats/webgpu/core/cewgpu/CewgpuPackageBuilder.js.map +0 -1
- package/dist/formats/webgpu/core/cewgpu/binary.js +0 -93
- package/dist/formats/webgpu/core/cewgpu/binary.js.map +0 -1
- package/dist/formats/webgpu/core/cewgpu/tags.js +0 -17
- package/dist/formats/webgpu/core/cewgpu/tags.js.map +0 -1
- package/dist/formats/webgpu/core/effectPackageValidation.js +0 -1078
- package/dist/formats/webgpu/core/effectPackageValidation.js.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { fixedSourceLanes } from './sourceLanes.js';
|
|
2
2
|
import { validateIndexableTempOperand } from './indexableTemps.js';
|
|
3
|
+
import { compareUtf8 } from '../../../../format/compareUtf8.js';
|
|
3
4
|
|
|
4
5
|
const COMPONENTS = ["x", "y", "z", "w"];
|
|
5
6
|
const REGISTER_FILES = new Set(["temp", "input", "output", "indexable_temp", "input_primitive_id", "output_depth", "output_coverage", "input_control_point", "output_control_point", "input_patch_constant", "input_domain_point", "output_control_point_id", "input_fork_instance_id", "input_join_instance_id", "input_thread_id", "input_thread_group_id", "input_thread_id_in_group", "input_coverage_mask", "input_thread_id_in_group_flattened", "input_gs_instance_id", "output_depth_greater_equal", "output_depth_less_equal"]);
|
|
@@ -33,11 +34,11 @@ function registerKey(program, operand, role) {
|
|
|
33
34
|
return `${operand.typeName}[${indices.join(",")}]`;
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
/**
|
|
37
|
-
* Classifies decoded instruction operands as register sources or destinations.
|
|
38
|
-
*
|
|
39
|
-
* @param {object} instruction Decoded instruction.
|
|
40
|
-
* @returns {Array<{operand: object, role: string}>} Ordered operand roles.
|
|
37
|
+
/**
|
|
38
|
+
* Classifies decoded instruction operands as register sources or destinations.
|
|
39
|
+
*
|
|
40
|
+
* @param {object} instruction Decoded instruction.
|
|
41
|
+
* @returns {Array<{operand: object, role: string}>} Ordered operand roles.
|
|
41
42
|
*/
|
|
42
43
|
function operandRoles(instruction) {
|
|
43
44
|
const operands = instruction.operands || [];
|
|
@@ -201,16 +202,16 @@ function analyzeBlock(program, block, values) {
|
|
|
201
202
|
register,
|
|
202
203
|
component,
|
|
203
204
|
ref
|
|
204
|
-
}))).sort((a, b) => a.register
|
|
205
|
+
}))).sort((a, b) => compareUtf8(a.register, b.register) || compareUtf8(a.component, b.component));
|
|
205
206
|
}
|
|
206
207
|
|
|
207
|
-
/**
|
|
208
|
-
* Adds block-local register versions, masked-write reconstruction records,
|
|
209
|
-
* and deterministic block-exit state. A later pass resolves the conservative
|
|
210
|
-
* block inputs through CFG predecessors.
|
|
211
|
-
*
|
|
212
|
-
* @param {object} program Mutable shader IR under construction.
|
|
213
|
-
* @returns {object} The same program.
|
|
208
|
+
/**
|
|
209
|
+
* Adds block-local register versions, masked-write reconstruction records,
|
|
210
|
+
* and deterministic block-exit state. A later pass resolves the conservative
|
|
211
|
+
* block inputs through CFG predecessors.
|
|
212
|
+
*
|
|
213
|
+
* @param {object} program Mutable shader IR under construction.
|
|
214
|
+
* @returns {object} The same program.
|
|
214
215
|
*/
|
|
215
216
|
function analyzeRegisterValues(program) {
|
|
216
217
|
const values = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyzeRegisterValues.js","sources":["../../../../../../src/formats/webgpu/core/ir/analyzeRegisterValues.js"],"sourcesContent":["import { fixedSourceLanes } from \"./sourceLanes.js\";\nimport { validateIndexableTempOperand } from \"./indexableTemps.js\";\n\nconst COMPONENTS = [ \"x\", \"y\", \"z\", \"w\" ];\n\nconst REGISTER_FILES = new Set([\n \"temp\", \"input\", \"output\", \"indexable_temp\", \"input_primitive_id\",\n \"output_depth\", \"output_coverage\", \"input_control_point\",\n \"output_control_point\", \"input_patch_constant\", \"input_domain_point\",\n \"output_control_point_id\", \"input_fork_instance_id\", \"input_join_instance_id\",\n \"input_thread_id\", \"input_thread_group_id\", \"input_thread_id_in_group\",\n \"input_coverage_mask\", \"input_thread_id_in_group_flattened\",\n \"input_gs_instance_id\", \"output_depth_greater_equal\", \"output_depth_less_equal\"\n]);\n\nconst WRITABLE_FILES = new Set([\n \"temp\", \"output\", \"indexable_temp\", \"output_depth\", \"output_coverage\",\n \"output_control_point\", \"output_depth_greater_equal\", \"output_depth_less_equal\"\n]);\n\nconst NO_DESTINATION = new Set([\n \"break\", \"breakc\", \"call\", \"callc\", \"case\", \"continue\", \"continuec\",\n \"cut\", \"default\", \"discard\", \"else\", \"emit\", \"emit_then_cut\", \"endif\",\n \"endloop\", \"endswitch\", \"if\", \"label\", \"loop\", \"nop\", \"ret\", \"retc\",\n \"switch\", \"sync\", \"store_uav_typed\", \"store_raw\", \"store_structured\",\n \"atomic_and\", \"atomic_or\", \"atomic_xor\", \"atomic_cmp_store\", \"atomic_iadd\",\n \"atomic_imax\", \"atomic_imin\", \"atomic_umax\", \"atomic_umin\"\n]);\n\nconst DUAL_DESTINATION = new Set([ \"sincos\", \"imul\", \"umul\", \"udiv\", \"swapc\" ]);\nconst FULL_SOURCE_LANES = new Set([\n \"ld\", \"ld_ms\", \"resinfo\"\n]);\n\nfunction operandComponents(operand, destination = false, activeComponents = null)\n{\n if (destination)\n {\n if (operand.mask) return COMPONENTS.filter((component) => operand.mask.includes(component));\n if (operand.componentCount === 1) return [ \"x\" ];\n return COMPONENTS.slice();\n }\n if (operand.swizzle)\n {\n return activeComponents\n ? activeComponents.map((component) => operand.swizzle[COMPONENTS.indexOf(component)])\n : Array.from(operand.swizzle);\n }\n if (operand.selected) return activeComponents ? activeComponents.map(() => operand.selected) : [ operand.selected ];\n if (operand.mask) return COMPONENTS.filter((component) => operand.mask.includes(component));\n if (operand.componentCount === 1) return [ \"x\" ];\n return activeComponents ? activeComponents.slice() : COMPONENTS.slice();\n}\n\nfunction registerKey(program, operand, role)\n{\n if (!REGISTER_FILES.has(operand.typeName)) return null;\n if (operand.typeName === \"indexable_temp\")\n {\n return validateIndexableTempOperand(program, operand, role)?.key || null;\n }\n const indices = (operand.indices || []).map((index) =>\n {\n const immediate = index.values?.join(\":\") || \"\";\n return index.relative ? `${immediate}+relative` : immediate;\n });\n return `${operand.typeName}[${indices.join(\",\")}]`;\n}\n\n/**\n * Classifies decoded instruction operands as register sources or destinations.\n *\n * @param {object} instruction Decoded instruction.\n * @returns {Array<{operand: object, role: string}>} Ordered operand roles.\n */\nexport function operandRoles(instruction)\n{\n const operands = instruction.operands || [];\n if (NO_DESTINATION.has(instruction.opcodeName))\n {\n return operands.map((operand) => ({ operand, role: \"source\" }));\n }\n if (DUAL_DESTINATION.has(instruction.opcodeName))\n {\n return operands.map((operand, index) => ({ operand, role: index < 2 ? \"destination\" : \"source\" }));\n }\n return operands.map((operand, index) => ({\n operand,\n role: index === 0 && WRITABLE_FILES.has(operand.typeName) ? \"destination\" : \"source\"\n }));\n}\n\nfunction valueRef(value, component)\n{\n return { valueId: value.id, component };\n}\n\nfunction ensureComponent(state, values, register, component, blockId)\n{\n let components = state.get(register);\n if (!components)\n {\n components = new Map();\n state.set(register, components);\n }\n if (!components.has(component))\n {\n const value = {\n kind: \"register-value\",\n id: `value${values.length}`,\n origin: \"block-input\",\n blockId,\n instructionIndex: null,\n register,\n writeMask: component,\n previous: null\n };\n values.push(value);\n components.set(component, valueRef(value, component));\n }\n return components.get(component);\n}\n\nfunction analyzeBlock(program, block, values)\n{\n const state = new Map();\n const inputIds = new Set();\n for (const instructionIndex of block.instructionIndices)\n {\n const instruction = program.instructions[instructionIndex];\n const roles = operandRoles(instruction);\n const destinationComponents = Array.from(new Set(roles\n .filter((entry) => entry.role === \"destination\" && entry.operand.typeName !== \"null\")\n .flatMap((entry) => operandComponents(entry.operand, true))));\n const activeSourceComponents = destinationComponents.length && !FULL_SOURCE_LANES.has(instruction.opcodeName)\n ? destinationComponents\n : null;\n const reads = [];\n const writes = [];\n\n for (let operandIndex = 0; operandIndex < roles.length; operandIndex += 1)\n {\n const { operand, role } = roles[operandIndex];\n if (role !== \"source\") continue;\n const register = registerKey(program, operand, \"source\");\n if (!register) continue;\n const components = operandComponents(\n operand,\n false,\n fixedSourceLanes(instruction, operandIndex, program) || activeSourceComponents);\n const refs = components.map((component) => ensureComponent(state, values, register, component, block.id));\n for (const ref of refs)\n {\n const value = values.find((entry) => entry.id === ref.valueId);\n if (value?.origin === \"block-input\") inputIds.add(value.id);\n }\n reads.push({ kind: \"register-read\", operandIndex, register, components, refs });\n }\n\n for (let operandIndex = 0; operandIndex < roles.length; operandIndex += 1)\n {\n const { operand } = roles[operandIndex];\n const indices = operand.indices || [];\n for (let dimension = 0; dimension < indices.length; dimension += 1)\n {\n const relative = indices[dimension].relative;\n if (!relative) continue;\n const register = registerKey(program, relative, \"source\");\n if (!register) throw new Error(\"Shader IR relative index uses an unsupported register file\");\n const components = operandComponents(relative, false);\n if (components.length !== 1) throw new Error(\"Shader IR relative index requires one scalar component\");\n const refs = components.map((component) => ensureComponent(state, values, register, component, block.id));\n for (const ref of refs)\n {\n const value = values.find((entry) => entry.id === ref.valueId);\n if (value?.origin === \"block-input\") inputIds.add(value.id);\n }\n reads.push({ kind: \"index-read\", operandIndex, dimension, register, components, refs });\n }\n }\n\n for (let operandIndex = 0; operandIndex < roles.length; operandIndex += 1)\n {\n const { operand, role } = roles[operandIndex];\n if (role !== \"destination\" || operand.typeName === \"null\") continue;\n const register = registerKey(program, operand, \"destination\");\n if (!register) continue;\n const mask = operandComponents(operand, true);\n const previous = {};\n for (const component of COMPONENTS)\n {\n if (!mask.includes(component))\n {\n previous[component] = ensureComponent(state, values, register, component, block.id);\n }\n }\n const value = {\n kind: \"register-value\",\n id: `value${values.length}`,\n origin: \"instruction-write\",\n blockId: block.id,\n instructionIndex,\n register,\n writeMask: mask.join(\"\"),\n previous: Object.keys(previous).length ? previous : null\n };\n values.push(value);\n let components = state.get(register);\n if (!components)\n {\n components = new Map();\n state.set(register, components);\n }\n for (const component of mask) components.set(component, valueRef(value, component));\n const result = {};\n for (const component of COMPONENTS)\n {\n result[component] = components.get(component) || ensureComponent(state, values, register, component, block.id);\n }\n writes.push({\n kind: \"register-write\",\n operandIndex,\n register,\n mask: mask.join(\"\"),\n valueId: value.id,\n previous: value.previous,\n result\n });\n }\n instruction.dataflow = { reads, writes };\n }\n block.inputValueIds = Array.from(inputIds);\n block.outputValues = Array.from(state.entries())\n .flatMap(([ register, components ]) => Array.from(components.entries())\n .map(([ component, ref ]) => ({ register, component, ref })))\n .sort((a, b) => a.register.localeCompare(b.register) || a.component.localeCompare(b.component));\n}\n\n/**\n * Adds block-local register versions, masked-write reconstruction records,\n * and deterministic block-exit state. A later pass resolves the conservative\n * block inputs through CFG predecessors.\n *\n * @param {object} program Mutable shader IR under construction.\n * @returns {object} The same program.\n */\nexport function analyzeRegisterValues(program)\n{\n const values = [];\n for (const block of program.blocks) analyzeBlock(program, block, values);\n program.values = values;\n return program;\n}\n"],"names":["COMPONENTS","REGISTER_FILES","Set","WRITABLE_FILES","NO_DESTINATION","DUAL_DESTINATION","FULL_SOURCE_LANES","operandComponents","operand","destination","activeComponents","mask","filter","component","includes","componentCount","slice","swizzle","map","indexOf","Array","from","selected","registerKey","program","role","has","typeName","validateIndexableTempOperand","key","indices","index","immediate","values","join","relative","operandRoles","instruction","operands","opcodeName","valueRef","value","valueId","id","ensureComponent","state","register","blockId","components","get","Map","set","kind","length","origin","instructionIndex","writeMask","previous","push","analyzeBlock","block","inputIds","instructionIndices","instructions","roles","destinationComponents","entry","flatMap","activeSourceComponents","reads","writes","operandIndex","fixedSourceLanes","refs","ref","find","add","dimension","Error","Object","keys","result","dataflow","inputValueIds","outputValues","entries","sort","a","b","localeCompare","analyzeRegisterValues","blocks"],"mappings":";;;AAGA,MAAMA,UAAU,GAAG,CAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAE;AAEzC,MAAMC,cAAc,GAAG,IAAIC,GAAG,CAAC,CAC3B,MAAM,EAAE,OAAO,EAAE,QAAQ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I,GAAC,CAAC,CAAC,CAAC,CAChEY,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAACzC,QAAQ,CAAC2C,aAAa,CAACD,CAAC,CAAC1C,QAAQ,CAAC,IAAIyC,CAAC,CAAC1E,SAAS,CAAC4E,aAAa,CAACD,CAAC,CAAC3E,SAAS,CAAC,CAAC;AACvG;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS6E,qBAAqBA,CAAClE,OAAO,EAC7C;EACI,MAAMS,MAAM,GAAG,EAAE;AACjB,EAAA,KAAK,MAAM2B,KAAK,IAAIpC,OAAO,CAACmE,MAAM,EAAEhC,YAAY,CAACnC,OAAO,EAAEoC,KAAK,EAAE3B,MAAM,CAAC;EACxET,OAAO,CAACS,MAAM,GAAGA,MAAM;AACvB,EAAA,OAAOT,OAAO;AAClB;;;;"}
|
|
1
|
+
{"version":3,"file":"analyzeRegisterValues.js","sources":["../../../../../../src/formats/webgpu/core/ir/analyzeRegisterValues.js"],"sourcesContent":["import { fixedSourceLanes } from \"./sourceLanes.js\";\r\nimport { validateIndexableTempOperand } from \"./indexableTemps.js\";\r\nimport { compareUtf8 } from \"../../../../format/compareUtf8.js\";\r\n\r\nconst COMPONENTS = [ \"x\", \"y\", \"z\", \"w\" ];\r\n\r\nconst REGISTER_FILES = new Set([\r\n \"temp\", \"input\", \"output\", \"indexable_temp\", \"input_primitive_id\",\r\n \"output_depth\", \"output_coverage\", \"input_control_point\",\r\n \"output_control_point\", \"input_patch_constant\", \"input_domain_point\",\r\n \"output_control_point_id\", \"input_fork_instance_id\", \"input_join_instance_id\",\r\n \"input_thread_id\", \"input_thread_group_id\", \"input_thread_id_in_group\",\r\n \"input_coverage_mask\", \"input_thread_id_in_group_flattened\",\r\n \"input_gs_instance_id\", \"output_depth_greater_equal\", \"output_depth_less_equal\"\r\n]);\r\n\r\nconst WRITABLE_FILES = new Set([\r\n \"temp\", \"output\", \"indexable_temp\", \"output_depth\", \"output_coverage\",\r\n \"output_control_point\", \"output_depth_greater_equal\", \"output_depth_less_equal\"\r\n]);\r\n\r\nconst NO_DESTINATION = new Set([\r\n \"break\", \"breakc\", \"call\", \"callc\", \"case\", \"continue\", \"continuec\",\r\n \"cut\", \"default\", \"discard\", \"else\", \"emit\", \"emit_then_cut\", \"endif\",\r\n \"endloop\", \"endswitch\", \"if\", \"label\", \"loop\", \"nop\", \"ret\", \"retc\",\r\n \"switch\", \"sync\", \"store_uav_typed\", \"store_raw\", \"store_structured\",\r\n \"atomic_and\", \"atomic_or\", \"atomic_xor\", \"atomic_cmp_store\", \"atomic_iadd\",\r\n \"atomic_imax\", \"atomic_imin\", \"atomic_umax\", \"atomic_umin\"\r\n]);\r\n\r\nconst DUAL_DESTINATION = new Set([ \"sincos\", \"imul\", \"umul\", \"udiv\", \"swapc\" ]);\r\nconst FULL_SOURCE_LANES = new Set([\r\n \"ld\", \"ld_ms\", \"resinfo\"\r\n]);\r\n\r\nfunction operandComponents(operand, destination = false, activeComponents = null)\r\n{\r\n if (destination)\r\n {\r\n if (operand.mask) return COMPONENTS.filter((component) => operand.mask.includes(component));\r\n if (operand.componentCount === 1) return [ \"x\" ];\r\n return COMPONENTS.slice();\r\n }\r\n if (operand.swizzle)\r\n {\r\n return activeComponents\r\n ? activeComponents.map((component) => operand.swizzle[COMPONENTS.indexOf(component)])\r\n : Array.from(operand.swizzle);\r\n }\r\n if (operand.selected) return activeComponents ? activeComponents.map(() => operand.selected) : [ operand.selected ];\r\n if (operand.mask) return COMPONENTS.filter((component) => operand.mask.includes(component));\r\n if (operand.componentCount === 1) return [ \"x\" ];\r\n return activeComponents ? activeComponents.slice() : COMPONENTS.slice();\r\n}\r\n\r\nfunction registerKey(program, operand, role)\r\n{\r\n if (!REGISTER_FILES.has(operand.typeName)) return null;\r\n if (operand.typeName === \"indexable_temp\")\r\n {\r\n return validateIndexableTempOperand(program, operand, role)?.key || null;\r\n }\r\n const indices = (operand.indices || []).map((index) =>\r\n {\r\n const immediate = index.values?.join(\":\") || \"\";\r\n return index.relative ? `${immediate}+relative` : immediate;\r\n });\r\n return `${operand.typeName}[${indices.join(\",\")}]`;\r\n}\r\n\r\n/**\r\n * Classifies decoded instruction operands as register sources or destinations.\r\n *\r\n * @param {object} instruction Decoded instruction.\r\n * @returns {Array<{operand: object, role: string}>} Ordered operand roles.\r\n */\r\nexport function operandRoles(instruction)\r\n{\r\n const operands = instruction.operands || [];\r\n if (NO_DESTINATION.has(instruction.opcodeName))\r\n {\r\n return operands.map((operand) => ({ operand, role: \"source\" }));\r\n }\r\n if (DUAL_DESTINATION.has(instruction.opcodeName))\r\n {\r\n return operands.map((operand, index) => ({ operand, role: index < 2 ? \"destination\" : \"source\" }));\r\n }\r\n return operands.map((operand, index) => ({\r\n operand,\r\n role: index === 0 && WRITABLE_FILES.has(operand.typeName) ? \"destination\" : \"source\"\r\n }));\r\n}\r\n\r\nfunction valueRef(value, component)\r\n{\r\n return { valueId: value.id, component };\r\n}\r\n\r\nfunction ensureComponent(state, values, register, component, blockId)\r\n{\r\n let components = state.get(register);\r\n if (!components)\r\n {\r\n components = new Map();\r\n state.set(register, components);\r\n }\r\n if (!components.has(component))\r\n {\r\n const value = {\r\n kind: \"register-value\",\r\n id: `value${values.length}`,\r\n origin: \"block-input\",\r\n blockId,\r\n instructionIndex: null,\r\n register,\r\n writeMask: component,\r\n previous: null\r\n };\r\n values.push(value);\r\n components.set(component, valueRef(value, component));\r\n }\r\n return components.get(component);\r\n}\r\n\r\nfunction analyzeBlock(program, block, values)\r\n{\r\n const state = new Map();\r\n const inputIds = new Set();\r\n for (const instructionIndex of block.instructionIndices)\r\n {\r\n const instruction = program.instructions[instructionIndex];\r\n const roles = operandRoles(instruction);\r\n const destinationComponents = Array.from(new Set(roles\r\n .filter((entry) => entry.role === \"destination\" && entry.operand.typeName !== \"null\")\r\n .flatMap((entry) => operandComponents(entry.operand, true))));\r\n const activeSourceComponents = destinationComponents.length && !FULL_SOURCE_LANES.has(instruction.opcodeName)\r\n ? destinationComponents\r\n : null;\r\n const reads = [];\r\n const writes = [];\r\n\r\n for (let operandIndex = 0; operandIndex < roles.length; operandIndex += 1)\r\n {\r\n const { operand, role } = roles[operandIndex];\r\n if (role !== \"source\") continue;\r\n const register = registerKey(program, operand, \"source\");\r\n if (!register) continue;\r\n const components = operandComponents(\r\n operand,\r\n false,\r\n fixedSourceLanes(instruction, operandIndex, program) || activeSourceComponents);\r\n const refs = components.map((component) => ensureComponent(state, values, register, component, block.id));\r\n for (const ref of refs)\r\n {\r\n const value = values.find((entry) => entry.id === ref.valueId);\r\n if (value?.origin === \"block-input\") inputIds.add(value.id);\r\n }\r\n reads.push({ kind: \"register-read\", operandIndex, register, components, refs });\r\n }\r\n\r\n for (let operandIndex = 0; operandIndex < roles.length; operandIndex += 1)\r\n {\r\n const { operand } = roles[operandIndex];\r\n const indices = operand.indices || [];\r\n for (let dimension = 0; dimension < indices.length; dimension += 1)\r\n {\r\n const relative = indices[dimension].relative;\r\n if (!relative) continue;\r\n const register = registerKey(program, relative, \"source\");\r\n if (!register) throw new Error(\"Shader IR relative index uses an unsupported register file\");\r\n const components = operandComponents(relative, false);\r\n if (components.length !== 1) throw new Error(\"Shader IR relative index requires one scalar component\");\r\n const refs = components.map((component) => ensureComponent(state, values, register, component, block.id));\r\n for (const ref of refs)\r\n {\r\n const value = values.find((entry) => entry.id === ref.valueId);\r\n if (value?.origin === \"block-input\") inputIds.add(value.id);\r\n }\r\n reads.push({ kind: \"index-read\", operandIndex, dimension, register, components, refs });\r\n }\r\n }\r\n\r\n for (let operandIndex = 0; operandIndex < roles.length; operandIndex += 1)\r\n {\r\n const { operand, role } = roles[operandIndex];\r\n if (role !== \"destination\" || operand.typeName === \"null\") continue;\r\n const register = registerKey(program, operand, \"destination\");\r\n if (!register) continue;\r\n const mask = operandComponents(operand, true);\r\n const previous = {};\r\n for (const component of COMPONENTS)\r\n {\r\n if (!mask.includes(component))\r\n {\r\n previous[component] = ensureComponent(state, values, register, component, block.id);\r\n }\r\n }\r\n const value = {\r\n kind: \"register-value\",\r\n id: `value${values.length}`,\r\n origin: \"instruction-write\",\r\n blockId: block.id,\r\n instructionIndex,\r\n register,\r\n writeMask: mask.join(\"\"),\r\n previous: Object.keys(previous).length ? previous : null\r\n };\r\n values.push(value);\r\n let components = state.get(register);\r\n if (!components)\r\n {\r\n components = new Map();\r\n state.set(register, components);\r\n }\r\n for (const component of mask) components.set(component, valueRef(value, component));\r\n const result = {};\r\n for (const component of COMPONENTS)\r\n {\r\n result[component] = components.get(component) || ensureComponent(state, values, register, component, block.id);\r\n }\r\n writes.push({\r\n kind: \"register-write\",\r\n operandIndex,\r\n register,\r\n mask: mask.join(\"\"),\r\n valueId: value.id,\r\n previous: value.previous,\r\n result\r\n });\r\n }\r\n instruction.dataflow = { reads, writes };\r\n }\r\n block.inputValueIds = Array.from(inputIds);\r\n block.outputValues = Array.from(state.entries())\r\n .flatMap(([ register, components ]) => Array.from(components.entries())\r\n .map(([ component, ref ]) => ({ register, component, ref })))\r\n .sort((a, b) => compareUtf8(a.register, b.register) || compareUtf8(a.component, b.component));\r\n}\r\n\r\n/**\r\n * Adds block-local register versions, masked-write reconstruction records,\r\n * and deterministic block-exit state. A later pass resolves the conservative\r\n * block inputs through CFG predecessors.\r\n *\r\n * @param {object} program Mutable shader IR under construction.\r\n * @returns {object} The same program.\r\n */\r\nexport function analyzeRegisterValues(program)\r\n{\r\n const values = [];\r\n for (const block of program.blocks) analyzeBlock(program, block, values);\r\n program.values = values;\r\n return program;\r\n}\r\n"],"names":["COMPONENTS","REGISTER_FILES","Set","WRITABLE_FILES","NO_DESTINATION","DUAL_DESTINATION","FULL_SOURCE_LANES","operandComponents","operand","destination","activeComponents","mask","filter","component","includes","componentCount","slice","swizzle","map","indexOf","Array","from","selected","registerKey","program","role","has","typeName","validateIndexableTempOperand","key","indices","index","immediate","values","join","relative","operandRoles","instruction","operands","opcodeName","valueRef","value","valueId","id","ensureComponent","state","register","blockId","components","get","Map","set","kind","length","origin","instructionIndex","writeMask","previous","push","analyzeBlock","block","inputIds","instructionIndices","instructions","roles","destinationComponents","entry","flatMap","activeSourceComponents","reads","writes","operandIndex","fixedSourceLanes","refs","ref","find","add","dimension","Error","Object","keys","result","dataflow","inputValueIds","outputValues","entries","sort","a","b","compareUtf8","analyzeRegisterValues","blocks"],"mappings":";;;;AAIA,MAAMA,UAAU,GAAG,CAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAE;AAEzC,MAAMC,cAAc,GAAG,IAAIC,GAAG,CAAC,CAC3B,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,oBAAoB,EACjE,cAAc,EAAE,iBAAiB,EAAE,qBAAqB,EACxD,sBAAsB,EAAE,sBAAsB,EAAE,oBAAoB,EACpE,yBAAyB,EAAE,wBAAwB,EAAE,wBAAwB,EAC7E,iBAAiB,EAAE,uBAAuB,EAAE,0BAA0B,EACtE,qBAAqB,EAAE,oCAAoC,EAC3D,sBAAsB,EAAE,4BAA4B,EAAE,yBAAyB,CAClF,CAAC;AAEF,MAAMC,cAAc,GAAG,IAAID,GAAG,CAAC,CAC3B,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE,cAAc,EAAE,iBAAiB,EACrE,sBAAsB,EAAE,4BAA4B,EAAE,yBAAyB,CAClF,CAAC;AAEF,MAAME,cAAc,GAAG,IAAIF,GAAG,CAAC,CAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EACnE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,EACrE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EACnE,QAAQ,EAAE,MAAM,EAAE,iBAAiB,EAAE,WAAW,EAAE,kBAAkB,EACpE,YAAY,E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AG/D,KAAK,CAACC,IAAI,CAACwC,QAAQ,CAAC;AAC1CD,EAAAA,KAAK,CAACwB,YAAY,GAAGhE,KAAK,CAACC,IAAI,CAACwB,KAAK,CAACwC,OAAO,EAAE,CAAC,CAC3ClB,OAAO,CAAC,CAAC,CAAErB,QAAQ,EAAEE,UAAU,CAAE,KAAK5B,KAAK,CAACC,IAAI,CAAC2B,UAAU,CAACqC,OAAO,EAAE,CAAC,CAClEnE,GAAG,CAAC,CAAC,CAAEL,SAAS,EAAE6D,GAAG,CAAE,MAAM;IAAE5B,QAAQ;IAAEjC,SAAS;AAAE6D,IAAAA;AAAI,GAAC,CAAC,CAAC,CAAC,CAChEY,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKC,WAAW,CAACF,CAAC,CAACzC,QAAQ,EAAE0C,CAAC,CAAC1C,QAAQ,CAAC,IAAI2C,WAAW,CAACF,CAAC,CAAC1E,SAAS,EAAE2E,CAAC,CAAC3E,SAAS,CAAC,CAAC;AACrG;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS6E,qBAAqBA,CAAClE,OAAO,EAC7C;EACI,MAAMS,MAAM,GAAG,EAAE;AACjB,EAAA,KAAK,MAAM2B,KAAK,IAAIpC,OAAO,CAACmE,MAAM,EAAEhC,YAAY,CAACnC,OAAO,EAAEoC,KAAK,EAAE3B,MAAM,CAAC;EACxET,OAAO,CAACS,MAAM,GAAGA,MAAM;AACvB,EAAA,OAAOT,OAAO;AAClB;;;;"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { compareUtf8 } from '../../../../format/compareUtf8.js';
|
|
2
|
+
|
|
1
3
|
const COMPONENTS = ["x", "y", "z", "w"];
|
|
2
4
|
const COMPONENT_INDEX = new Map(COMPONENTS.map((component, index) => [component, index]));
|
|
3
5
|
const SCALAR_TYPES = Object.freeze(["unknown", "float32", "int32", "uint32", "bool", "bitpattern32"]);
|
|
@@ -214,13 +216,13 @@ function correspondingRef(refs, index) {
|
|
|
214
216
|
return refs.length === 1 ? refs[0] : refs[index % refs.length];
|
|
215
217
|
}
|
|
216
218
|
|
|
217
|
-
/**
|
|
218
|
-
* Infers component storage types from opcode domains, signatures, moves, and
|
|
219
|
-
* SSA merges. Conflicting typeless-register uses become `bitpattern32` and
|
|
220
|
-
* receive explicit per-use reinterpret records.
|
|
221
|
-
*
|
|
222
|
-
* @param {object} program Mutable shader IR under construction.
|
|
223
|
-
* @returns {object} The same program.
|
|
219
|
+
/**
|
|
220
|
+
* Infers component storage types from opcode domains, signatures, moves, and
|
|
221
|
+
* SSA merges. Conflicting typeless-register uses become `bitpattern32` and
|
|
222
|
+
* receive explicit per-use reinterpret records.
|
|
223
|
+
*
|
|
224
|
+
* @param {object} program Mutable shader IR under construction.
|
|
225
|
+
* @returns {object} The same program.
|
|
224
226
|
*/
|
|
225
227
|
function inferValueTypes(program) {
|
|
226
228
|
const parent = new Map();
|
|
@@ -247,7 +249,7 @@ function inferValueTypes(program) {
|
|
|
247
249
|
const left = find(ensure(leftRef));
|
|
248
250
|
const right = find(ensure(rightRef));
|
|
249
251
|
if (left === right) return;
|
|
250
|
-
const [root, child] = left
|
|
252
|
+
const [root, child] = compareUtf8(left, right) <= 0 ? [left, right] : [right, left];
|
|
251
253
|
parent.set(child, root);
|
|
252
254
|
for (const type of constraints.get(child)) constraints.get(root).add(type);
|
|
253
255
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inferValueTypes.js","sources":["../../../../../../src/formats/webgpu/core/ir/inferValueTypes.js"],"sourcesContent":["const COMPONENTS = [ \"x\", \"y\", \"z\", \"w\" ];\nconst COMPONENT_INDEX = new Map(COMPONENTS.map((component, index) => [ component, index ]));\n\nexport const SCALAR_TYPES = Object.freeze([\n \"unknown\", \"float32\", \"int32\", \"uint32\", \"bool\", \"bitpattern32\"\n]);\n\nconst FLOAT_OPS = new Set([\n \"add\", \"deriv_rtx\", \"deriv_rty\", \"deriv_rtx_coarse\", \"deriv_rtx_fine\",\n \"deriv_rty_coarse\", \"deriv_rty_fine\", \"div\", \"dp2\", \"dp3\", \"dp4\",\n \"exp\", \"frc\", \"log\", \"mad\", \"max\", \"min\", \"mul\", \"rcp\", \"round_ne\",\n \"round_ni\", \"round_pi\", \"round_z\", \"rsq\", \"sqrt\", \"sincos\"\n]);\nconst FLOAT_COMPARE = new Set([ \"eq\", \"ge\", \"lt\", \"ne\" ]);\nconst INT_OPS = new Set([ \"iadd\", \"imad\", \"imax\", \"imin\", \"imul\", \"ineg\", \"ishl\", \"ishr\" ]);\nconst INT_COMPARE = new Set([ \"ieq\", \"ige\", \"ilt\", \"ine\" ]);\nconst UINT_OPS = new Set([\n \"countbits\", \"firstbit_hi\", \"firstbit_lo\", \"firstbit_shi\", \"uaddc\",\n \"ubfe\", \"udiv\", \"umad\", \"umax\", \"umin\", \"umul\", \"ushr\", \"usubb\"\n]);\nconst UINT_COMPARE = new Set([ \"uge\", \"ult\" ]);\nconst BITWISE_OPS = new Set([ \"and\", \"not\", \"or\", \"xor\" ]);\nconst CONTROL_MASK_OPS = new Set([ \"breakc\", \"continuec\", \"discard\", \"if\", \"retc\", \"switch\" ]);\nconst SAMPLE_OPS = new Set([\n \"sample\", \"sample_b\", \"sample_c\", \"sample_c_lz\", \"sample_d\", \"sample_l\"\n]);\n\nfunction bindingResultType(program, instruction, operandTypeName, resourceKind)\n{\n const resource = instruction.operands.find((operand) => operand.typeName === operandTypeName);\n const reference = resource?.resourceReference;\n const binding = program.bindings.find((entry) => entry.resourceKind === resourceKind\n && (reference?.rangeId !== null && reference?.rangeId !== undefined\n ? entry.range.rangeId === reference.rangeId\n : entry.registerIndex === resource?.registerIndex));\n const mapped = (binding?.returnType?.returnTypeNames || []).map((type) => ({\n unorm: \"float32\",\n snorm: \"float32\",\n float: \"float32\",\n sint: \"int32\",\n uint: \"uint32\"\n })[type] || \"unknown\");\n const concrete = mapped.filter((type) => type !== \"unknown\");\n if (!concrete.length) return null;\n return new Set(concrete).size === 1 ? concrete[0] : \"bitpattern32\";\n}\n\nfunction sampleResultType(program, instruction)\n{\n return bindingResultType(program, instruction, \"resource\", \"sampled-resource\");\n}\n\nfunction ruleFor(opcodeName, program, instruction)\n{\n if (FLOAT_OPS.has(opcodeName)) return { name: \"float-arithmetic\", destination: \"float32\", sources: \"float32\" };\n if (FLOAT_COMPARE.has(opcodeName)) return { name: \"float-comparison-mask\", destination: \"uint32\", sources: \"float32\" };\n if (INT_OPS.has(opcodeName)) return { name: \"signed-integer\", destination: \"int32\", sources: \"int32\" };\n if (INT_COMPARE.has(opcodeName)) return { name: \"signed-comparison-mask\", destination: \"uint32\", sources: \"int32\" };\n if (UINT_OPS.has(opcodeName)) return { name: \"unsigned-integer\", destination: \"uint32\", sources: \"uint32\" };\n if (UINT_COMPARE.has(opcodeName)) return { name: \"unsigned-comparison-mask\", destination: \"uint32\", sources: \"uint32\" };\n if (BITWISE_OPS.has(opcodeName)) return { name: \"bitwise\", destination: \"uint32\", sources: \"uint32\" };\n if (CONTROL_MASK_OPS.has(opcodeName)) return { name: \"control-mask\", destination: null, sourceByOperand: { 0: \"uint32\" }, conditionProjection: \"nonzero\" };\n if (SAMPLE_OPS.has(opcodeName))\n {\n const sourceByOperand = { 1: \"float32\" };\n if ([ \"sample_b\", \"sample_c\", \"sample_l\" ].includes(opcodeName)) sourceByOperand[4] = \"float32\";\n if (opcodeName === \"sample_d\") Object.assign(sourceByOperand, { 4: \"float32\", 5: \"float32\" });\n return { name: \"sample-resource\", destination: sampleResultType(program, instruction), sourceByOperand };\n }\n if (opcodeName === \"resinfo\")\n {\n return {\n name: \"resource-info\",\n destination: instruction?.resinfoReturnTypeName === \"uint\" ? \"uint32\" : \"float32\"\n };\n }\n if (opcodeName === \"f16tof32\") return { name: \"half-unpack\", destination: \"float32\", sourceByOperand: { 1: \"uint32\" } };\n if (opcodeName === \"f32tof16\") return { name: \"half-pack\", destination: \"uint32\", sourceByOperand: { 1: \"float32\" } };\n if (opcodeName === \"ld\")\n {\n return {\n name: \"texture-load\",\n destination: sampleResultType(program, instruction),\n sourceByOperand: { 1: \"uint32\" }\n };\n }\n if (opcodeName === \"atomic_iadd\")\n {\n return {\n name: \"atomic-add\",\n destination: null,\n sourceByOperand: { 1: \"uint32\", 2: \"uint32\" }\n };\n }\n if (opcodeName === \"store_uav_typed\")\n {\n return {\n name: \"typed-uav-store\",\n destination: null,\n sourceByOperand: {\n 1: \"uint32\",\n 2: bindingResultType(program, instruction, \"uav\", \"storage-resource\")\n }\n };\n }\n if (opcodeName === \"ld_structured\")\n {\n return {\n name: \"structured-load\",\n destination: null,\n sourceByOperand: { 1: \"uint32\", 2: \"uint32\" }\n };\n }\n if (opcodeName === \"store_structured\")\n {\n return {\n name: \"structured-store\",\n destination: null,\n sourceByOperand: { 1: \"uint32\", 2: \"uint32\" }\n };\n }\n const conversions = {\n ftoi: [ \"int32\", \"float32\" ],\n ftou: [ \"uint32\", \"float32\" ],\n itof: [ \"float32\", \"int32\" ],\n utof: [ \"float32\", \"uint32\" ]\n };\n if (conversions[opcodeName])\n {\n const [ destination, source ] = conversions[opcodeName];\n return { name: \"numeric-conversion\", destination, sourceByOperand: { 1: source }, conversion: { from: source, to: destination } };\n }\n if (opcodeName === \"mov\") return { name: \"move\", destination: null, equalitySources: [ 1 ] };\n if (opcodeName === \"movc\") return { name: \"conditional-move\", destination: null, sourceByOperand: { 1: \"uint32\" }, equalitySources: [ 2, 3 ] };\n return { name: \"untyped\", destination: null };\n}\n\nfunction nodeKey(ref)\n{\n return `${ref.valueId}.${ref.component}`;\n}\n\nfunction valueComponents(value)\n{\n return Array.from(value.writeMask || \"\");\n}\n\nfunction signatureType(program, register, component)\n{\n if ([ \"output_depth\", \"output_depth_greater_equal\", \"output_depth_less_equal\" ].includes(register)) return \"float32\";\n const match = /^(input|output)\\[(\\d+)/.exec(register);\n if (!match) return null;\n const elements = program.signatures?.[match[1]] || [];\n const componentBit = 1 << COMPONENT_INDEX.get(component);\n const element = elements.find((entry) => entry.registerIndex === Number(match[2]) && (entry.mask & componentBit));\n return element && SCALAR_TYPES.includes(element.componentTypeName) ? element.componentTypeName : null;\n}\n\nfunction correspondingRef(refs, index)\n{\n if (!refs.length) return null;\n return refs.length === 1 ? refs[0] : refs[index % refs.length];\n}\n\n/**\n * Infers component storage types from opcode domains, signatures, moves, and\n * SSA merges. Conflicting typeless-register uses become `bitpattern32` and\n * receive explicit per-use reinterpret records.\n *\n * @param {object} program Mutable shader IR under construction.\n * @returns {object} The same program.\n */\nexport function inferValueTypes(program)\n{\n const parent = new Map();\n const constraints = new Map();\n\n const ensure = (ref) =>\n {\n const key = nodeKey(ref);\n if (!parent.has(key))\n {\n parent.set(key, key);\n constraints.set(key, new Set());\n }\n return key;\n };\n const find = (key) =>\n {\n let current = key;\n while (parent.get(current) !== current) current = parent.get(current);\n while (parent.get(key) !== key)\n {\n const next = parent.get(key);\n parent.set(key, current);\n key = next;\n }\n return current;\n };\n const union = (leftRef, rightRef) =>\n {\n const left = find(ensure(leftRef));\n const right = find(ensure(rightRef));\n if (left === right) return;\n const [ root, child ] = left.localeCompare(right) <= 0 ? [ left, right ] : [ right, left ];\n parent.set(child, root);\n for (const type of constraints.get(child)) constraints.get(root).add(type);\n };\n const constrain = (ref, type) =>\n {\n if (!type) return;\n constraints.get(find(ensure(ref))).add(type);\n };\n\n for (const value of program.values)\n {\n for (const component of valueComponents(value)) ensure({ valueId: value.id, component });\n if (value.origin === \"control-flow-merge\")\n {\n const mergeRef = { valueId: value.id, component: value.writeMask };\n for (const incoming of value.incoming) union(mergeRef, incoming);\n }\n }\n\n for (const instruction of program.instructions)\n {\n const rule = ruleFor(instruction.opcodeName, program, instruction);\n const writes = instruction.dataflow.writes;\n for (const sourceOperandIndex of rule.equalitySources || [])\n {\n const read = instruction.dataflow.reads.find((entry) => entry.operandIndex === sourceOperandIndex && entry.kind !== \"index-read\");\n if (!read) continue;\n for (const write of writes)\n {\n Array.from(write.mask).forEach((component, index) =>\n {\n const sourceRef = correspondingRef(read.refs, index);\n if (sourceRef) union({ valueId: write.valueId, component }, sourceRef);\n });\n }\n }\n }\n\n for (const value of program.values)\n {\n for (const component of valueComponents(value))\n {\n const type = signatureType(program, value.register, component);\n if (type) constrain({ valueId: value.id, component }, type);\n }\n }\n for (const instruction of program.instructions)\n {\n const rule = ruleFor(instruction.opcodeName, program, instruction);\n if (rule.destination)\n {\n for (const write of instruction.dataflow.writes)\n {\n for (const component of write.mask) constrain({ valueId: write.valueId, component }, rule.destination);\n }\n }\n for (const read of instruction.dataflow.reads)\n {\n if (read.kind === \"index-read\") continue;\n const expected = rule.sourceByOperand?.[read.operandIndex] ?? rule.sources ?? null;\n for (const ref of read.refs) constrain(ref, expected);\n }\n }\n\n // A live value (read by an instruction or feeding a phi) whose type is\n // otherwise unconstrained — e.g. an immediate `0` that only ever flows\n // through moves and never reaches a typed use — defaults to raw bitpattern32\n // bits so it can be emitted. This covers EVERY lane of a live value, not\n // just the read lane: an emitted multi-lane value needs a type for its dead\n // lanes too (the vector constructor references all of them). Because moves\n // union source and destination, the default propagates consistently across\n // the whole move chain and any phi it feeds. Genuinely dead writes are never\n // read, keep no constraint (stay `unknown`), and are dropped by the lowerers.\n const liveValueIds = new Set();\n for (const instruction of program.instructions)\n {\n for (const read of instruction.dataflow.reads)\n {\n if (read.kind === \"index-read\") continue;\n for (const ref of read.refs) liveValueIds.add(ref.valueId);\n }\n }\n for (const value of program.values)\n {\n for (const incoming of value.incoming || []) liveValueIds.add(incoming.valueId);\n }\n for (const value of program.values)\n {\n if (!liveValueIds.has(value.id)) continue;\n for (const component of valueComponents(value))\n {\n const ref = { valueId: value.id, component };\n if (!constraints.get(find(ensure(ref))).size) constrain(ref, \"bitpattern32\");\n }\n }\n\n const typeForRef = (ref) =>\n {\n const types = Array.from(constraints.get(find(ensure(ref))));\n if (types.length === 0) return \"unknown\";\n return types.length === 1 ? types[0] : \"bitpattern32\";\n };\n\n for (const value of program.values)\n {\n value.componentTypes = {};\n for (const component of valueComponents(value))\n {\n value.componentTypes[component] = typeForRef({ valueId: value.id, component });\n }\n }\n\n for (const instruction of program.instructions)\n {\n const rule = ruleFor(instruction.opcodeName, program, instruction);\n const writes = instruction.dataflow.writes;\n const destinationTypes = writes.flatMap((write) => Array.from(write.mask)\n .map((component) => program.values.find((value) => value.id === write.valueId)?.componentTypes[component]))\n .filter(Boolean);\n const moveType = destinationTypes.length && new Set(destinationTypes).size === 1 ? destinationTypes[0] : null;\n const operandTypes = instruction.operands.map((operand, operandIndex) =>\n {\n let expectedType = rule.sourceByOperand?.[operandIndex] ?? null;\n if (!expectedType && rule.sources && operandIndex > 0) expectedType = rule.sources;\n if (!expectedType && (rule.equalitySources || []).includes(operandIndex)) expectedType = moveType;\n if (instruction.dataflow.writes.some((write) => write.operandIndex === operandIndex)) expectedType = rule.destination ?? moveType;\n return {\n operandIndex,\n role: instruction.dataflow.writes.some((write) => write.operandIndex === operandIndex) ? \"destination\" : \"source\",\n expectedType: expectedType || \"unknown\",\n modifier: operand.modifierName || \"none\",\n minPrecision: operand.minPrecisionName || \"default\",\n immediate: operand.typeName === \"immediate32\"\n ? operand.immediateValues.map((value, component) => ({ component: COMPONENTS[component], uint32: value.uint32, float32: value.float32 }))\n : null\n };\n });\n const bitcasts = [];\n for (const read of instruction.dataflow.reads)\n {\n if (read.kind === \"index-read\") continue;\n let expected = rule.sourceByOperand?.[read.operandIndex] ?? rule.sources ?? null;\n if (!expected && (rule.equalitySources || []).includes(read.operandIndex)) expected = moveType;\n if (!expected || expected === \"unknown\") continue;\n read.refs.forEach((ref, componentIndex) =>\n {\n const storage = typeForRef(ref);\n if (storage !== expected && storage !== \"unknown\")\n {\n bitcasts.push({ kind: \"read-bitcast\", operandIndex: read.operandIndex, componentIndex, valueId: ref.valueId, component: ref.component, from: storage, to: expected });\n }\n });\n }\n for (const write of writes)\n {\n if (!rule.destination) continue;\n Array.from(write.mask).forEach((component) =>\n {\n const storage = typeForRef({ valueId: write.valueId, component });\n if (storage !== rule.destination && storage !== \"unknown\")\n {\n bitcasts.push({ kind: \"result-bitcast\", operandIndex: write.operandIndex, valueId: write.valueId, component, from: rule.destination, to: storage });\n }\n });\n }\n for (const operand of operandTypes)\n {\n if (!operand.immediate || ![ \"float32\", \"int32\" ].includes(operand.expectedType)) continue;\n for (const immediate of operand.immediate)\n {\n bitcasts.push({ kind: \"immediate-bitcast\", operandIndex: operand.operandIndex, component: immediate.component, from: \"uint32\", to: operand.expectedType, uint32: immediate.uint32 });\n }\n }\n instruction.typeInfo = {\n kind: \"instruction-types\",\n rule: rule.name,\n resultType: rule.destination ?? moveType ?? \"unknown\",\n conversion: rule.conversion || null,\n conditionProjection: rule.conditionProjection || null,\n operandTypes,\n bitcasts\n };\n }\n\n program.typeSystem = {\n kind: \"scalar-type-system\",\n scalarTypes: SCALAR_TYPES.slice(),\n comparisonResult: \"uint32-mask\",\n conditionProjection: \"nonzero\",\n registerStorage: \"component-granular\"\n };\n return program;\n}\n"],"names":["COMPONENTS","COMPONENT_INDEX","Map","map","component","index","SCALAR_TYPES","Object","freeze","FLOAT_OPS","Set","FLOAT_COMPARE","INT_OPS","INT_COMPARE","UINT_OPS","UINT_COMPARE","BITWISE_OPS","CONTROL_MASK_OPS","SAMPLE_OPS","bindingResultType","program","instruction","operandTypeName","resourceKind","resource","operands","find","operand","typeName","reference","resourceReference","binding","bindings","entry","rangeId","undefined","range","registerIndex","mapped","returnType","returnTypeNames","type","unorm","snorm","float","sint","uint","concrete","filter","length","size","sampleResultType","ruleFor","opcodeName","has","name","destination","sources","sourceByOperand","conditionProjection","includes","assign","resinfoReturnTypeName","conversions","ftoi","ftou","itof","utof","source","conversion","from","to","equalitySources","nodeKey","ref","valueId","valueComponents","value","Array","writeMask","signatureType","register","match","exec","elements","signatures","componentBit","get","element","Number","mask","componentTypeName","correspondingRef","refs","inferValueTypes","parent","constraints","ensure","key","set","current","next","union","leftRef","rightRef","left","right","root","child","localeCompare","add","constrain","values","id","origin","mergeRef","incoming","instructions","rule","writes","dataflow","sourceOperandIndex","read","reads","operandIndex","kind","write","forEach","sourceRef","expected","liveValueIds","typeForRef","types","componentTypes","destinationTypes","flatMap","Boolean","moveType","operandTypes","expectedType","some","role","modifier","modifierName","minPrecision","minPrecisionName","immediate","immediateValues","uint32","float32","bitcasts","componentIndex","storage","push","typeInfo","resultType","typeSystem","scalarTypes","slice","comparisonResult","registerStorage"],"mappings":"AAAA,MAAMA,UAAU,GAAG,CAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAE;AACzC,MAAMC,eAAe,GAAG,IAAIC,GAAG,CAACF,UAAU,CAACG,GAAG,CAAC,CAACC,SAAS,EAAEC,KAAK,KAAK,CAAED,SAAS,EAAEC,KAAK,CAAE,CAAC,CAAC;AAEpF,MAAMC,YAAY,GAAGC,MAAM,CAACC,MAAM,CAAC,CACtC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,cAAc,CAClE;AAED,MAAMC,SAAS,GAAG,IAAIC,GAAG,CAAC,CACtB,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,kBAAkB,EAAE,gBAAgB,EACrE,kBAAkB,EAAE,gBAAgB,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAChE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAClE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAC7D,CAAC;AACF,MAAMC,aAAa,GAAG,IAAID,GAAG,CAAC,CAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAE,CAAC;AACzD,MAAME,OAAO,GAAG,IAAIF,GAAG,CAAC,CAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAE,CAAC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inferValueTypes.js"],"sourcesContent":["import { compareUtf8 } from \"../../../../format/compareUtf8.js\";\r\n\r\nconst COMPONENTS = [ \"x\", \"y\", \"z\", \"w\" ];\r\nconst COMPONENT_INDEX = new Map(COMPONENTS.map((component, index) => [ component, index ]));\r\n\r\nexport const SCALAR_TYPES = Object.freeze([\r\n \"unknown\", \"float32\", \"int32\", \"uint32\", \"bool\", \"bitpattern32\"\r\n]);\r\n\r\nconst FLOAT_OPS = new Set([\r\n \"add\", \"deriv_rtx\", \"deriv_rty\", \"deriv_rtx_coarse\", \"deriv_rtx_fine\",\r\n \"deriv_rty_coarse\", \"deriv_rty_fine\", \"div\", \"dp2\", \"dp3\", \"dp4\",\r\n \"exp\", \"frc\", \"log\", \"mad\", \"max\", \"min\", \"mul\", \"rcp\", \"round_ne\",\r\n \"round_ni\", \"round_pi\", \"round_z\", \"rsq\", \"sqrt\", \"sincos\"\r\n]);\r\nconst FLOAT_COMPARE = new Set([ \"eq\", \"ge\", \"lt\", \"ne\" ]);\r\nconst INT_OPS = new Set([ \"iadd\", \"imad\", \"imax\", \"imin\", \"imul\", \"ineg\", \"ishl\", \"ishr\" ]);\r\nconst INT_COMPARE = new Set([ \"ieq\", \"ige\", \"ilt\", \"ine\" ]);\r\nconst UINT_OPS = new Set([\r\n \"countbits\", \"firstbit_hi\", \"firstbit_lo\", \"firstbit_shi\", \"uaddc\",\r\n \"ubfe\", \"udiv\", \"umad\", \"umax\", \"umin\", \"umul\", \"ushr\", \"usubb\"\r\n]);\r\nconst UINT_COMPARE = new Set([ \"uge\", \"ult\" ]);\r\nconst BITWISE_OPS = new Set([ \"and\", \"not\", \"or\", \"xor\" ]);\r\nconst CONTROL_MASK_OPS = new Set([ \"breakc\", \"continuec\", \"discard\", \"if\", \"retc\", \"switch\" ]);\r\nconst SAMPLE_OPS = new Set([\r\n \"sample\", \"sample_b\", \"sample_c\", \"sample_c_lz\", \"sample_d\", \"sample_l\"\r\n]);\r\n\r\nfunction bindingResultType(program, instruction, operandTypeName, resourceKind)\r\n{\r\n const resource = instruction.operands.find((operand) => operand.typeName === operandTypeName);\r\n const reference = resource?.resourceReference;\r\n const binding = program.bindings.find((entry) => entry.resourceKind === resourceKind\r\n && (reference?.rangeId !== null && reference?.rangeId !== undefined\r\n ? entry.range.rangeId === reference.rangeId\r\n : entry.registerIndex === resource?.registerIndex));\r\n const mapped = (binding?.returnType?.returnTypeNames || []).map((type) => ({\r\n unorm: \"float32\",\r\n snorm: \"float32\",\r\n float: \"float32\",\r\n sint: \"int32\",\r\n uint: \"uint32\"\r\n })[type] || \"unknown\");\r\n const concrete = mapped.filter((type) => type !== \"unknown\");\r\n if (!concrete.length) return null;\r\n return new Set(concrete).size === 1 ? concrete[0] : \"bitpattern32\";\r\n}\r\n\r\nfunction sampleResultType(program, instruction)\r\n{\r\n return bindingResultType(program, instruction, \"resource\", \"sampled-resource\");\r\n}\r\n\r\nfunction ruleFor(opcodeName, program, instruction)\r\n{\r\n if (FLOAT_OPS.has(opcodeName)) return { name: \"float-arithmetic\", destination: \"float32\", sources: \"float32\" };\r\n if (FLOAT_COMPARE.has(opcodeName)) return { name: \"float-comparison-mask\", destination: \"uint32\", sources: \"float32\" };\r\n if (INT_OPS.has(opcodeName)) return { name: \"signed-integer\", destination: \"int32\", sources: \"int32\" };\r\n if (INT_COMPARE.has(opcodeName)) return { name: \"signed-comparison-mask\", destination: \"uint32\", sources: \"int32\" };\r\n if (UINT_OPS.has(opcodeName)) return { name: \"unsigned-integer\", destination: \"uint32\", sources: \"uint32\" };\r\n if (UINT_COMPARE.has(opcodeName)) return { name: \"unsigned-comparison-mask\", destination: \"uint32\", sources: \"uint32\" };\r\n if (BITWISE_OPS.has(opcodeName)) return { name: \"bitwise\", destination: \"uint32\", sources: \"uint32\" };\r\n if (CONTROL_MASK_OPS.has(opcodeName)) return { name: \"control-mask\", destination: null, sourceByOperand: { 0: \"uint32\" }, conditionProjection: \"nonzero\" };\r\n if (SAMPLE_OPS.has(opcodeName))\r\n {\r\n const sourceByOperand = { 1: \"float32\" };\r\n if ([ \"sample_b\", \"sample_c\", \"sample_l\" ].includes(opcodeName)) sourceByOperand[4] = \"float32\";\r\n if (opcodeName === \"sample_d\") Object.assign(sourceByOperand, { 4: \"float32\", 5: \"float32\" });\r\n return { name: \"sample-resource\", destination: sampleResultType(program, instruction), sourceByOperand };\r\n }\r\n if (opcodeName === \"resinfo\")\r\n {\r\n return {\r\n name: \"resource-info\",\r\n destination: instruction?.resinfoReturnTypeName === \"uint\" ? \"uint32\" : \"float32\"\r\n };\r\n }\r\n if (opcodeName === \"f16tof32\") return { name: \"half-unpack\", destination: \"float32\", sourceByOperand: { 1: \"uint32\" } };\r\n if (opcodeName === \"f32tof16\") return { name: \"half-pack\", destination: \"uint32\", sourceByOperand: { 1: \"float32\" } };\r\n if (opcodeName === \"ld\")\r\n {\r\n return {\r\n name: \"texture-load\",\r\n destination: sampleResultType(program, instruction),\r\n sourceByOperand: { 1: \"uint32\" }\r\n };\r\n }\r\n if (opcodeName === \"atomic_iadd\")\r\n {\r\n return {\r\n name: \"atomic-add\",\r\n destination: null,\r\n sourceByOperand: { 1: \"uint32\", 2: \"uint32\" }\r\n };\r\n }\r\n if (opcodeName === \"store_uav_typed\")\r\n {\r\n return {\r\n name: \"typed-uav-store\",\r\n destination: null,\r\n sourceByOperand: {\r\n 1: \"uint32\",\r\n 2: bindingResultType(program, instruction, \"uav\", \"storage-resource\")\r\n }\r\n };\r\n }\r\n if (opcodeName === \"ld_structured\")\r\n {\r\n return {\r\n name: \"structured-load\",\r\n destination: null,\r\n sourceByOperand: { 1: \"uint32\", 2: \"uint32\" }\r\n };\r\n }\r\n if (opcodeName === \"store_structured\")\r\n {\r\n return {\r\n name: \"structured-store\",\r\n destination: null,\r\n sourceByOperand: { 1: \"uint32\", 2: \"uint32\" }\r\n };\r\n }\r\n const conversions = {\r\n ftoi: [ \"int32\", \"float32\" ],\r\n ftou: [ \"uint32\", \"float32\" ],\r\n itof: [ \"float32\", \"int32\" ],\r\n utof: [ \"float32\", \"uint32\" ]\r\n };\r\n if (conversions[opcodeName])\r\n {\r\n const [ destination, source ] = conversions[opcodeName];\r\n return { name: \"numeric-conversion\", destination, sourceByOperand: { 1: source }, conversion: { from: source, to: destination } };\r\n }\r\n if (opcodeName === \"mov\") return { name: \"move\", destination: null, equalitySources: [ 1 ] };\r\n if (opcodeName === \"movc\") return { name: \"conditional-move\", destination: null, sourceByOperand: { 1: \"uint32\" }, equalitySources: [ 2, 3 ] };\r\n return { name: \"untyped\", destination: null };\r\n}\r\n\r\nfunction nodeKey(ref)\r\n{\r\n return `${ref.valueId}.${ref.component}`;\r\n}\r\n\r\nfunction valueComponents(value)\r\n{\r\n return Array.from(value.writeMask || \"\");\r\n}\r\n\r\nfunction signatureType(program, register, component)\r\n{\r\n if ([ \"output_depth\", \"output_depth_greater_equal\", \"output_depth_less_equal\" ].includes(register)) return \"float32\";\r\n const match = /^(input|output)\\[(\\d+)/.exec(register);\r\n if (!match) return null;\r\n const elements = program.signatures?.[match[1]] || [];\r\n const componentBit = 1 << COMPONENT_INDEX.get(component);\r\n const element = elements.find((entry) => entry.registerIndex === Number(match[2]) && (entry.mask & componentBit));\r\n return element && SCALAR_TYPES.includes(element.componentTypeName) ? element.componentTypeName : null;\r\n}\r\n\r\nfunction correspondingRef(refs, index)\r\n{\r\n if (!refs.length) return null;\r\n return refs.length === 1 ? refs[0] : refs[index % refs.length];\r\n}\r\n\r\n/**\r\n * Infers component storage types from opcode domains, signatures, moves, and\r\n * SSA merges. Conflicting typeless-register uses become `bitpattern32` and\r\n * receive explicit per-use reinterpret records.\r\n *\r\n * @param {object} program Mutable shader IR under construction.\r\n * @returns {object} The same program.\r\n */\r\nexport function inferValueTypes(program)\r\n{\r\n const parent = new Map();\r\n const constraints = new Map();\r\n\r\n const ensure = (ref) =>\r\n {\r\n const key = nodeKey(ref);\r\n if (!parent.has(key))\r\n {\r\n parent.set(key, key);\r\n constraints.set(key, new Set());\r\n }\r\n return key;\r\n };\r\n const find = (key) =>\r\n {\r\n let current = key;\r\n while (parent.get(current) !== current) current = parent.get(current);\r\n while (parent.get(key) !== key)\r\n {\r\n const next = parent.get(key);\r\n parent.set(key, current);\r\n key = next;\r\n }\r\n return current;\r\n };\r\n const union = (leftRef, rightRef) =>\r\n {\r\n const left = find(ensure(leftRef));\r\n const right = find(ensure(rightRef));\r\n if (left === right) return;\r\n const [ root, child ] = compareUtf8(left, right) <= 0 ? [ left, right ] : [ right, left ];\r\n parent.set(child, root);\r\n for (const type of constraints.get(child)) constraints.get(root).add(type);\r\n };\r\n const constrain = (ref, type) =>\r\n {\r\n if (!type) return;\r\n constraints.get(find(ensure(ref))).add(type);\r\n };\r\n\r\n for (const value of program.values)\r\n {\r\n for (const component of valueComponents(value)) ensure({ valueId: value.id, component });\r\n if (value.origin === \"control-flow-merge\")\r\n {\r\n const mergeRef = { valueId: value.id, component: value.writeMask };\r\n for (const incoming of value.incoming) union(mergeRef, incoming);\r\n }\r\n }\r\n\r\n for (const instruction of program.instructions)\r\n {\r\n const rule = ruleFor(instruction.opcodeName, program, instruction);\r\n const writes = instruction.dataflow.writes;\r\n for (const sourceOperandIndex of rule.equalitySources || [])\r\n {\r\n const read = instruction.dataflow.reads.find((entry) => entry.operandIndex === sourceOperandIndex && entry.kind !== \"index-read\");\r\n if (!read) continue;\r\n for (const write of writes)\r\n {\r\n Array.from(write.mask).forEach((component, index) =>\r\n {\r\n const sourceRef = correspondingRef(read.refs, index);\r\n if (sourceRef) union({ valueId: write.valueId, component }, sourceRef);\r\n });\r\n }\r\n }\r\n }\r\n\r\n for (const value of program.values)\r\n {\r\n for (const component of valueComponents(value))\r\n {\r\n const type = signatureType(program, value.register, component);\r\n if (type) constrain({ valueId: value.id, component }, type);\r\n }\r\n }\r\n for (const instruction of program.instructions)\r\n {\r\n const rule = ruleFor(instruction.opcodeName, program, instruction);\r\n if (rule.destination)\r\n {\r\n for (const write of instruction.dataflow.writes)\r\n {\r\n for (const component of write.mask) constrain({ valueId: write.valueId, component }, rule.destination);\r\n }\r\n }\r\n for (const read of instruction.dataflow.reads)\r\n {\r\n if (read.kind === \"index-read\") continue;\r\n const expected = rule.sourceByOperand?.[read.operandIndex] ?? rule.sources ?? null;\r\n for (const ref of read.refs) constrain(ref, expected);\r\n }\r\n }\r\n\r\n // A live value (read by an instruction or feeding a phi) whose type is\r\n // otherwise unconstrained — e.g. an immediate `0` that only ever flows\r\n // through moves and never reaches a typed use — defaults to raw bitpattern32\r\n // bits so it can be emitted. This covers EVERY lane of a live value, not\r\n // just the read lane: an emitted multi-lane value needs a type for its dead\r\n // lanes too (the vector constructor references all of them). Because moves\r\n // union source and destination, the default propagates consistently across\r\n // the whole move chain and any phi it feeds. Genuinely dead writes are never\r\n // read, keep no constraint (stay `unknown`), and are dropped by the lowerers.\r\n const liveValueIds = new Set();\r\n for (const instruction of program.instructions)\r\n {\r\n for (const read of instruction.dataflow.reads)\r\n {\r\n if (read.kind === \"index-read\") continue;\r\n for (const ref of read.refs) liveValueIds.add(ref.valueId);\r\n }\r\n }\r\n for (const value of program.values)\r\n {\r\n for (const incoming of value.incoming || []) liveValueIds.add(incoming.valueId);\r\n }\r\n for (const value of program.values)\r\n {\r\n if (!liveValueIds.has(value.id)) continue;\r\n for (const component of valueComponents(value))\r\n {\r\n const ref = { valueId: value.id, component };\r\n if (!constraints.get(find(ensure(ref))).size) constrain(ref, \"bitpattern32\");\r\n }\r\n }\r\n\r\n const typeForRef = (ref) =>\r\n {\r\n const types = Array.from(constraints.get(find(ensure(ref))));\r\n if (types.length === 0) return \"unknown\";\r\n return types.length === 1 ? types[0] : \"bitpattern32\";\r\n };\r\n\r\n for (const value of program.values)\r\n {\r\n value.componentTypes = {};\r\n for (const component of valueComponents(value))\r\n {\r\n value.componentTypes[component] = typeForRef({ valueId: value.id, component });\r\n }\r\n }\r\n\r\n for (const instruction of program.instructions)\r\n {\r\n const rule = ruleFor(instruction.opcodeName, program, instruction);\r\n const writes = instruction.dataflow.writes;\r\n const destinationTypes = writes.flatMap((write) => Array.from(write.mask)\r\n .map((component) => program.values.find((value) => value.id === write.valueId)?.componentTypes[component]))\r\n .filter(Boolean);\r\n const moveType = destinationTypes.length && new Set(destinationTypes).size === 1 ? destinationTypes[0] : null;\r\n const operandTypes = instruction.operands.map((operand, operandIndex) =>\r\n {\r\n let expectedType = rule.sourceByOperand?.[operandIndex] ?? null;\r\n if (!expectedType && rule.sources && operandIndex > 0) expectedType = rule.sources;\r\n if (!expectedType && (rule.equalitySources || []).includes(operandIndex)) expectedType = moveType;\r\n if (instruction.dataflow.writes.some((write) => write.operandIndex === operandIndex)) expectedType = rule.destination ?? moveType;\r\n return {\r\n operandIndex,\r\n role: instruction.dataflow.writes.some((write) => write.operandIndex === operandIndex) ? \"destination\" : \"source\",\r\n expectedType: expectedType || \"unknown\",\r\n modifier: operand.modifierName || \"none\",\r\n minPrecision: operand.minPrecisionName || \"default\",\r\n immediate: operand.typeName === \"immediate32\"\r\n ? operand.immediateValues.map((value, component) => ({ component: COMPONENTS[component], uint32: value.uint32, float32: value.float32 }))\r\n : null\r\n };\r\n });\r\n const bitcasts = [];\r\n for (const read of instruction.dataflow.reads)\r\n {\r\n if (read.kind === \"index-read\") continue;\r\n let expected = rule.sourceByOperand?.[read.operandIndex] ?? rule.sources ?? null;\r\n if (!expected && (rule.equalitySources || []).includes(read.operandIndex)) expected = moveType;\r\n if (!expected || expected === \"unknown\") continue;\r\n read.refs.forEach((ref, componentIndex) =>\r\n {\r\n const storage = typeForRef(ref);\r\n if (storage !== expected && storage !== \"unknown\")\r\n {\r\n bitcasts.push({ kind: \"read-bitcast\", operandIndex: read.operandIndex, componentIndex, valueId: ref.valueId, component: ref.component, from: storage, to: expected });\r\n }\r\n });\r\n }\r\n for (const write of writes)\r\n {\r\n if (!rule.destination) continue;\r\n Array.from(write.mask).forEach((component) =>\r\n {\r\n const storage = typeForRef({ valueId: write.valueId, component });\r\n if (storage !== rule.destination && storage !== \"unknown\")\r\n {\r\n bitcasts.push({ kind: \"result-bitcast\", operandIndex: write.operandIndex, valueId: write.valueId, component, from: rule.destination, to: storage });\r\n }\r\n });\r\n }\r\n for (const operand of operandTypes)\r\n {\r\n if (!operand.immediate || ![ \"float32\", \"int32\" ].includes(operand.expectedType)) continue;\r\n for (const immediate of operand.immediate)\r\n {\r\n bitcasts.push({ kind: \"immediate-bitcast\", operandIndex: operand.operandIndex, component: immediate.component, from: \"uint32\", to: operand.expectedType, uint32: immediate.uint32 });\r\n }\r\n }\r\n instruction.typeInfo = {\r\n kind: \"instruction-types\",\r\n rule: rule.name,\r\n resultType: rule.destination ?? moveType ?? \"unknown\",\r\n conversion: rule.conversion || null,\r\n conditionProjection: rule.conditionProjection || null,\r\n operandTypes,\r\n bitcasts\r\n };\r\n }\r\n\r\n program.typeSystem = {\r\n kind: \"scalar-type-system\",\r\n scalarTypes: SCALAR_TYPES.slice(),\r\n comparisonResult: \"uint32-mask\",\r\n conditionProjection: \"nonzero\",\r\n registerStorage: \"component-granular\"\r\n };\r\n return program;\r\n}\r\n"],"names":["COMPONENTS","COMPONENT_INDEX","Map","map","component","index","SCALAR_TYPES","Object","freeze","FLOAT_OPS","Set","FLOAT_COMPARE","INT_OPS","INT_COMPARE","UINT_OPS","UINT_COMPARE","BITWISE_OPS","CONTROL_MASK_OPS","SAMPLE_OPS","bindingResultType","program","instruction","operandTypeName","resourceKind","resource","operands","find","operand","typeName","reference","resourceReference","binding","bindings","entry","rangeId","undefined","range","registerIndex","mapped","returnType","returnTypeNames","type","unorm","snorm","float","sint","uint","concrete","filter","length","size","sampleResultType","ruleFor","opcodeName","has","name","destination","sources","sourceByOperand","conditionProjection","includes","assign","resinfoReturnTypeName","conversions","ftoi","ftou","itof","utof","source","conversion","from","to","equalitySources","nodeKey","ref","valueId","valueComponents","value","Array","writeMask","signatureType","register","match","exec","elements","signatures","componentBit","get","element","Number","mask","componentTypeName","correspondingRef","refs","inferValueTypes","parent","constraints","ensure","key","set","current","next","union","leftRef","rightRef","left","right","root","child","compareUtf8","add","constrain","values","id","origin","mergeRef","incoming","instructions","rule","writes","dataflow","sourceOperandIndex","read","reads","operandIndex","kind","write","forEach","sourceRef","expected","liveValueIds","typeForRef","types","componentTypes","destinationTypes","flatMap","Boolean","moveType","operandTypes","expectedType","some","role","modifier","modifierName","minPrecision","minPrecisionName","immediate","immediateValues","uint32","float32","bitcasts","componentIndex","storage","push","typeInfo","resultType","typeSystem","scalarTypes","slice","comparisonResult","registerStorage"],"mappings":";;AAEA,MAAMA,UAAU,GAAG,CAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAE;AACzC,MAAMC,eAAe,GAAG,IAAIC,GAAG,CAACF,UAAU,CAACG,GAAG,CAAC,CAACC,SAAS,EAAEC,KAAK,KAAK,CAAED,SAAS,EAAEC,KAAK,CAAE,CAAC,CAAC;AAEpF,MAAMC,YAAY,GAAGC,MAAM,CAACC,MAAM,CAAC,CACtC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,cAAc,CAClE;AAED,MAAMC,SAAS,GAAG,IAAIC,GAAG,CAAC,CACtB,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,kBAAkB,EAAE,gBAAgB,EACrE,kBAAkB,EAAE,gBAAgB,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAChE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAClE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAC7D,CAAC;AACF,MAAMC,aAAa,GAAG,IAAID,GAAG,CAAC,CAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAE,CAAC;AACzD,MAAME,OAAO,GAAG,IAAIF,GAAG,CAAC,CAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,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@ -1,15 +1,15 @@
|
|
|
1
1
|
import { readEffectAnalysis } from './effectAnalysis.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { buildEffectAnalysis, inspectWithValues } from './helpers.js';
|
|
3
|
+
import { buildCarbonEffectContainer } from './buildCarbonEffectContainer.js';
|
|
4
4
|
import { lowerDxbcToIr } from './ir/lowerDxbcToIr.js';
|
|
5
5
|
import { buildWgslBindingPlan } from './wgsl/buildWgslBindingPlan.js';
|
|
6
6
|
import { buildWgsl } from './wgsl/emitWgsl.js';
|
|
7
7
|
import { buildWgslSet } from './wgsl/buildWgslSet.js';
|
|
8
8
|
import { buildResourceTransformPlan } from './wgsl/buildResourceTransformPlan.js';
|
|
9
9
|
import { buildEffectPermutationGraph, EFFECT_PERMUTATION_GRAPH_VERSION, EFFECT_PERMUTATION_GRAPH_FORMAT, EFFECT_PERMUTATION_GRAPH_CHUNK } from '../../../format/effect/effectPermutationGraph.js';
|
|
10
|
-
import { buildCompleteEffectReflection
|
|
10
|
+
import { buildCompleteEffectReflection } from '../../../format/effect/effectReflectionPackage.js';
|
|
11
11
|
import { buildEffectBackendBodySet, EFFECT_BACKEND_BODY_SET_VERSION, EFFECT_BACKEND_BODY_SET_FORMAT, EFFECT_BACKEND_BODY_SET_CHUNK } from './effectBackendBodySet.js';
|
|
12
|
-
import { DXBC_WGSL_TRANSLATOR_VERSION, DXBC_WGSL_TRANSLATOR_NAME, FORMAT_WEBGPU_PACKAGE_VERSION, FORMAT_WEBGPU_PACKAGE_NAME, WEBGPU_BACKEND_NAME } from './packageMetadata.js';
|
|
12
|
+
import { DXBC_WGSL_TRANSLATOR_VERSION, DXBC_WGSL_TRANSLATOR_NAME, FORMAT_WEBGPU_PACKAGE_VERSION, FORMAT_WEBGPU_PACKAGE_NAME, WEBGPU_BACKEND_NAME, EFFECT_INFO_VERSION } from './packageMetadata.js';
|
|
13
13
|
import { sha256Utf8, sha256Bytes } from '../../../format/effect/sha256.js';
|
|
14
14
|
import { isParticleClearEffectCandidate, preflightParticleClearEffectProfile, particleClearEffectProofFor } from './wgsl/lowerParticleClearComputePrograms.js';
|
|
15
15
|
import { normalizeEffectPermutation, validateResolvedPermutation, selectEffectStages, buildWgslSelectionMetadata } from './packageEffectSelection.js';
|
|
@@ -17,9 +17,10 @@ import { normalizeEffectPermutation, validateResolvedPermutation, selectEffectSt
|
|
|
17
17
|
/**
|
|
18
18
|
* Build one structurally valid CEWGPU package from compiled Tr2 effect bytes.
|
|
19
19
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
20
|
+
* The version-15 build result retains every unique body's portable source
|
|
21
|
+
* reflection as in-memory evidence while the emitted Carbon wire stores WGSL
|
|
22
|
+
* or empty program slots plus representable non-program fields. Filesystem
|
|
23
|
+
* concerns remain in callers.
|
|
23
24
|
*
|
|
24
25
|
* @param {Uint8Array|ArrayBuffer|ArrayBufferView} input Compiled effect bytes.
|
|
25
26
|
* @param {object} [options] Source, body-mode, permutation, and stage-selection policy.
|
|
@@ -188,9 +189,24 @@ function buildEffectPackage(input, options = {}) {
|
|
|
188
189
|
wgslSelection
|
|
189
190
|
} : {})
|
|
190
191
|
};
|
|
191
|
-
|
|
192
|
+
// The switchover. Former stored chunks are now compatibility views over the
|
|
193
|
+
// Carbon records: the permutation graph comes from the header and offset
|
|
194
|
+
// table, and a translated pass comes from shaderData plus its trailing
|
|
195
|
+
// block. The description tree retains only representable non-program
|
|
196
|
+
// reflection; full portable source reflection remains in the rich
|
|
197
|
+
// in-memory return value below.
|
|
198
|
+
//
|
|
199
|
+
// The wire no longer stores cross-chunk digests. The rich return value keeps
|
|
200
|
+
// hashes as build evidence; they are not records in the emitted container.
|
|
201
|
+
const emittedBodySet = backendBodySet ?? selectedModeBodySet(permutationGraph, wgsl, analysis.bodyIndex);
|
|
202
|
+
const container = buildCarbonEffectContainer(resolved.effectRes, permutationGraph, emittedBodySet, {
|
|
203
|
+
compilerVersion: resolved.effectRes.m_compilerVersionBytes
|
|
204
|
+
});
|
|
205
|
+
const bytes = container.bytes;
|
|
192
206
|
const inspection = inspectWithValues(bytes, {
|
|
193
|
-
source
|
|
207
|
+
source,
|
|
208
|
+
emit: "json"
|
|
209
|
+
});
|
|
194
210
|
const qualification = Object.freeze({
|
|
195
211
|
ok: true,
|
|
196
212
|
level: "structural",
|
|
@@ -221,6 +237,75 @@ function buildEffectPackage(input, options = {}) {
|
|
|
221
237
|
qualification
|
|
222
238
|
});
|
|
223
239
|
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Wraps a selected-mode translation as the body set the container emitter takes.
|
|
243
|
+
*
|
|
244
|
+
* `mode: "all"` builds a real body set covering every unique body. `mode:
|
|
245
|
+
* "selected"` translates exactly one, and the container still carries every
|
|
246
|
+
* permutation — that asymmetry is the format working as intended rather than a
|
|
247
|
+
* gap. When the container emitter rebuilds an untranslated body, it retains
|
|
248
|
+
* representable non-program description fields and writes zero-length program
|
|
249
|
+
* slots.
|
|
250
|
+
*
|
|
251
|
+
* So this does not translate anything. It reshapes the one translation already
|
|
252
|
+
* performed into the body-set contract, and marks every other body unsupported.
|
|
253
|
+
*
|
|
254
|
+
* @param {object} permutationGraph Validated permutation graph.
|
|
255
|
+
* @param {object} wgsl Emitted WGSL set for the selected body.
|
|
256
|
+
* @param {number} bodyIndex Selected permutation index.
|
|
257
|
+
* @returns {object} Body set covering one translated body.
|
|
258
|
+
*/
|
|
259
|
+
function selectedModeBodySet(permutationGraph, wgsl, bodyIndex) {
|
|
260
|
+
const selectedBodyKey = permutationGraph.variants.find(variant => variant.permutationIndex === bodyIndex)?.bodyKey ?? permutationGraph.variants[0]?.bodyKey ?? null;
|
|
261
|
+
const shadersByPass = new Map();
|
|
262
|
+
for (const shader of wgsl.shaders) {
|
|
263
|
+
const passKey = `${shader.techniqueName}.pass${shader.passIndex}`;
|
|
264
|
+
if (!shadersByPass.has(passKey)) shadersByPass.set(passKey, []);
|
|
265
|
+
shadersByPass.get(passKey).push(shader);
|
|
266
|
+
}
|
|
267
|
+
const passUnits = [];
|
|
268
|
+
const passes = [];
|
|
269
|
+
for (const [passKey, shaders] of shadersByPass) {
|
|
270
|
+
const transforms = (wgsl.resourceTransforms ?? []).filter(transform => transform.layoutKey === passKey);
|
|
271
|
+
const unit = {
|
|
272
|
+
key: `unit${passUnits.length}`,
|
|
273
|
+
wgslSetVersion: wgsl.formatVersion,
|
|
274
|
+
shaders,
|
|
275
|
+
layouts: wgsl.layouts.filter(layout => layout.key === passKey),
|
|
276
|
+
...(transforms.length ? {
|
|
277
|
+
resourceTransforms: transforms
|
|
278
|
+
} : {})
|
|
279
|
+
};
|
|
280
|
+
passUnits.push(unit);
|
|
281
|
+
passes.push({
|
|
282
|
+
passKey,
|
|
283
|
+
unitKey: unit.key
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
const bodies = permutationGraph.bodies.map(body => body.key === selectedBodyKey ? {
|
|
287
|
+
bodyKey: body.key,
|
|
288
|
+
representativePermutationIndex: bodyIndex,
|
|
289
|
+
status: "translated",
|
|
290
|
+
error: null,
|
|
291
|
+
passCount: passes.length,
|
|
292
|
+
passes
|
|
293
|
+
} : {
|
|
294
|
+
bodyKey: body.key,
|
|
295
|
+
representativePermutationIndex: permutationGraph.variants.find(variant => variant.bodyKey === body.key)?.permutationIndex ?? 0,
|
|
296
|
+
status: "unsupported",
|
|
297
|
+
error: "not translated in selected mode",
|
|
298
|
+
passCount: 0,
|
|
299
|
+
passes: []
|
|
300
|
+
});
|
|
301
|
+
return {
|
|
302
|
+
bodyCount: bodies.length,
|
|
303
|
+
translatedBodyCount: 1,
|
|
304
|
+
passUnitCount: passUnits.length,
|
|
305
|
+
passUnits,
|
|
306
|
+
bodies
|
|
307
|
+
};
|
|
308
|
+
}
|
|
224
309
|
function normalizeMode(value, allPermutations) {
|
|
225
310
|
if (allPermutations !== undefined && typeof allPermutations !== "boolean") {
|
|
226
311
|
throw new TypeError("Effect allPermutations compatibility option must be boolean");
|