@carbonenginejs/runtime-resource 0.9.2 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +3 -2
- package/README.md +47 -6
- package/dist/CjsMotherLode.js +88 -88
- package/dist/CjsMotherLode.js.map +1 -1
- package/dist/CjsResMan.js +717 -228
- package/dist/CjsResMan.js.map +1 -1
- package/dist/CjsResManFetchProvider.js +94 -0
- package/dist/CjsResManFetchProvider.js.map +1 -0
- package/dist/{CjsResManQueue.js → CjsResManWorkQueue.js} +112 -25
- package/dist/CjsResManWorkQueue.js.map +1 -0
- package/dist/format/CjsBlueReader.js +89 -0
- package/dist/format/CjsBlueReader.js.map +1 -1
- package/dist/format/CjsFormat.js +42 -16
- package/dist/format/CjsFormat.js.map +1 -1
- package/dist/format/CjsReader.js +4 -0
- package/dist/format/CjsReader.js.map +1 -1
- package/dist/format/CjsResourceProbe.js +2 -0
- package/dist/format/CjsResourceProbe.js.map +1 -1
- package/dist/format/effect/effectPermutationGraph.js +257 -0
- package/dist/format/effect/effectPermutationGraph.js.map +1 -0
- package/dist/format/effect/effectReflectionPackage.js +636 -0
- package/dist/format/effect/effectReflectionPackage.js.map +1 -0
- package/dist/format/effect/sha256.js +114 -0
- package/dist/format/effect/sha256.js.map +1 -0
- package/dist/format/payloadContract.js +20 -0
- package/dist/format/payloadContract.js.map +1 -1
- package/dist/formats/black/CjsBlackFormat.js +15 -1
- package/dist/formats/black/CjsBlackFormat.js.map +1 -1
- package/dist/formats/black/core/CjsBlackBinaryReader.js +103 -0
- package/dist/formats/black/core/CjsBlackBinaryReader.js.map +1 -1
- package/dist/formats/black/core/CjsBlackPropertyReaders.js +61 -0
- package/dist/formats/black/core/CjsBlackPropertyReaders.js.map +1 -1
- package/dist/formats/black/core/CjsBlackReader.js +125 -0
- package/dist/formats/black/core/CjsBlackReader.js.map +1 -1
- package/dist/formats/black/core/CjsBlackSchemaRegistry.js +103 -0
- package/dist/formats/black/core/CjsBlackSchemaRegistry.js.map +1 -1
- package/dist/formats/black/core/helpers.js +17 -0
- package/dist/formats/black/core/helpers.js.map +1 -1
- package/dist/formats/bnk/CjsBnkFormat.js +8 -0
- package/dist/formats/bnk/CjsBnkFormat.js.map +1 -1
- package/dist/formats/bnk/core/helpers.js +20 -0
- package/dist/formats/bnk/core/helpers.js.map +1 -1
- package/dist/formats/bnk/core/musicNodes.js +40 -3
- package/dist/formats/bnk/core/musicNodes.js.map +1 -1
- package/dist/formats/bnk/core/soundbanksInfo.js +2 -0
- package/dist/formats/bnk/core/soundbanksInfo.js.map +1 -1
- package/dist/formats/cmf/core/binary.js +71 -0
- package/dist/formats/cmf/core/binary.js.map +1 -1
- package/dist/formats/cmf/core/buffers.js +4 -0
- package/dist/formats/cmf/core/buffers.js.map +1 -1
- package/dist/formats/cmf/core/helpers.js +31 -0
- package/dist/formats/cmf/core/helpers.js.map +1 -1
- package/dist/formats/cmf/core/schema.js +10 -0
- package/dist/formats/cmf/core/schema.js.map +1 -1
- package/dist/formats/cmf/core/shared.js +9 -0
- package/dist/formats/cmf/core/shared.js.map +1 -1
- package/dist/formats/cmf/core/writer.js +54 -0
- package/dist/formats/cmf/core/writer.js.map +1 -1
- package/dist/formats/dds/core/bc6h.js +10 -0
- package/dist/formats/dds/core/bc6h.js.map +1 -1
- package/dist/formats/dds/core/bc7.js +16 -0
- package/dist/formats/dds/core/bc7.js.map +1 -1
- package/dist/formats/dds/core/helpers.js +47 -0
- package/dist/formats/dds/core/helpers.js.map +1 -1
- package/dist/formats/dxbc/CjsDxbcFormat.js +142 -0
- package/dist/formats/dxbc/CjsDxbcFormat.js.map +1 -0
- package/dist/formats/dxbc/core/DxbcReader.js +266 -0
- package/dist/formats/dxbc/core/DxbcReader.js.map +1 -0
- package/dist/formats/dxbc/core/container.js +169 -0
- package/dist/formats/dxbc/core/container.js.map +1 -0
- package/dist/formats/dxbc/core/decoder.js +789 -0
- package/dist/formats/dxbc/core/decoder.js.map +1 -0
- package/dist/formats/dxbc/core/errors.js +19 -0
- package/dist/formats/dxbc/core/errors.js.map +1 -0
- package/dist/formats/dxbc/core/helpers.js +220 -0
- package/dist/formats/dxbc/core/helpers.js.map +1 -0
- package/dist/formats/dxbc/core/opcodes.js +45 -0
- package/dist/formats/dxbc/core/opcodes.js.map +1 -0
- package/dist/formats/dxbc/core/program.js +91 -0
- package/dist/formats/dxbc/core/program.js.map +1 -0
- package/dist/formats/dxbc/core/signature.js +172 -0
- package/dist/formats/dxbc/core/signature.js.map +1 -0
- package/dist/formats/dxbc/index.js +2 -0
- package/dist/formats/dxbc/index.js.map +1 -0
- package/dist/formats/fbx/core/helpers.js +21 -0
- package/dist/formats/fbx/core/helpers.js.map +1 -1
- package/dist/formats/flac/CjsFlacFormat.js +49 -0
- package/dist/formats/flac/CjsFlacFormat.js.map +1 -1
- package/dist/formats/flac/core/helpers.js +20 -0
- package/dist/formats/flac/core/helpers.js.map +1 -1
- package/dist/formats/gif/CjsGifFormat.js +49 -0
- package/dist/formats/gif/CjsGifFormat.js.map +1 -1
- package/dist/formats/gif/core/helpers.js +20 -0
- package/dist/formats/gif/core/helpers.js.map +1 -1
- package/dist/formats/gltf/core/helpers.js +15 -0
- package/dist/formats/gltf/core/helpers.js.map +1 -1
- package/dist/formats/gltf/core/parser.js +13 -0
- package/dist/formats/gltf/core/parser.js.map +1 -1
- package/dist/formats/gltf/core/targets.js +10 -0
- package/dist/formats/gltf/core/targets.js.map +1 -1
- package/dist/formats/gr2/core/bitknit2.js +2 -0
- package/dist/formats/gr2/core/bitknit2.js.map +1 -1
- package/dist/formats/gr2/core/helpers.js +20 -0
- package/dist/formats/gr2/core/helpers.js.map +1 -1
- package/dist/formats/gr2/core/targets.js +10 -0
- package/dist/formats/gr2/core/targets.js.map +1 -1
- package/dist/formats/hlsl/CjsHlslFormat.js +254 -0
- package/dist/formats/hlsl/CjsHlslFormat.js.map +1 -0
- package/dist/formats/hlsl/core/HlslBinaryUtils.js +15 -0
- package/dist/formats/hlsl/core/HlslBinaryUtils.js.map +1 -0
- package/dist/formats/hlsl/core/HlslEffectReadError.js +19 -0
- package/dist/formats/hlsl/core/HlslEffectReadError.js.map +1 -0
- package/dist/formats/hlsl/core/HlslEffectStateManager.js +130 -0
- package/dist/formats/hlsl/core/HlslEffectStateManager.js.map +1 -0
- package/dist/formats/hlsl/core/HlslReader.js +266 -0
- package/dist/formats/hlsl/core/HlslReader.js.map +1 -0
- package/dist/formats/hlsl/core/HlslRenderStateSetup.js +37 -0
- package/dist/formats/hlsl/core/HlslRenderStateSetup.js.map +1 -0
- package/dist/formats/hlsl/core/HlslResourceSetDescription.js +94 -0
- package/dist/formats/hlsl/core/HlslResourceSetDescription.js.map +1 -0
- package/dist/formats/hlsl/core/HlslShaderBytecode.js +44 -0
- package/dist/formats/hlsl/core/HlslShaderBytecode.js.map +1 -0
- package/dist/formats/hlsl/core/analysis.js +51 -0
- package/dist/formats/hlsl/core/analysis.js.map +1 -0
- package/dist/formats/hlsl/core/helpers.js +270 -0
- package/dist/formats/hlsl/core/helpers.js.map +1 -0
- package/dist/formats/hlsl/core/json.js +284 -0
- package/dist/formats/hlsl/core/json.js.map +1 -0
- package/dist/formats/hlsl/core/metadata.js +327 -0
- package/dist/formats/hlsl/core/metadata.js.map +1 -0
- package/dist/formats/hlsl/core/portableReflection.js +848 -0
- package/dist/formats/hlsl/core/portableReflection.js.map +1 -0
- package/dist/formats/hlsl/core/render-states.js +280 -0
- package/dist/formats/hlsl/core/render-states.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/HlslRenderContextEnum.js +43 -0
- package/dist/formats/hlsl/core/tr2/HlslRenderContextEnum.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/resources/HlslEffectRes.js +294 -0
- package/dist/formats/hlsl/core/tr2/resources/HlslEffectRes.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/resources/HlslShaderPermutation.js +33 -0
- package/dist/formats/hlsl/core/tr2/resources/HlslShaderPermutation.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectBindingManifest.js +416 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectBindingManifest.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectConstant.js +40 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectConstant.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectDescription.js +742 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectDescription.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectLibrary.js +52 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectLibrary.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectParameterAnnotation.js +38 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectParameterAnnotation.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectResource.js +50 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectResource.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectStageInput.js +86 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectStageInput.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectTechnique.js +31 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectTechnique.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslPass.js +42 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslPass.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslSamplerDescription.js +55 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslSamplerDescription.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslSamplerSetup.js +29 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslSamplerSetup.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslShader.js +220 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslShader.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslShaderOption.js +30 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslShaderOption.js.map +1 -0
- package/dist/formats/hlsl/index.js +2 -0
- package/dist/formats/hlsl/index.js.map +1 -0
- package/dist/formats/hlsl/portable.js +2 -0
- package/dist/formats/hlsl/portable.js.map +1 -0
- package/dist/formats/index.js +4 -0
- package/dist/formats/index.js.map +1 -1
- package/dist/formats/jpeg/core/helpers.js +52 -0
- package/dist/formats/jpeg/core/helpers.js.map +1 -1
- package/dist/formats/jpeg/core/jpeg.js +93 -0
- package/dist/formats/jpeg/core/jpeg.js.map +1 -1
- package/dist/formats/mp3/core/helpers.js +37 -0
- package/dist/formats/mp3/core/helpers.js.map +1 -1
- package/dist/formats/mp4/core/helpers.js +35 -0
- package/dist/formats/mp4/core/helpers.js.map +1 -1
- package/dist/formats/ogg/CjsOggFormat.js +49 -0
- package/dist/formats/ogg/CjsOggFormat.js.map +1 -1
- package/dist/formats/ogg/core/helpers.js +23 -0
- package/dist/formats/ogg/core/helpers.js.map +1 -1
- package/dist/formats/ogg/core/vorbis.js +13 -0
- package/dist/formats/ogg/core/vorbis.js.map +1 -1
- package/dist/formats/png/core/helpers.js +52 -0
- package/dist/formats/png/core/helpers.js.map +1 -1
- package/dist/formats/red/CjsRedFormat.js +2 -0
- package/dist/formats/red/CjsRedFormat.js.map +1 -1
- package/dist/formats/red/core/CjsRedReader.js +52 -0
- package/dist/formats/red/core/CjsRedReader.js.map +1 -1
- package/dist/formats/red/core/helpers.js +19 -0
- package/dist/formats/red/core/helpers.js.map +1 -1
- package/dist/formats/stl/core/stl.js +8 -0
- package/dist/formats/stl/core/stl.js.map +1 -1
- package/dist/formats/stl/core/targets.js +10 -0
- package/dist/formats/stl/core/targets.js.map +1 -1
- package/dist/formats/tga/core/helpers.js +47 -0
- package/dist/formats/tga/core/helpers.js.map +1 -1
- package/dist/formats/wav/core/helpers.js +37 -0
- package/dist/formats/wav/core/helpers.js.map +1 -1
- package/dist/formats/webgl/CjsWebglFormat.js +221 -0
- package/dist/formats/webgl/CjsWebglFormat.js.map +1 -0
- package/dist/formats/webgl/core/cewg/CewgPackage.js +339 -0
- package/dist/formats/webgl/core/cewg/CewgPackage.js.map +1 -0
- package/dist/formats/webgl/core/cewg/CewgPackageBuilder.js +104 -0
- package/dist/formats/webgl/core/cewg/CewgPackageBuilder.js.map +1 -0
- package/dist/formats/webgl/core/cewg/binary.js +101 -0
- package/dist/formats/webgl/core/cewg/binary.js.map +1 -0
- package/dist/formats/webgl/core/cewgCompleteness.js +81 -0
- package/dist/formats/webgl/core/cewgCompleteness.js.map +1 -0
- package/dist/formats/webgl/core/effectPackage.js +789 -0
- package/dist/formats/webgl/core/effectPackage.js.map +1 -0
- package/dist/formats/webgl/core/effectPackageValidation.js +331 -0
- package/dist/formats/webgl/core/effectPackageValidation.js.map +1 -0
- package/dist/formats/webgl/core/errors.js +27 -0
- package/dist/formats/webgl/core/errors.js.map +1 -0
- package/dist/formats/webgl/core/glsl/DxbcGlslEmitter.js +2678 -0
- package/dist/formats/webgl/core/glsl/DxbcGlslEmitter.js.map +1 -0
- package/dist/formats/webgl/core/glsl/DxbcGlslHelpers.js +89 -0
- package/dist/formats/webgl/core/glsl/DxbcGlslHelpers.js.map +1 -0
- package/dist/formats/webgl/core/glsl/DxbcGlslOperandFormatter.js +428 -0
- package/dist/formats/webgl/core/glsl/DxbcGlslOperandFormatter.js.map +1 -0
- package/dist/formats/webgl/core/helpers.js +306 -0
- package/dist/formats/webgl/core/helpers.js.map +1 -0
- package/dist/formats/webgl/index.js +2 -0
- package/dist/formats/webgl/index.js.map +1 -0
- package/dist/formats/webgpu/CjsWebgpuFormat.js +376 -0
- package/dist/formats/webgpu/CjsWebgpuFormat.js.map +1 -0
- package/dist/formats/webgpu/core/cewgpu/CewgpuPackage.js +415 -0
- package/dist/formats/webgpu/core/cewgpu/CewgpuPackage.js.map +1 -0
- package/dist/formats/webgpu/core/cewgpu/CewgpuPackageBuilder.js +100 -0
- package/dist/formats/webgpu/core/cewgpu/CewgpuPackageBuilder.js.map +1 -0
- package/dist/formats/webgpu/core/cewgpu/binary.js +93 -0
- package/dist/formats/webgpu/core/cewgpu/binary.js.map +1 -0
- package/dist/formats/webgpu/core/cewgpu/tags.js +17 -0
- package/dist/formats/webgpu/core/cewgpu/tags.js.map +1 -0
- package/dist/formats/webgpu/core/effectAnalysis.js +82 -0
- package/dist/formats/webgpu/core/effectAnalysis.js.map +1 -0
- package/dist/formats/webgpu/core/effectBackendBodySet.js +305 -0
- package/dist/formats/webgpu/core/effectBackendBodySet.js.map +1 -0
- package/dist/formats/webgpu/core/effectPackageValidation.js +1078 -0
- package/dist/formats/webgpu/core/effectPackageValidation.js.map +1 -0
- package/dist/formats/webgpu/core/errors.js +20 -0
- package/dist/formats/webgpu/core/errors.js.map +1 -0
- package/dist/formats/webgpu/core/helpers.js +448 -0
- package/dist/formats/webgpu/core/helpers.js.map +1 -0
- package/dist/formats/webgpu/core/ir/analyzeRegisterValues.js +223 -0
- package/dist/formats/webgpu/core/ir/analyzeRegisterValues.js.map +1 -0
- package/dist/formats/webgpu/core/ir/buildControlFlow.js +220 -0
- package/dist/formats/webgpu/core/ir/buildControlFlow.js.map +1 -0
- package/dist/formats/webgpu/core/ir/indexableTemps.js +137 -0
- package/dist/formats/webgpu/core/ir/indexableTemps.js.map +1 -0
- package/dist/formats/webgpu/core/ir/inferValueTypes.js +454 -0
- package/dist/formats/webgpu/core/ir/inferValueTypes.js.map +1 -0
- package/dist/formats/webgpu/core/ir/lowerDxbcToIr.js +494 -0
- package/dist/formats/webgpu/core/ir/lowerDxbcToIr.js.map +1 -0
- package/dist/formats/webgpu/core/ir/resolveRegisterFlow.js +177 -0
- package/dist/formats/webgpu/core/ir/resolveRegisterFlow.js.map +1 -0
- package/dist/formats/webgpu/core/ir/sourceLanes.js +61 -0
- package/dist/formats/webgpu/core/ir/sourceLanes.js.map +1 -0
- package/dist/formats/webgpu/core/packageEffect.js +300 -0
- package/dist/formats/webgpu/core/packageEffect.js.map +1 -0
- package/dist/formats/webgpu/core/packageEffectSelection.js +164 -0
- package/dist/formats/webgpu/core/packageEffectSelection.js.map +1 -0
- package/dist/formats/webgpu/core/packageMetadata.js +8 -0
- package/dist/formats/webgpu/core/packageMetadata.js.map +1 -0
- package/dist/formats/webgpu/core/schema.js +4 -0
- package/dist/formats/webgpu/core/schema.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js +275 -0
- package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/buildWgslBindingPlan.js +182 -0
- package/dist/formats/webgpu/core/wgsl/buildWgslBindingPlan.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/buildWgslSet.js +324 -0
- package/dist/formats/webgpu/core/wgsl/buildWgslSet.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/emitWgsl.js +356 -0
- package/dist/formats/webgpu/core/wgsl/emitWgsl.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/hoistEscapingValues.js +77 -0
- package/dist/formats/webgpu/core/wgsl/hoistEscapingValues.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/lowerBindingLayout.js +451 -0
- package/dist/formats/webgpu/core/wgsl/lowerBindingLayout.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/lowerComputeProgram.js +754 -0
- package/dist/formats/webgpu/core/wgsl/lowerComputeProgram.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/lowerCreateHistogramsComputeProgram.js +457 -0
- package/dist/formats/webgpu/core/wgsl/lowerCreateHistogramsComputeProgram.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/lowerFragmentProgram.js +1572 -0
- package/dist/formats/webgpu/core/wgsl/lowerFragmentProgram.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/lowerMergeHistogramsComputeProgram.js +659 -0
- package/dist/formats/webgpu/core/wgsl/lowerMergeHistogramsComputeProgram.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/lowerParticleClearComputePrograms.js +734 -0
- package/dist/formats/webgpu/core/wgsl/lowerParticleClearComputePrograms.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/lowerParticleEmitComputeProgram.js +583 -0
- package/dist/formats/webgpu/core/wgsl/lowerParticleEmitComputeProgram.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/lowerSkinVerticesComputeProgram.js +621 -0
- package/dist/formats/webgpu/core/wgsl/lowerSkinVerticesComputeProgram.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/lowerSortComputeProgram.js +824 -0
- package/dist/formats/webgpu/core/wgsl/lowerSortComputeProgram.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/lowerSortInnerComputeProgram.js +697 -0
- package/dist/formats/webgpu/core/wgsl/lowerSortInnerComputeProgram.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/lowerSortStepComputeProgram.js +559 -0
- package/dist/formats/webgpu/core/wgsl/lowerSortStepComputeProgram.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/lowerVertexProgram.js +1328 -0
- package/dist/formats/webgpu/core/wgsl/lowerVertexProgram.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/particleEmitSemanticDigest.js +110 -0
- package/dist/formats/webgpu/core/wgsl/particleEmitSemanticDigest.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/precisionControls.js +55 -0
- package/dist/formats/webgpu/core/wgsl/precisionControls.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/selectionPlans.js +758 -0
- package/dist/formats/webgpu/core/wgsl/selectionPlans.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/uniformity.js +78 -0
- package/dist/formats/webgpu/core/wgsl/uniformity.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/validateExactComputeIr.js +196 -0
- package/dist/formats/webgpu/core/wgsl/validateExactComputeIr.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/validateHandleOperand.js +37 -0
- package/dist/formats/webgpu/core/wgsl/validateHandleOperand.js.map +1 -0
- package/dist/formats/webgpu/index.js +2 -0
- package/dist/formats/webgpu/index.js.map +1 -0
- package/dist/formats/webm/core/helpers.js +35 -0
- package/dist/formats/webm/core/helpers.js.map +1 -1
- package/dist/formats/webp/CjsWebpFormat.js +49 -0
- package/dist/formats/webp/CjsWebpFormat.js.map +1 -1
- package/dist/formats/webp/core/helpers.js +23 -0
- package/dist/formats/webp/core/helpers.js.map +1 -1
- package/dist/formats/wem/CjsWemFormat.js +8 -0
- package/dist/formats/wem/CjsWemFormat.js.map +1 -1
- package/dist/formats/wem/core/bitStream.js +2 -0
- package/dist/formats/wem/core/bitStream.js.map +1 -1
- package/dist/formats/wem/core/helpers.js +20 -0
- package/dist/formats/wem/core/helpers.js.map +1 -1
- package/dist/formats/yaml/CjsYamlFormat.js +45 -0
- package/dist/formats/yaml/CjsYamlFormat.js.map +1 -1
- package/dist/formats/yaml/core/CjsYamlReader.js +91 -0
- package/dist/formats/yaml/core/CjsYamlReader.js.map +1 -1
- package/dist/formats/yaml/core/helpers.js +10 -0
- package/dist/formats/yaml/core/helpers.js.map +1 -1
- package/dist/index.js +56 -43
- package/dist/index.js.map +1 -1
- package/dist/{CjsResource.js → resource/CjsResource.js} +232 -17
- package/dist/resource/CjsResource.js.map +1 -0
- package/dist/{resources → resource}/Tr2LightProfileRes.js +4 -3
- package/dist/resource/Tr2LightProfileRes.js.map +1 -0
- package/dist/{resources → resource/audio}/AudioGeometryResData.js +1 -1
- package/dist/resource/audio/AudioGeometryResData.js.map +1 -0
- package/dist/resource/audio/CjsAudioBufferRes.js +86 -0
- package/dist/resource/audio/CjsAudioBufferRes.js.map +1 -0
- package/dist/resource/audio/CjsAudioRes.js +213 -0
- package/dist/resource/audio/CjsAudioRes.js.map +1 -0
- package/dist/resource/audio/index.js +4 -0
- package/dist/resource/audio/index.js.map +1 -0
- package/dist/{resources → resource/geometry}/MeshDecalData.js +1 -1
- package/dist/resource/geometry/MeshDecalData.js.map +1 -0
- package/dist/{resources → resource/geometry}/MeshDecalLodData.js +1 -1
- package/dist/resource/geometry/MeshDecalLodData.js.map +1 -0
- package/dist/resource/geometry/TriGeometryRes.js +656 -0
- package/dist/resource/geometry/TriGeometryRes.js.map +1 -0
- package/dist/{resources → resource/geometry}/TriGeometryResAreaData.js +1 -1
- package/dist/resource/geometry/TriGeometryResAreaData.js.map +1 -0
- package/dist/{resources → resource/geometry}/TriGeometryResJointData.js +1 -1
- package/dist/resource/geometry/TriGeometryResJointData.js.map +1 -0
- package/dist/{resources → resource/geometry}/TriGeometryResLodData.js +1 -1
- package/dist/resource/geometry/TriGeometryResLodData.js.map +1 -0
- package/dist/{resources → resource/geometry}/TriGeometryResMeshData.js +1 -1
- package/dist/resource/geometry/TriGeometryResMeshData.js.map +1 -0
- package/dist/{resources → resource/geometry}/TriGeometryResSkeletonData.js +1 -1
- package/dist/resource/geometry/TriGeometryResSkeletonData.js.map +1 -0
- package/dist/{resources → resource/geometry}/TriJointBinding.js +1 -1
- package/dist/resource/geometry/TriJointBinding.js.map +1 -0
- package/dist/{resources → resource/geometry}/TriMorphTargetGeometryConstants.js +1 -1
- package/dist/resource/geometry/TriMorphTargetGeometryConstants.js.map +1 -0
- package/dist/{resources → resource/geometry}/TriRtGeometryConstants.js +1 -1
- package/dist/resource/geometry/TriRtGeometryConstants.js.map +1 -0
- package/dist/{resources → resource/geometry/granny}/GStateBindingCallbackData.js +1 -1
- package/dist/resource/geometry/granny/GStateBindingCallbackData.js.map +1 -0
- package/dist/{resources → resource/geometry/granny}/Tr2GrannyIntersectionResult.js +1 -1
- package/dist/resource/geometry/granny/Tr2GrannyIntersectionResult.js.map +1 -0
- package/dist/{resources → resource/geometry/granny}/Tr2GrannyStateRes.js +6 -5
- package/dist/resource/geometry/granny/Tr2GrannyStateRes.js.map +1 -0
- package/dist/{resources → resource/geometry/granny}/TriGrannyRes.js +6 -5
- package/dist/resource/geometry/granny/TriGrannyRes.js.map +1 -0
- package/dist/{resources → resource/geometry/granny}/enums.js +1 -9
- package/dist/resource/geometry/granny/enums.js.map +1 -0
- package/dist/resource/geometry/granny/index.js +6 -0
- package/dist/resource/geometry/granny/index.js.map +1 -0
- package/dist/resource/geometry/index.js +17 -0
- package/dist/resource/geometry/index.js.map +1 -0
- package/dist/resource/index.js +52 -0
- package/dist/resource/index.js.map +1 -0
- package/dist/resource/resourceBoundary.js +64 -0
- package/dist/resource/resourceBoundary.js.map +1 -0
- package/dist/resource/shader/Tr2EffectRes.js +429 -0
- package/dist/resource/shader/Tr2EffectRes.js.map +1 -0
- package/dist/resource/shader/Tr2MaterialArea.js +34 -0
- package/dist/resource/shader/Tr2MaterialArea.js.map +1 -0
- package/dist/resource/shader/Tr2MaterialMesh.js +30 -0
- package/dist/resource/shader/Tr2MaterialMesh.js.map +1 -0
- package/dist/resource/shader/Tr2MaterialRes.js +35 -0
- package/dist/resource/shader/Tr2MaterialRes.js.map +1 -0
- package/dist/resource/shader/Tr2Shader.js +256 -0
- package/dist/resource/shader/Tr2Shader.js.map +1 -0
- package/dist/resource/shader/Tr2ShaderPermutation.js +47 -0
- package/dist/resource/shader/Tr2ShaderPermutation.js.map +1 -0
- package/dist/resource/shader/index.js +17 -0
- package/dist/resource/shader/index.js.map +1 -0
- package/dist/resource/shader/portable.js +33 -0
- package/dist/resource/shader/portable.js.map +1 -0
- package/dist/resource/shader/reflection/Tr2EffectConstant.js +135 -0
- package/dist/resource/shader/reflection/Tr2EffectConstant.js.map +1 -0
- package/dist/resource/shader/reflection/Tr2EffectDefine.js +28 -0
- package/dist/resource/shader/reflection/Tr2EffectDefine.js.map +1 -0
- package/dist/resource/shader/reflection/Tr2EffectDescription.js +107 -0
- package/dist/resource/shader/reflection/Tr2EffectDescription.js.map +1 -0
- package/dist/resource/shader/reflection/Tr2EffectLibrary.js +145 -0
- package/dist/resource/shader/reflection/Tr2EffectLibrary.js.map +1 -0
- package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js +103 -0
- package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js.map +1 -0
- package/dist/resource/shader/reflection/Tr2EffectResource.js +84 -0
- package/dist/resource/shader/reflection/Tr2EffectResource.js.map +1 -0
- package/dist/resource/shader/reflection/Tr2EffectStageInput.js +239 -0
- package/dist/resource/shader/reflection/Tr2EffectStageInput.js.map +1 -0
- package/dist/resource/shader/reflection/Tr2EffectTechnique.js +66 -0
- package/dist/resource/shader/reflection/Tr2EffectTechnique.js.map +1 -0
- package/dist/resource/shader/reflection/Tr2Pass.js +109 -0
- package/dist/resource/shader/reflection/Tr2Pass.js.map +1 -0
- package/dist/resource/shader/sampler/Tr2SamplerSetup.js +75 -0
- package/dist/resource/shader/sampler/Tr2SamplerSetup.js.map +1 -0
- package/dist/{texture → resource/texture}/CjsTextureArrayRes.js +83 -6
- package/dist/resource/texture/CjsTextureArrayRes.js.map +1 -0
- package/dist/{texture/CjsTextureParameterProxy.js → resource/texture/CjsTextureArrayResParameterProxy.js} +56 -10
- package/dist/resource/texture/CjsTextureArrayResParameterProxy.js.map +1 -0
- package/dist/{resources → resource/texture}/Tr2ImageRes.js +6 -4
- package/dist/resource/texture/Tr2ImageRes.js.map +1 -0
- package/dist/{resources → resource/texture}/Tr2TextureLodManager.js +3 -1
- package/dist/resource/texture/Tr2TextureLodManager.js.map +1 -0
- package/dist/{resources → resource/texture}/Tr2TextureLodUpdateRequest.js +1 -1
- package/dist/resource/texture/Tr2TextureLodUpdateRequest.js.map +1 -0
- package/dist/{resources → resource/texture}/Tr2TexturePackChannel.js +1 -1
- package/dist/resource/texture/Tr2TexturePackChannel.js.map +1 -0
- package/dist/{resources → resource/texture}/Tr2TexturePipeline.js +6 -4
- package/dist/resource/texture/Tr2TexturePipeline.js.map +1 -0
- package/dist/{resources → resource/texture}/Tr2TexturePipelineParams.js +1 -1
- package/dist/resource/texture/Tr2TexturePipelineParams.js.map +1 -0
- package/dist/{resources → resource/texture}/Tr2TexturePipelineStepCompress.js +1 -1
- package/dist/resource/texture/Tr2TexturePipelineStepCompress.js.map +1 -0
- package/dist/{resources → resource/texture}/Tr2TexturePipelineStepGenerateMips.js +1 -1
- package/dist/resource/texture/Tr2TexturePipelineStepGenerateMips.js.map +1 -0
- package/dist/{resources → resource/texture}/Tr2TexturePipelineStepLimitSize.js +1 -1
- package/dist/resource/texture/Tr2TexturePipelineStepLimitSize.js.map +1 -0
- package/dist/{resources → resource/texture}/Tr2TexturePipelineStepLoad.js +1 -1
- package/dist/resource/texture/Tr2TexturePipelineStepLoad.js.map +1 -0
- package/dist/{resources → resource/texture}/Tr2TexturePipelineStepPack.js +1 -1
- package/dist/resource/texture/Tr2TexturePipelineStepPack.js.map +1 -0
- package/dist/{resources → resource/texture}/TriTextureRes.js +42 -26
- package/dist/resource/texture/TriTextureRes.js.map +1 -0
- package/dist/resource/texture/index.js +15 -0
- package/dist/resource/texture/index.js.map +1 -0
- package/dist/{resources → resource/texture}/texturePipelineBehavior.js +59 -59
- package/dist/resource/texture/texturePipelineBehavior.js.map +1 -0
- package/dist/worker/CjsResManMainThreadLoader.js +87 -0
- package/dist/worker/CjsResManMainThreadLoader.js.map +1 -0
- package/dist/worker/CjsResManWorker.js +217 -0
- package/dist/worker/CjsResManWorker.js.map +1 -0
- package/dist/worker/CjsResManWorkerLoader.js +434 -0
- package/dist/worker/CjsResManWorkerLoader.js.map +1 -0
- package/dist/worker/protocol.js +12 -0
- package/dist/worker/protocol.js.map +1 -0
- package/docs/README.md +16 -3
- package/docs/architecture.md +39 -16
- package/docs/concepts/resource-lifecycle.md +2 -1
- package/docs/formats/README.md +8 -0
- package/docs/formats/provenance.md +11 -3
- package/docs/reference/classes/README.md +6 -4
- package/docs/reference/classes/audio.md +30 -0
- package/docs/reference/classes/core.md +31 -11
- package/docs/reference/classes/formats.md +440 -0
- package/docs/reference/classes/resources.md +151 -41
- package/docs/reference/classes/texture.md +7 -7
- package/docs/reference/motherlode-cache.md +17 -0
- package/docs/reference/queues.md +9 -1
- package/docs/reference/workers.md +135 -0
- package/docs/roadmap.md +27 -1
- package/format-notices/dxbc/LICENSE +21 -0
- package/format-notices/dxbc/NOTICE +20 -0
- package/format-notices/hlsl/LICENSE +21 -0
- package/format-notices/hlsl/NOTICE +25 -0
- package/format-notices/webgl/LICENSE +21 -0
- package/format-notices/webgl/NOTICE +35 -0
- package/format-notices/webgpu/LICENSE +21 -0
- package/format-notices/webgpu/NOTICE +31 -0
- package/package.json +13 -1
- package/dist/CjsResManQueue.js.map +0 -1
- package/dist/CjsResource.js.map +0 -1
- package/dist/CjsResourceSource.js +0 -68
- package/dist/CjsResourceSource.js.map +0 -1
- package/dist/resourcePath.js +0 -18
- package/dist/resourcePath.js.map +0 -1
- package/dist/resourceStates.js +0 -9
- package/dist/resourceStates.js.map +0 -1
- package/dist/resources/AudioGeometryResData.js.map +0 -1
- package/dist/resources/GStateBindingCallbackData.js.map +0 -1
- package/dist/resources/MeshDecalData.js.map +0 -1
- package/dist/resources/MeshDecalLodData.js.map +0 -1
- package/dist/resources/Tr2EffectRes.js +0 -71
- package/dist/resources/Tr2EffectRes.js.map +0 -1
- package/dist/resources/Tr2GrannyIntersectionResult.js.map +0 -1
- package/dist/resources/Tr2GrannyStateRes.js.map +0 -1
- package/dist/resources/Tr2ImageRes.js.map +0 -1
- package/dist/resources/Tr2LightProfileRes.js.map +0 -1
- package/dist/resources/Tr2MaterialArea.js +0 -34
- package/dist/resources/Tr2MaterialArea.js.map +0 -1
- package/dist/resources/Tr2MaterialMesh.js +0 -31
- package/dist/resources/Tr2MaterialMesh.js.map +0 -1
- package/dist/resources/Tr2MaterialRes.js +0 -34
- package/dist/resources/Tr2MaterialRes.js.map +0 -1
- package/dist/resources/Tr2ShaderPermutation.js +0 -43
- package/dist/resources/Tr2ShaderPermutation.js.map +0 -1
- package/dist/resources/Tr2TextureLodManager.js.map +0 -1
- package/dist/resources/Tr2TextureLodUpdateRequest.js.map +0 -1
- package/dist/resources/Tr2TexturePackChannel.js.map +0 -1
- package/dist/resources/Tr2TexturePipeline.js.map +0 -1
- package/dist/resources/Tr2TexturePipelineParams.js.map +0 -1
- package/dist/resources/Tr2TexturePipelineStepCompress.js.map +0 -1
- package/dist/resources/Tr2TexturePipelineStepGenerateMips.js.map +0 -1
- package/dist/resources/Tr2TexturePipelineStepLimitSize.js.map +0 -1
- package/dist/resources/Tr2TexturePipelineStepLoad.js.map +0 -1
- package/dist/resources/Tr2TexturePipelineStepPack.js.map +0 -1
- package/dist/resources/TriGeometryRes.js +0 -239
- package/dist/resources/TriGeometryRes.js.map +0 -1
- package/dist/resources/TriGeometryResAreaData.js.map +0 -1
- package/dist/resources/TriGeometryResJointData.js.map +0 -1
- package/dist/resources/TriGeometryResLodData.js.map +0 -1
- package/dist/resources/TriGeometryResMeshData.js.map +0 -1
- package/dist/resources/TriGeometryResSkeletonData.js.map +0 -1
- package/dist/resources/TriGrannyRes.js.map +0 -1
- package/dist/resources/TriJointBinding.js.map +0 -1
- package/dist/resources/TriMorphTargetGeometryConstants.js.map +0 -1
- package/dist/resources/TriRtGeometryConstants.js.map +0 -1
- package/dist/resources/TriTextureRes.js.map +0 -1
- package/dist/resources/enums.js.map +0 -1
- package/dist/resources/resourceBoundary.js +0 -47
- package/dist/resources/resourceBoundary.js.map +0 -1
- package/dist/resources/texturePipelineBehavior.js.map +0 -1
- package/dist/texture/CjsTextureArrayRes.js.map +0 -1
- package/dist/texture/CjsTextureParameterProxy.js.map +0 -1
|
@@ -0,0 +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;AAC3F,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Format.js';
|
|
2
|
+
import { analyzeRegisterValues, operandRoles } from './analyzeRegisterValues.js';
|
|
3
|
+
import { buildControlFlow } from './buildControlFlow.js';
|
|
4
|
+
import { resolveRegisterFlow } from './resolveRegisterFlow.js';
|
|
5
|
+
import { inferValueTypes, SCALAR_TYPES } from './inferValueTypes.js';
|
|
6
|
+
|
|
7
|
+
const SHADER_IR_FORMAT = "CJS_SHADER_IR";
|
|
8
|
+
const SHADER_IR_VERSION = 1;
|
|
9
|
+
const PRECISE_MASK = /^x?y?z?w?$/u;
|
|
10
|
+
const BINDING_KINDS = Object.freeze({
|
|
11
|
+
dcl_constant_buffer: "uniform-buffer",
|
|
12
|
+
dcl_sampler: "sampler",
|
|
13
|
+
dcl_resource: "sampled-resource",
|
|
14
|
+
dcl_resource_raw: "sampled-resource",
|
|
15
|
+
dcl_resource_structured: "sampled-resource",
|
|
16
|
+
dcl_unordered_access_view_typed: "storage-resource",
|
|
17
|
+
dcl_unordered_access_view_raw: "storage-resource",
|
|
18
|
+
dcl_unordered_access_view_structured: "storage-resource"
|
|
19
|
+
});
|
|
20
|
+
const BLOCK_BEFORE = new Set(["loop", "else", "endif", "endloop", "case", "default", "endswitch"]);
|
|
21
|
+
const BLOCK_AFTER = new Set(["if", "loop", "switch", "break", "breakc", "continue", "continuec", "ret", "retc", "discard", "else", "endif", "endloop", "case", "default", "endswitch"]);
|
|
22
|
+
function clonePlain(value) {
|
|
23
|
+
if (value === null || value === undefined) return value ?? null;
|
|
24
|
+
if (ArrayBuffer.isView(value)) return Array.from(value);
|
|
25
|
+
if (Array.isArray(value)) return value.map(clonePlain);
|
|
26
|
+
if (typeof value === "object") {
|
|
27
|
+
const out = {};
|
|
28
|
+
for (const [key, entry] of Object.entries(value)) out[key] = clonePlain(entry);
|
|
29
|
+
return out;
|
|
30
|
+
}
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
function readDecoded(input, options) {
|
|
34
|
+
if (input instanceof Uint8Array || input instanceof ArrayBuffer || ArrayBuffer.isView(input)) {
|
|
35
|
+
const raw = CjsDxbcFormat.read(input, {
|
|
36
|
+
emit: CjsDxbcFormat.OUTPUT_RAW,
|
|
37
|
+
source: options.source || "memory",
|
|
38
|
+
decodeInstructions: true
|
|
39
|
+
});
|
|
40
|
+
return {
|
|
41
|
+
program: raw.program,
|
|
42
|
+
instructions: raw.decoder?.instructions || [],
|
|
43
|
+
signatures: {
|
|
44
|
+
input: raw.inputSignature?.elements || [],
|
|
45
|
+
output: raw.outputSignature?.elements || [],
|
|
46
|
+
patch: raw.patchSignature?.elements || []
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
if (input?.program && input?.decoder) {
|
|
51
|
+
return {
|
|
52
|
+
program: input.program,
|
|
53
|
+
instructions: input.decoder.instructions || [],
|
|
54
|
+
signatures: {
|
|
55
|
+
input: input.inputSignature?.elements || input.signatures?.input || [],
|
|
56
|
+
output: input.outputSignature?.elements || input.signatures?.output || [],
|
|
57
|
+
patch: input.patchSignature?.elements || input.signatures?.patch || []
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
if (input?.program && Array.isArray(input.instructions)) {
|
|
62
|
+
return {
|
|
63
|
+
program: input.program,
|
|
64
|
+
instructions: input.instructions,
|
|
65
|
+
signatures: input.signatures || {}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
throw new TypeError("CjsWebgpuFormat.BuildShaderIr: expected DXBC bytes or decoded program/instructions");
|
|
69
|
+
}
|
|
70
|
+
function normalizedRange(declaration) {
|
|
71
|
+
if (declaration.bindingRange) return clonePlain(declaration.bindingRange);
|
|
72
|
+
const registerIndex = declaration.registerIndex ?? null;
|
|
73
|
+
return {
|
|
74
|
+
bindingModel: "sm5.0-register",
|
|
75
|
+
rangeId: null,
|
|
76
|
+
lowerBound: registerIndex,
|
|
77
|
+
upperBound: registerIndex,
|
|
78
|
+
unbounded: false,
|
|
79
|
+
registerCount: registerIndex === null ? 0 : 1,
|
|
80
|
+
registerSpace: 0
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function buildBinding(instruction) {
|
|
84
|
+
const resourceKind = BINDING_KINDS[instruction.opcodeName];
|
|
85
|
+
if (!resourceKind) return null;
|
|
86
|
+
const declaration = instruction.declaration || {};
|
|
87
|
+
const range = normalizedRange(declaration);
|
|
88
|
+
return {
|
|
89
|
+
kind: "binding",
|
|
90
|
+
id: `${resourceKind}:space${range.registerSpace}:range${range.rangeId ?? range.lowerBound}`,
|
|
91
|
+
resourceKind,
|
|
92
|
+
operandType: instruction.operands?.[0]?.typeName || null,
|
|
93
|
+
declarationOffset: instruction.offset,
|
|
94
|
+
registerIndex: declaration.registerIndex ?? range.lowerBound,
|
|
95
|
+
range,
|
|
96
|
+
accessPattern: declaration.accessPattern || null,
|
|
97
|
+
resourceDimension: declaration.resourceDimensionName || null,
|
|
98
|
+
structureStride: declaration.structureStride ?? null,
|
|
99
|
+
returnType: clonePlain(declaration.returnType || null)
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function controlKind(opcodeName) {
|
|
103
|
+
if (["if", "else", "endif"].includes(opcodeName)) return "selection";
|
|
104
|
+
if (["loop", "endloop", "break", "breakc", "continue", "continuec"].includes(opcodeName)) return "loop";
|
|
105
|
+
if (["switch", "case", "default", "endswitch"].includes(opcodeName)) return "switch";
|
|
106
|
+
if (["ret", "retc", "discard", "abort"].includes(opcodeName)) return "termination";
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
const COMPONENT_ORDER = ["x", "y", "z", "w"];
|
|
110
|
+
const FLOAT_VIEW = new DataView(new ArrayBuffer(4));
|
|
111
|
+
function immediateRecord(value) {
|
|
112
|
+
const bits = (value?.uint32 ?? 0) >>> 0;
|
|
113
|
+
FLOAT_VIEW.setUint32(0, bits);
|
|
114
|
+
return {
|
|
115
|
+
uint32: bits,
|
|
116
|
+
float32: FLOAT_VIEW.getFloat32(0)
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Recognizes indexable temps that are immutable constant tables: every write
|
|
122
|
+
* is a straight-line pre-control-flow `mov x#[slot].mask, l(...)` immediate,
|
|
123
|
+
* and at least one access uses relative addressing. Such registers lower to a
|
|
124
|
+
* module-scope WGSL `const` array (the same shape as the DXBC icb), so their
|
|
125
|
+
* dynamic reads never need mutable-register SSA. Any relative indexable-temp
|
|
126
|
+
* usage that does not fit this shape fails closed here with a diagnostic.
|
|
127
|
+
*
|
|
128
|
+
* @param {object[]} declarationInstructions Decoded declaration instructions.
|
|
129
|
+
* @param {object[]} executable Decoded executable instructions.
|
|
130
|
+
* @returns {{tables: object[]|null, removed: Set<number>|null}} Tables and initializer indices.
|
|
131
|
+
*/
|
|
132
|
+
function extractConstTables(declarationInstructions, executable) {
|
|
133
|
+
const declared = new Map();
|
|
134
|
+
const duplicateDeclarations = new Set();
|
|
135
|
+
for (const declaration of declarationInstructions) {
|
|
136
|
+
if (declaration.opcodeName !== "dcl_indexable_temp") continue;
|
|
137
|
+
const data = declaration.declaration || {};
|
|
138
|
+
if (declared.has(data.registerIndex)) duplicateDeclarations.add(data.registerIndex);
|
|
139
|
+
declared.set(data.registerIndex, {
|
|
140
|
+
slotCount: data.registerCount,
|
|
141
|
+
componentCount: data.componentCount
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
const touched = new Map();
|
|
145
|
+
const entryFor = registerIndex => {
|
|
146
|
+
let entry = touched.get(registerIndex);
|
|
147
|
+
if (!entry) {
|
|
148
|
+
entry = {
|
|
149
|
+
writes: [],
|
|
150
|
+
hasRelative: false,
|
|
151
|
+
invalid: null
|
|
152
|
+
};
|
|
153
|
+
touched.set(registerIndex, entry);
|
|
154
|
+
}
|
|
155
|
+
return entry;
|
|
156
|
+
};
|
|
157
|
+
const invalidate = (entry, reason) => {
|
|
158
|
+
if (!entry.invalid) entry.invalid = reason;
|
|
159
|
+
};
|
|
160
|
+
let firstControl = executable.findIndex(instruction => controlKind(instruction.opcodeName) !== null);
|
|
161
|
+
if (firstControl < 0) firstControl = executable.length;
|
|
162
|
+
executable.forEach((instruction, instructionIndex) => {
|
|
163
|
+
operandRoles(instruction).forEach(({
|
|
164
|
+
operand,
|
|
165
|
+
role
|
|
166
|
+
}, operandIndex) => {
|
|
167
|
+
if (operand.typeName !== "indexable_temp") return;
|
|
168
|
+
const indices = operand.indices || [];
|
|
169
|
+
const registerIndex = indices[0]?.values?.[0];
|
|
170
|
+
const entry = entryFor(registerIndex);
|
|
171
|
+
if (indices.length !== 2 || indices[0]?.relative || indices[0]?.values?.length !== 1 || !Number.isInteger(registerIndex) || registerIndex < 0 || operand.registerIndex !== registerIndex) {
|
|
172
|
+
return invalidate(entry, "requires one consistent fixed register identity and [register][slot] addressing");
|
|
173
|
+
}
|
|
174
|
+
if (indices[1]?.relative) entry.hasRelative = true;
|
|
175
|
+
if (role === "source") {
|
|
176
|
+
const lanes = operand.selected ? [operand.selected] : operand.swizzle ? Array.from(new Set(operand.swizzle)) : COMPONENT_ORDER.slice();
|
|
177
|
+
entry.reads = entry.reads || [];
|
|
178
|
+
entry.reads.push({
|
|
179
|
+
instructionIndex,
|
|
180
|
+
lanes
|
|
181
|
+
});
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Destination use: only straight-line immediate table initializers
|
|
186
|
+
// are representable; anything else is a mutable indexable temp.
|
|
187
|
+
const source = instruction.operands?.[1];
|
|
188
|
+
const slot = indices[1]?.values?.[0];
|
|
189
|
+
if (instruction.opcodeName !== "mov" || instruction.saturate) {
|
|
190
|
+
return invalidate(entry, "is only writable by non-saturating mov initializers");
|
|
191
|
+
}
|
|
192
|
+
if (instructionIndex >= firstControl) {
|
|
193
|
+
return invalidate(entry, "initializers must precede all control flow");
|
|
194
|
+
}
|
|
195
|
+
if (indices[1]?.relative || indices[1]?.values?.length !== 1 || !Number.isInteger(slot) || slot < 0) {
|
|
196
|
+
return invalidate(entry, "initializers require an immediate slot index");
|
|
197
|
+
}
|
|
198
|
+
if (source?.typeName !== "immediate32" || (source.modifierName || "none") !== "none" || ![1, 4].includes(source.immediateValues?.length ?? 0)) {
|
|
199
|
+
return invalidate(entry, "initializers require immediate32 sources");
|
|
200
|
+
}
|
|
201
|
+
if ((operand.modifierName || "none") !== "none" || (operand.minPrecisionName || "default") !== "default" || (source.minPrecisionName || "default") !== "default" || instruction.extensions?.length) {
|
|
202
|
+
return invalidate(entry, "initializers require canonical default-precision mov operands");
|
|
203
|
+
}
|
|
204
|
+
if (!operand.mask || operand.swizzle || operand.selected || source.mask || source.swizzle && source.selected || source.selected && !COMPONENT_ORDER.includes(source.selected) || source.swizzle && (source.swizzle.length !== 4 || Array.from(source.swizzle).some(lane => !COMPONENT_ORDER.includes(lane)))) {
|
|
205
|
+
return invalidate(entry, "initializers require canonical destination and source component selection");
|
|
206
|
+
}
|
|
207
|
+
const valuesByLane = {};
|
|
208
|
+
for (const lane of operand.mask) {
|
|
209
|
+
const destinationLane = COMPONENT_ORDER.indexOf(lane);
|
|
210
|
+
const sourceLane = source.selected || source.swizzle?.[destinationLane] || lane;
|
|
211
|
+
const sourceLaneIndex = COMPONENT_ORDER.indexOf(sourceLane);
|
|
212
|
+
const value = source.immediateValues.length === 1 ? source.immediateValues[0] : source.immediateValues[sourceLaneIndex];
|
|
213
|
+
if (!value) {
|
|
214
|
+
return invalidate(entry, "an initializer selects an unavailable immediate lane");
|
|
215
|
+
}
|
|
216
|
+
valuesByLane[lane] = value;
|
|
217
|
+
}
|
|
218
|
+
entry.writes.push({
|
|
219
|
+
instructionIndex,
|
|
220
|
+
slot,
|
|
221
|
+
mask: operand.mask,
|
|
222
|
+
valuesByLane
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
const tables = [];
|
|
227
|
+
const removed = new Set();
|
|
228
|
+
for (const [registerIndex, entry] of touched) {
|
|
229
|
+
if (!entry.hasRelative) continue;
|
|
230
|
+
const declaration = declared.get(registerIndex);
|
|
231
|
+
const describe = reason => new Error(`Shader IR indexable temp x${registerIndex} relative addressing is not supported: ${reason}`);
|
|
232
|
+
if (entry.invalid) throw describe(entry.invalid);
|
|
233
|
+
if (duplicateDeclarations.has(registerIndex)) throw describe("it has duplicate declarations");
|
|
234
|
+
if (!declaration || !Number.isInteger(declaration.slotCount) || declaration.slotCount < 1) {
|
|
235
|
+
throw describe("it has no usable declaration");
|
|
236
|
+
}
|
|
237
|
+
if (!Number.isInteger(declaration.componentCount) || declaration.componentCount < 1 || declaration.componentCount > 4) {
|
|
238
|
+
throw describe("it has an invalid component count");
|
|
239
|
+
}
|
|
240
|
+
const lastWrite = Math.max(...entry.writes.map(write => write.instructionIndex));
|
|
241
|
+
const firstRead = Math.min(...(entry.reads || []).map(read => read.instructionIndex));
|
|
242
|
+
if (lastWrite >= firstRead) {
|
|
243
|
+
throw describe("all initializers must precede every read");
|
|
244
|
+
}
|
|
245
|
+
const laneMask = entry.writes[0]?.mask;
|
|
246
|
+
if (Array.from(laneMask || "").some(lane => COMPONENT_ORDER.indexOf(lane) >= declaration.componentCount)) {
|
|
247
|
+
throw describe("an initializer writes outside the declared component range");
|
|
248
|
+
}
|
|
249
|
+
const rows = Array.from({
|
|
250
|
+
length: declaration.slotCount
|
|
251
|
+
}, () => COMPONENT_ORDER.map(() => null));
|
|
252
|
+
for (const write of entry.writes) {
|
|
253
|
+
if (write.mask !== laneMask) throw describe("initializers must share one write mask");
|
|
254
|
+
if (write.slot < 0 || write.slot >= declaration.slotCount) {
|
|
255
|
+
throw describe("an initializer writes outside the declared range");
|
|
256
|
+
}
|
|
257
|
+
for (const lane of write.mask) {
|
|
258
|
+
const laneIndex = COMPONENT_ORDER.indexOf(lane);
|
|
259
|
+
if (rows[write.slot][laneIndex] !== null) throw describe("a slot lane is written twice");
|
|
260
|
+
rows[write.slot][laneIndex] = immediateRecord(write.valuesByLane[lane]);
|
|
261
|
+
}
|
|
262
|
+
removed.add(write.instructionIndex);
|
|
263
|
+
}
|
|
264
|
+
for (const [slot, row] of rows.entries()) {
|
|
265
|
+
for (const lane of laneMask || "") {
|
|
266
|
+
if (row[COMPONENT_ORDER.indexOf(lane)] === null) {
|
|
267
|
+
throw describe(`slot ${slot} is never fully written`);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
for (const read of entry.reads || []) {
|
|
272
|
+
if (read.lanes.some(lane => !(laneMask || "").includes(lane))) {
|
|
273
|
+
throw describe("a read selects lanes the table never writes");
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
tables.push(Object.freeze({
|
|
277
|
+
kind: "const-table",
|
|
278
|
+
registerIndex,
|
|
279
|
+
symbol: `xt${registerIndex}`,
|
|
280
|
+
slotCount: declaration.slotCount,
|
|
281
|
+
laneMask: laneMask || "",
|
|
282
|
+
rows: rows.map(row => row.map(value => value ?? {
|
|
283
|
+
uint32: 0,
|
|
284
|
+
float32: 0
|
|
285
|
+
}))
|
|
286
|
+
}));
|
|
287
|
+
}
|
|
288
|
+
return tables.length ? {
|
|
289
|
+
tables,
|
|
290
|
+
removed
|
|
291
|
+
} : {
|
|
292
|
+
tables: null,
|
|
293
|
+
removed: null
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
function buildInstruction(instruction, index) {
|
|
297
|
+
return {
|
|
298
|
+
kind: "instruction",
|
|
299
|
+
index,
|
|
300
|
+
dxbcOffset: instruction.offset,
|
|
301
|
+
opcode: instruction.opcode,
|
|
302
|
+
opcodeName: instruction.opcodeName,
|
|
303
|
+
controlKind: controlKind(instruction.opcodeName),
|
|
304
|
+
testBoolean: instruction.testBoolean || null,
|
|
305
|
+
saturate: !!instruction.saturate,
|
|
306
|
+
preciseMask: instruction.preciseMask || "",
|
|
307
|
+
...(instruction.opcodeName === "resinfo" ? {
|
|
308
|
+
resinfoReturnTypeName: instruction.resinfoReturnTypeName || "float"
|
|
309
|
+
} : {}),
|
|
310
|
+
...(instruction.opcodeName === "sync" ? {
|
|
311
|
+
syncFlags: Number.isInteger(instruction.syncFlags) ? instruction.syncFlags : null,
|
|
312
|
+
syncFlagNames: Array.isArray(instruction.syncFlagNames) ? clonePlain(instruction.syncFlagNames) : null
|
|
313
|
+
} : {}),
|
|
314
|
+
...(instruction.extensions?.length ? {
|
|
315
|
+
extensions: clonePlain(instruction.extensions)
|
|
316
|
+
} : {}),
|
|
317
|
+
...(instruction.tailTokens?.length ? {
|
|
318
|
+
tailTokens: clonePlain(instruction.tailTokens)
|
|
319
|
+
} : {}),
|
|
320
|
+
operands: clonePlain(instruction.operands || [])
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
function buildBlocks(instructions) {
|
|
324
|
+
if (instructions.length === 0) return [];
|
|
325
|
+
const leaders = new Set([0]);
|
|
326
|
+
for (let index = 0; index < instructions.length; index += 1) {
|
|
327
|
+
if (BLOCK_BEFORE.has(instructions[index].opcodeName)) leaders.add(index);
|
|
328
|
+
if (BLOCK_AFTER.has(instructions[index].opcodeName) && index + 1 < instructions.length) leaders.add(index + 1);
|
|
329
|
+
}
|
|
330
|
+
const starts = Array.from(leaders).sort((a, b) => a - b);
|
|
331
|
+
return starts.map((start, blockIndex) => {
|
|
332
|
+
const end = (starts[blockIndex + 1] ?? instructions.length) - 1;
|
|
333
|
+
const last = instructions[end];
|
|
334
|
+
return {
|
|
335
|
+
kind: "basic-block",
|
|
336
|
+
id: `block${blockIndex}`,
|
|
337
|
+
index: blockIndex,
|
|
338
|
+
startInstruction: start,
|
|
339
|
+
endInstruction: end,
|
|
340
|
+
startDxbcOffset: instructions[start].dxbcOffset,
|
|
341
|
+
endDxbcOffset: last.dxbcOffset,
|
|
342
|
+
instructionIndices: Array.from({
|
|
343
|
+
length: end - start + 1
|
|
344
|
+
}, (_, offset) => start + offset),
|
|
345
|
+
terminator: last.controlKind ? last.opcodeName : null
|
|
346
|
+
};
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
function validateProgram(program) {
|
|
350
|
+
if (!program.stage || !Number.isInteger(program.shaderModel.major)) {
|
|
351
|
+
throw new Error("Invalid shader IR program identity");
|
|
352
|
+
}
|
|
353
|
+
for (let index = 1; index < program.instructions.length; index += 1) {
|
|
354
|
+
if (program.instructions[index].dxbcOffset <= program.instructions[index - 1].dxbcOffset) {
|
|
355
|
+
throw new Error("Shader IR instruction offsets must be strictly increasing");
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
const covered = program.blocks.flatMap(block => block.instructionIndices);
|
|
359
|
+
if (covered.length !== program.instructions.length || covered.some((value, index) => value !== index)) {
|
|
360
|
+
throw new Error("Shader IR basic blocks must cover every executable instruction exactly once");
|
|
361
|
+
}
|
|
362
|
+
const blockIds = new Set(program.blocks.map(block => block.id));
|
|
363
|
+
for (const block of program.blocks) {
|
|
364
|
+
if (block.successors.some(edge => !blockIds.has(edge.blockId))) {
|
|
365
|
+
throw new Error("Shader IR control-flow edge references an unknown block");
|
|
366
|
+
}
|
|
367
|
+
for (const edge of block.successors) {
|
|
368
|
+
const successor = program.blocks.find(entry => entry.id === edge.blockId);
|
|
369
|
+
if (!successor.predecessors.some(entry => entry.blockId === block.id && entry.kind === edge.kind)) {
|
|
370
|
+
throw new Error("Shader IR control-flow successor/predecessor edges must be symmetric");
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
const bindingIds = new Set();
|
|
375
|
+
for (const binding of program.bindings) {
|
|
376
|
+
if (bindingIds.has(binding.id)) throw new Error(`Duplicate shader IR binding ${binding.id}`);
|
|
377
|
+
bindingIds.add(binding.id);
|
|
378
|
+
}
|
|
379
|
+
const valueIds = new Set(program.values.map(value => value.id));
|
|
380
|
+
const valuesById = new Map(program.values.map(value => [value.id, value]));
|
|
381
|
+
if (valueIds.size !== program.values.length) throw new Error("Shader IR register value ids must be unique");
|
|
382
|
+
for (const block of program.blocks) {
|
|
383
|
+
if (block.inputValueIds.some(id => !valueIds.has(id))) {
|
|
384
|
+
throw new Error("Shader IR block input references an unknown value");
|
|
385
|
+
}
|
|
386
|
+
if (block.outputValues.some(output => !valueIds.has(output.ref.valueId))) {
|
|
387
|
+
throw new Error("Shader IR block output references an unknown value");
|
|
388
|
+
}
|
|
389
|
+
if (block.mergeSite?.valueIds?.some(id => !valueIds.has(id) || valuesById.get(id).origin !== "control-flow-merge" || valuesById.get(id).blockId !== block.id)) {
|
|
390
|
+
throw new Error("Shader IR merge site references an invalid merge value");
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
for (const instruction of program.instructions) {
|
|
394
|
+
if (!instruction.dataflow) throw new Error("Shader IR instruction is missing register dataflow");
|
|
395
|
+
const refs = [...instruction.dataflow.reads.flatMap(read => read.refs), ...instruction.dataflow.writes.flatMap(write => [{
|
|
396
|
+
valueId: write.valueId
|
|
397
|
+
}, ...Object.values(write.previous || {}), ...Object.values(write.result || {})])];
|
|
398
|
+
if (refs.some(ref => !valueIds.has(ref.valueId))) {
|
|
399
|
+
throw new Error("Shader IR register dataflow references an unknown value");
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
for (const value of program.values) {
|
|
403
|
+
if (value.origin === "block-input") throw new Error("Shader IR contains an unresolved block input");
|
|
404
|
+
if (value.origin === "control-flow-merge") {
|
|
405
|
+
if (value.incoming.length < 2) throw new Error("Shader IR merge value must have at least two incoming values");
|
|
406
|
+
if (value.incoming.some(incoming => !valueIds.has(incoming.valueId))) {
|
|
407
|
+
throw new Error("Shader IR merge value references an unknown incoming value");
|
|
408
|
+
}
|
|
409
|
+
if (value.incoming.some(incoming => incoming.component !== value.writeMask || valuesById.get(incoming.valueId).register !== value.register)) {
|
|
410
|
+
throw new Error("Shader IR merge value has an incompatible incoming register component");
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
if (!value.componentTypes || Object.values(value.componentTypes).some(type => !SCALAR_TYPES.includes(type))) {
|
|
414
|
+
throw new Error("Shader IR register value has an invalid component type");
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
for (const instruction of program.instructions) {
|
|
418
|
+
if (!instruction.typeInfo) throw new Error("Shader IR instruction is missing type information");
|
|
419
|
+
if (typeof instruction.preciseMask !== "string" || !PRECISE_MASK.test(instruction.preciseMask)) {
|
|
420
|
+
throw new Error(`Shader IR instruction ${instruction.index} has an invalid precise component mask`);
|
|
421
|
+
}
|
|
422
|
+
if (instruction.typeInfo.bitcasts.some(bitcast => !SCALAR_TYPES.includes(bitcast.from) || !SCALAR_TYPES.includes(bitcast.to))) {
|
|
423
|
+
throw new Error("Shader IR instruction has an invalid bitcast type");
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
function deepFreeze(value) {
|
|
428
|
+
if (!value || typeof value !== "object" || Object.isFrozen(value)) return value;
|
|
429
|
+
for (const entry of Object.values(value)) deepFreeze(entry);
|
|
430
|
+
return Object.freeze(value);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Lowers decoded DXBC framing into the stable front-end shader IR.
|
|
435
|
+
* Type inference and SSA value reconstruction are later passes.
|
|
436
|
+
*
|
|
437
|
+
* @param {Uint8Array|ArrayBuffer|ArrayBufferView|object} input DXBC bytes or decoded result.
|
|
438
|
+
* @param {object} [options] IR provenance options.
|
|
439
|
+
* @returns {object} Frozen, validated shader IR program.
|
|
440
|
+
*/
|
|
441
|
+
function lowerDxbcToIr(input, options = {}) {
|
|
442
|
+
const decoded = readDecoded(input, options);
|
|
443
|
+
if (!decoded.program) throw new Error("DXBC input has no shader program");
|
|
444
|
+
const declarationInstructions = decoded.instructions.filter(instruction => instruction.isDeclaration);
|
|
445
|
+
let executable = decoded.instructions.filter(instruction => !instruction.isDeclaration);
|
|
446
|
+
const constTableExtraction = extractConstTables(declarationInstructions, executable);
|
|
447
|
+
if (constTableExtraction.removed) {
|
|
448
|
+
executable = executable.filter((_, index) => !constTableExtraction.removed.has(index));
|
|
449
|
+
}
|
|
450
|
+
const instructions = executable.map(buildInstruction);
|
|
451
|
+
const icbInstruction = declarationInstructions.find(instruction => instruction.customData?.immediateConstantBuffer);
|
|
452
|
+
const immediateConstantBuffer = icbInstruction ? clonePlain(icbInstruction.customData.immediateConstantBuffer) : null;
|
|
453
|
+
const program = {
|
|
454
|
+
kind: "shader-program",
|
|
455
|
+
format: SHADER_IR_FORMAT,
|
|
456
|
+
formatVersion: SHADER_IR_VERSION,
|
|
457
|
+
source: options.source || decoded.program.source || "memory",
|
|
458
|
+
stage: decoded.program.programTypeName,
|
|
459
|
+
programType: decoded.program.programType,
|
|
460
|
+
shaderModel: {
|
|
461
|
+
major: decoded.program.majorVersion,
|
|
462
|
+
minor: decoded.program.minorVersion
|
|
463
|
+
},
|
|
464
|
+
signatures: {
|
|
465
|
+
input: clonePlain(decoded.signatures?.input || []),
|
|
466
|
+
output: clonePlain(decoded.signatures?.output || []),
|
|
467
|
+
patch: clonePlain(decoded.signatures?.patch || [])
|
|
468
|
+
},
|
|
469
|
+
declarations: declarationInstructions.map(instruction => ({
|
|
470
|
+
kind: "declaration",
|
|
471
|
+
dxbcOffset: instruction.offset,
|
|
472
|
+
opcodeName: instruction.opcodeName,
|
|
473
|
+
data: clonePlain(instruction.declaration),
|
|
474
|
+
operands: clonePlain(instruction.operands || []),
|
|
475
|
+
...(instruction.tailTokens?.length ? {
|
|
476
|
+
tailTokens: clonePlain(instruction.tailTokens)
|
|
477
|
+
} : {})
|
|
478
|
+
})),
|
|
479
|
+
bindings: declarationInstructions.map(buildBinding).filter(Boolean),
|
|
480
|
+
immediateConstantBuffer,
|
|
481
|
+
constTables: constTableExtraction.tables,
|
|
482
|
+
instructions,
|
|
483
|
+
blocks: buildBlocks(instructions)
|
|
484
|
+
};
|
|
485
|
+
buildControlFlow(program);
|
|
486
|
+
analyzeRegisterValues(program);
|
|
487
|
+
resolveRegisterFlow(program);
|
|
488
|
+
inferValueTypes(program);
|
|
489
|
+
validateProgram(program);
|
|
490
|
+
return deepFreeze(program);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
export { SHADER_IR_FORMAT, SHADER_IR_VERSION, lowerDxbcToIr };
|
|
494
|
+
//# sourceMappingURL=lowerDxbcToIr.js.map
|