@carbonenginejs/runtime-resource 0.12.2 → 0.13.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/LICENSE +21 -21
- package/NOTICE +32 -32
- package/README.md +129 -108
- package/dist/CjsMotherLode.js +1271 -1271
- package/dist/CjsResMan.js +3858 -3494
- package/dist/CjsResMan.js.map +1 -1
- package/dist/CjsResManFetchProvider.js +94 -94
- package/dist/CjsResManWorkQueue.js +301 -301
- package/dist/_virtual/_rollupPluginBabelHelpers.js +150 -150
- package/dist/format/CjsBlueReader.js +358 -358
- package/dist/format/CjsByteReader.js +310 -310
- package/dist/format/CjsByteWriter.js +242 -242
- package/dist/format/CjsFormat.js +223 -223
- package/dist/format/CjsFormatError.js +41 -41
- package/dist/format/CjsReader.js +22 -22
- package/dist/format/CjsResourceProbe.js +279 -279
- package/dist/format/CjsStringTable.js +268 -268
- package/dist/format/carbonEffect/CjsCarbonEffectReader.js +408 -361
- package/dist/format/carbonEffect/CjsCarbonEffectReader.js.map +1 -1
- package/dist/format/carbonEffect/CjsCarbonEffectWriter.js +373 -373
- package/dist/format/carbonEffect/buildCarbonEffectContainer.js +182 -0
- package/dist/format/carbonEffect/buildCarbonEffectContainer.js.map +1 -0
- package/dist/format/carbonEffect/carbonEffectBackendBlock.js +321 -427
- package/dist/format/carbonEffect/carbonEffectBackendBlock.js.map +1 -1
- package/dist/format/carbonEffect/carbonEffectRecords.js +1147 -955
- package/dist/format/carbonEffect/carbonEffectRecords.js.map +1 -1
- package/dist/format/carbonEffect/carbonEffectResourceTransform.js +197 -0
- package/dist/format/carbonEffect/carbonEffectResourceTransform.js.map +1 -0
- package/dist/format/compareUtf8.js +36 -36
- package/dist/format/effect/effectBodyInventory.js +146 -0
- package/dist/format/effect/effectBodyInventory.js.map +1 -0
- package/dist/format/effect/effectPermutationGraph.js +257 -257
- package/dist/format/effect/effectPermutationGraph.js.map +1 -1
- package/dist/format/effect/sha256.js +114 -114
- package/dist/format/index.js +11 -11
- package/dist/format/payloadContract.js +193 -193
- package/dist/formats/black/CjsBlackFormat.js +310 -292
- package/dist/formats/black/CjsBlackFormat.js.map +1 -1
- package/dist/formats/black/core/CjsBlackBinaryReader.js +260 -260
- package/dist/formats/black/core/CjsBlackPropertyReaders.js +448 -448
- package/dist/formats/black/core/CjsBlackReader.js +764 -764
- package/dist/formats/black/core/CjsBlackSchemaRegistry.js +540 -540
- package/dist/formats/black/core/black-schema-v1-2026-07-23.json.js +4 -4
- package/dist/formats/black/core/blackConstants.js +7 -7
- package/dist/formats/black/core/blackDefinitions.js +10 -10
- package/dist/formats/black/core/blackEnums.js +6 -6
- package/dist/formats/black/core/blackSchema.js +3 -3
- package/dist/formats/black/core/blackVersion.js +22 -22
- package/dist/formats/black/core/helpers.js +199 -199
- package/dist/formats/black/core/schema.js +4 -4
- package/dist/formats/black/index.js +2 -2
- package/dist/formats/bnk/CjsBnkFormat.js +175 -156
- package/dist/formats/bnk/CjsBnkFormat.js.map +1 -1
- package/dist/formats/bnk/core/busNodes.js +252 -0
- package/dist/formats/bnk/core/busNodes.js.map +1 -0
- package/dist/formats/bnk/core/effectNodes.js +147 -0
- package/dist/formats/bnk/core/effectNodes.js.map +1 -0
- package/dist/formats/bnk/core/eventAction.js +416 -305
- package/dist/formats/bnk/core/eventAction.js.map +1 -1
- package/dist/formats/bnk/core/globalSettings.js +215 -0
- package/dist/formats/bnk/core/globalSettings.js.map +1 -0
- package/dist/formats/bnk/core/graph.js +137 -137
- package/dist/formats/bnk/core/helpers.js +512 -480
- package/dist/formats/bnk/core/helpers.js.map +1 -1
- package/dist/formats/bnk/core/musicNodes.js +533 -509
- package/dist/formats/bnk/core/musicNodes.js.map +1 -1
- package/dist/formats/bnk/core/nodeBase.js +553 -532
- package/dist/formats/bnk/core/nodeBase.js.map +1 -1
- package/dist/formats/bnk/core/sfxNodes.js +632 -632
- package/dist/formats/bnk/core/soundbanksInfo.js +209 -209
- package/dist/formats/bnk/index.js +2 -2
- package/dist/formats/cmf/CjsCmfFormat.js +497 -497
- package/dist/formats/cmf/core/binary.js +194 -194
- package/dist/formats/cmf/core/buffers.js +237 -237
- package/dist/formats/cmf/core/constants.js +47 -47
- package/dist/formats/cmf/core/gr2Anim.js +453 -453
- package/dist/formats/cmf/core/helpers.js +318 -318
- package/dist/formats/cmf/core/pack.js +276 -276
- package/dist/formats/cmf/core/schema.js +374 -374
- package/dist/formats/cmf/core/shared.js +277 -277
- package/dist/formats/cmf/core/writer.js +571 -571
- package/dist/formats/cmf/index.js +2 -2
- package/dist/formats/dds/CjsDdsFormat.js +200 -200
- package/dist/formats/dds/core/bc6h.js +298 -298
- package/dist/formats/dds/core/bc7.js +272 -272
- package/dist/formats/dds/core/helpers.js +862 -862
- package/dist/formats/dds/index.js +2 -2
- package/dist/formats/dxbc/CjsDxbcFormat.js +142 -142
- package/dist/formats/dxbc/core/DxbcReader.js +266 -266
- package/dist/formats/dxbc/core/container.js +169 -169
- package/dist/formats/dxbc/core/decoder.js +789 -789
- package/dist/formats/dxbc/core/errors.js +19 -19
- package/dist/formats/dxbc/core/helpers.js +220 -220
- package/dist/formats/dxbc/core/opcodes.js +45 -45
- package/dist/formats/dxbc/core/program.js +91 -91
- package/dist/formats/dxbc/core/signature.js +172 -172
- package/dist/formats/dxbc/index.js +2 -2
- package/dist/formats/fbx/CjsFbxFormat.js +266 -266
- package/dist/formats/fbx/core/helpers.js +3932 -3932
- package/dist/formats/fbx/index.js +2 -2
- package/dist/formats/flac/CjsFlacFormat.js +142 -142
- package/dist/formats/flac/core/helpers.js +315 -315
- package/dist/formats/flac/index.js +2 -2
- package/dist/formats/gif/CjsGifFormat.js +141 -141
- package/dist/formats/gif/core/helpers.js +380 -380
- package/dist/formats/gif/index.js +2 -2
- package/dist/formats/gltf/CjsGltfFormat.js +290 -290
- package/dist/formats/gltf/core/helpers.js +307 -307
- package/dist/formats/gltf/core/json.js +79 -79
- package/dist/formats/gltf/core/parser.js +679 -679
- package/dist/formats/gltf/core/targets.js +173 -173
- package/dist/formats/gltf/index.js +2 -2
- package/dist/formats/gr2/CjsGr2Format.js +289 -289
- package/dist/formats/gr2/core/bitknit2.js +282 -282
- package/dist/formats/gr2/core/curves.js +1047 -1047
- package/dist/formats/gr2/core/gsf.js +72 -72
- package/dist/formats/gr2/core/helpers.js +352 -352
- package/dist/formats/gr2/core/json.js +622 -622
- package/dist/formats/gr2/core/oodle1.js +388 -388
- package/dist/formats/gr2/core/tangents.js +48 -48
- package/dist/formats/gr2/core/targets.js +361 -361
- package/dist/formats/gr2/index.js +2 -2
- package/dist/formats/hlsl/CjsHlslFormat.js +254 -254
- package/dist/formats/hlsl/core/HlslBinaryUtils.js +15 -15
- package/dist/formats/hlsl/core/HlslEffectReadError.js +19 -19
- package/dist/formats/hlsl/core/HlslEffectStateManager.js +130 -130
- package/dist/formats/hlsl/core/HlslRenderStateSetup.js +37 -37
- package/dist/formats/hlsl/core/HlslResourceSetDescription.js +94 -94
- package/dist/formats/hlsl/core/HlslShaderBytecode.js +44 -44
- package/dist/formats/hlsl/core/analysis.js +51 -51
- package/dist/formats/hlsl/core/carbonDescriptionToRuntime.js +850 -781
- package/dist/formats/hlsl/core/carbonDescriptionToRuntime.js.map +1 -1
- package/dist/formats/hlsl/core/detailMapFamily.js +128 -0
- package/dist/formats/hlsl/core/detailMapFamily.js.map +1 -0
- package/dist/formats/hlsl/core/helpers.js +270 -270
- package/dist/formats/hlsl/core/json.js +284 -284
- package/dist/formats/hlsl/core/localLightFamily.js +133 -0
- package/dist/formats/hlsl/core/localLightFamily.js.map +1 -0
- package/dist/formats/hlsl/core/metadata.js +327 -327
- package/dist/formats/hlsl/core/render-states.js +280 -280
- package/dist/formats/hlsl/core/tr2/HlslRenderContextEnum.js +43 -43
- package/dist/formats/hlsl/core/tr2/resources/HlslEffectRes.js +320 -314
- package/dist/formats/hlsl/core/tr2/resources/HlslEffectRes.js.map +1 -1
- package/dist/formats/hlsl/core/tr2/resources/HlslShaderPermutation.js +33 -33
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectBindingManifest.js +416 -416
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectConstant.js +40 -40
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectDescription.js +62 -742
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectDescription.js.map +1 -1
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectLibrary.js +52 -52
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectParameterAnnotation.js +38 -38
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectResource.js +50 -50
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectStageInput.js +86 -86
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectTechnique.js +31 -31
- package/dist/formats/hlsl/core/tr2/shader/HlslPass.js +42 -42
- package/dist/formats/hlsl/core/tr2/shader/HlslSamplerDescription.js +55 -55
- package/dist/formats/hlsl/core/tr2/shader/HlslSamplerSetup.js +29 -29
- package/dist/formats/hlsl/core/tr2/shader/HlslShader.js +220 -220
- package/dist/formats/hlsl/core/tr2/shader/HlslShaderOption.js +30 -30
- package/dist/formats/hlsl/index.js +3 -3
- package/dist/formats/index.js +33 -31
- package/dist/formats/index.js.map +1 -1
- package/dist/formats/jpeg/CjsJpegFormat.js +212 -212
- package/dist/formats/jpeg/core/helpers.js +402 -402
- package/dist/formats/jpeg/core/jpeg.js +480 -480
- package/dist/formats/jpeg/index.js +2 -2
- package/dist/formats/mp3/CjsMp3Format.js +197 -197
- package/dist/formats/mp3/core/helpers.js +375 -375
- package/dist/formats/mp3/index.js +2 -2
- package/dist/formats/mp4/CjsMp4Format.js +197 -197
- package/dist/formats/mp4/core/helpers.js +484 -484
- package/dist/formats/mp4/index.js +2 -2
- package/dist/formats/obj/CjsObjFormat.js +253 -253
- package/dist/formats/obj/core/helpers.js +573 -573
- package/dist/formats/obj/core/json.js +64 -64
- package/dist/formats/obj/core/parser.js +321 -321
- package/dist/formats/obj/index.js +2 -2
- package/dist/formats/ogg/CjsOggFormat.js +143 -143
- package/dist/formats/ogg/core/helpers.js +410 -410
- package/dist/formats/ogg/core/imdct.js +178 -178
- package/dist/formats/ogg/core/vorbis.js +1017 -1017
- package/dist/formats/ogg/index.js +2 -2
- package/dist/formats/pickle/CjsPickleFormat.js +214 -0
- package/dist/formats/pickle/CjsPickleFormat.js.map +1 -0
- package/dist/formats/pickle/core/CjsPickleProtocol0Reader.js +551 -0
- package/dist/formats/pickle/core/CjsPickleProtocol0Reader.js.map +1 -0
- package/dist/formats/pickle/index.js +2 -0
- package/dist/formats/pickle/index.js.map +1 -0
- package/dist/formats/png/CjsPngFormat.js +201 -201
- package/dist/formats/png/core/helpers.js +635 -635
- package/dist/formats/png/index.js +2 -2
- package/dist/formats/red/CjsRedFormat.js +263 -263
- package/dist/formats/red/core/CjsRedReader.js +246 -246
- package/dist/formats/red/core/blackDefinitions.js +3 -3
- package/dist/formats/red/core/helpers.js +158 -158
- package/dist/formats/red/core/redGraph.js +71 -68
- package/dist/formats/red/core/redGraph.js.map +1 -1
- package/dist/formats/red/core/schema.js +4 -4
- package/dist/formats/red/index.js +2 -2
- package/dist/formats/stl/CjsStlFormat.js +365 -365
- package/dist/formats/stl/core/helpers.js +261 -261
- package/dist/formats/stl/core/json.js +51 -51
- package/dist/formats/stl/core/stl.js +642 -642
- package/dist/formats/stl/core/targets.js +173 -173
- package/dist/formats/stl/index.js +2 -2
- package/dist/formats/tga/CjsTgaFormat.js +197 -197
- package/dist/formats/tga/core/helpers.js +493 -493
- package/dist/formats/tga/index.js +2 -2
- package/dist/formats/wav/CjsWavFormat.js +198 -198
- package/dist/formats/wav/core/helpers.js +365 -365
- package/dist/formats/wav/index.js +2 -2
- package/dist/formats/webgl/CjsWebglFormat.js +199 -221
- package/dist/formats/webgl/CjsWebglFormat.js.map +1 -1
- package/dist/formats/webgl/core/buildGlslEffectContainer.js +70 -0
- package/dist/formats/webgl/core/buildGlslEffectContainer.js.map +1 -0
- package/dist/formats/webgl/core/effectPackage.js +900 -792
- package/dist/formats/webgl/core/effectPackage.js.map +1 -1
- package/dist/formats/webgl/core/errors.js +27 -27
- package/dist/formats/webgl/core/errors.js.map +1 -1
- package/dist/formats/webgl/core/glsl/DxbcGlslEmitter.js +2820 -2678
- package/dist/formats/webgl/core/glsl/DxbcGlslEmitter.js.map +1 -1
- package/dist/formats/webgl/core/glsl/DxbcGlslHelpers.js +89 -89
- package/dist/formats/webgl/core/glsl/DxbcGlslOperandFormatter.js +486 -428
- package/dist/formats/webgl/core/glsl/DxbcGlslOperandFormatter.js.map +1 -1
- package/dist/formats/webgl/core/glsl/packedLightFixups.js +98 -0
- package/dist/formats/webgl/core/glsl/packedLightFixups.js.map +1 -0
- package/dist/formats/webgl/core/glslBackendBlock.js +552 -0
- package/dist/formats/webgl/core/glslBackendBlock.js.map +1 -0
- package/dist/formats/webgl/core/glslBackendBodySet.js +243 -0
- package/dist/formats/webgl/core/glslBackendBodySet.js.map +1 -0
- package/dist/formats/webgl/core/{cewgCompleteness.js → glslEffectCompleteness.js} +85 -81
- package/dist/formats/webgl/core/glslEffectCompleteness.js.map +1 -0
- package/dist/formats/webgl/core/helpers.js +167 -306
- package/dist/formats/webgl/core/helpers.js.map +1 -1
- package/dist/formats/webgl/core/inspectGlslEffectContainer.js +122 -0
- package/dist/formats/webgl/core/inspectGlslEffectContainer.js.map +1 -0
- package/dist/formats/webgl/core/readGlslEffectContainer.js +303 -0
- package/dist/formats/webgl/core/readGlslEffectContainer.js.map +1 -0
- package/dist/formats/webgl/index.js +2 -2
- package/dist/formats/webgpu/CjsWebgpuFormat.js +357 -357
- package/dist/formats/webgpu/CjsWebgpuFormat.js.map +1 -1
- package/dist/formats/webgpu/core/buildCarbonEffectContainer.js +89 -197
- package/dist/formats/webgpu/core/buildCarbonEffectContainer.js.map +1 -1
- package/dist/formats/webgpu/core/{cewgpu/CewgpuContainer.js → carbonWebgpu/CarbonWebgpuContainer.js} +354 -368
- package/dist/formats/webgpu/core/carbonWebgpu/CarbonWebgpuContainer.js.map +1 -0
- package/dist/formats/webgpu/core/{cewgpu → carbonWebgpu}/containerViews.js +355 -355
- package/dist/formats/webgpu/core/carbonWebgpu/containerViews.js.map +1 -0
- package/dist/formats/webgpu/core/{cewgpu → carbonWebgpu}/validateContainer.js +90 -90
- package/dist/formats/webgpu/core/carbonWebgpu/validateContainer.js.map +1 -0
- package/dist/formats/webgpu/core/effectAnalysis.js +82 -82
- package/dist/formats/webgpu/core/effectBackendBodySet.js +289 -289
- package/dist/formats/webgpu/core/effectBackendBodySet.js.map +1 -1
- package/dist/formats/webgpu/core/errors.js +20 -20
- package/dist/formats/webgpu/core/errors.js.map +1 -1
- package/dist/formats/webgpu/core/helpers.js +443 -443
- package/dist/formats/webgpu/core/helpers.js.map +1 -1
- package/dist/formats/webgpu/core/ir/analyzeRegisterValues.js +212 -212
- package/dist/formats/webgpu/core/ir/buildControlFlow.js +220 -220
- package/dist/formats/webgpu/core/ir/indexableTemps.js +137 -137
- package/dist/formats/webgpu/core/ir/inferValueTypes.js +449 -449
- package/dist/formats/webgpu/core/ir/lowerDxbcToIr.js +494 -494
- package/dist/formats/webgpu/core/ir/resolveRegisterFlow.js +177 -177
- package/dist/formats/webgpu/core/ir/sourceLanes.js +61 -61
- package/dist/formats/webgpu/core/packageEffect.js +381 -385
- package/dist/formats/webgpu/core/packageEffect.js.map +1 -1
- package/dist/formats/webgpu/core/packageEffectSelection.js +164 -164
- package/dist/formats/webgpu/core/packageEffectSelection.js.map +1 -1
- package/dist/formats/webgpu/core/packageMetadata.js +17 -17
- package/dist/formats/webgpu/core/schema.js +4 -4
- package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js +263 -263
- package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js.map +1 -1
- package/dist/formats/webgpu/core/wgsl/buildWgslBindingPlan.js +172 -172
- package/dist/formats/webgpu/core/wgsl/buildWgslSet.js +320 -320
- package/dist/formats/webgpu/core/wgsl/buildWgslSet.js.map +1 -1
- package/dist/formats/webgpu/core/wgsl/emitWgsl.js +356 -356
- package/dist/formats/webgpu/core/wgsl/hoistEscapingValues.js +77 -77
- package/dist/formats/webgpu/core/wgsl/lowerBindingLayout.js +451 -451
- package/dist/formats/webgpu/core/wgsl/lowerComputeProgram.js +735 -735
- package/dist/formats/webgpu/core/wgsl/lowerCreateHistogramsComputeProgram.js +457 -457
- package/dist/formats/webgpu/core/wgsl/lowerFragmentProgram.js +1572 -1572
- package/dist/formats/webgpu/core/wgsl/lowerMergeHistogramsComputeProgram.js +659 -659
- package/dist/formats/webgpu/core/wgsl/lowerParticleClearComputePrograms.js +734 -734
- package/dist/formats/webgpu/core/wgsl/lowerParticleEmitComputeProgram.js +583 -583
- package/dist/formats/webgpu/core/wgsl/lowerSkinVerticesComputeProgram.js +621 -621
- package/dist/formats/webgpu/core/wgsl/lowerSortComputeProgram.js +824 -824
- package/dist/formats/webgpu/core/wgsl/lowerSortInnerComputeProgram.js +697 -697
- package/dist/formats/webgpu/core/wgsl/lowerSortStepComputeProgram.js +559 -559
- package/dist/formats/webgpu/core/wgsl/lowerVertexProgram.js +1328 -1328
- package/dist/formats/webgpu/core/wgsl/particleEmitSemanticDigest.js +110 -110
- package/dist/formats/webgpu/core/wgsl/precisionControls.js +55 -55
- package/dist/formats/webgpu/core/wgsl/selectionPlans.js +717 -717
- package/dist/formats/webgpu/core/wgsl/uniformity.js +78 -78
- package/dist/formats/webgpu/core/wgsl/validateExactComputeIr.js +196 -196
- package/dist/formats/webgpu/core/wgsl/validateHandleOperand.js +37 -37
- package/dist/formats/webgpu/index.js +2 -2
- package/dist/formats/webm/CjsWebmFormat.js +197 -197
- package/dist/formats/webm/core/helpers.js +572 -572
- package/dist/formats/webm/index.js +2 -2
- package/dist/formats/webp/CjsWebpFormat.js +140 -140
- package/dist/formats/webp/core/helpers.js +237 -237
- package/dist/formats/webp/index.js +2 -2
- package/dist/formats/wem/CjsWemFormat.js +250 -250
- package/dist/formats/wem/core/bitStream.js +261 -261
- package/dist/formats/wem/core/codebookLibrary.js +164 -164
- package/dist/formats/wem/core/helpers.js +437 -437
- package/dist/formats/wem/core/packedCodebooksAotuv603.js +30 -30
- package/dist/formats/wem/core/ptadpcm.js +77 -77
- package/dist/formats/wem/core/resolve.js +121 -121
- package/dist/formats/wem/core/wemToOgg.js +485 -485
- package/dist/formats/wem/index.js +2 -2
- package/dist/formats/yaml/CjsYamlFormat.js +134 -134
- package/dist/formats/yaml/CjsYamlFormat.js.map +1 -1
- package/dist/formats/yaml/core/CjsYamlReader.js +400 -402
- package/dist/formats/yaml/core/CjsYamlReader.js.map +1 -1
- package/dist/formats/yaml/core/helpers.js +196 -170
- package/dist/formats/yaml/core/helpers.js.map +1 -1
- package/dist/formats/yaml/index.js +2 -2
- package/dist/index.js +64 -62
- package/dist/index.js.map +1 -1
- package/dist/resource/CjsLoadingObject.js +19 -0
- package/dist/resource/CjsLoadingObject.js.map +1 -0
- package/dist/resource/CjsResource.js +801 -797
- package/dist/resource/CjsResource.js.map +1 -1
- package/dist/resource/ResourceHandlerMode.js +14 -0
- package/dist/resource/ResourceHandlerMode.js.map +1 -0
- package/dist/resource/Tr2LightProfileRes.js +32 -32
- package/dist/resource/audio/AudioGeometryResData.js +47 -47
- package/dist/resource/audio/CjsAudioBufferRes.js +86 -86
- package/dist/resource/audio/CjsAudioRes.js +213 -213
- package/dist/resource/audio/index.js +4 -4
- package/dist/resource/geometry/MeshDecalData.js +37 -37
- package/dist/resource/geometry/MeshDecalLodData.js +34 -34
- package/dist/resource/geometry/TriGeometryRes.js +675 -675
- package/dist/resource/geometry/TriGeometryResAreaData.js +59 -59
- package/dist/resource/geometry/TriGeometryResJointData.js +38 -38
- package/dist/resource/geometry/TriGeometryResLodData.js +88 -88
- package/dist/resource/geometry/TriGeometryResMeshData.js +63 -63
- package/dist/resource/geometry/TriGeometryResSkeletonData.js +34 -34
- package/dist/resource/geometry/TriJointBinding.js +38 -38
- package/dist/resource/geometry/TriMorphTargetGeometryConstants.js +46 -46
- package/dist/resource/geometry/TriRtGeometryConstants.js +88 -88
- package/dist/resource/geometry/granny/GStateBindingCallbackData.js +31 -31
- package/dist/resource/geometry/granny/Tr2GrannyIntersectionResult.js +60 -60
- package/dist/resource/geometry/granny/Tr2GrannyStateRes.js +36 -36
- package/dist/resource/geometry/granny/TriGrannyRes.js +35 -35
- package/dist/resource/geometry/granny/enums.js +10 -10
- package/dist/resource/geometry/granny/index.js +6 -6
- package/dist/resource/geometry/index.js +17 -17
- package/dist/resource/index.js +54 -52
- package/dist/resource/index.js.map +1 -1
- package/dist/resource/resourceBoundary.js +64 -64
- package/dist/resource/shader/Tr2EffectRes.js +336 -431
- package/dist/resource/shader/Tr2EffectRes.js.map +1 -1
- package/dist/resource/shader/Tr2MaterialArea.js +31 -31
- package/dist/resource/shader/Tr2MaterialMesh.js +27 -27
- package/dist/resource/shader/Tr2MaterialRes.js +31 -31
- package/dist/resource/shader/Tr2Shader.js +283 -261
- package/dist/resource/shader/Tr2Shader.js.map +1 -1
- package/dist/resource/shader/Tr2ShaderPermutation.js +43 -43
- package/dist/resource/shader/index.js +17 -17
- package/dist/resource/shader/reflection/Tr2EffectConstant.js +143 -135
- package/dist/resource/shader/reflection/Tr2EffectConstant.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectDefine.js +30 -30
- package/dist/resource/shader/reflection/Tr2EffectDescription.js +114 -109
- package/dist/resource/shader/reflection/Tr2EffectDescription.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectLibrary.js +168 -147
- package/dist/resource/shader/reflection/Tr2EffectLibrary.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js +125 -105
- package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectResource.js +120 -86
- package/dist/resource/shader/reflection/Tr2EffectResource.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectStageInput.js +372 -241
- package/dist/resource/shader/reflection/Tr2EffectStageInput.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectTechnique.js +78 -68
- package/dist/resource/shader/reflection/Tr2EffectTechnique.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2Pass.js +168 -111
- package/dist/resource/shader/reflection/Tr2Pass.js.map +1 -1
- package/dist/resource/shader/reflection/carbonRecordFields.js +159 -0
- package/dist/resource/shader/reflection/carbonRecordFields.js.map +1 -0
- package/dist/resource/shader/reflection/shaderStage.js +22 -0
- package/dist/resource/shader/reflection/shaderStage.js.map +1 -0
- package/dist/resource/shader/sampler/Tr2SamplerSetup.js +135 -77
- package/dist/resource/shader/sampler/Tr2SamplerSetup.js.map +1 -1
- package/dist/resource/texture/CjsTextureArrayRes.js +472 -472
- package/dist/resource/texture/CjsTextureArrayResParameterProxy.js +179 -179
- package/dist/resource/texture/Tr2ImageRes.js +120 -120
- package/dist/resource/texture/Tr2TextureLodManager.js +82 -82
- package/dist/resource/texture/Tr2TextureLodUpdateRequest.js +37 -37
- package/dist/resource/texture/Tr2TexturePackChannel.js +37 -37
- package/dist/resource/texture/Tr2TexturePipeline.js +54 -54
- package/dist/resource/texture/Tr2TexturePipelineParams.js +34 -34
- package/dist/resource/texture/Tr2TexturePipelineStepCompress.js +40 -40
- package/dist/resource/texture/Tr2TexturePipelineStepGenerateMips.js +22 -22
- package/dist/resource/texture/Tr2TexturePipelineStepLimitSize.js +34 -34
- package/dist/resource/texture/Tr2TexturePipelineStepLoad.js +31 -31
- package/dist/resource/texture/Tr2TexturePipelineStepPack.js +43 -43
- package/dist/resource/texture/TriTextureRes.js +359 -359
- package/dist/resource/texture/index.js +15 -15
- package/dist/resource/texture/texturePipelineBehavior.js +308 -308
- package/dist/worker/CjsResManMainThreadLoader.js +89 -87
- package/dist/worker/CjsResManMainThreadLoader.js.map +1 -1
- package/dist/worker/CjsResManWorker.js +218 -217
- package/dist/worker/CjsResManWorker.js.map +1 -1
- package/dist/worker/CjsResManWorkerLoader.js +437 -434
- package/dist/worker/CjsResManWorkerLoader.js.map +1 -1
- package/dist/worker/protocol.js +12 -12
- package/docs/README.md +98 -98
- package/docs/architecture.md +118 -109
- package/docs/concepts/resource-lifecycle.md +226 -225
- package/docs/concepts/shader-resource-model.md +111 -114
- package/docs/concepts/writing-an-engine-adapter.md +115 -115
- package/docs/formats/README.md +138 -136
- package/docs/formats/carbon-effect-container.md +553 -452
- package/docs/formats/dxbc/README.md +68 -68
- package/docs/formats/dxbc/architecture.md +80 -80
- package/docs/formats/dxbc/reference/api.md +77 -77
- package/docs/formats/dxbc/reference/classes/README.md +9 -9
- package/docs/formats/dxbc/reference/decoded-output.md +122 -122
- package/docs/formats/gr2.md +160 -160
- package/docs/formats/hlsl/README.md +54 -54
- package/docs/formats/hlsl/architecture.md +65 -67
- package/docs/formats/hlsl/guides/hydrating-json-output.md +60 -62
- package/docs/formats/hlsl/guides/reading-effects.md +64 -64
- package/docs/formats/hlsl/reference/advanced-analysis.md +61 -66
- package/docs/formats/hlsl/reference/api.md +92 -98
- package/docs/formats/hlsl/reference/classes/README.md +11 -11
- package/docs/formats/hlsl/reference/json-graph.md +97 -100
- package/docs/formats/pickle.md +82 -0
- package/docs/formats/provenance.md +196 -196
- package/docs/formats/stl.md +37 -37
- package/docs/formats/webgl/README.md +115 -57
- package/docs/formats/webgl/architecture.md +69 -70
- package/docs/formats/webgl/carbon-constant-layouts.md +326 -326
- package/docs/formats/webgl/decl-io.md +1234 -1234
- package/docs/formats/webgl/memory-structured.md +890 -871
- package/docs/formats/webgl/reference/classes/README.md +9 -9
- package/docs/formats/webgl/texture-sample.md +964 -964
- package/docs/formats/webgpu/README.md +84 -84
- package/docs/formats/webgpu/architecture.md +95 -96
- package/docs/formats/webgpu/formats/{cewgpu.md → carbon-webgpu.md} +215 -216
- package/docs/formats/webgpu/guides/effect-packaging.md +189 -191
- package/docs/formats/webgpu/reference/api.md +196 -197
- package/docs/formats/webgpu/reference/classes/README.md +9 -9
- package/docs/formats/webgpu/reference/wgsl-compatibility.md +1546 -1543
- package/docs/formats/wwise.md +146 -85
- package/docs/reference/classes/README.md +35 -35
- package/docs/reference/classes/audio.md +30 -30
- package/docs/reference/classes/core.md +216 -206
- package/docs/reference/classes/dropped.md +46 -46
- package/docs/reference/classes/formats.md +944 -952
- package/docs/reference/classes/resources.md +456 -456
- package/docs/reference/classes/texture.md +26 -26
- package/docs/reference/events.md +117 -117
- package/docs/reference/motherlode-cache.md +275 -275
- package/docs/reference/queues.md +194 -110
- package/docs/reference/reload.md +107 -107
- package/docs/reference/texture-arrays.md +113 -113
- package/docs/reference/texture-pipeline.md +53 -53
- package/docs/reference/workers.md +142 -135
- package/docs/roadmap.md +150 -150
- package/format-notices/black/LICENSE +21 -21
- package/format-notices/black/NOTICE +47 -47
- package/format-notices/bnk/LICENSE +21 -21
- package/format-notices/bnk/NOTICE +21 -21
- package/format-notices/cmf/LICENSE +21 -21
- package/format-notices/cmf/NOTICE +36 -36
- package/format-notices/dds/LICENSE +21 -21
- package/format-notices/dds/NOTICE +14 -14
- package/format-notices/dxbc/LICENSE +21 -21
- package/format-notices/dxbc/NOTICE +20 -20
- package/format-notices/fbx/LICENSE +21 -21
- package/format-notices/fbx/NOTICE +14 -14
- package/format-notices/flac/LICENSE +21 -21
- package/format-notices/flac/NOTICE +14 -14
- package/format-notices/gif/LICENSE +21 -21
- package/format-notices/gif/NOTICE +14 -14
- package/format-notices/gltf/LICENSE +21 -21
- package/format-notices/gltf/NOTICE +27 -27
- package/format-notices/gr2/LICENSE +21 -21
- package/format-notices/gr2/NOTICE +60 -60
- package/format-notices/gr2/THIRD-PARTY-NOTICES.md +93 -93
- package/format-notices/hlsl/LICENSE +21 -21
- package/format-notices/hlsl/NOTICE +25 -25
- package/format-notices/jpeg/LICENSE +21 -21
- package/format-notices/jpeg/NOTICE +14 -14
- package/format-notices/mp3/LICENSE +21 -21
- package/format-notices/mp3/NOTICE +14 -14
- package/format-notices/mp4/LICENSE +21 -21
- package/format-notices/mp4/NOTICE +14 -14
- package/format-notices/obj/LICENSE +21 -21
- package/format-notices/obj/NOTICE +26 -26
- package/format-notices/ogg/LICENSE +21 -21
- package/format-notices/ogg/NOTICE +28 -28
- package/format-notices/png/LICENSE +21 -21
- package/format-notices/png/NOTICE +14 -14
- package/format-notices/red/LICENSE +21 -21
- package/format-notices/red/NOTICE +31 -31
- package/format-notices/stl/LICENSE +21 -21
- package/format-notices/stl/NOTICE +21 -21
- package/format-notices/tga/LICENSE +21 -21
- package/format-notices/tga/NOTICE +14 -14
- package/format-notices/wav/LICENSE +21 -21
- package/format-notices/wav/NOTICE +14 -14
- package/format-notices/webgl/LICENSE +21 -21
- package/format-notices/webgl/NOTICE +35 -35
- package/format-notices/webgpu/LICENSE +21 -21
- package/format-notices/webgpu/NOTICE +31 -31
- package/format-notices/webm/LICENSE +21 -21
- package/format-notices/webm/NOTICE +14 -14
- package/format-notices/webp/LICENSE +21 -21
- package/format-notices/webp/NOTICE +14 -14
- package/format-notices/wem/LICENSE +57 -57
- package/format-notices/wem/NOTICE +33 -33
- package/format-notices/yaml/LICENSE +21 -21
- package/format-notices/yaml/NOTICE +44 -44
- package/package.json +63 -63
- package/dist/format/carbonEffect/carbonDescriptionFromPortable.js +0 -372
- package/dist/format/carbonEffect/carbonDescriptionFromPortable.js.map +0 -1
- package/dist/format/effect/effectReflectionPackage.js +0 -636
- package/dist/format/effect/effectReflectionPackage.js.map +0 -1
- package/dist/formats/hlsl/core/HlslReader.js +0 -16
- package/dist/formats/hlsl/core/HlslReader.js.map +0 -1
- package/dist/formats/hlsl/core/portableReflection.js +0 -848
- package/dist/formats/hlsl/core/portableReflection.js.map +0 -1
- package/dist/formats/hlsl/portable.js +0 -2
- package/dist/formats/hlsl/portable.js.map +0 -1
- package/dist/formats/webgl/core/cewg/CewgPackage.js +0 -340
- package/dist/formats/webgl/core/cewg/CewgPackage.js.map +0 -1
- package/dist/formats/webgl/core/cewg/CewgPackageBuilder.js +0 -104
- package/dist/formats/webgl/core/cewg/CewgPackageBuilder.js.map +0 -1
- package/dist/formats/webgl/core/cewg/binary.js +0 -19
- package/dist/formats/webgl/core/cewg/binary.js.map +0 -1
- package/dist/formats/webgl/core/cewgCompleteness.js.map +0 -1
- package/dist/formats/webgl/core/effectPackageValidation.js +0 -331
- package/dist/formats/webgl/core/effectPackageValidation.js.map +0 -1
- package/dist/formats/webgpu/core/cewgpu/CewgpuContainer.js.map +0 -1
- package/dist/formats/webgpu/core/cewgpu/containerViews.js.map +0 -1
- package/dist/formats/webgpu/core/cewgpu/validateContainer.js.map +0 -1
- package/dist/resource/shader/portable.js +0 -33
- package/dist/resource/shader/portable.js.map +0 -1
- package/docs/formats/hlsl/reference/portable-reflection.md +0 -141
- package/docs/formats/webgl/effect-reflection.md +0 -127
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"effectPackageValidation.js","sources":["../../../../../src/formats/webgl/core/effectPackageValidation.js"],"sourcesContent":["import {\n EFFECT_PERMUTATION_GRAPH_CHUNK,\n EFFECT_PERMUTATION_GRAPH_FORMAT,\n EFFECT_PERMUTATION_GRAPH_VERSION,\n validateEffectPermutationGraph\n} from \"../../../format/effect/effectPermutationGraph.js\";\nimport {\n EFFECT_REFLECTION_BLOB_CHUNK,\n EFFECT_REFLECTION_CHUNK,\n effectReflectionForPermutation,\n validateEffectReflectionPointer\n} from \"../../../format/effect/effectReflectionPackage.js\";\nimport { inspectCewgRasterCompleteness } from \"./cewgCompleteness.js\";\nimport { markEffectReflectionValidated } from \"./cewg/CewgPackage.js\";\nimport { sha256Bytes } from \"../../../format/effect/sha256.js\";\n\nexport const EFFECT_INFO_VERSION = 3;\n\nconst EFFECT_PACKAGE_KINDS = new Set([\n \"tr2-effect-webgl\",\n \"tr2-effect-webgl-permutations\"\n]);\nconst REQUIRED_EFFECT_CHUNKS = Object.freeze([ \"INFO\", \"META\", \"GLSL\" ]);\nconst SEMANTIC_VERSION = /^[0-9]+\\.[0-9]+\\.[0-9]+(?:-[0-9A-Za-z.-]+)?(?:\\+[0-9A-Za-z.-]+)?$/u;\nconst SHA256 = /^[0-9a-f]{64}$/u;\n\n/**\n * Validates the canonical CEWG effect envelope after the binary container has\n * been decoded. Generic CEWG containers without a recognized package kind\n * remain readable.\n *\n * @param {object} pkg Loaded CEWG package.\n * @returns {boolean} True when the package is generic, legacy, or valid.\n */\nexport function validateEffectPackageEnvelope(pkg)\n{\n if (!pkg.GetChunk(\"INFO\")) return true;\n\n const info = requireRecord(pkg.GetJson(\"INFO\"), \"CEWG INFO\");\n if (!EFFECT_PACKAGE_KINDS.has(info.packageKind)) return true;\n\n for (const tag of REQUIRED_EFFECT_CHUNKS)\n {\n if (!pkg.GetChunk(tag))\n {\n throw new Error(`CEWG effect package requires ${tag}`);\n }\n }\n if (info.format !== \"CEWG\")\n {\n throw new Error(\"CEWG INFO format is malformed\");\n }\n if (info.formatVersion === 1)\n {\n return true;\n }\n if (info.formatVersion !== EFFECT_INFO_VERSION)\n {\n throw new Error(`CEWG INFO schema must be version ${EFFECT_INFO_VERSION}`);\n }\n if (info.targetBackend !== \"webgl\"\n || info.backendPackage !== \"@carbonenginejs/runtime-resource/formats/webgl\"\n || !SEMANTIC_VERSION.test(info.backendPackageVersion)\n || info.translator !== \"dxbc-js-emitter\"\n || !SEMANTIC_VERSION.test(info.translatorVersion))\n {\n throw new Error(\"CEWG INFO producer provenance is malformed\");\n }\n\n const sourceIdentity = validateSourceIdentity(info.sourceIdentity);\n if (info.sourceByteLength !== sourceIdentity.byteLength\n || info.sourceSha256 !== sourceIdentity.sha256)\n {\n throw new Error(\"CEWG INFO source identity fields disagree\");\n }\n requireString(info.sourcePath, \"CEWG INFO.sourcePath\");\n requireUint(info.defaultPermutationIndex, \"CEWG INFO.defaultPermutationIndex\");\n requireUint(info.sourceEffectVersion, \"CEWG INFO.sourceEffectVersion\");\n const expectedMode = info.packageKind === \"tr2-effect-webgl-permutations\"\n ? \"all\"\n : \"selected\";\n if (info.permutationMode !== expectedMode)\n {\n throw new Error(\"CEWG INFO package kind and permutation mode disagree\");\n }\n\n const graphPointer = requireRecord(\n info.permutationGraph,\n \"CEWG INFO.permutationGraph\"\n );\n if (graphPointer.chunk !== EFFECT_PERMUTATION_GRAPH_CHUNK\n || graphPointer.format !== EFFECT_PERMUTATION_GRAPH_FORMAT\n || graphPointer.formatVersion !== EFFECT_PERMUTATION_GRAPH_VERSION\n || !SHA256.test(graphPointer.sha256))\n {\n throw new Error(\"CEWG INFO.permutationGraph is malformed\");\n }\n const graphChunk = pkg.GetChunk(EFFECT_PERMUTATION_GRAPH_CHUNK);\n if (!graphChunk)\n {\n throw new Error(`CEWG INFO.permutationGraph requires ${EFFECT_PERMUTATION_GRAPH_CHUNK}`);\n }\n if (sha256Bytes(graphChunk.bytes) !== graphPointer.sha256)\n {\n throw new Error(\"CEWG INFO permutation-graph digest disagrees with PGRF\");\n }\n const graph = requireRecord(pkg.GetJson(EFFECT_PERMUTATION_GRAPH_CHUNK), \"CEWG PGRF\");\n const graphCounts = validateEffectPermutationGraph(graph, {\n sourceByteLength: sourceIdentity.byteLength\n });\n if (requireUint(\n graphPointer.permutationCount,\n \"CEWG INFO.permutationGraph.permutationCount\"\n ) !== graphCounts.permutationCount\n || requireUint(\n graphPointer.uniqueBodyCount,\n \"CEWG INFO.permutationGraph.uniqueBodyCount\"\n ) !== graphCounts.uniqueBodyCount\n || info.sourcePermutationCount !== graphCounts.permutationCount\n || info.sourceUniqueBodyCount !== graphCounts.uniqueBodyCount)\n {\n throw new Error(\"CEWG INFO permutation-graph counts disagree with PGRF\");\n }\n if (info.defaultPermutationIndex >= graphCounts.permutationCount)\n {\n throw new Error(\"CEWG default permutation index is absent from PGRF\");\n }\n\n const metadata = requireRecord(pkg.GetJson(\"META\"), \"CEWG META\");\n const glsl = requireRecord(pkg.GetJson(\"GLSL\"), \"CEWG GLSL\");\n validateBackendGraph(\n info,\n metadata,\n glsl,\n graph\n );\n if (metadata.sourcePath !== info.sourcePath)\n {\n throw new Error(\"CEWG META source path disagrees with INFO\");\n }\n validateCompleteness(info);\n\n if (info.formatVersion === 2)\n {\n if (info.sourceEffectVersion < 8 || info.sourceEffectVersion > 14)\n {\n throw new Error(\"CEWG INFO v2 source effect version must be 8-14\");\n }\n if (Object.prototype.hasOwnProperty.call(info, \"effectReflection\")\n || pkg.GetChunk(EFFECT_REFLECTION_CHUNK)\n || pkg.GetChunk(EFFECT_REFLECTION_BLOB_CHUNK))\n {\n throw new Error(\"CEWG INFO v2 cannot contain complete effect reflection\");\n }\n return true;\n }\n\n const reflectionChunk = pkg.GetChunk(EFFECT_REFLECTION_CHUNK);\n const blobChunk = pkg.GetChunk(EFFECT_REFLECTION_BLOB_CHUNK);\n if (!reflectionChunk || !blobChunk)\n {\n throw new Error(\"CEWG INFO v3 requires RFLX and RBLB\");\n }\n const reflection = requireRecord(\n pkg.GetJson(EFFECT_REFLECTION_CHUNK),\n \"CEWG RFLX\"\n );\n if (info.sourceEffectVersion !== 15\n || reflection.source?.effectVersion !== info.sourceEffectVersion)\n {\n throw new Error(\"CEWG INFO v3 source effect version disagrees with RFLX\");\n }\n validateEffectReflectionPointer(\n requireRecord(info.effectReflection, \"CEWG INFO.effectReflection\"),\n reflection,\n blobChunk.bytes,\n {\n permutationGraph: graph,\n sourceIdentity,\n sourcePath: info.sourcePath,\n reflectionBytes: reflectionChunk.bytes\n }\n );\n validateReflectionBackendGraph(\n reflection,\n graph,\n metadata,\n glsl\n );\n markEffectReflectionValidated(pkg);\n return true;\n}\n\nfunction validateReflectionBackendGraph(reflection, graph, metadata, glsl)\n{\n const metadataBodies = new Map(metadata.bodies.map((body) => [\n body.key,\n body\n ]));\n const checkedBodies = new Set();\n for (const variant of metadata.variants)\n {\n if (checkedBodies.has(variant.bodyKey)) continue;\n checkedBodies.add(variant.bodyKey);\n const metadataBody = metadataBodies.get(variant.bodyKey);\n const reflected = effectReflectionForPermutation(\n reflection,\n graph,\n variant.permutationIndex\n );\n const manifest = requireRecord(\n metadataBody?.manifest,\n `CEWG META body ${variant.bodyKey} manifest`\n );\n const reflectedPasses = [];\n const reflectedStages = [];\n for (const technique of requireArray(\n reflected.techniques,\n `CEWG RFLX body ${variant.bodyKey} techniques`\n ))\n {\n for (const [ passIndex, pass ] of requireArray(\n technique.passes,\n `CEWG RFLX technique ${technique.name} passes`\n ).entries())\n {\n reflectedPasses.push({\n techniqueName: technique.name,\n passIndex,\n states: pass.renderStates\n });\n for (const stage of requireArray(\n pass.stages,\n `CEWG RFLX ${technique.name}.pass${passIndex} stages`\n ))\n {\n reflectedStages.push({\n techniqueName: technique.name,\n passIndex,\n stage\n });\n }\n }\n }\n const manifestPasses = requireArray(\n manifest.passes,\n `CEWG META body ${variant.bodyKey} passes`\n );\n const manifestStages = requireArray(\n manifest.stages,\n `CEWG META body ${variant.bodyKey} stages`\n );\n if (manifestPasses.length !== reflectedPasses.length\n || manifestStages.length !== reflectedStages.length)\n {\n throw new Error(\n `CEWG META body ${variant.bodyKey} disagrees with RFLX pass/stage counts`\n );\n }\n for (const reflectedPass of reflectedPasses)\n {\n const manifestPass = manifestPasses.find((entry) =>\n entry.techniqueName === reflectedPass.techniqueName\n && entry.passIndex === reflectedPass.passIndex);\n if (!manifestPass\n || !jsonEqual(manifestPass.states, reflectedPass.states))\n {\n throw new Error(\n `CEWG META pass ${reflectedPass.techniqueName}.pass${reflectedPass.passIndex} disagrees with RFLX`\n );\n }\n }\n for (const reflectedStage of reflectedStages)\n {\n const stage = reflectedStage.stage;\n const sourceProgram = stage.sourceProgram;\n const signature = stage.input?.signature;\n const manifestStage = manifestStages.find((entry) =>\n entry.techniqueName === reflectedStage.techniqueName\n && entry.passIndex === reflectedStage.passIndex\n && entry.stageType === stage.stageType\n && entry.stageName === stage.stageName);\n if (!manifestStage\n || sourceProgram?.kind !== \"stage\"\n || sourceProgram.stageType !== manifestStage.stageType\n || sourceProgram.stageName !== manifestStage.stageName\n || sourceProgram.shaderSize\n !== manifestStage.shaderBytecode?.shaderSize\n || sourceProgram.stringTableOffset\n !== manifestStage.shaderBytecode?.stringTableOffset\n || !samePipelineInputs(\n signature?.pipelineInputs,\n manifestStage.pipelineInputs\n )\n || !jsonEqual(\n signature?.threadGroupSize,\n manifestStage.threadGroupSize\n ))\n {\n throw new Error(\n `CEWG META stage ${reflectedStage.techniqueName}.pass${reflectedStage.passIndex}.${stage.stageName} disagrees with RFLX`\n );\n }\n }\n }\n if (checkedBodies.size !== metadataBodies.size\n || requireArray(glsl.bodies, \"CEWG GLSL.bodies\").some((body) =>\n !checkedBodies.has(body.key)))\n {\n throw new Error(\"CEWG backend body inventory disagrees with RFLX\");\n }\n}\n\nfunction validateSourceIdentity(value)\n{\n const identity = requireRecord(value, \"CEWG INFO.sourceIdentity\");\n requireString(identity.logicalPath, \"CEWG INFO.sourceIdentity.logicalPath\");\n requireUint(identity.byteLength, \"CEWG INFO.sourceIdentity.byteLength\");\n if (!SHA256.test(identity.sha256))\n {\n throw new Error(\"CEWG INFO.sourceIdentity.sha256 is malformed\");\n }\n return identity;\n}\n\nfunction validateCompleteness(info)\n{\n const completeness = requireRecord(\n info.completeness,\n \"CEWG INFO.completeness\"\n );\n for (const key of [\n \"packageValid\",\n \"sourceComplete\",\n \"backendComplete\",\n \"runtimeComplete\"\n ])\n {\n if (typeof completeness[key] !== \"boolean\")\n {\n throw new Error(`CEWG INFO.completeness.${key} must be boolean`);\n }\n }\n if (!completeness.packageValid || completeness.runtimeComplete)\n {\n throw new Error(\"CEWG INFO completeness overstates runtime coverage\");\n }\n if (info.formatVersion === 3)\n {\n if (info.sourceBodyCoverage !== \"all-unique\"\n || !completeness.sourceComplete\n || info.backendProgramCoverage !== (\n selectionCoversWholeEffect(info.selection)\n ? \"all-stages\"\n : \"filtered\"\n ))\n {\n throw new Error(\"CEWG INFO v3 source coverage is inconsistent\");\n }\n }\n else if (Object.prototype.hasOwnProperty.call(info, \"sourceBodyCoverage\")\n || Object.prototype.hasOwnProperty.call(info, \"backendBodyCoverage\")\n || Object.prototype.hasOwnProperty.call(info, \"backendProgramCoverage\")\n || completeness.sourceComplete)\n {\n throw new Error(\"CEWG INFO v2 source coverage is inconsistent\");\n }\n const expectedBackendCoverage = info.permutationMode === \"all\"\n ? \"all\"\n : \"selected\";\n if ((info.formatVersion === 3\n && info.backendBodyCoverage !== expectedBackendCoverage)\n || completeness.backendComplete)\n {\n throw new Error(\"CEWG INFO backend coverage is inconsistent\");\n }\n}\n\nfunction selectionCoversWholeEffect(value)\n{\n const selection = requireRecord(value, \"CEWG INFO.selection\");\n return selection.technique === null\n && selection.pass === null\n && selection.stage === null;\n}\n\nfunction validateBackendGraph(info, metadata, glsl, graph)\n{\n if (glsl.format !== \"CEWG_GLSL_SET\" || glsl.formatVersion !== 1\n || glsl.permutationMode !== info.permutationMode\n || !jsonEqual(glsl.selection, info.selection))\n {\n throw new Error(\"CEWG GLSL envelope disagrees with INFO\");\n }\n const metadataVariants = requireArray(metadata.variants, \"CEWG META.variants\");\n const glslVariants = requireArray(glsl.variants, \"CEWG GLSL.variants\");\n const metadataBodies = requireArray(metadata.bodies, \"CEWG META.bodies\");\n const glslBodies = requireArray(glsl.bodies, \"CEWG GLSL.bodies\");\n const stages = requireArray(glsl.stages, \"CEWG GLSL.stages\");\n const shaders = requireArray(glsl.shaders, \"CEWG GLSL.shaders\");\n if (metadataVariants.length !== info.permutationCount\n || glslVariants.length !== info.permutationCount)\n {\n throw new Error(\"CEWG backend variant counts disagree with INFO\");\n }\n const expectedIndices = info.permutationMode === \"all\"\n ? graph.variants.map((variant) => variant.permutationIndex)\n : [ info.defaultPermutationIndex ];\n if (expectedIndices.length !== metadataVariants.length)\n {\n throw new Error(\"CEWG backend permutation coverage disagrees with INFO\");\n }\n for (let index = 0; index < expectedIndices.length; index++)\n {\n const expected = expectedIndices[index];\n const metadataVariant = requireRecord(\n metadataVariants[index],\n `CEWG META variant ${index}`\n );\n const glslVariant = requireRecord(\n glslVariants[index],\n `CEWG GLSL variant ${index}`\n );\n if (metadataVariant.permutationIndex !== expected\n || glslVariant.permutationIndex !== expected\n || metadataVariant.key !== glslVariant.key\n || metadataVariant.bodyKey !== glslVariant.bodyKey)\n {\n throw new Error(`CEWG backend variant ${index} is inconsistent`);\n }\n const sourceVariant = graph.variants[expected];\n if (metadataVariant.bodyOffset !== sourceVariant.sourceRecord.offset\n || metadataVariant.bodySize !== sourceVariant.sourceRecord.byteLength)\n {\n throw new Error(`CEWG backend variant ${index} disagrees with PGRF`);\n }\n }\n if (metadataBodies.length !== info.uniqueBodyCount\n || glslBodies.length !== info.uniqueBodyCount\n || stages.length !== info.bodyStageCount\n || shaders.length !== info.uniqueShaderCount)\n {\n throw new Error(\"CEWG backend graph counts disagree with INFO\");\n }\n\n const metadataBodyMap = keyedRecordMap(metadataBodies, \"CEWG META body\");\n const glslBodyMap = keyedRecordMap(glslBodies, \"CEWG GLSL body\");\n const stageMap = keyedRecordMap(stages, \"CEWG GLSL stage\");\n const shaderMap = keyedRecordMap(shaders, \"CEWG GLSL shader\");\n const variantKeys = new Set();\n const referencedBodies = new Set();\n for (const [ index, variant ] of glslVariants.entries())\n {\n if (typeof variant.key !== \"string\" || !variant.key\n || variantKeys.has(variant.key)\n || !glslBodyMap.has(variant.bodyKey)\n || !metadataBodyMap.has(metadataVariants[index].bodyKey))\n {\n throw new Error(`CEWG backend variant ${index} references an invalid body`);\n }\n variantKeys.add(variant.key);\n referencedBodies.add(variant.bodyKey);\n }\n\n const referencedStages = new Set();\n for (const body of glslBodies)\n {\n const metadataBody = metadataBodyMap.get(body.key);\n const bodyStages = requireArray(\n body.stages,\n `CEWG GLSL body ${body.key}.stages`\n );\n if (!metadataBody\n || referencedBodies.has(body.key) === false\n || bodyStages.length !== new Set(bodyStages).size)\n {\n throw new Error(`CEWG backend body ${body.key} is inconsistent`);\n }\n for (const stageKey of bodyStages)\n {\n const stage = stageMap.get(stageKey);\n if (!stage || stage.bodyKey !== body.key)\n {\n throw new Error(\n `CEWG backend body ${body.key} references an invalid stage`\n );\n }\n referencedStages.add(stageKey);\n }\n }\n\n const referencedShaders = new Set();\n for (const stage of stages)\n {\n if (!referencedStages.has(stage.key)\n || !glslBodyMap.has(stage.bodyKey)\n || !shaderMap.has(stage.shaderKey))\n {\n throw new Error(`CEWG backend stage ${stage.key} is inconsistent`);\n }\n referencedShaders.add(stage.shaderKey);\n }\n if (referencedStages.size !== stageMap.size\n || referencedShaders.size !== shaderMap.size)\n {\n throw new Error(\"CEWG backend graph contains orphan stages or shaders\");\n }\n\n const excludedShaderCount = shaders.filter((shader) =>\n shader.excluded).length;\n const failedShaderCount = shaders.filter((shader) =>\n !shader.hlsl2webgl?.ok && !shader.excluded).length;\n const failedBodyCount = glslBodies.filter((body) => body.error).length;\n const availableShaderCount = shaders.filter((shader) =>\n shader.hlsl2webgl?.ok && shader.source).length;\n const raster = inspectCewgRasterCompleteness(stages, shaders);\n const counts = {\n translatedShaderCount:\n shaders.length - failedShaderCount - excludedShaderCount,\n excludedShaderCount,\n failedShaderCount,\n failedBodyCount,\n availableShaderCount,\n expectedRasterPassCount: raster.expectedPassCount,\n completeRasterPassCount: raster.completePassCount,\n incompleteRasterPassCount: raster.incompletePasses.length\n };\n for (const [ field, actual ] of Object.entries(counts))\n {\n if (info[field] !== actual)\n {\n throw new Error(`CEWG INFO.${field} disagrees with the backend graph`);\n }\n }\n}\n\nfunction keyedRecordMap(records, context)\n{\n const map = new Map();\n for (const [ index, value ] of records.entries())\n {\n const record = requireRecord(value, `${context} ${index}`);\n if (typeof record.key !== \"string\" || !record.key\n || map.has(record.key))\n {\n throw new Error(`${context} ${index} has a missing or duplicate key`);\n }\n map.set(record.key, record);\n }\n return map;\n}\n\nfunction samePipelineInputs(reflected, manifest)\n{\n const fields = [\n \"usage\",\n \"registerIndex\",\n \"usageIndex\",\n \"usedMask\",\n \"type\",\n \"dimension\"\n ];\n return Array.isArray(reflected)\n && Array.isArray(manifest)\n && reflected.length === manifest.length\n && reflected.every((entry, index) =>\n fields.every((field) => entry[field] === manifest[index]?.[field]));\n}\n\nfunction requireRecord(value, context)\n{\n if (!value || typeof value !== \"object\" || Array.isArray(value))\n {\n throw new Error(`${context} must be an object`);\n }\n return value;\n}\n\nfunction requireArray(value, context)\n{\n if (!Array.isArray(value))\n {\n throw new Error(`${context} must be an array`);\n }\n return value;\n}\n\nfunction requireString(value, context)\n{\n if (typeof value !== \"string\" || !value)\n {\n throw new Error(`${context} must be a non-empty string`);\n }\n return value;\n}\n\nfunction requireUint(value, context)\n{\n if (!Number.isSafeInteger(value) || value < 0)\n {\n throw new Error(`${context} must be a non-negative safe integer`);\n }\n return value;\n}\n\nfunction jsonEqual(left, right)\n{\n return JSON.stringify(left) === JSON.stringify(right);\n}\n"],"names":["EFFECT_INFO_VERSION","EFFECT_PACKAGE_KINDS","Set","REQUIRED_EFFECT_CHUNKS","Object","freeze","SEMANTIC_VERSION","SHA256","validateEffectPackageEnvelope","pkg","GetChunk","info","requireRecord","GetJson","has","packageKind","tag","Error","format","formatVersion","targetBackend","backendPackage","test","backendPackageVersion","translator","translatorVersion","sourceIdentity","validateSourceIdentity","sourceByteLength","byteLength","sourceSha256","sha256","requireString","sourcePath","requireUint","defaultPermutationIndex","sourceEffectVersion","expectedMode","permutationMode","graphPointer","permutationGraph","chunk","EFFECT_PERMUTATION_GRAPH_CHUNK","EFFECT_PERMUTATION_GRAPH_FORMAT","EFFECT_PERMUTATION_GRAPH_VERSION","graphChunk","sha256Bytes","bytes","graph","graphCounts","validateEffectPermutationGraph","permutationCount","uniqueBodyCount","sourcePermutationCount","sourceUniqueBodyCount","metadata","glsl","validateBackendGraph","validateCompleteness","prototype","hasOwnProperty","call","EFFECT_REFLECTION_CHUNK","EFFECT_REFLECTION_BLOB_CHUNK","reflectionChunk","blobChunk","reflection","source","effectVersion","validateEffectReflectionPointer","effectReflection","reflectionBytes","validateReflectionBackendGraph","markEffectReflectionValidated","metadataBodies","Map","bodies","map","body","key","checkedBodies","variant","variants","bodyKey","add","metadataBody","get","reflected","effectReflectionForPermutation","permutationIndex","manifest","reflectedPasses","reflectedStages","technique","requireArray","techniques","passIndex","pass","passes","name","entries","push","techniqueName","states","renderStates","stage","stages","manifestPasses","manifestStages","length","reflectedPass","manifestPass","find","entry","jsonEqual","reflectedStage","sourceProgram","signature","input","manifestStage","stageType","stageName","kind","shaderSize","shaderBytecode","stringTableOffset","samePipelineInputs","pipelineInputs","threadGroupSize","size","some","value","identity","logicalPath","completeness","packageValid","runtimeComplete","sourceBodyCoverage","sourceComplete","backendProgramCoverage","selectionCoversWholeEffect","selection","expectedBackendCoverage","backendBodyCoverage","backendComplete","metadataVariants","glslVariants","glslBodies","shaders","expectedIndices","index","expected","metadataVariant","glslVariant","sourceVariant","bodyOffset","sourceRecord","offset","bodySize","bodyStageCount","uniqueShaderCount","metadataBodyMap","keyedRecordMap","glslBodyMap","stageMap","shaderMap","variantKeys","referencedBodies","referencedStages","bodyStages","stageKey","referencedShaders","shaderKey","excludedShaderCount","filter","shader","excluded","failedShaderCount","hlsl2webgl","ok","failedBodyCount","error","availableShaderCount","raster","inspectCewgRasterCompleteness","counts","translatedShaderCount","expectedRasterPassCount","expectedPassCount","completeRasterPassCount","completePassCount","incompleteRasterPassCount","incompletePasses","field","actual","records","context","record","set","fields","Array","isArray","every","Number","isSafeInteger","left","right","JSON","stringify"],"mappings":";;;;;;AAgBO,MAAMA,mBAAmB,GAAG;AAEnC,MAAMC,oBAAoB,GAAG,IAAIC,GAAG,CAAC,CACjC,kBAAkB,EAClB,+BAA+B,CAClC,CAAC;AACF,MAAMC,sBAAsB,GAAGC,MAAM,CAACC,MAAM,CAAC,CAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAE,CAAC;AACxE,MAAMC,gBAAgB,GAAG,oEAAoE;AAC7F,MAAMC,MAAM,GAAG,iBAAiB;;AAEhC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,6BAA6BA,CAACC,GAAG,EACjD;EACI,IAAI,CAACA,GAAG,CAACC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,IAAI;AAEtC,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KAAK,CAAC,EACzB;AACI,IAAA,MAAM,IAAIlH,KAAK,CAAC,CAAA,EAAGmL,OAAO,mBAAmB,CAAC;AAClD,EAAA;AACA,EAAA,OAAOjE,KAAK;AAChB;AAEA,SAASnG,aAAaA,CAACmG,KAAK,EAAEiE,OAAO,EACrC;AACI,EAAA,IAAI,OAAOjE,KAAK,KAAK,QAAQ,IAAI,CAACA,KAAK,EACvC;AACI,IAAA,MAAM,IAAIlH,KAAK,CAAC,CAAA,EAAGmL,OAAO,6BAA6B,CAAC;AAC5D,EAAA;AACA,EAAA,OAAOjE,KAAK;AAChB;AAEA,SAASjG,WAAWA,CAACiG,KAAK,EAAEiE,OAAO,EACnC;EACI,IAAI,CAACO,MAAM,CAACC,aAAa,CAACzE,KAAK,CAAC,IAAIA,KAAK,GAAG,CAAC,EAC7C;AACI,IAAA,MAAM,IAAIlH,KAAK,CAAC,CAAA,EAAGmL,OAAO,sCAAsC,CAAC;AACrE,EAAA;AACA,EAAA,OAAOjE,KAAK;AAChB;AAEA,SAASjB,SAASA,CAAC2F,IAAI,EAAEC,KAAK,EAC9B;AACI,EAAA,OAAOC,IAAI,CAACC,SAAS,CAACH,IAAI,CAAC,KAAKE,IAAI,CAACC,SAAS,CAACF,KAAK,CAAC;AACzD;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CewgpuContainer.js","sources":["../../../../../../src/formats/webgpu/core/cewgpu/CewgpuContainer.js"],"sourcesContent":["import {\n CjsCarbonEffectReader,\n readBackendBlock\n} from \"../../../../format/carbonEffect/index.js\";\nimport { WGSL_ENTRY_POINT } from \"../buildCarbonEffectContainer.js\";\nimport { sha256Bytes } from \"../../../../format/effect/sha256.js\";\nimport { deriveBackendBodySet } from \"./containerViews.js\";\n\n/**\n * Reader for the WebGPU effect container.\n *\n * The chunk package stored the permutation graph, the source reflection, the\n * translated body set and the emitted WGSL as four documents that had to be kept\n * consistent with each other, and carried digests to detect when they were not.\n * Under the record layout there is one document. The permutation graph is the\n * header's own permutation records and offset table, the reflection is the\n * description tree, and a translated pass is that tree's `shaderData` plus its\n * trailing block. So the accessors below are **views**, not stored copies, and\n * the class of bug the digests guarded against cannot occur: there is nothing\n * left to disagree.\n *\n * Keys the chunk format stored explicitly are derived here instead:\n *\n * - a body key is its position among distinct offset-table entries, which is\n * exactly what Carbon's alias dedupe produces;\n * - a pass's technique name, pass index and stage name come from its position in\n * the record tree, which is why cross-technique passes share on the wire;\n * - the WGSL entry point is a constant of the emitter, asserted on write.\n */\n\nconst textDecoder = new TextDecoder(\"utf-8\", { fatal: false });\n\n/** WGSL stage names by Carbon stage type, for the stage types WebGPU supports. */\nconst WEBGPU_STAGE_NAME = Object.freeze({ 0: \"vertex\", 1: \"pixel\", 2: \"compute\" });\n\n/** WebGPU pipeline stage for a WGSL stage name. */\nconst WEBGPU_STAGE = Object.freeze({ vertex: \"vertex\", pixel: \"fragment\", compute: \"compute\" });\n\n/**\n * Reports whether bytes look like a Carbon v15 effect container.\n *\n * This is a **shape** check, not an identity check, and the distinction is the\n * point: our containers are stock Carbon v15 files, so nothing in the bytes\n * separates ours from a shipped `effect.dx11` file. Identity comes from where\n * the file was resolved — `effect.webgpu/` versus `effect.dx11/` — exactly as it\n * does for Carbon, whose three backend trees are also byte-format-identical.\n *\n * Use this to reject something that is not a v15 container at all. Do not use it\n * to decide what a payload is.\n *\n * @param {Uint8Array} bytes Candidate bytes.\n * @returns {boolean} True when the first dword is Carbon's v15 version.\n */\nexport function looksLikeCewgpuContainer(bytes)\n{\n if (!bytes || bytes.length < 4) return false;\n return bytes[0] === 15 && bytes[1] === 0 && bytes[2] === 0 && bytes[3] === 0;\n}\n\n/**\n * Decomposes a permutation index into per-axis option indices.\n *\n * The inverse of Carbon's own selection arithmetic: it accumulates\n * `value * multiplier` over the axes in declaration order, multiplying the\n * running radix by each axis's option count.\n *\n * @param {object[]} axes Permutation axis records.\n * @param {number} permutationIndex Permutation index.\n * @returns {number[]} Option index per axis.\n */\nfunction optionIndicesFor(axes, permutationIndex)\n{\n let remaining = permutationIndex;\n return axes.map((axis) =>\n {\n const radix = axis.options.length || 1;\n const value = remaining % radix;\n remaining = Math.floor(remaining / radix);\n return value;\n });\n}\n\n/**\n * Reader over one WebGPU effect container.\n */\nexport class CewgpuContainer\n{\n /**\n * Creates an empty container reader.\n */\n constructor()\n {\n this.readError = null;\n this.sourcePath = \"\";\n this.containerVersion = 0;\n this.bytes = null;\n this.carbon = null;\n this._descriptions = new Map();\n this._bodyKeyByOffset = null;\n }\n\n /**\n * Reads a container from bytes.\n *\n * @param {ArrayBuffer|ArrayBufferView|Uint8Array} source Container bytes.\n * @param {object} [options] Read options.\n * @param {string} [options.sourcePath] Source path for diagnostics.\n * @returns {boolean} True when the container was decoded.\n */\n Read(source, options = {})\n {\n this.readError = null;\n this.sourcePath = options.sourcePath || \"\";\n this._descriptions = new Map();\n this._bodyKeyByOffset = null;\n\n try\n {\n const bytes = source instanceof Uint8Array\n ? source\n : (source instanceof ArrayBuffer\n ? new Uint8Array(source)\n : new Uint8Array(source.buffer, source.byteOffset, source.byteLength));\n\n this.bytes = bytes;\n this.carbon = new CjsCarbonEffectReader(bytes, {\n source: this.sourcePath || \"CEWGPU\"\n });\n this.containerVersion = this.carbon.version;\n return true;\n }\n catch (error)\n {\n this.readError = error;\n this.carbon = null;\n return false;\n }\n }\n\n /**\n * Reports whether the container decoded.\n *\n * @returns {boolean} True when readable.\n */\n IsGood()\n {\n return this.carbon !== null;\n }\n\n /**\n * Reads one permutation's description, memoised by stored body.\n *\n * Aliased permutations share one stored blob, so they share one parse.\n *\n * @param {number} permutationIndex Permutation index.\n * @returns {object} Description record tree.\n */\n GetDescription(permutationIndex)\n {\n const record = this.carbon.records[permutationIndex];\n if (!record)\n {\n throw new Error(`CEWGPU container has no body at permutation ${permutationIndex}`);\n }\n if (!this._descriptions.has(record.offset))\n {\n this._descriptions.set(\n record.offset,\n this.carbon.readDescription(permutationIndex, { backend: true })\n );\n }\n return this._descriptions.get(record.offset);\n }\n\n /**\n * Maps each distinct stored body to a stable key, in offset-table order.\n *\n * @returns {Map<number, string>} Body key by stored offset.\n */\n get bodyKeyByOffset()\n {\n if (!this._bodyKeyByOffset)\n {\n const keys = new Map();\n for (const record of this.carbon.records)\n {\n if (!keys.has(record.offset)) keys.set(record.offset, `body${keys.size}`);\n }\n this._bodyKeyByOffset = keys;\n }\n return this._bodyKeyByOffset;\n }\n\n /**\n * Derives the permutation graph the chunk package used to store.\n *\n * @returns {object} Permutation graph view.\n */\n get permutationGraph()\n {\n const bodyKeys = this.bodyKeyByOffset;\n const bodies = [];\n\n for (const [ offset, key ] of bodyKeys)\n {\n const record = this.carbon.records.find((entry) => entry.offset === offset);\n bodies.push(Object.freeze({\n key,\n offset,\n byteLength: record.size,\n // Hashed from the stored description blob. The chunk graph\n // carried a digest per body; here it is a function of the bytes\n // it identifies, so it cannot disagree with them. It is also what\n // Tr2EffectRes uses to prove bodies are distinct -- aliased rows\n // share one blob and therefore one digest, which is exactly the\n // identity the offset table already expresses.\n sha256: sha256Bytes(this.bytes.subarray(offset, offset + record.size)),\n permutationCount: this.carbon.records\n .filter((entry) => entry.offset === offset).length\n }));\n }\n\n return Object.freeze({\n // The envelope the chunk `PGRF` document carried. Not provenance:\n // `Tr2EffectRes.SetPayload` validates it before accepting a payload\n // at all, so a graph without it is refused outright.\n format: \"CJS_EFFECT_PERMUTATION_GRAPH\",\n formatVersion: 1,\n // Fixed by construction rather than recorded. A container always\n // carries every permutation, the offset table gives body identity\n // only, and source reflection is not a separate document.\n coverage: Object.freeze({\n permutations: \"complete\",\n bodies: \"identity-only\",\n reflection: \"absent\"\n }),\n axes: Object.freeze(this.carbon.permutations.map((axis, index) => Object.freeze({\n index,\n name: axis.name.value,\n defaultOption: axis.defaultOption,\n description: axis.description.value,\n type: axis.type,\n options: Object.freeze(axis.options.map((option) => option.value))\n }))),\n variants: Object.freeze(this.carbon.records.map((record, permutationIndex) =>\n Object.freeze({\n permutationIndex,\n bodyKey: bodyKeys.get(record.offset),\n // Mixed-radix decomposition of the index over the axes, which\n // is the inverse of the sum Carbon's GetShader() builds when\n // it walks options in declaration order.\n optionIndices: Object.freeze(\n optionIndicesFor(this.carbon.permutations, permutationIndex)\n ),\n // The offset-table row itself. Aliased permutations share a\n // stored record, so the consumer can prove that two\n // permutations resolve to the same emitted bytes.\n sourceRecord: Object.freeze({\n offset: record.offset,\n byteLength: record.size\n })\n }))),\n bodies: Object.freeze(bodies)\n });\n }\n\n /**\n * Resolves the translated backend passes for one permutation.\n *\n * A body whose stages carry no program is reported unsupported, which is\n * what a zero-length `shaderData` means: the reflection is known, the\n * program is not.\n *\n * @param {number} [permutationIndex] Permutation index.\n * @returns {object|null} Resolved backend body.\n */\n GetBackendBodyPrograms(permutationIndex = 0)\n {\n if (!this.IsGood()) return null;\n\n const record = this.carbon.records[permutationIndex];\n if (!record) return null;\n\n const description = this.GetDescription(permutationIndex);\n const bodyKey = this.bodyKeyByOffset.get(record.offset);\n const passes = [];\n let translated = false;\n\n for (const technique of description.techniques)\n {\n for (const [ passIndex, pass ] of technique.passes.entries())\n {\n const passKey = `${technique.name.value}.pass${passIndex}`;\n const shaders = [];\n\n for (const stage of pass.stages)\n {\n const stageName = WEBGPU_STAGE_NAME[stage.type];\n if (!stageName || stage.shaderData.size === 0) continue;\n translated = true;\n shaders.push(Object.freeze({\n key: `${passKey}.${stageName}`,\n techniqueName: technique.name.value,\n passIndex,\n stageName,\n stage: WEBGPU_STAGE[stageName],\n stageType: stage.type,\n entryPoint: WGSL_ENTRY_POINT,\n code: textDecoder.decode(stage.shaderData.bytes),\n ...(stageName === \"compute\"\n ? { threadGroupSize: [ ...stage.threadGroupSize ] }\n : {})\n }));\n }\n\n if (!shaders.length) continue;\n\n const block = pass.backendBlock && pass.backendBlock.size !== 0\n ? readBackendBlock(pass.backendBlock.bytes, {\n layoutKey: passKey,\n source: this.sourcePath || \"CEWGPU\"\n })\n : null;\n\n passes.push(Object.freeze({\n passKey,\n shaders: Object.freeze(shaders),\n layouts: Object.freeze(block\n ? [ Object.freeze({\n key: passKey,\n techniqueName: technique.name.value,\n passIndex,\n bindGroups: block.bindGroups\n }) ]\n : []),\n ...(block?.transforms?.length\n ? { resourceTransforms: Object.freeze(block.transforms) }\n : {})\n }));\n }\n }\n\n return Object.freeze({\n permutationIndex,\n bodyKey,\n status: translated ? \"translated\" : \"unsupported\",\n error: translated ? null : \"body carries no translated programs\",\n passes: Object.freeze(passes)\n });\n }\n\n /**\n * Derives the body-set view, for consumers holding the raw container.\n *\n * `packageToJson` exposes the same document. A consumer taking the raw emit\n * reads it here instead, which is why this is a getter on the container\n * rather than only a field in the JSON projection.\n *\n * @returns {object} Body-set document.\n */\n get backendBodySet()\n {\n return deriveBackendBodySet(this);\n }\n\n /**\n * Returns the Carbon description currently exposed through the legacy\n * portable-reflection accessor.\n *\n * This is not a `CJS_EFFECT_BODY_REFLECTION` envelope. Direct\n * `Tr2EffectRes` hydration requires an adapter and remains an open\n * integration boundary.\n *\n * @param {number} [permutationIndex] Permutation index.\n * @returns {object|null} Raw Carbon description record tree.\n */\n GetPortableEffectReflection(permutationIndex = 0)\n {\n if (!this.IsGood()) return null;\n return this.GetDescription(permutationIndex);\n }\n\n /**\n * Summarises the container without materialising every body.\n *\n * @returns {object} Container summary.\n */\n get info()\n {\n const bodyKeys = this.bodyKeyByOffset;\n return Object.freeze({\n format: \"CEWGPU\",\n // Carbon's own version dword, always 15. There is no container\n // version of ours: see buildCarbonEffectContainer for why nothing\n // announces the payload, and why identity comes from the path.\n containerVersion: this.containerVersion,\n sourcePath: this.sourcePath,\n compilerVersion: Object.freeze([ ...this.carbon.compilerVersion ]),\n sourceHash: textDecoder.decode(this.carbon.sourceHash),\n permutationCount: this.carbon.records.length,\n uniqueBodyCount: bodyKeys.size,\n axisCount: this.carbon.permutations.length\n });\n }\n}\n\nexport default CewgpuContainer;\n"],"names":["textDecoder","TextDecoder","fatal","WEBGPU_STAGE_NAME","Object","freeze","WEBGPU_STAGE","vertex","pixel","compute","looksLikeCewgpuContainer","bytes","length","optionIndicesFor","axes","permutationIndex","remaining","map","axis","radix","options","value","Math","floor","CewgpuContainer","constructor","readError","sourcePath","containerVersion","carbon","_descriptions","Map","_bodyKeyByOffset","Read","source","Uint8Array","ArrayBuffer","buffer","byteOffset","byteLength","CjsCarbonEffectReader","version","error","IsGood","GetDescription","record","records","Error","has","offset","set","readDescription","backend","get","bodyKeyByOffset","keys","size","permutationGraph","bodyKeys","bodies","key","find","entry","push","sha256","sha256Bytes","subarray","permutationCount","filter","format","formatVersion","coverage","permutations","reflection","index","name","defaultOption","description","type","option","variants","bodyKey","optionIndices","sourceRecord","GetBackendBodyPrograms","passes","translated","technique","techniques","passIndex","pass","entries","passKey","shaders","stage","stages","stageName","shaderData","techniqueName","stageType","entryPoint","WGSL_ENTRY_POINT","code","decode","threadGroupSize","block","backendBlock","readBackendBlock","layoutKey","layouts","bindGroups","transforms","resourceTransforms","status","backendBodySet","deriveBackendBodySet","GetPortableEffectReflection","info","compilerVersion","sourceHash","uniqueBodyCount","axisCount"],"mappings":";;;;;;;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAMA,WAAW,GAAG,IAAIC,WAAW,CAAC,OAAO,EAAE;AAAEC,EAAAA,KAAK,EAAE;AAAM,CAAC,CAAC;;AAE9D;AACA,MAAMC,iBAAiB,GAAGC,MAAM,CAACC,MAAM,CAAC;AAAE,EAAA,CAAC,EAAE,QAAQ;AAAE,EAAA,CAAC,EAAE,OAAO;AAAE,EAAA,CAAC,EAAE;AAAU,CAAC,CAAC;;AAElF;AACA,MAAMC,YAAY,GAAGF,MAAM,CAACC,MAAM,CAAC;AAAEE,EAAAA,MAAM,EAAE,QAAQ;AAAEC,EAAAA,KAAK,EAAE,UAAU;AAAEC,EAAAA,OAAO,EAAE;AAAU,CAAC,CAAC;;AAE/F;A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,CAACgF,MAAM;AAChC,KAAC,CAAC;AACN,EAAA;;AAEA;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACI,IAAI6B,cAAcA,GAClB;IACI,OAAOC,oBAAoB,CAAC,IAAI,CAAC;AACrC,EAAA;;AAEA;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACIC,EAAAA,2BAA2BA,CAACrG,gBAAgB,GAAG,CAAC,EAChD;IACI,IAAI,CAAC,IAAI,CAAC4B,MAAM,EAAE,EAAE,OAAO,IAAI;AAC/B,IAAA,OAAO,IAAI,CAACC,cAAc,CAAC7B,gBAAgB,CAAC;AAChD,EAAA;;AAEA;AACJ;AACA;AACA;AACA;EACI,IAAIsG,IAAIA,GACR;AACI,IAAA,MAAM3D,QAAQ,GAAG,IAAI,CAACJ,eAAe;IACrC,OAAOlD,MAAM,CAACC,MAAM,CAAC;AACjBgE,MAAAA,MAAM,EAAE,QAAQ;AAChB;AACA;AACA;MACAzC,gBAAgB,EAAE,IAAI,CAACA,gBAAgB;MACvCD,UAAU,EAAE,IAAI,CAACA,UAAU;AAC3B2F,MAAAA,eAAe,EAAElH,MAAM,CAACC,MAAM,CAAC,CAAE,GAAG,IAAI,CAACwB,MAAM,CAACyF,eAAe,CAAE,CAAC;MAClEC,UAAU,EAAEvH,WAAW,CAACuG,MAAM,CAAC,IAAI,CAAC1E,MAAM,CAAC0F,UAAU,CAAC;AACtDpD,MAAAA,gBAAgB,EAAE,IAAI,CAACtC,MAAM,CAACiB,OAAO,CAAClC,MAAM;MAC5C4G,eAAe,EAAE9D,QAAQ,CAACF,IAAI;AAC9BiE,MAAAA,SAAS,EAAE,IAAI,CAAC5F,MAAM,CAAC2C,YAAY,CAAC5D;AACxC,KAAC,CAAC;AACN,EAAA;AACJ;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"containerViews.js","sources":["../../../../../../src/formats/webgpu/core/cewgpu/containerViews.js"],"sourcesContent":["import { HlslEffectBindingManifest } from \"../../../hlsl/core/tr2/shader/HlslEffectBindingManifest.js\";\nimport { HlslShaderBytecode } from \"../../../hlsl/core/HlslShaderBytecode.js\";\nimport { hlslShaderStageName } from \"../../../hlsl/core/tr2/HlslRenderContextEnum.js\";\nimport { runtimeDescriptionFromCarbon } from \"../../../hlsl/core/carbonDescriptionToRuntime.js\";\nimport { buildEffectAnalysis } from \"../helpers.js\";\nimport { WGSL_SET_VERSION } from \"../wgsl/buildWgslSet.js\";\nimport { sha256Utf8 } from \"../../../../format/effect/sha256.js\";\n\n/**\n * Derived compatibility views over a container.\n *\n * The chunk package stored `ANLS` and `WGSL` as documents beside the reflection\n * they were computed from, and carried digests to detect the two disagreeing.\n * The container stores one document, so these are **views**: functions of the\n * records, computed on read. The class of bug the digests guarded cannot occur,\n * because there is no second copy to drift.\n *\n * The analysis view is deliberately not a reimplementation. It runs\n * `buildEffectAnalysis` — the same function the packager runs on source — over a\n * description rebuilt by `runtimeDescriptionFromCarbon`. That is what keeps the\n * view honest: if it were rewritten to emit the fields consumers read today, it\n * would be free to drift from the real analysis, and nothing would notice.\n * `carbon-analysis-adapter-corpus.test.mjs` diffs the two over every shipped\n * permutation and finds zero differences.\n *\n * These views exist for `engine-webgpu`, which reads format-package JSON for\n * Carbon reflection instead of reading `Tr2Shader`. That is a recorded layering\n * defect and is not this port's to fix; the views keep it working unchanged\n * while the wire format moves underneath it. They go away with that cleanup.\n */\n\n/**\n * Resolves the permutation Carbon's own `GetShader()` would select with no\n * option overrides.\n *\n * Carbon multiplies each axis's default option by the running product of the\n * preceding axes' option counts. The chunk package stored a single selected\n * body and its index; the container carries every permutation, so the view has\n * to name a default rather than inherit one, and Carbon's own default is the\n * only defensible choice.\n *\n * @param {object} container Loaded container.\n * @returns {number} Permutation index.\n */\nexport function defaultPermutationIndex(container)\n{\n let multiplier = 1;\n let index = 0;\n for (const axis of container.carbon.permutations)\n {\n index += axis.defaultOption * multiplier;\n multiplier *= axis.options.length || 1;\n }\n return index < container.carbon.records.length ? index : 0;\n}\n\n/**\n * Rebuilds the runtime effect description for one permutation.\n *\n * @param {object} container Loaded container.\n * @param {number} permutationIndex Permutation index.\n * @param {string} source Source label.\n * @returns {object} Runtime-shaped effect description.\n */\nfunction describeRuntime(container, permutationIndex, source)\n{\n return runtimeDescriptionFromCarbon(container.GetDescription(permutationIndex), {\n effectName: source,\n version: container.carbon.version,\n bytecodeFor: (stage, stageType) => new HlslShaderBytecode({\n stageType,\n // Carbon's six stage names, not WebGPU's three. A three-entry table\n // reports a geometry stage as null, which the corpus caught.\n stageName: hlslShaderStageName(stageType),\n bytes: stage.shaderData.bytes,\n shaderSize: stage.shaderData.size,\n stringTableOffset: stage.shaderData.offset,\n effectName: source\n })\n });\n}\n\n/**\n * Derives the analysis document for one permutation.\n *\n * One field is honestly different from the stored `ANLS` it replaces:\n * `stages[].shaderBytecode` describes the **WGSL** program the container\n * carries, where the stored document described the source DXBC. The container\n * does not carry DXBC, so reproducing the old numbers would mean inventing\n * them. Nothing in the engine's read surface uses this field; it is a\n * diagnostic.\n *\n * @param {object} container Loaded container.\n * @param {object} [options] View options.\n * @param {string} [options.source] Source label.\n * @param {number} [options.permutationIndex] Permutation to describe.\n * @returns {object} Analysis document.\n */\nexport function deriveAnalysis(container, options = {})\n{\n const source = options.source || container.sourcePath || \"memory\";\n const permutationIndex = options.permutationIndex ?? defaultPermutationIndex(container);\n const effectDescription = describeRuntime(container, permutationIndex, source);\n\n return buildEffectAnalysis({\n effectDescription,\n bindingManifest: HlslEffectBindingManifest.fromEffectDescription(effectDescription, {\n effectName: source\n }),\n effectRes: {\n sourcePath: source,\n m_compilerVersion: null\n },\n selection: {\n bodyIndex: permutationIndex,\n selectedOptions: container.carbon.permutations.map((axis) => ({\n name: axis.name.value,\n value: axis.options[axis.defaultOption]?.value ?? null\n }))\n }\n }, { source, decodeBytecode: false, decodeInstructions: false });\n}\n\n/**\n * Derives the WGSL set document for one permutation.\n *\n * `sourceMap` is absent rather than empty, and that is not an oversight: its\n * offsets index DXBC bytes the container does not carry, so it is a translator\n * diagnostic and was dropped on write. It was separately measured to suppress\n * no sharing, so keeping it would have bought nothing either.\n *\n * @param {object} container Loaded container.\n * @param {object} [options] View options.\n * @param {number} [options.permutationIndex] Permutation to describe.\n * @returns {object} WGSL set document.\n */\nexport function deriveWgsl(container, options = {})\n{\n const permutationIndex = options.permutationIndex ?? defaultPermutationIndex(container);\n const body = container.GetBackendBodyPrograms(permutationIndex);\n const shaders = [];\n const layouts = [];\n const resourceTransforms = [];\n\n for (const pass of body?.passes ?? [])\n {\n for (const shader of pass.shaders)\n {\n shaders.push({\n key: shader.key,\n techniqueName: shader.techniqueName,\n passIndex: shader.passIndex,\n stageName: shader.stageName,\n stage: shader.stage,\n stageType: shader.stageType,\n entryPoint: shader.entryPoint,\n code: shader.code,\n ...(shader.threadGroupSize ? { threadGroupSize: [ ...shader.threadGroupSize ] } : {})\n });\n }\n for (const layout of pass.layouts) layouts.push(layout);\n for (const transform of pass.resourceTransforms ?? []) resourceTransforms.push(transform);\n }\n\n return {\n format: \"CJS_WGSL_SET\",\n formatVersion: WGSL_SET_VERSION,\n shaders,\n layouts,\n ...(resourceTransforms.length ? { resourceTransforms } : {})\n };\n}\n\n/**\n * Derives the `WGSB` body-set view the chunk package used to store.\n *\n * `engine-webgpu` resolves a permutation's translated programs through this,\n * which is part of the recorded layering defect -- it should read the shader,\n * not a package document. The view keeps that path working unchanged while the\n * wire format moves underneath it, and goes away with the cleanup.\n *\n * Nothing here is stored. A body's status is whether its stages carry programs,\n * its passes are the record tree's passes, and a pass unit is that pass's\n * shaders and layouts. Bodies are keyed by distinct stored offset, which is\n * exactly what Carbon's alias dedupe produces.\n *\n * @param {object} container Loaded container.\n * @returns {object} Body-set document.\n */\nexport function deriveBackendBodySet(container)\n{\n const bodyKeys = container.bodyKeyByOffset;\n const passUnits = [];\n const bodies = [];\n const seen = new Set();\n\n for (let index = 0; index < container.carbon.records.length; index += 1)\n {\n const offset = container.carbon.records[index].offset;\n if (seen.has(offset)) continue;\n seen.add(offset);\n\n const bodyKey = bodyKeys.get(offset);\n const body = container.GetBackendBodyPrograms(index);\n\n if (!body || body.status !== \"translated\")\n {\n bodies.push({\n bodyKey,\n representativePermutationIndex: index,\n status: \"unsupported\",\n error: body?.error ?? \"body carries no translated programs\",\n passCount: 0,\n passes: []\n });\n continue;\n }\n\n const passes = [];\n for (const pass of body.passes)\n {\n const unit = {\n key: `unit${passUnits.length}`,\n // Hashed from the unit's own content. The chunk body set stored\n // this digest to detect a unit drifting from what referenced it;\n // derived from the content it identifies, it cannot.\n sha256: sha256Utf8(`${JSON.stringify({\n shaders: pass.shaders,\n layouts: pass.layouts,\n resourceTransforms: pass.resourceTransforms ?? []\n })}\n`),\n wgslSetVersion: WGSL_SET_VERSION,\n shaders: pass.shaders,\n layouts: pass.layouts,\n ...(pass.resourceTransforms?.length\n ? { resourceTransforms: pass.resourceTransforms }\n : {})\n };\n passUnits.push(unit);\n passes.push({ passKey: pass.passKey, unitKey: unit.key });\n }\n\n bodies.push({\n bodyKey,\n representativePermutationIndex: index,\n status: \"translated\",\n error: null,\n passCount: passes.length,\n passes\n });\n }\n\n return {\n format: \"CJS_WGSL_BODY_SET\",\n formatVersion: 1,\n bodyCount: bodies.length,\n translatedBodyCount: bodies.filter((body) => body.status === \"translated\").length,\n passUnitCount: passUnits.length,\n passUnits,\n bodies\n };\n}\n\n/**\n * Finds the permutation a package resolves to.\n *\n * A \"selected\" package is not a different format -- the container always carries\n * every permutation. What makes it selected is that exactly one body was\n * translated, so the resolved permutation is the first one whose body carries\n * programs. When every body is translated, there is nothing to single out and\n * Carbon's own default applies.\n *\n * @param {object} container Loaded container.\n * @returns {number} Permutation index.\n */\nexport function resolvedPermutationIndex(container)\n{\n const translated = [];\n const seen = new Set();\n\n for (let index = 0; index < container.carbon.records.length; index += 1)\n {\n const offset = container.carbon.records[index].offset;\n if (seen.has(offset)) continue;\n seen.add(offset);\n\n const body = container.GetBackendBodyPrograms(index);\n if (body?.status === \"translated\") translated.push(index);\n if (translated.length > 1) return defaultPermutationIndex(container);\n }\n\n return translated.length === 1 ? translated[0] : defaultPermutationIndex(container);\n}\n\n/**\n * Derives the `META`-shaped view the chunk package used to store.\n *\n * Every field here is recovered from the records rather than carried:\n * `selectedOptions` from the resolved permutation's option indices, and\n * `wgslSelection` from which passes and stages actually hold programs. Build-time\n * *policy* -- `bodyMode`, `sourceIdentity`, `completeness` -- is deliberately not\n * here: it describes how the artifact was produced, not what it is, and Carbon\n * stores none of it.\n *\n * @param {object} container Loaded container.\n * @param {object} [options] View options.\n * @param {string} [options.source] Source label.\n * @param {number} [options.permutationIndex] Permutation to describe.\n * @returns {object} Metadata document.\n */\nexport function deriveMetadata(container, options = {})\n{\n const source = options.source || container.sourcePath || \"memory\";\n const permutationIndex = options.permutationIndex ?? resolvedPermutationIndex(container);\n const variant = container.permutationGraph.variants[permutationIndex];\n const axes = container.carbon.permutations;\n\n const selectedOptions = axes.map((axis, axisIndex) => ({\n name: axis.name.value,\n value: axis.options[variant?.optionIndices?.[axisIndex] ?? axis.defaultOption]?.value ?? null\n }));\n\n const body = container.GetBackendBodyPrograms(permutationIndex);\n const selectedStageKeys = (body?.passes ?? [])\n .flatMap((pass) => pass.shaders.map((shader) => shader.key));\n const passKeys = (body?.passes ?? []).map((pass) => pass.passKey);\n\n return {\n effectName: source,\n sourcePath: source,\n bodyIndex: permutationIndex,\n selectedOptions,\n ...(passKeys.length === 1\n ? {\n wgslSelection: {\n mode: \"explicit\",\n completePasses: true,\n techniqueName: passKeys[0].slice(0, passKeys[0].lastIndexOf(\".pass\")),\n passIndex: Number(/\\.pass([0-9]+)$/u.exec(passKeys[0])?.[1] ?? 0),\n requestedStageNames: Array.from(new Set(\n (body?.passes ?? []).flatMap((pass) => pass.shaders.map((shader) => shader.stageName))\n )),\n selectedStageKeys\n }\n }\n : {})\n };\n}\n\n/**\n * Derives the `INFO`-shaped summary the chunk package used to store.\n *\n * Everything here is counted from the records rather than trusted from a stored\n * field, which is why no digest accompanies it: a count derived from the thing\n * it counts cannot disagree with it.\n *\n * @param {object} container Loaded container.\n * @param {object} [options] View options.\n * @param {string} [options.source] Source label.\n * @returns {object} Info document.\n */\nexport function deriveInfo(container, options = {})\n{\n const source = options.source || container.sourcePath || \"memory\";\n const graph = container.permutationGraph;\n return {\n format: \"CEWGPU\",\n packageKind: \"tr2-effect-webgpu\",\n sourcePath: source,\n effectVersion: container.carbon.version,\n compilerVersion: [ ...container.carbon.compilerVersion ],\n permutationCount: graph.variants.length,\n uniqueBodyCount: graph.bodies.length\n };\n}\n\nexport default deriveAnalysis;\n"],"names":["defaultPermutationIndex","container","multiplier","index","axis","carbon","permutations","defaultOption","options","length","records","describeRuntime","permutationIndex","source","runtimeDescriptionFromCarbon","GetDescription","effectName","version","bytecodeFor","stage","stageType","HlslShaderBytecode","stageName","hlslShaderStageName","bytes","shaderData","shaderSize","size","stringTableOffset","offset","deriveAnalysis","sourcePath","effectDescription","buildEffectAnalysis","bindingManifest","HlslEffectBindingManifest","fromEffectDescription","effectRes","m_compilerVersion","selection","bodyIndex","selectedOptions","map","name","value","decodeBytecode","decodeInstructions","deriveWgsl","body","GetBackendBodyPrograms","shaders","layouts","resourceTransforms","pass","passes","shader","push","key","techniqueName","passIndex","entryPoint","code","threadGroupSize","layout","transform","format","formatVersion","WGSL_SET_VERSION","deriveBackendBodySet","bodyKeys","bodyKeyByOffset","passUnits","bodies","seen","Set","has","add","bodyKey","get","status","representativePermutationIndex","error","passCount","unit","sha256","sha256Utf8","JSON","stringify","wgslSetVersion","passKey","unitKey","bodyCount","translatedBodyCount","filter","passUnitCount","resolvedPermutationIndex","translated","deriveMetadata","variant","permutationGraph","variants","axes","axisIndex","optionIndices","selectedStageKeys","flatMap","passKeys","wgslSelection","mode","completePasses","slice","lastIndexOf","Number","exec","requestedStageNames","Array","from","deriveInfo","graph","packageKind","effectVersion","compilerVersion","permutationCount","uniqueBodyCount"],"mappings":";;;;;;;;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AACoH,eAAe,CAAE;AACxDC,IAAAA,gBAAgB,EAAEJ,KAAK,CAAClB,QAAQ,CAAC3F,MAAM;AACvCkH,IAAAA,eAAe,EAAEL,KAAK,CAAC9C,MAAM,CAAC/D;GACjC;AACL;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validateContainer.js","sources":["../../../../../../src/formats/webgpu/core/cewgpu/validateContainer.js"],"sourcesContent":["import { WebgpuReadError } from \"../errors.js\";\n\n/**\n * Structural validation for a loaded WebGPU effect container.\n *\n * This replaces `validateEffectPackageEnvelope`, which was 1762 lines. Most of\n * that is **deleted rather than translated**, and the reason matters: those\n * checks were not format invariants. The chunk container shattered one logical\n * tree into flat string-keyed arrays across `INFO`, `META`, `ANLS`, `WGSL`,\n * `PGRF` and `WGSB`, each holding a projection of the same effect, and roughly\n * 600 lines asserted that the projections still agreed with each other. A record\n * layout makes that question unaskable: containment replaces reference, position\n * replaces key, and the count word before an array replaces `Array.isArray`.\n *\n * What is deliberately **not** re-checked here, because phase 1 already enforces\n * it and checking twice means two places to keep correct:\n *\n * - count caps, arena containment, offset-table density and positional indexing,\n * and the version range — `CjsCarbonEffectReader`;\n * - every sized record parsing to exactly its declared end — Rule 1, in the\n * record codec and the block codec;\n * - duplicate stage type within a pass, and stage-type range — the shape adapter\n * fails closed on both, which is where a runtime description is built.\n *\n * What remains is the one thing that is genuinely this layer's: the container\n * admits all six of Carbon's stage types by design, and WebGPU can express three.\n * That restriction belongs to the backend, not to the container — the Carbon\n * region is backend-invariant, and a container that admitted only three would not\n * be Carbon's container.\n */\n\n/** Stage types WebGPU can express, by Carbon's `InputStageType` numbering. */\nconst WEBGPU_STAGE_TYPES = new Set([ 0, 1, 2 ]);\n\n/**\n * Validates a loaded container for WebGPU consumption.\n *\n * @param {object} container Loaded `CewgpuContainer`.\n * @param {object} [options] Validation options.\n * @param {string} [options.source] Source label for diagnostics.\n * @throws {WebgpuReadError} When the container cannot serve WebGPU.\n */\nexport function validateEffectContainer(container, options = {})\n{\n const source = options.source || container.sourcePath || \"memory\";\n\n if (!container?.IsGood())\n {\n throw new WebgpuReadError(\"CEWGPU container is not readable\", {\n source,\n cause: container?.readError ?? null\n });\n }\n\n if (!container.carbon.records.length)\n {\n throw new WebgpuReadError(\"CEWGPU container declares no permutation bodies\", { source });\n }\n\n // One check per distinct stored body. Aliased rows share a blob, so checking\n // per permutation would re-check identical bytes up to twenty times over on\n // the effects that alias hardest.\n const checked = new Set();\n\n for (let index = 0; index < container.carbon.records.length; index += 1)\n {\n const offset = container.carbon.records[index].offset;\n if (checked.has(offset)) continue;\n checked.add(offset);\n\n const description = container.GetDescription(index);\n\n for (const technique of description.techniques)\n {\n for (const [ passIndex, pass ] of technique.passes.entries())\n {\n for (const stage of pass.stages)\n {\n // A stage carrying no program is reflection-only: the body\n // is known, the translation is not, and the emitter says so\n // with a zero-length payload. Those are legitimate — 107\n // shipped body-passes carry a geometry stage — so the rule\n // is about stages with a program, not about stages.\n if (stage.shaderData.size === 0) continue;\n\n if (!WEBGPU_STAGE_TYPES.has(stage.type))\n {\n throw new WebgpuReadError(\n `CEWGPU container carries a program for stage type ${stage.type}, `\n + \"which WebGPU cannot express\",\n {\n source,\n permutationIndex: index,\n pass: `${technique.name.value}.pass${passIndex}`,\n stageType: stage.type\n }\n );\n }\n }\n }\n }\n }\n}\n\nexport default validateEffectContainer;\n"],"names":["WEBGPU_STAGE_TYPES","Set","validateEffectContainer","container","options","source","sourcePath","IsGood","WebgpuReadError","cause","readError","carbon","records","length","checked","index","offset","has","add","description","GetDescription","technique","techniques","passIndex","pass","passes","entries","stage","stages","shaderData","size","type","permutationIndex","name","value","stageType"],"mappings":";;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,MAAMA,kBAAkB,GAAG,IAAIC,GAAG,CAAC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,OAAO,EAAE,EAC5D;AACI,QAAA,KAAK,MAAMC,KAAK,IAAIH,IAAI,CAACI,MAAM,EAC/B;AACI;AACA;AACA;AACA;AACA;AACA,UAAA,IAAID,KAAK,CAACE,UAAU,CAACC,IAAI,KAAK,CAAC,EAAE;UAEjC,IAAI,CAAC9B,kBAAkB,CAACiB,GAAG,CAACU,KAAK,CAACI,IAAI,CAAC,EACvC;YACI,MAAM,IAAIvB,eAAe,CACrB,CAAA,kDAAA,EAAqDmB,KAAK,CAACI,IAAI,CAAA,EAAA,CAAI,GACjE,6BAA6B,EAC/B;cACI1B,MAAM;AACN2B,cAAAA,gBAAgB,EAAEjB,KAAK;cACvBS,IAAI,EAAE,GAAGH,SAAS,CAACY,IAAI,CAACC,KAAK,CAAA,KAAA,EAAQX,SAAS,CAAA,CAAE;cAChDY,SAAS,EAAER,KAAK,CAACI;AACrB,aACJ,CAAC;AACL,UAAA;AACJ,QAAA;AACJ,MAAA;AACJ,IAAA;AACJ,EAAA;AACJ;;;;"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { copyBytes } from '@carbonenginejs/runtime-utils/bytes';
|
|
2
|
-
import { isUint32, isPlainObject } from '@carbonenginejs/runtime-utils/is';
|
|
3
|
-
import { cloneCarbonValue } from '@carbonenginejs/runtime-utils/types';
|
|
4
|
-
|
|
5
|
-
/** Require one of Carbon's six authored shader-stage indices. */
|
|
6
|
-
function requirePortableStageType(value) {
|
|
7
|
-
if (!isUint32(value)) {
|
|
8
|
-
throw new RangeError("Portable shader stage type must fit uint32");
|
|
9
|
-
}
|
|
10
|
-
if (value >= 6) {
|
|
11
|
-
throw new RangeError("Portable shader stage type must be in [0, 5]");
|
|
12
|
-
}
|
|
13
|
-
return value;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/** Clone and validate one owned source-program payload. */
|
|
17
|
-
function clonePortableSourceProgram(value, expectedKind) {
|
|
18
|
-
if (!isPlainObject(value)) {
|
|
19
|
-
throw new TypeError(`Portable ${expectedKind} source program must be an object`);
|
|
20
|
-
}
|
|
21
|
-
if (value.kind !== expectedKind) {
|
|
22
|
-
throw new Error(`Portable source program kind "${value.kind}" is not "${expectedKind}"`);
|
|
23
|
-
}
|
|
24
|
-
if (!(value.bytes instanceof Uint8Array)) {
|
|
25
|
-
throw new TypeError(`Portable ${expectedKind} source program must be Uint8Array bytes`);
|
|
26
|
-
}
|
|
27
|
-
const result = cloneCarbonValue(value);
|
|
28
|
-
result.bytes = copyBytes(value.bytes);
|
|
29
|
-
return result;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export { clonePortableSourceProgram, requirePortableStageType };
|
|
33
|
-
//# sourceMappingURL=portable.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"portable.js","sources":["../../../../src/resource/shader/portable.js"],"sourcesContent":["import { copyBytes } from \"@carbonenginejs/runtime-utils/bytes\";\nimport {\n isPlainObject,\n isUint32\n} from \"@carbonenginejs/runtime-utils/is\";\nimport { cloneCarbonValue } from \"@carbonenginejs/runtime-utils/types\";\n\n/** Require one of Carbon's six authored shader-stage indices. */\nexport function requirePortableStageType(value)\n{\n if (!isUint32(value))\n {\n throw new RangeError(\"Portable shader stage type must fit uint32\");\n }\n if (value >= 6)\n {\n throw new RangeError(\"Portable shader stage type must be in [0, 5]\");\n }\n return value;\n}\n\n/** Clone and validate one owned source-program payload. */\nexport function clonePortableSourceProgram(value, expectedKind)\n{\n if (!isPlainObject(value))\n {\n throw new TypeError(\n `Portable ${expectedKind} source program must be an object`\n );\n }\n if (value.kind !== expectedKind)\n {\n throw new Error(\n `Portable source program kind \"${value.kind}\" is not \"${expectedKind}\"`\n );\n }\n if (!(value.bytes instanceof Uint8Array))\n {\n throw new TypeError(\n `Portable ${expectedKind} source program must be Uint8Array bytes`\n );\n }\n\n const result = cloneCarbonValue(value);\n result.bytes = copyBytes(value.bytes);\n return result;\n}\n"],"names":["requirePortableStageType","value","isUint32","RangeError","clonePortableSourceProgram","expectedKind","isPlainObject","TypeError","kind","Error","bytes","Uint8Array","result","cloneCarbonValue","copyBytes"],"mappings":";;;;AAOA;AACO,SAASA,wBAAwBA,CAACC,KAAK,EAC9C;AACE,EAAA,IAAI,CAACC,QAAQ,CAACD,KAAK,CAAC,EACpB;AACE,IAAA,MAAM,IAAIE,UAAU,CAAC,4CAA4C,CAAC;AACpE,EAAA;EACA,IAAIF,KAAK,IAAI,CAAC,EACd;AACE,IAAA,MAAM,IAAIE,UAAU,CAAC,8CAA8C,CAAC;AACtE,EAAA;AACA,EAAA,OAAOF,KAAK;AACd;;AAEA;AACO,SAASG,0BAA0BA,CAACH,KAAK,EAAEI,YAAY,EAC9D;AACE,EAAA,IAAI,CAACC,aAAa,CAACL,KAAK,CAAC,EACzB;AACE,IAAA,MAAM,IAAIM,SAAS,CACjB,CAAA,SAAA,EAAYF,YAAY,mCAC1B,CAAC;AACH,EAAA;AACA,EAAA,IAAIJ,KAAK,CAACO,IAAI,KAAKH,YAAY,EAC/B;IACE,MAAM,IAAII,KAAK,CACb,CAAA,8BAAA,EAAiCR,KAAK,CAACO,IAAI,CAAA,UAAA,EAAaH,YAAY,CAAA,CAAA,CACtE,CAAC;AACH,EAAA;AACA,EAAA,IAAI,EAAEJ,KAAK,CAACS,KAAK,YAAYC,UAAU,CAAC,EACxC;AACE,IAAA,MAAM,IAAIJ,SAAS,CACjB,CAAA,SAAA,EAAYF,YAAY,0CAC1B,CAAC;AACH,EAAA;AAEA,EAAA,MAAMO,MAAM,GAAGC,gBAAgB,CAACZ,KAAK,CAAC;EACtCW,MAAM,CAACF,KAAK,GAAGI,SAAS,CAACb,KAAK,CAACS,KAAK,CAAC;AACrC,EAAA,OAAOE,MAAM;AACf;;;;"}
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
# Portable body reflection
|
|
2
|
-
|
|
3
|
-
Status: Evolving
|
|
4
|
-
Scope: `@carbonenginejs/runtime-resource/formats/hlsl/portable`
|
|
5
|
-
Audience: Backend effect-packager authors
|
|
6
|
-
Summary: Defines exact, handle-free reflection for one compiled effect body.
|
|
7
|
-
|
|
8
|
-
## Purpose
|
|
9
|
-
|
|
10
|
-
The ordinary JSON and metadata modes describe one option-selected effect for
|
|
11
|
-
inspection. Backend package builders need a stronger boundary: exact
|
|
12
|
-
permutation-table selection, authored constant defaults, source programs, and
|
|
13
|
-
all reflection fields without renderer handles.
|
|
14
|
-
|
|
15
|
-
The portable subpath supplies that boundary:
|
|
16
|
-
|
|
17
|
-
```js
|
|
18
|
-
import {
|
|
19
|
-
buildEffectBodyReflection,
|
|
20
|
-
enumerateUniqueEffectBodies,
|
|
21
|
-
readEffectBodyReflection,
|
|
22
|
-
validateEffectBodyReflection
|
|
23
|
-
} from "@carbonenginejs/runtime-resource/formats/hlsl/portable";
|
|
24
|
-
|
|
25
|
-
const document = readEffectBodyReflection(bytes, {
|
|
26
|
-
source: "effect.sm_depth",
|
|
27
|
-
permutationIndex: 4
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
validateEffectBodyReflection(document);
|
|
31
|
-
|
|
32
|
-
const groups = enumerateUniqueEffectBodies(effectRes);
|
|
33
|
-
const uniqueReflections = groups.map((group) =>
|
|
34
|
-
buildEffectBodyReflection(effectRes, group.permutationIndex));
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
`buildEffectBodyReflection(effectRes, permutationIndex)` accepts an already
|
|
38
|
-
loaded raw `Tr2EffectRes`. This avoids reparsing when a backend builder already
|
|
39
|
-
uses `readEffectAnalysis`.
|
|
40
|
-
|
|
41
|
-
`enumerateUniqueEffectBodies(effectRes)` inspects version-15 source records and
|
|
42
|
-
bytes without decoding. It returns first-occurrence-ordered groups containing
|
|
43
|
-
one canonical `permutationIndex`/`sourceRecord` plus every byte-identical
|
|
44
|
-
variant alias. Exact range aliases are a fast path; distinct ranges are
|
|
45
|
-
fingerprinted and then compared byte-for-byte. The inventory caps the
|
|
46
|
-
Cartesian body table at 65,536 records, rejects partial overlaps, and leaves
|
|
47
|
-
the effect cache and state-manager registries unchanged.
|
|
48
|
-
|
|
49
|
-
## Contract
|
|
50
|
-
|
|
51
|
-
Version 1 accepts compiled effect version 15 only. Earlier container versions
|
|
52
|
-
synthesize or normalize several signature fields while reading; rejecting them
|
|
53
|
-
keeps every portable field source-exact.
|
|
54
|
-
|
|
55
|
-
The root identifies `CJS_EFFECT_BODY_REFLECTION` version 1,
|
|
56
|
-
`mode: "single-body"`, `keyScope: "body-local"`,
|
|
57
|
-
`coverage.bodies: "single"`, the diagnostic source label and
|
|
58
|
-
compiled-effect version/compiler/shared-table/source envelope in `source`, the exact
|
|
59
|
-
`permutationIndex`, and its
|
|
60
|
-
`sourceRecord.offset` / `sourceRecord.byteLength` span. Its effect graph
|
|
61
|
-
preserves:
|
|
62
|
-
|
|
63
|
-
- ordered parameter annotation groups;
|
|
64
|
-
- ordered techniques, passes, raw render-state pairs, and libraries;
|
|
65
|
-
- every present vertex, pixel, compute, geometry, hull, or domain stage;
|
|
66
|
-
- constant, resource, UAV, dynamic sampler, and stage-annotation metadata;
|
|
67
|
-
- complete pipeline-input, register, static-sampler, and thread-group
|
|
68
|
-
signatures;
|
|
69
|
-
- exact authored constant-default bytes and declared length; and
|
|
70
|
-
- owned copies of every stage and library source-program payload.
|
|
71
|
-
|
|
72
|
-
Every source-program record retains its exact shared-table offset. The
|
|
73
|
-
validator requires its complete byte range to remain within
|
|
74
|
-
`source.stringTableByteLength`.
|
|
75
|
-
Stage programs are explicitly `kind: "stage"` and carry their authored stage
|
|
76
|
-
identity. DXR library programs are `kind: "library"` and deliberately carry no
|
|
77
|
-
synthetic compute-stage identity.
|
|
78
|
-
|
|
79
|
-
Numeric BOOL, INT, and FLOAT annotations retain their exact serialized
|
|
80
|
-
`rawValue`. Sampler floats retain raw IEEE-754 bits. Static sampler border
|
|
81
|
-
colors remain their source enum byte; dynamic sampler border colors remain
|
|
82
|
-
four float bit patterns.
|
|
83
|
-
|
|
84
|
-
`source.nativeHash` is the compiler-provided v15 hash field, not a package
|
|
85
|
-
content digest. The backend package must independently hash its whole source
|
|
86
|
-
and body payloads.
|
|
87
|
-
|
|
88
|
-
Version-15 resource and signature counts retain Carbon's authored zero value.
|
|
89
|
-
For heap-view/bindless SRV, UAV, and sampler bindings, `arrayElements: 0` and
|
|
90
|
-
the matching signature `arrayCount: 0` / `registerCount: 0` represent an
|
|
91
|
-
unbounded descriptor range; they are valid source reflection, not an empty or
|
|
92
|
-
malformed binding. Every resource and UAV map entry must reconcile with
|
|
93
|
-
exactly one signature register; signature-only records remain valid.
|
|
94
|
-
|
|
95
|
-
The compiled body has no authored effect-name field. The caller-supplied
|
|
96
|
-
diagnostic name or path is retained only as `source.label`.
|
|
97
|
-
|
|
98
|
-
The serializer rejects defaults or constant extents beyond Carbon's 4,096-byte
|
|
99
|
-
stage constant-buffer limit.
|
|
100
|
-
|
|
101
|
-
## Source truth and realization
|
|
102
|
-
|
|
103
|
-
The portable document excludes shader, program, render-state, sampler, and
|
|
104
|
-
library handles. It also excludes resource-set descriptions, heap-view arrays,
|
|
105
|
-
backend layouts, masks, sort values, and caches. `runtime-resource` consumes
|
|
106
|
-
the document to hydrate the canonical device-free shader/reflection graph,
|
|
107
|
-
select permutations, and cache shaders. Engines own handles, layouts,
|
|
108
|
-
resource sets, programs, pipelines, and other GPU realization.
|
|
109
|
-
|
|
110
|
-
Register dynamic classification is not persisted. It depends on per-frame
|
|
111
|
-
reader/engine policy and is not an authored binary field.
|
|
112
|
-
|
|
113
|
-
Authored constant defaults are separate from the raw model's mutable
|
|
114
|
-
`constantValues`. Carbon-compatible sampler-heap realization may zero-extend
|
|
115
|
-
the latter; it cannot change the portable source prefix.
|
|
116
|
-
|
|
117
|
-
## Selection and completeness
|
|
118
|
-
|
|
119
|
-
The parser-internal `GetShaderByIndex(index)` and the portable serializer
|
|
120
|
-
bypass global and local option selection. This is distinct from
|
|
121
|
-
`runtime-resource` `Tr2EffectRes.GetShaderByIndex`, which hydrates and caches a
|
|
122
|
-
canonical shader. The portable serializer performs a fresh non-caching decode
|
|
123
|
-
with a temporary state manager, so mutation of a previously cached raw shader
|
|
124
|
-
cannot change reflection rebuilt from the same owned source bytes.
|
|
125
|
-
This makes a body-table index stable even when an application has global
|
|
126
|
-
effect options.
|
|
127
|
-
|
|
128
|
-
Version 1 describes one complete listed body. Body-local technique, pass,
|
|
129
|
-
stage, and library keys must be namespaced by a backend package before they are
|
|
130
|
-
flattened across bodies. This document does not claim that a backend package
|
|
131
|
-
contains every permutation body or a program for every body. A backend
|
|
132
|
-
container must reconcile all three of `permutationIndex`,
|
|
133
|
-
`sourceRecord.offset`, and `sourceRecord.byteLength` with its own body identity
|
|
134
|
-
and permutation graph, then reconcile the source byte length and native hash
|
|
135
|
-
before claiming completeness.
|
|
136
|
-
|
|
137
|
-
## Related documentation
|
|
138
|
-
|
|
139
|
-
- [JSON and metadata graphs](json-graph.md)
|
|
140
|
-
- [Advanced analysis exports](advanced-analysis.md)
|
|
141
|
-
- [Architecture](../architecture.md)
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
# CEWG effect reflection contract
|
|
2
|
-
|
|
3
|
-
Status: Evolving
|
|
4
|
-
Scope: `@carbonenginejs/runtime-resource/formats/webgl` effect packages and portable reflection
|
|
5
|
-
Audience: Package users, runtime integrators, and GPU-engine maintainers
|
|
6
|
-
Summary: Defines CEWG reflection, validation, ownership, and completeness.
|
|
7
|
-
|
|
8
|
-
`@carbonenginejs/runtime-resource/formats/webgl` packages immutable compiled-effect data. It
|
|
9
|
-
does not create runtime shader classes or WebGL objects.
|
|
10
|
-
|
|
11
|
-
## Ownership
|
|
12
|
-
|
|
13
|
-
- `format-hlsl` owns the portable, GPU-free reflection schema and source
|
|
14
|
-
parser.
|
|
15
|
-
- `format-webgl` owns CEWG serialization, GLSL backend records, integrity
|
|
16
|
-
validation, and reconstruction of one portable body by permutation index.
|
|
17
|
-
- `runtime-resource` owns loaded effect-package bytes, option selection,
|
|
18
|
-
per-index caching, canonical `Tr2Shader`, and its device-free reflection and
|
|
19
|
-
sampler records.
|
|
20
|
-
- `runtime-trinity` owns the mutable `Tr2Effect`/`Tr2Material` facade,
|
|
21
|
-
parameters, authored shader options, and sampler overrides. `Tw2*` is legacy
|
|
22
|
-
ccpwgl comparison terminology, not a maintained runtime class surface.
|
|
23
|
-
- The WebGL engine owns handles, locations, layouts, buffer packing, texture
|
|
24
|
-
binding, and draw-time validation.
|
|
25
|
-
|
|
26
|
-
The current runtime connection is one-way: runtime-resource consumes the
|
|
27
|
-
package's immutable portable data and hydrates a fresh canonical shader graph;
|
|
28
|
-
runtime-trinity depends on and consumes that graph. runtime-resource does not
|
|
29
|
-
import runtime-trinity. Engines add only backend realization.
|
|
30
|
-
|
|
31
|
-
## Container and schemas
|
|
32
|
-
|
|
33
|
-
The binary CEWG container remains version 1. Effect packages use one of these
|
|
34
|
-
INFO schemas:
|
|
35
|
-
|
|
36
|
-
| INFO | Source input | Required chunks | Source reflection |
|
|
37
|
-
| --- | --- | --- | --- |
|
|
38
|
-
| v1 | legacy | `INFO META GLSL` | unspecified |
|
|
39
|
-
| v2 | effect v8-v14 | `INFO META PGRF GLSL` | permutation topology only |
|
|
40
|
-
| v3 | effect v15 | `INFO META PGRF RFLX RBLB GLSL` | complete for every unique body |
|
|
41
|
-
|
|
42
|
-
`PGRF` v1 records every Cartesian permutation, its option indices, its exact
|
|
43
|
-
source record, and a content-deduplicated body identity.
|
|
44
|
-
|
|
45
|
-
`RFLX` v2 records complete portable reflection once per unique source body:
|
|
46
|
-
techniques, passes, stages, source programs, exact constant-default bytes,
|
|
47
|
-
constants, resources, UAVs, samplers, signatures, static samplers,
|
|
48
|
-
annotations, render states, and libraries. Binary fields use verified
|
|
49
|
-
references into the shared `RBLB` byte arena.
|
|
50
|
-
|
|
51
|
-
`META` and `GLSL` retain the WebGL backend graph: permutation-to-body
|
|
52
|
-
mappings, Carbon manifests, stage and shader identities, translated source,
|
|
53
|
-
bindings, vertex inputs/outputs, and backend-specific transform contracts.
|
|
54
|
-
Backend body keys deliberately retain the historical
|
|
55
|
-
`body_<offset>_<size>` form; PGRF/RFLX content identities are separate.
|
|
56
|
-
|
|
57
|
-
All cross-document references, counts, SHA-256 digests, source identity,
|
|
58
|
-
package mode, body/stage/shader graph edges, reflection blobs, and reflected
|
|
59
|
-
pass/stage identities are validated while reading a canonical package.
|
|
60
|
-
Generic CEWG containers remain readable, but they cannot use the portable
|
|
61
|
-
reflection accessor.
|
|
62
|
-
|
|
63
|
-
## Runtime accessor
|
|
64
|
-
|
|
65
|
-
Read with `emit: "raw"` and call:
|
|
66
|
-
|
|
67
|
-
```js
|
|
68
|
-
const pkg = CjsWebglFormat.read(bytes, {
|
|
69
|
-
emit: CjsWebglFormat.OUTPUT_RAW
|
|
70
|
-
});
|
|
71
|
-
const portable = pkg.GetPortableEffectReflection(permutationIndex);
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
Omitting the index selects `INFO.defaultPermutationIndex`. The method returns
|
|
75
|
-
`null` for legacy, partial, generic, or unvalidated packages. Every returned
|
|
76
|
-
binary field is a fresh owned `Uint8Array`; callers may mutate it without
|
|
77
|
-
changing subsequent reads. This method is the supported stable exception on
|
|
78
|
-
the otherwise internal `CewgPackage` object.
|
|
79
|
-
|
|
80
|
-
The default JSON read exposes packed PGRF/RFLX documents for inspection, but
|
|
81
|
-
does not inline RBLB. Runtime hydration must retain the package bytes and use
|
|
82
|
-
the accessor.
|
|
83
|
-
|
|
84
|
-
## Completeness
|
|
85
|
-
|
|
86
|
-
- `sourceComplete` is true only for v15 packages with PGRF v1 plus
|
|
87
|
-
all-unique RFLX v2/RBLB.
|
|
88
|
-
- `backendComplete` remains false. Successful translation does not yet prove
|
|
89
|
-
the engine's physical binding/layout and transform contract.
|
|
90
|
-
- `runtimeComplete` remains false. Live shader objects and GPU handles are
|
|
91
|
-
outside the format package.
|
|
92
|
-
- `qualification.ok` separately reports whether the selected WebGL programs
|
|
93
|
-
translated and formed the required raster/compute families.
|
|
94
|
-
|
|
95
|
-
Selected-only or technique/pass/stage-filtered packages still carry complete
|
|
96
|
-
v15 source reflection, but only their selected backend programs.
|
|
97
|
-
|
|
98
|
-
## Tier and permutation policy
|
|
99
|
-
|
|
100
|
-
For EVE shader work:
|
|
101
|
-
|
|
102
|
-
- High is `.sm_depth`.
|
|
103
|
-
- Medium is `.sm_hi`.
|
|
104
|
-
- Low is `.sm_lo`.
|
|
105
|
-
- Unpacked Quad V5 evidence must explicitly select `SOPPT_ENABLED`; the
|
|
106
|
-
default permutation is commonly PPT-off and is not representative.
|
|
107
|
-
|
|
108
|
-
Always resolve an option tuple against the current source axes. Do not persist
|
|
109
|
-
a permutation index across builds.
|
|
110
|
-
|
|
111
|
-
## Validation evidence
|
|
112
|
-
|
|
113
|
-
The 2026-07-28 build-3444265 gate covered 1,074 High/Medium CEWG packages:
|
|
114
|
-
|
|
115
|
-
- all 1,074 baseline/candidate statuses matched;
|
|
116
|
-
- 1,016 remained qualified and 58 remained diagnostic;
|
|
117
|
-
- all 17,444 permutations reconstructed byte-exact portable reflection;
|
|
118
|
-
- all 7,134 unique reflected bodies matched fresh `format-hlsl` output;
|
|
119
|
-
- the oracle covered 49,308 source programs, 2,563,024 exact default bytes,
|
|
120
|
-
148,972 constants, 88,970 resources, 808 UAVs, 25,564 samplers, and 202,147
|
|
121
|
-
annotations; and
|
|
122
|
-
- GLSL source remained unchanged. Vertex-stage metadata was corrected so the
|
|
123
|
-
Carbon `BITANGENT` alias names the actual emitted `in_BITANGENT#`
|
|
124
|
-
declaration instead of stale `in_BINORMAL#` metadata.
|
|
125
|
-
|
|
126
|
-
The real unpacked Quad V5 PPT-on High and Medium bodies compile and link all
|
|
127
|
-
Main, Depth, Picking, Shadow, and DynamicLightShadow programs in WebGL2.
|