@carbonenginejs/runtime-resource 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/format/effect/effectPermutationGraph.js +257 -0
- package/dist/format/effect/effectPermutationGraph.js.map +1 -0
- package/dist/format/effect/effectReflectionPackage.js +636 -0
- package/dist/format/effect/effectReflectionPackage.js.map +1 -0
- package/dist/format/effect/sha256.js +114 -0
- package/dist/format/effect/sha256.js.map +1 -0
- package/dist/formats/dxbc/CjsDxbcFormat.js +142 -0
- package/dist/formats/dxbc/CjsDxbcFormat.js.map +1 -0
- package/dist/formats/dxbc/core/DxbcReader.js +266 -0
- package/dist/formats/dxbc/core/DxbcReader.js.map +1 -0
- package/dist/formats/dxbc/core/container.js +169 -0
- package/dist/formats/dxbc/core/container.js.map +1 -0
- package/dist/formats/dxbc/core/decoder.js +789 -0
- package/dist/formats/dxbc/core/decoder.js.map +1 -0
- package/dist/formats/dxbc/core/errors.js +19 -0
- package/dist/formats/dxbc/core/errors.js.map +1 -0
- package/dist/formats/dxbc/core/helpers.js +220 -0
- package/dist/formats/dxbc/core/helpers.js.map +1 -0
- package/dist/formats/dxbc/core/opcodes.js +45 -0
- package/dist/formats/dxbc/core/opcodes.js.map +1 -0
- package/dist/formats/dxbc/core/program.js +91 -0
- package/dist/formats/dxbc/core/program.js.map +1 -0
- package/dist/formats/dxbc/core/signature.js +172 -0
- package/dist/formats/dxbc/core/signature.js.map +1 -0
- package/dist/formats/dxbc/index.js +2 -0
- package/dist/formats/dxbc/index.js.map +1 -0
- package/dist/formats/hlsl/CjsHlslFormat.js +254 -0
- package/dist/formats/hlsl/CjsHlslFormat.js.map +1 -0
- package/dist/formats/hlsl/core/HlslBinaryUtils.js +15 -0
- package/dist/formats/hlsl/core/HlslBinaryUtils.js.map +1 -0
- package/dist/formats/hlsl/core/HlslEffectReadError.js +19 -0
- package/dist/formats/hlsl/core/HlslEffectReadError.js.map +1 -0
- package/dist/formats/hlsl/core/HlslEffectStateManager.js +130 -0
- package/dist/formats/hlsl/core/HlslEffectStateManager.js.map +1 -0
- package/dist/formats/hlsl/core/HlslReader.js +266 -0
- package/dist/formats/hlsl/core/HlslReader.js.map +1 -0
- package/dist/formats/hlsl/core/HlslRenderStateSetup.js +37 -0
- package/dist/formats/hlsl/core/HlslRenderStateSetup.js.map +1 -0
- package/dist/formats/hlsl/core/HlslResourceSetDescription.js +94 -0
- package/dist/formats/hlsl/core/HlslResourceSetDescription.js.map +1 -0
- package/dist/formats/hlsl/core/HlslShaderBytecode.js +44 -0
- package/dist/formats/hlsl/core/HlslShaderBytecode.js.map +1 -0
- package/dist/formats/hlsl/core/analysis.js +51 -0
- package/dist/formats/hlsl/core/analysis.js.map +1 -0
- package/dist/formats/hlsl/core/helpers.js +270 -0
- package/dist/formats/hlsl/core/helpers.js.map +1 -0
- package/dist/formats/hlsl/core/json.js +284 -0
- package/dist/formats/hlsl/core/json.js.map +1 -0
- package/dist/formats/hlsl/core/metadata.js +327 -0
- package/dist/formats/hlsl/core/metadata.js.map +1 -0
- package/dist/formats/hlsl/core/portableReflection.js +848 -0
- package/dist/formats/hlsl/core/portableReflection.js.map +1 -0
- package/dist/formats/hlsl/core/render-states.js +280 -0
- package/dist/formats/hlsl/core/render-states.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/HlslRenderContextEnum.js +43 -0
- package/dist/formats/hlsl/core/tr2/HlslRenderContextEnum.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/resources/HlslEffectRes.js +294 -0
- package/dist/formats/hlsl/core/tr2/resources/HlslEffectRes.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/resources/HlslShaderPermutation.js +33 -0
- package/dist/formats/hlsl/core/tr2/resources/HlslShaderPermutation.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectBindingManifest.js +416 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectBindingManifest.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectConstant.js +40 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectConstant.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectDescription.js +742 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectDescription.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectLibrary.js +52 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectLibrary.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectParameterAnnotation.js +38 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectParameterAnnotation.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectResource.js +50 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectResource.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectStageInput.js +86 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectStageInput.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectTechnique.js +31 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectTechnique.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslPass.js +42 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslPass.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslSamplerDescription.js +55 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslSamplerDescription.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslSamplerSetup.js +29 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslSamplerSetup.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslShader.js +220 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslShader.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslShaderOption.js +30 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslShaderOption.js.map +1 -0
- package/dist/formats/hlsl/index.js +2 -0
- package/dist/formats/hlsl/index.js.map +1 -0
- package/dist/formats/hlsl/portable.js +2 -0
- package/dist/formats/hlsl/portable.js.map +1 -0
- package/dist/formats/index.js +4 -0
- package/dist/formats/index.js.map +1 -1
- package/dist/formats/webgl/CjsWebglFormat.js +221 -0
- package/dist/formats/webgl/CjsWebglFormat.js.map +1 -0
- package/dist/formats/webgl/core/cewg/CewgPackage.js +339 -0
- package/dist/formats/webgl/core/cewg/CewgPackage.js.map +1 -0
- package/dist/formats/webgl/core/cewg/CewgPackageBuilder.js +104 -0
- package/dist/formats/webgl/core/cewg/CewgPackageBuilder.js.map +1 -0
- package/dist/formats/webgl/core/cewg/binary.js +101 -0
- package/dist/formats/webgl/core/cewg/binary.js.map +1 -0
- package/dist/formats/webgl/core/cewgCompleteness.js +81 -0
- package/dist/formats/webgl/core/cewgCompleteness.js.map +1 -0
- package/dist/formats/webgl/core/effectPackage.js +789 -0
- package/dist/formats/webgl/core/effectPackage.js.map +1 -0
- package/dist/formats/webgl/core/effectPackageValidation.js +331 -0
- package/dist/formats/webgl/core/effectPackageValidation.js.map +1 -0
- package/dist/formats/webgl/core/errors.js +27 -0
- package/dist/formats/webgl/core/errors.js.map +1 -0
- package/dist/formats/webgl/core/glsl/DxbcGlslEmitter.js +2678 -0
- package/dist/formats/webgl/core/glsl/DxbcGlslEmitter.js.map +1 -0
- package/dist/formats/webgl/core/glsl/DxbcGlslHelpers.js +89 -0
- package/dist/formats/webgl/core/glsl/DxbcGlslHelpers.js.map +1 -0
- package/dist/formats/webgl/core/glsl/DxbcGlslOperandFormatter.js +428 -0
- package/dist/formats/webgl/core/glsl/DxbcGlslOperandFormatter.js.map +1 -0
- package/dist/formats/webgl/core/helpers.js +306 -0
- package/dist/formats/webgl/core/helpers.js.map +1 -0
- package/dist/formats/webgl/index.js +2 -0
- package/dist/formats/webgl/index.js.map +1 -0
- package/dist/formats/webgpu/CjsWebgpuFormat.js +376 -0
- package/dist/formats/webgpu/CjsWebgpuFormat.js.map +1 -0
- package/dist/formats/webgpu/core/cewgpu/CewgpuPackage.js +415 -0
- package/dist/formats/webgpu/core/cewgpu/CewgpuPackage.js.map +1 -0
- package/dist/formats/webgpu/core/cewgpu/CewgpuPackageBuilder.js +100 -0
- package/dist/formats/webgpu/core/cewgpu/CewgpuPackageBuilder.js.map +1 -0
- package/dist/formats/webgpu/core/cewgpu/binary.js +93 -0
- package/dist/formats/webgpu/core/cewgpu/binary.js.map +1 -0
- package/dist/formats/webgpu/core/cewgpu/tags.js +17 -0
- package/dist/formats/webgpu/core/cewgpu/tags.js.map +1 -0
- package/dist/formats/webgpu/core/effectAnalysis.js +82 -0
- package/dist/formats/webgpu/core/effectAnalysis.js.map +1 -0
- package/dist/formats/webgpu/core/effectBackendBodySet.js +305 -0
- package/dist/formats/webgpu/core/effectBackendBodySet.js.map +1 -0
- package/dist/formats/webgpu/core/effectPackageValidation.js +1078 -0
- package/dist/formats/webgpu/core/effectPackageValidation.js.map +1 -0
- package/dist/formats/webgpu/core/errors.js +20 -0
- package/dist/formats/webgpu/core/errors.js.map +1 -0
- package/dist/formats/webgpu/core/helpers.js +448 -0
- package/dist/formats/webgpu/core/helpers.js.map +1 -0
- package/dist/formats/webgpu/core/ir/analyzeRegisterValues.js +223 -0
- package/dist/formats/webgpu/core/ir/analyzeRegisterValues.js.map +1 -0
- package/dist/formats/webgpu/core/ir/buildControlFlow.js +220 -0
- package/dist/formats/webgpu/core/ir/buildControlFlow.js.map +1 -0
- package/dist/formats/webgpu/core/ir/indexableTemps.js +137 -0
- package/dist/formats/webgpu/core/ir/indexableTemps.js.map +1 -0
- package/dist/formats/webgpu/core/ir/inferValueTypes.js +454 -0
- package/dist/formats/webgpu/core/ir/inferValueTypes.js.map +1 -0
- package/dist/formats/webgpu/core/ir/lowerDxbcToIr.js +494 -0
- package/dist/formats/webgpu/core/ir/lowerDxbcToIr.js.map +1 -0
- package/dist/formats/webgpu/core/ir/resolveRegisterFlow.js +177 -0
- package/dist/formats/webgpu/core/ir/resolveRegisterFlow.js.map +1 -0
- package/dist/formats/webgpu/core/ir/sourceLanes.js +61 -0
- package/dist/formats/webgpu/core/ir/sourceLanes.js.map +1 -0
- package/dist/formats/webgpu/core/packageEffect.js +300 -0
- package/dist/formats/webgpu/core/packageEffect.js.map +1 -0
- package/dist/formats/webgpu/core/packageEffectSelection.js +164 -0
- package/dist/formats/webgpu/core/packageEffectSelection.js.map +1 -0
- package/dist/formats/webgpu/core/packageMetadata.js +8 -0
- package/dist/formats/webgpu/core/packageMetadata.js.map +1 -0
- package/dist/formats/webgpu/core/schema.js +4 -0
- package/dist/formats/webgpu/core/schema.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js +275 -0
- package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/buildWgslBindingPlan.js +182 -0
- package/dist/formats/webgpu/core/wgsl/buildWgslBindingPlan.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/buildWgslSet.js +324 -0
- package/dist/formats/webgpu/core/wgsl/buildWgslSet.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/emitWgsl.js +356 -0
- package/dist/formats/webgpu/core/wgsl/emitWgsl.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/hoistEscapingValues.js +77 -0
- package/dist/formats/webgpu/core/wgsl/hoistEscapingValues.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/lowerBindingLayout.js +451 -0
- package/dist/formats/webgpu/core/wgsl/lowerBindingLayout.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/lowerComputeProgram.js +754 -0
- package/dist/formats/webgpu/core/wgsl/lowerComputeProgram.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/lowerCreateHistogramsComputeProgram.js +457 -0
- package/dist/formats/webgpu/core/wgsl/lowerCreateHistogramsComputeProgram.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/lowerFragmentProgram.js +1572 -0
- package/dist/formats/webgpu/core/wgsl/lowerFragmentProgram.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/lowerMergeHistogramsComputeProgram.js +659 -0
- package/dist/formats/webgpu/core/wgsl/lowerMergeHistogramsComputeProgram.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/lowerParticleClearComputePrograms.js +734 -0
- package/dist/formats/webgpu/core/wgsl/lowerParticleClearComputePrograms.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/lowerParticleEmitComputeProgram.js +583 -0
- package/dist/formats/webgpu/core/wgsl/lowerParticleEmitComputeProgram.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/lowerSkinVerticesComputeProgram.js +621 -0
- package/dist/formats/webgpu/core/wgsl/lowerSkinVerticesComputeProgram.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/lowerSortComputeProgram.js +824 -0
- package/dist/formats/webgpu/core/wgsl/lowerSortComputeProgram.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/lowerSortInnerComputeProgram.js +697 -0
- package/dist/formats/webgpu/core/wgsl/lowerSortInnerComputeProgram.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/lowerSortStepComputeProgram.js +559 -0
- package/dist/formats/webgpu/core/wgsl/lowerSortStepComputeProgram.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/lowerVertexProgram.js +1328 -0
- package/dist/formats/webgpu/core/wgsl/lowerVertexProgram.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/particleEmitSemanticDigest.js +110 -0
- package/dist/formats/webgpu/core/wgsl/particleEmitSemanticDigest.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/precisionControls.js +55 -0
- package/dist/formats/webgpu/core/wgsl/precisionControls.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/selectionPlans.js +758 -0
- package/dist/formats/webgpu/core/wgsl/selectionPlans.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/uniformity.js +78 -0
- package/dist/formats/webgpu/core/wgsl/uniformity.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/validateExactComputeIr.js +196 -0
- package/dist/formats/webgpu/core/wgsl/validateExactComputeIr.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/validateHandleOperand.js +37 -0
- package/dist/formats/webgpu/core/wgsl/validateHandleOperand.js.map +1 -0
- package/dist/formats/webgpu/index.js +2 -0
- package/dist/formats/webgpu/index.js.map +1 -0
- package/dist/resource/shader/Tr2EffectRes.js +159 -150
- package/dist/resource/shader/Tr2EffectRes.js.map +1 -1
- package/dist/resource/shader/Tr2MaterialArea.js +23 -28
- package/dist/resource/shader/Tr2MaterialArea.js.map +1 -1
- package/dist/resource/shader/Tr2MaterialMesh.js +21 -27
- package/dist/resource/shader/Tr2MaterialMesh.js.map +1 -1
- package/dist/resource/shader/Tr2MaterialRes.js +24 -29
- package/dist/resource/shader/Tr2MaterialRes.js.map +1 -1
- package/dist/resource/shader/Tr2Shader.js +45 -39
- package/dist/resource/shader/Tr2Shader.js.map +1 -1
- package/dist/resource/shader/Tr2ShaderPermutation.js +30 -32
- package/dist/resource/shader/Tr2ShaderPermutation.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectConstant.js +113 -78
- package/dist/resource/shader/reflection/Tr2EffectConstant.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectDefine.js +17 -23
- package/dist/resource/shader/reflection/Tr2EffectDefine.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectDescription.js +23 -29
- package/dist/resource/shader/reflection/Tr2EffectDescription.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectLibrary.js +44 -40
- package/dist/resource/shader/reflection/Tr2EffectLibrary.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js +82 -86
- package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectResource.js +55 -61
- package/dist/resource/shader/reflection/Tr2EffectResource.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectStageInput.js +49 -45
- package/dist/resource/shader/reflection/Tr2EffectStageInput.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectTechnique.js +25 -30
- package/dist/resource/shader/reflection/Tr2EffectTechnique.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2Pass.js +30 -32
- package/dist/resource/shader/reflection/Tr2Pass.js.map +1 -1
- package/dist/resource/shader/sampler/Tr2SamplerSetup.js +21 -26
- package/dist/resource/shader/sampler/Tr2SamplerSetup.js.map +1 -1
- package/docs/formats/README.md +4 -0
- package/docs/formats/provenance.md +11 -3
- package/docs/reference/classes/formats.md +440 -0
- package/format-notices/dxbc/LICENSE +21 -0
- package/format-notices/dxbc/NOTICE +20 -0
- package/format-notices/hlsl/LICENSE +21 -0
- package/format-notices/hlsl/NOTICE +25 -0
- package/format-notices/webgl/LICENSE +21 -0
- package/format-notices/webgl/NOTICE +35 -0
- package/format-notices/webgpu/LICENSE +21 -0
- package/format-notices/webgpu/NOTICE +31 -0
- package/package.json +6 -1
- package/dist/resource/shader/portableValidation.js +0 -461
- package/dist/resource/shader/portableValidation.js.map +0 -1
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { HlslRenderContextEnum } from '../HlslRenderContextEnum.js';
|
|
2
|
+
import { HlslEffectDescription, ANY_TECHNIQUE } from './HlslEffectDescription.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Trinity shader wrapper around a decoded `HlslEffectDescription`.
|
|
6
|
+
*/
|
|
7
|
+
class HlslShader {
|
|
8
|
+
/**
|
|
9
|
+
* Creates an empty shader wrapper.
|
|
10
|
+
*/
|
|
11
|
+
constructor() {
|
|
12
|
+
this.m_sortValue = 0;
|
|
13
|
+
this.m_effect = new HlslEffectDescription();
|
|
14
|
+
this.m_hasVertexBufferAccessInRtShadow = false;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Finds a technique index by name, or returns the first technique for `ANY_TECHNIQUE`.
|
|
19
|
+
*
|
|
20
|
+
* @param {string} [name] Technique name to locate.
|
|
21
|
+
* @returns {number} Technique index, or -1 when missing.
|
|
22
|
+
*/
|
|
23
|
+
GetTechniqueIndex(name = ANY_TECHNIQUE) {
|
|
24
|
+
if (!this.m_effect.techniques.length) {
|
|
25
|
+
return -1;
|
|
26
|
+
}
|
|
27
|
+
if (name === ANY_TECHNIQUE || name === null || name === undefined) {
|
|
28
|
+
return 0;
|
|
29
|
+
}
|
|
30
|
+
return this.m_effect.techniques.findIndex(technique => technique.name === name);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Returns the number of passes in a decoded technique.
|
|
35
|
+
*
|
|
36
|
+
* @param {number} techniqueIndex Technique index.
|
|
37
|
+
* @returns {number} Pass count.
|
|
38
|
+
*/
|
|
39
|
+
GetPassCount(techniqueIndex) {
|
|
40
|
+
const technique = this.m_effect.techniques[techniqueIndex];
|
|
41
|
+
return technique ? technique.passes.length : 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Applies shader program and render-state handles for one pass to a render context.
|
|
46
|
+
*
|
|
47
|
+
* @param {number} techniqueIndex Technique index.
|
|
48
|
+
* @param {number} passIndex Pass index.
|
|
49
|
+
* @param {object} renderContext Render context with an `m_esm` state manager.
|
|
50
|
+
* @returns {boolean} True when the pass existed.
|
|
51
|
+
*/
|
|
52
|
+
ApplyAllStateForPass(techniqueIndex, passIndex, renderContext) {
|
|
53
|
+
const pass = this.m_effect.techniques[techniqueIndex]?.passes?.[passIndex];
|
|
54
|
+
if (!pass) return false;
|
|
55
|
+
renderContext?.m_esm?.ApplyShaderProgram?.(pass.shaderProgram);
|
|
56
|
+
renderContext?.m_esm?.ApplyRenderStates?.(pass.renderStates);
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Applies only render-state handles for one pass to a render context.
|
|
62
|
+
*
|
|
63
|
+
* @param {number} techniqueIndex Technique index.
|
|
64
|
+
* @param {number} passIndex Pass index.
|
|
65
|
+
* @param {object} renderContext Render context with an `m_esm` state manager.
|
|
66
|
+
* @returns {boolean} True when the pass existed.
|
|
67
|
+
*/
|
|
68
|
+
ApplyRenderStates(techniqueIndex, passIndex, renderContext) {
|
|
69
|
+
const pass = this.m_effect.techniques[techniqueIndex]?.passes?.[passIndex];
|
|
70
|
+
if (!pass) return false;
|
|
71
|
+
renderContext?.m_esm?.ApplyRenderStates?.(pass.renderStates);
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Registers and applies a shader program override for a pass.
|
|
77
|
+
*
|
|
78
|
+
* @param {number} techniqueIndex Base technique index.
|
|
79
|
+
* @param {number} passIndex Base pass index.
|
|
80
|
+
* @param {HlslShader} overrideShader Shader providing the override program.
|
|
81
|
+
* @param {number} overridePassIndex Override pass index.
|
|
82
|
+
* @param {object} renderContext Render context with an `m_esm` state manager.
|
|
83
|
+
* @returns {number} Override program handle, or 0 when unavailable.
|
|
84
|
+
*/
|
|
85
|
+
ApplyShaderOverride(techniqueIndex, passIndex, overrideShader, overridePassIndex, renderContext) {
|
|
86
|
+
const program = this.m_effect.techniques[techniqueIndex]?.passes?.[passIndex]?.shaderProgram;
|
|
87
|
+
const overrideProgram = overrideShader?.m_effect?.techniques?.[0]?.passes?.[overridePassIndex]?.shaderProgram;
|
|
88
|
+
if (!program || !overrideProgram) return 0;
|
|
89
|
+
const combined = renderContext?.m_esm?.RegisterShaderProgramOverride?.(program, overrideProgram) || 0;
|
|
90
|
+
renderContext?.m_esm?.ApplyShaderProgram?.(combined);
|
|
91
|
+
return combined;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Returns the shader-stage bit mask for a technique.
|
|
96
|
+
*
|
|
97
|
+
* @param {number} techniqueIndex Technique index.
|
|
98
|
+
* @returns {number} Shader-stage bit mask.
|
|
99
|
+
*/
|
|
100
|
+
GetShaderTypeMask(techniqueIndex) {
|
|
101
|
+
return this.m_effect.techniques[techniqueIndex]?.shaderTypeMask || 0;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Finds the first constant metadata record with the supplied name.
|
|
106
|
+
*
|
|
107
|
+
* @param {string} name Constant name.
|
|
108
|
+
* @returns {object|null} Constant metadata or null.
|
|
109
|
+
*/
|
|
110
|
+
GetConstant(name) {
|
|
111
|
+
for (const technique of this.m_effect.techniques) {
|
|
112
|
+
for (const pass of technique.passes) {
|
|
113
|
+
for (const stage of pass.stageInputs) {
|
|
114
|
+
const found = stage.constants.find(constant => constant.name === name);
|
|
115
|
+
if (found) return found;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Finds the first SRV or UAV resource metadata record with the supplied name.
|
|
124
|
+
*
|
|
125
|
+
* @param {string} name Resource name.
|
|
126
|
+
* @returns {object|null} Resource metadata or null.
|
|
127
|
+
*/
|
|
128
|
+
GetResource(name) {
|
|
129
|
+
for (const technique of this.m_effect.techniques) {
|
|
130
|
+
for (const pass of technique.passes) {
|
|
131
|
+
for (const stage of pass.stageInputs) {
|
|
132
|
+
for (const resource of stage.resources.values()) {
|
|
133
|
+
if (resource.name === name) return resource;
|
|
134
|
+
}
|
|
135
|
+
for (const resource of stage.uavs.values()) {
|
|
136
|
+
if (resource.name === name) return resource;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Looks up annotations attached to a parameter name.
|
|
146
|
+
*
|
|
147
|
+
* @param {string} parameterName Parameter name.
|
|
148
|
+
* @returns {object[]|null} Annotation records or null.
|
|
149
|
+
*/
|
|
150
|
+
GetParameterAnnotations(parameterName) {
|
|
151
|
+
return this.m_effect.annotations.get(parameterName) || null;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Returns Carbon's compact pass sort value.
|
|
156
|
+
*
|
|
157
|
+
* @returns {number} Sort value.
|
|
158
|
+
*/
|
|
159
|
+
GetSortValue() {
|
|
160
|
+
return this.m_sortValue;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Returns the decoded effect description.
|
|
165
|
+
*
|
|
166
|
+
* @returns {HlslEffectDescription} Effect description.
|
|
167
|
+
*/
|
|
168
|
+
GetEffectDescription() {
|
|
169
|
+
return this.m_effect;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Returns the decoded effect description.
|
|
174
|
+
*
|
|
175
|
+
* @returns {HlslEffectDescription} Effect description.
|
|
176
|
+
*/
|
|
177
|
+
GetEffect() {
|
|
178
|
+
return this.m_effect;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Recomputes Carbon's sort value from the first technique/pass handles.
|
|
183
|
+
*/
|
|
184
|
+
ProcessEffect() {
|
|
185
|
+
this.m_sortValue = 0;
|
|
186
|
+
const technique = this.m_effect.techniques[0];
|
|
187
|
+
const pass = technique?.passes?.[0];
|
|
188
|
+
if (!pass) return;
|
|
189
|
+
const ps = pass.stageInputs[HlslRenderContextEnum.PIXEL_SHADER]?.m_shader & 0x3ff;
|
|
190
|
+
const vs = pass.stageInputs[HlslRenderContextEnum.VERTEX_SHADER]?.m_shader & 0x3ff;
|
|
191
|
+
const states = pass.renderStates & 0x3ff;
|
|
192
|
+
const numPasses = technique.passes.length & 0x3;
|
|
193
|
+
this.m_sortValue = numPasses << 30 | ps << 20 | vs << 10 | states;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Reports whether this shader uses vertex-buffer access in RT shadow mode.
|
|
198
|
+
*
|
|
199
|
+
* @returns {boolean} True when RT shadow vertex-buffer access is flagged.
|
|
200
|
+
*/
|
|
201
|
+
HasVertexBufferAccessInRtShadow() {
|
|
202
|
+
return this.m_hasVertexBufferAccessInRtShadow;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Returns a JSON-safe shader wrapper summary.
|
|
207
|
+
*
|
|
208
|
+
* @returns {object} Serializable shader summary.
|
|
209
|
+
*/
|
|
210
|
+
toJSON() {
|
|
211
|
+
return {
|
|
212
|
+
m_sortValue: this.m_sortValue,
|
|
213
|
+
m_hasVertexBufferAccessInRtShadow: this.m_hasVertexBufferAccessInRtShadow,
|
|
214
|
+
effect: this.m_effect.toJSON()
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export { HlslShader };
|
|
220
|
+
//# sourceMappingURL=HlslShader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HlslShader.js","sources":["../../../../../../../src/formats/hlsl/core/tr2/shader/HlslShader.js"],"sourcesContent":["import { HlslRenderContextEnum } from \"../HlslRenderContextEnum.js\";\nimport { ANY_TECHNIQUE, HlslEffectDescription } from \"./HlslEffectDescription.js\";\n\n/**\n * Trinity shader wrapper around a decoded `HlslEffectDescription`.\n */\nexport class HlslShader\n{\n /**\n * Creates an empty shader wrapper.\n */\n constructor()\n {\n this.m_sortValue = 0;\n this.m_effect = new HlslEffectDescription();\n this.m_hasVertexBufferAccessInRtShadow = false;\n }\n\n /**\n * Finds a technique index by name, or returns the first technique for `ANY_TECHNIQUE`.\n *\n * @param {string} [name] Technique name to locate.\n * @returns {number} Technique index, or -1 when missing.\n */\n GetTechniqueIndex(name = ANY_TECHNIQUE)\n {\n if (!this.m_effect.techniques.length)\n {\n return -1;\n }\n if (name === ANY_TECHNIQUE || name === null || name === undefined)\n {\n return 0;\n }\n return this.m_effect.techniques.findIndex((technique) => technique.name === name);\n }\n\n /**\n * Returns the number of passes in a decoded technique.\n *\n * @param {number} techniqueIndex Technique index.\n * @returns {number} Pass count.\n */\n GetPassCount(techniqueIndex)\n {\n const technique = this.m_effect.techniques[techniqueIndex];\n return technique ? technique.passes.length : 0;\n }\n\n /**\n * Applies shader program and render-state handles for one pass to a render context.\n *\n * @param {number} techniqueIndex Technique index.\n * @param {number} passIndex Pass index.\n * @param {object} renderContext Render context with an `m_esm` state manager.\n * @returns {boolean} True when the pass existed.\n */\n ApplyAllStateForPass(techniqueIndex, passIndex, renderContext)\n {\n const pass = this.m_effect.techniques[techniqueIndex]?.passes?.[passIndex];\n if (!pass) return false;\n renderContext?.m_esm?.ApplyShaderProgram?.(pass.shaderProgram);\n renderContext?.m_esm?.ApplyRenderStates?.(pass.renderStates);\n return true;\n }\n\n /**\n * Applies only render-state handles for one pass to a render context.\n *\n * @param {number} techniqueIndex Technique index.\n * @param {number} passIndex Pass index.\n * @param {object} renderContext Render context with an `m_esm` state manager.\n * @returns {boolean} True when the pass existed.\n */\n ApplyRenderStates(techniqueIndex, passIndex, renderContext)\n {\n const pass = this.m_effect.techniques[techniqueIndex]?.passes?.[passIndex];\n if (!pass) return false;\n renderContext?.m_esm?.ApplyRenderStates?.(pass.renderStates);\n return true;\n }\n\n /**\n * Registers and applies a shader program override for a pass.\n *\n * @param {number} techniqueIndex Base technique index.\n * @param {number} passIndex Base pass index.\n * @param {HlslShader} overrideShader Shader providing the override program.\n * @param {number} overridePassIndex Override pass index.\n * @param {object} renderContext Render context with an `m_esm` state manager.\n * @returns {number} Override program handle, or 0 when unavailable.\n */\n ApplyShaderOverride(techniqueIndex, passIndex, overrideShader, overridePassIndex, renderContext)\n {\n const program = this.m_effect.techniques[techniqueIndex]?.passes?.[passIndex]?.shaderProgram;\n const overrideProgram = overrideShader?.m_effect?.techniques?.[0]?.passes?.[overridePassIndex]?.shaderProgram;\n if (!program || !overrideProgram) return 0;\n const combined = renderContext?.m_esm?.RegisterShaderProgramOverride?.(program, overrideProgram) || 0;\n renderContext?.m_esm?.ApplyShaderProgram?.(combined);\n return combined;\n }\n\n /**\n * Returns the shader-stage bit mask for a technique.\n *\n * @param {number} techniqueIndex Technique index.\n * @returns {number} Shader-stage bit mask.\n */\n GetShaderTypeMask(techniqueIndex)\n {\n return this.m_effect.techniques[techniqueIndex]?.shaderTypeMask || 0;\n }\n\n /**\n * Finds the first constant metadata record with the supplied name.\n *\n * @param {string} name Constant name.\n * @returns {object|null} Constant metadata or null.\n */\n GetConstant(name)\n {\n for (const technique of this.m_effect.techniques)\n {\n for (const pass of technique.passes)\n {\n for (const stage of pass.stageInputs)\n {\n const found = stage.constants.find((constant) => constant.name === name);\n if (found) return found;\n }\n }\n }\n return null;\n }\n\n /**\n * Finds the first SRV or UAV resource metadata record with the supplied name.\n *\n * @param {string} name Resource name.\n * @returns {object|null} Resource metadata or null.\n */\n GetResource(name)\n {\n for (const technique of this.m_effect.techniques)\n {\n for (const pass of technique.passes)\n {\n for (const stage of pass.stageInputs)\n {\n for (const resource of stage.resources.values())\n {\n if (resource.name === name) return resource;\n }\n for (const resource of stage.uavs.values())\n {\n if (resource.name === name) return resource;\n }\n }\n }\n }\n return null;\n }\n\n /**\n * Looks up annotations attached to a parameter name.\n *\n * @param {string} parameterName Parameter name.\n * @returns {object[]|null} Annotation records or null.\n */\n GetParameterAnnotations(parameterName)\n {\n return this.m_effect.annotations.get(parameterName) || null;\n }\n\n /**\n * Returns Carbon's compact pass sort value.\n *\n * @returns {number} Sort value.\n */\n GetSortValue()\n {\n return this.m_sortValue;\n }\n\n /**\n * Returns the decoded effect description.\n *\n * @returns {HlslEffectDescription} Effect description.\n */\n GetEffectDescription()\n {\n return this.m_effect;\n }\n\n /**\n * Returns the decoded effect description.\n *\n * @returns {HlslEffectDescription} Effect description.\n */\n GetEffect()\n {\n return this.m_effect;\n }\n\n /**\n * Recomputes Carbon's sort value from the first technique/pass handles.\n */\n ProcessEffect()\n {\n this.m_sortValue = 0;\n const technique = this.m_effect.techniques[0];\n const pass = technique?.passes?.[0];\n if (!pass) return;\n\n const ps = pass.stageInputs[HlslRenderContextEnum.PIXEL_SHADER]?.m_shader & 0x3ff;\n const vs = pass.stageInputs[HlslRenderContextEnum.VERTEX_SHADER]?.m_shader & 0x3ff;\n const states = pass.renderStates & 0x3ff;\n const numPasses = technique.passes.length & 0x3;\n\n this.m_sortValue = (numPasses << 30) | (ps << 20) | (vs << 10) | states;\n }\n\n /**\n * Reports whether this shader uses vertex-buffer access in RT shadow mode.\n *\n * @returns {boolean} True when RT shadow vertex-buffer access is flagged.\n */\n HasVertexBufferAccessInRtShadow()\n {\n return this.m_hasVertexBufferAccessInRtShadow;\n }\n\n /**\n * Returns a JSON-safe shader wrapper summary.\n *\n * @returns {object} Serializable shader summary.\n */\n toJSON()\n {\n return {\n m_sortValue: this.m_sortValue,\n m_hasVertexBufferAccessInRtShadow: this.m_hasVertexBufferAccessInRtShadow,\n effect: this.m_effect.toJSON()\n };\n }\n}\n"],"names":["HlslShader","constructor","m_sortValue","m_effect","HlslEffectDescription","m_hasVertexBufferAccessInRtShadow","GetTechniqueIndex","name","ANY_TECHNIQUE","techniques","length","undefined","findIndex","technique","GetPassCount","techniqueIndex","passes","ApplyAllStateForPass","passIndex","renderContext","pass","m_esm","ApplyShaderProgram","shaderProgram","ApplyRenderStates","renderStates","ApplyShaderOverride","overrideShader","overridePassIndex","program","overrideProgram","combined","RegisterShaderProgramOverride","GetShaderTypeMask","shaderTypeMask","GetConstant","stage","stageInputs","found","constants","find","constant","GetResource","resource","resources","values","uavs","GetParameterAnnotations","parameterName","annotations","get","GetSortValue","GetEffectDescription","GetEffect","ProcessEffect","ps","HlslRenderContextEnum","PIXEL_SHADER","m_shader","vs","VERTEX_SHADER","states","numPasses","HasVertexBufferAccessInRtShadow","toJSON","effect"],"mappings":";;;AAGA;AACA;AACA;AACO,MAAMA,UAAU,CACvB;AACI;AACJ;AACA;AACIC,EAAAA,WAAWA,GACX;IACI,IAAI,CAACC,WAAW,GAAG,CAAC;AACpB,IAAA,IAAI,CAACC,QAAQ,GAAG,IAAIC,qBAAqB,EAAE;IAC3C,IAAI,CAACC,iCAAiC,GAAG,KAAK;AAClD,EA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;MAC7BG,iCAAiC,EAAE,IAAI,CAACA,iCAAiC;AACzE4D,MAAAA,MAAM,EAAE,IAAI,CAAC9D,QAAQ,CAAC6D,MAAM;KAC/B;AACL,EAAA;AACJ;;;;"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Name/value shader permutation option used during effect lookup.
|
|
3
|
+
*/
|
|
4
|
+
class HlslShaderOption {
|
|
5
|
+
/**
|
|
6
|
+
* Creates a shader option selection.
|
|
7
|
+
*
|
|
8
|
+
* @param {string} [name] Permutation axis name.
|
|
9
|
+
* @param {string} [value] Selected option value.
|
|
10
|
+
*/
|
|
11
|
+
constructor(name = "", value = "") {
|
|
12
|
+
this.name = name;
|
|
13
|
+
this.value = value;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Returns a JSON-safe option selection.
|
|
18
|
+
*
|
|
19
|
+
* @returns {object} Serializable option selection.
|
|
20
|
+
*/
|
|
21
|
+
toJSON() {
|
|
22
|
+
return {
|
|
23
|
+
name: this.name,
|
|
24
|
+
value: this.value
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { HlslShaderOption };
|
|
30
|
+
//# sourceMappingURL=HlslShaderOption.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HlslShaderOption.js","sources":["../../../../../../../src/formats/hlsl/core/tr2/shader/HlslShaderOption.js"],"sourcesContent":["/**\n * Name/value shader permutation option used during effect lookup.\n */\nexport class HlslShaderOption\n{\n /**\n * Creates a shader option selection.\n *\n * @param {string} [name] Permutation axis name.\n * @param {string} [value] Selected option value.\n */\n constructor(name = \"\", value = \"\")\n {\n this.name = name;\n this.value = value;\n }\n\n /**\n * Returns a JSON-safe option selection.\n *\n * @returns {object} Serializable option selection.\n */\n toJSON()\n {\n return {\n name: this.name,\n value: this.value\n };\n }\n}\n"],"names":["HlslShaderOption","constructor","name","value","toJSON"],"mappings":"AAAA;AACA;AACA;AACO,MAAMA,gBAAgB,CAC7B;AACI;AACJ;AACA;AACA;AACA;AACA;EACIC,WAAWA,CAACC,IAAI,GAAG,EAAE,EAAEC,KAAK,GAAG,EAAE,EACjC;IACI,IAAI,CAACD,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACC,KAAK,GAAGA,KAAK;AACtB,EAAA;;AAEA;AACJ;AACA;AACA;AACA;AACIC,EAAAA,MAAMA,GACN;IACI,OAAO;MACHF,IAAI,EAAE,IAAI,CAACA,IAAI;MACfC,KAAK,EAAE,IAAI,CAACA;KACf;AACL,EAAA;AACJ;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { EFFECT_BODY_REFLECTION_FORMAT, EFFECT_BODY_REFLECTION_VERSION, buildEffectBodyReflection, enumerateUniqueEffectBodies, isEffectBodyReflection, readEffectBodyReflection, validateEffectBodyInput, validateEffectBodyReflection } from './core/portableReflection.js';
|
|
2
|
+
//# sourceMappingURL=portable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portable.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/formats/index.js
CHANGED
|
@@ -2,6 +2,10 @@ export { CjsBlackFormat } from './black/CjsBlackFormat.js';
|
|
|
2
2
|
export { CjsBnkFormat } from './bnk/CjsBnkFormat.js';
|
|
3
3
|
export { CjsCmfFormat } from './cmf/CjsCmfFormat.js';
|
|
4
4
|
export { CjsDdsFormat } from './dds/CjsDdsFormat.js';
|
|
5
|
+
export { CjsDxbcFormat } from './dxbc/CjsDxbcFormat.js';
|
|
6
|
+
export { CjsHlslFormat } from './hlsl/CjsHlslFormat.js';
|
|
7
|
+
export { CjsWebglFormat } from './webgl/CjsWebglFormat.js';
|
|
8
|
+
export { CjsWebgpuFormat } from './webgpu/CjsWebgpuFormat.js';
|
|
5
9
|
export { CjsFbxFormat } from './fbx/CjsFbxFormat.js';
|
|
6
10
|
export { CjsFlacFormat } from './flac/CjsFlacFormat.js';
|
|
7
11
|
export { CjsGifFormat } from './gif/CjsGifFormat.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { DEFAULT_VALUES, normalizeValues, readWithValues, inspectWithValues, buildPackage, emitGlslWithOptions, toJsonValue, isCewg, OUTPUT_JSON, OUTPUT_RAW } from './core/helpers.js';
|
|
2
|
+
import { buildEffectPackage } from './core/effectPackage.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Exposed CarbonEngineJS-facing WebGL format class.
|
|
6
|
+
*
|
|
7
|
+
* Keep this file small and reviewable: CEWG container parsing lives under
|
|
8
|
+
* src/core/cewg (internal parsing machinery, not part of this package's
|
|
9
|
+
* public surface); the DXBC-to-GLSL ES 3.00 emitter lives under
|
|
10
|
+
* src/core/glsl; input/option normalization and the shared read/build/emit
|
|
11
|
+
* paths live in src/core/helpers.js.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const FORMAT_NAME = "CjsWebglFormat";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* CarbonEngineJS-facing format surface for `.cewg` WebGL shader packages, and
|
|
18
|
+
* a DXBC -> GLSL ES 3.00 emitter for the WebGL2 vertex/pixel/map-style-compute
|
|
19
|
+
* stages ccpwgl targets.
|
|
20
|
+
*
|
|
21
|
+
* The Cjs prefix marks this as a JavaScript format/construction boundary.
|
|
22
|
+
* CEWG is a CarbonEngineJS-invented container format (flat four-byte-tagged
|
|
23
|
+
* chunks: `INFO`/`META`/`GLSL`/...), not a Microsoft or CCP one. `Read`
|
|
24
|
+
* parses a package to plain JSON by default (`emit: "raw"` exposes the live
|
|
25
|
+
* `CewgPackage` instance instead); `Inspect` is a cheap chunk/shader-count
|
|
26
|
+
* summary; `Build` assembles package bytes from chunk payloads; `EmitGlsl`
|
|
27
|
+
* translates one DXBC vertex/pixel/map-style-compute stage to GLSL ES 3.00.
|
|
28
|
+
*/
|
|
29
|
+
class CjsWebglFormat {
|
|
30
|
+
#emit = DEFAULT_VALUES.emit;
|
|
31
|
+
#source = DEFAULT_VALUES.source;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Create a reusable format profile.
|
|
35
|
+
*
|
|
36
|
+
* @param {object} [options] Default format values.
|
|
37
|
+
*/
|
|
38
|
+
constructor(options = {}) {
|
|
39
|
+
this.SetValues(options);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Set format values for this reusable profile.
|
|
44
|
+
*
|
|
45
|
+
* @param {object} [options] Values to merge into the profile.
|
|
46
|
+
* @returns {CjsWebglFormat} This format profile.
|
|
47
|
+
*/
|
|
48
|
+
SetValues(options = {}) {
|
|
49
|
+
const values = normalizeValues(this.GetValues(), options, FORMAT_NAME);
|
|
50
|
+
this.#emit = values.emit;
|
|
51
|
+
this.#source = values.source;
|
|
52
|
+
return this;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Get this profile's current values, optionally with per-call overrides.
|
|
57
|
+
*
|
|
58
|
+
* @param {object} [options] Optional values to merge into a copy.
|
|
59
|
+
* @returns {object} A copy of the effective values.
|
|
60
|
+
*/
|
|
61
|
+
GetValues(options = {}) {
|
|
62
|
+
return normalizeValues({
|
|
63
|
+
emit: this.#emit,
|
|
64
|
+
source: this.#source
|
|
65
|
+
}, options, FORMAT_NAME);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Read a CEWG package with this profile's values.
|
|
70
|
+
*
|
|
71
|
+
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input CEWG package bytes.
|
|
72
|
+
* @param {object} [options] Per-call value overrides.
|
|
73
|
+
* @returns {object} Plain JSON data, or the raw CewgPackage instance when emit is "raw".
|
|
74
|
+
*/
|
|
75
|
+
Read(input, options = {}) {
|
|
76
|
+
return readWithValues(input, this.GetValues(options));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Inspect a CEWG package without building the full JSON shape.
|
|
81
|
+
*
|
|
82
|
+
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input CEWG package bytes.
|
|
83
|
+
* @param {object} [options] Per-call value overrides.
|
|
84
|
+
* @returns {object} Plain summary data.
|
|
85
|
+
*/
|
|
86
|
+
Inspect(input, options = {}) {
|
|
87
|
+
return inspectWithValues(input, this.GetValues(options));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Assembles a CEWG package from ordered chunk payloads.
|
|
92
|
+
*
|
|
93
|
+
* @param {Array<[string, string|object|Uint8Array|ArrayBuffer|ArrayBufferView]>} chunks Ordered package chunks.
|
|
94
|
+
* @returns {Uint8Array} Package bytes.
|
|
95
|
+
*/
|
|
96
|
+
Build(chunks) {
|
|
97
|
+
return buildPackage(chunks);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Translates one DXBC vertex/pixel/map-style-compute stage into GLSL ES 3.00.
|
|
102
|
+
*
|
|
103
|
+
* @param {ArrayBuffer|ArrayBufferView|Uint8Array} dxbcBytes DXBC container bytes.
|
|
104
|
+
* @param {object} [options] Combined ccpwgl-profile/emit options. See {@link CjsWebglFormat.emitGlsl}.
|
|
105
|
+
* @returns {object} GLSL text plus the IO contract the packaging layer records.
|
|
106
|
+
*/
|
|
107
|
+
EmitGlsl(dxbcBytes, options = {}) {
|
|
108
|
+
return emitGlslWithOptions(dxbcBytes, options);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Builds a complete CEWG package from compiled Tr2 effect bytes.
|
|
113
|
+
*
|
|
114
|
+
* @param {Uint8Array|ArrayBuffer|ArrayBufferView} input Compiled effect bytes.
|
|
115
|
+
* @param {object} [options] Selection, provenance, and emitter policy.
|
|
116
|
+
* @returns {object} Package bytes plus inspection and qualification records.
|
|
117
|
+
*/
|
|
118
|
+
BuildEffect(input, options = {}) {
|
|
119
|
+
return buildEffectPackage(input, options);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Instance JSON-compatible conversion.
|
|
124
|
+
*
|
|
125
|
+
* @param {any} value Format output to convert.
|
|
126
|
+
* @returns {any} Plain JSON-compatible data.
|
|
127
|
+
*/
|
|
128
|
+
ToJSON(value) {
|
|
129
|
+
return toJsonValue(value);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Static payload sniff. Static methods use camelCase by convention.
|
|
134
|
+
*
|
|
135
|
+
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Candidate bytes.
|
|
136
|
+
* @returns {boolean} True when the payload starts with the CEWG magic.
|
|
137
|
+
*/
|
|
138
|
+
static isCewg(input) {
|
|
139
|
+
return isCewg(input);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Static one-shot read.
|
|
144
|
+
*
|
|
145
|
+
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input CEWG package bytes.
|
|
146
|
+
* @param {object} [options] Format values.
|
|
147
|
+
* @returns {object} Plain JSON data, or the raw CewgPackage instance when emit is "raw".
|
|
148
|
+
*/
|
|
149
|
+
static read(input, options = {}) {
|
|
150
|
+
return readWithValues(input, normalizeValues(DEFAULT_VALUES, options, FORMAT_NAME));
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Static one-shot inspection.
|
|
155
|
+
*
|
|
156
|
+
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input CEWG package bytes.
|
|
157
|
+
* @param {object} [options] Format values.
|
|
158
|
+
* @returns {object} Plain summary data.
|
|
159
|
+
*/
|
|
160
|
+
static inspect(input, options = {}) {
|
|
161
|
+
return inspectWithValues(input, normalizeValues(DEFAULT_VALUES, options, FORMAT_NAME));
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Static one-shot package build.
|
|
166
|
+
*
|
|
167
|
+
* @param {Array<[string, string|object|Uint8Array|ArrayBuffer|ArrayBufferView]>} chunks Ordered package chunks.
|
|
168
|
+
* @returns {Uint8Array} Package bytes.
|
|
169
|
+
*/
|
|
170
|
+
static build(chunks) {
|
|
171
|
+
return buildPackage(chunks);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Static one-shot DXBC-to-GLSL emission.
|
|
176
|
+
*
|
|
177
|
+
* @param {ArrayBuffer|ArrayBufferView|Uint8Array} dxbcBytes DXBC container bytes.
|
|
178
|
+
* @param {object} [options] Combined ccpwgl-profile/emit options: `constantBufferStyle`
|
|
179
|
+
* (`"array"` (default) uniform `vec4[]` for ccpwgl's uniform4fv path, or `"std140"`),
|
|
180
|
+
* `pixelConstantBufferRemap` (default `{ 0: 7 }`, pixel-stage cb slot renames),
|
|
181
|
+
* `samplerName(register, stageName)` (naming function), `vertexStructuredCapacity`
|
|
182
|
+
* (default 69, bone-array element capacity), `dataTextureWidth` (default 2048),
|
|
183
|
+
* `pairVaryings` (per-call varying zero-fill list), `source` (per-call error-detail name).
|
|
184
|
+
* @returns {object} GLSL text plus the IO contract the packaging layer records.
|
|
185
|
+
*/
|
|
186
|
+
static emitGlsl(dxbcBytes, options = {}) {
|
|
187
|
+
return emitGlslWithOptions(dxbcBytes, options);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Static whole-effect CEWG builder.
|
|
192
|
+
*
|
|
193
|
+
* @param {Uint8Array|ArrayBuffer|ArrayBufferView} input Compiled effect bytes.
|
|
194
|
+
* @param {object} [options] Selection, provenance, and emitter policy.
|
|
195
|
+
* @returns {object} Package bytes plus inspection and qualification records.
|
|
196
|
+
*/
|
|
197
|
+
static buildEffect(input, options = {}) {
|
|
198
|
+
return buildEffectPackage(input, options);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Static JSON-compatible conversion.
|
|
203
|
+
*
|
|
204
|
+
* @param {any} value Format output to convert.
|
|
205
|
+
* @returns {any} Plain JSON-compatible data.
|
|
206
|
+
*/
|
|
207
|
+
static toJSON(value) {
|
|
208
|
+
return toJsonValue(value);
|
|
209
|
+
}
|
|
210
|
+
static OUTPUT_JSON = OUTPUT_JSON;
|
|
211
|
+
static OUTPUT_RAW = OUTPUT_RAW;
|
|
212
|
+
static type = Object.freeze(["shader"]);
|
|
213
|
+
static mediaTypes = Object.freeze(["shader"]);
|
|
214
|
+
static inputTypes = Object.freeze(["cewg"]);
|
|
215
|
+
static outputTypes = Object.freeze([OUTPUT_JSON]);
|
|
216
|
+
static debugOutputTypes = Object.freeze([OUTPUT_RAW]);
|
|
217
|
+
static packageVersion = "0.2.0";
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export { CjsWebglFormat, CjsWebglFormat as default };
|
|
221
|
+
//# sourceMappingURL=CjsWebglFormat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CjsWebglFormat.js","sources":["../../../../src/formats/webgl/CjsWebglFormat.js"],"sourcesContent":["/**\n * Exposed CarbonEngineJS-facing WebGL format class.\n *\n * Keep this file small and reviewable: CEWG container parsing lives under\n * src/core/cewg (internal parsing machinery, not part of this package's\n * public surface); the DXBC-to-GLSL ES 3.00 emitter lives under\n * src/core/glsl; input/option normalization and the shared read/build/emit\n * paths live in src/core/helpers.js.\n */\n\nimport {\n DEFAULT_VALUES,\n OUTPUT_JSON,\n OUTPUT_RAW,\n buildPackage,\n emitGlslWithOptions,\n inspectWithValues,\n isCewg,\n normalizeValues,\n readWithValues,\n toJsonValue\n} from \"./core/helpers.js\";\nimport { buildEffectPackage } from \"./core/effectPackage.js\";\n\nconst FORMAT_NAME = \"CjsWebglFormat\";\n\n/**\n * CarbonEngineJS-facing format surface for `.cewg` WebGL shader packages, and\n * a DXBC -> GLSL ES 3.00 emitter for the WebGL2 vertex/pixel/map-style-compute\n * stages ccpwgl targets.\n *\n * The Cjs prefix marks this as a JavaScript format/construction boundary.\n * CEWG is a CarbonEngineJS-invented container format (flat four-byte-tagged\n * chunks: `INFO`/`META`/`GLSL`/...), not a Microsoft or CCP one. `Read`\n * parses a package to plain JSON by default (`emit: \"raw\"` exposes the live\n * `CewgPackage` instance instead); `Inspect` is a cheap chunk/shader-count\n * summary; `Build` assembles package bytes from chunk payloads; `EmitGlsl`\n * translates one DXBC vertex/pixel/map-style-compute stage to GLSL ES 3.00.\n */\nexport class CjsWebglFormat\n{\n\n #emit = DEFAULT_VALUES.emit;\n #source = DEFAULT_VALUES.source;\n\n /**\n * Create a reusable format profile.\n *\n * @param {object} [options] Default format values.\n */\n constructor(options = {})\n {\n this.SetValues(options);\n }\n\n /**\n * Set format values for this reusable profile.\n *\n * @param {object} [options] Values to merge into the profile.\n * @returns {CjsWebglFormat} This format profile.\n */\n SetValues(options = {})\n {\n const values = normalizeValues(this.GetValues(), options, FORMAT_NAME);\n\n this.#emit = values.emit;\n this.#source = values.source;\n\n return this;\n }\n\n /**\n * Get this profile's current values, optionally with per-call overrides.\n *\n * @param {object} [options] Optional values to merge into a copy.\n * @returns {object} A copy of the effective values.\n */\n GetValues(options = {})\n {\n return normalizeValues({\n emit: this.#emit,\n source: this.#source\n }, options, FORMAT_NAME);\n }\n\n /**\n * Read a CEWG package with this profile's values.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input CEWG package bytes.\n * @param {object} [options] Per-call value overrides.\n * @returns {object} Plain JSON data, or the raw CewgPackage instance when emit is \"raw\".\n */\n Read(input, options = {})\n {\n return readWithValues(input, this.GetValues(options));\n }\n\n /**\n * Inspect a CEWG package without building the full JSON shape.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input CEWG package bytes.\n * @param {object} [options] Per-call value overrides.\n * @returns {object} Plain summary data.\n */\n Inspect(input, options = {})\n {\n return inspectWithValues(input, this.GetValues(options));\n }\n\n /**\n * Assembles a CEWG package from ordered chunk payloads.\n *\n * @param {Array<[string, string|object|Uint8Array|ArrayBuffer|ArrayBufferView]>} chunks Ordered package chunks.\n * @returns {Uint8Array} Package bytes.\n */\n Build(chunks)\n {\n return buildPackage(chunks);\n }\n\n /**\n * Translates one DXBC vertex/pixel/map-style-compute stage into GLSL ES 3.00.\n *\n * @param {ArrayBuffer|ArrayBufferView|Uint8Array} dxbcBytes DXBC container bytes.\n * @param {object} [options] Combined ccpwgl-profile/emit options. See {@link CjsWebglFormat.emitGlsl}.\n * @returns {object} GLSL text plus the IO contract the packaging layer records.\n */\n EmitGlsl(dxbcBytes, options = {})\n {\n return emitGlslWithOptions(dxbcBytes, options);\n }\n\n /**\n * Builds a complete CEWG package from compiled Tr2 effect bytes.\n *\n * @param {Uint8Array|ArrayBuffer|ArrayBufferView} input Compiled effect bytes.\n * @param {object} [options] Selection, provenance, and emitter policy.\n * @returns {object} Package bytes plus inspection and qualification records.\n */\n BuildEffect(input, options = {})\n {\n return buildEffectPackage(input, options);\n }\n\n /**\n * Instance JSON-compatible conversion.\n *\n * @param {any} value Format output to convert.\n * @returns {any} Plain JSON-compatible data.\n */\n ToJSON(value)\n {\n return toJsonValue(value);\n }\n\n /**\n * Static payload sniff. Static methods use camelCase by convention.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Candidate bytes.\n * @returns {boolean} True when the payload starts with the CEWG magic.\n */\n static isCewg(input)\n {\n return isCewg(input);\n }\n\n /**\n * Static one-shot read.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input CEWG package bytes.\n * @param {object} [options] Format values.\n * @returns {object} Plain JSON data, or the raw CewgPackage instance when emit is \"raw\".\n */\n static read(input, options = {})\n {\n return readWithValues(input, normalizeValues(DEFAULT_VALUES, options, FORMAT_NAME));\n }\n\n /**\n * Static one-shot inspection.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input CEWG package bytes.\n * @param {object} [options] Format values.\n * @returns {object} Plain summary data.\n */\n static inspect(input, options = {})\n {\n return inspectWithValues(input, normalizeValues(DEFAULT_VALUES, options, FORMAT_NAME));\n }\n\n /**\n * Static one-shot package build.\n *\n * @param {Array<[string, string|object|Uint8Array|ArrayBuffer|ArrayBufferView]>} chunks Ordered package chunks.\n * @returns {Uint8Array} Package bytes.\n */\n static build(chunks)\n {\n return buildPackage(chunks);\n }\n\n /**\n * Static one-shot DXBC-to-GLSL emission.\n *\n * @param {ArrayBuffer|ArrayBufferView|Uint8Array} dxbcBytes DXBC container bytes.\n * @param {object} [options] Combined ccpwgl-profile/emit options: `constantBufferStyle`\n * (`\"array\"` (default) uniform `vec4[]` for ccpwgl's uniform4fv path, or `\"std140\"`),\n * `pixelConstantBufferRemap` (default `{ 0: 7 }`, pixel-stage cb slot renames),\n * `samplerName(register, stageName)` (naming function), `vertexStructuredCapacity`\n * (default 69, bone-array element capacity), `dataTextureWidth` (default 2048),\n * `pairVaryings` (per-call varying zero-fill list), `source` (per-call error-detail name).\n * @returns {object} GLSL text plus the IO contract the packaging layer records.\n */\n static emitGlsl(dxbcBytes, options = {})\n {\n return emitGlslWithOptions(dxbcBytes, options);\n }\n\n /**\n * Static whole-effect CEWG builder.\n *\n * @param {Uint8Array|ArrayBuffer|ArrayBufferView} input Compiled effect bytes.\n * @param {object} [options] Selection, provenance, and emitter policy.\n * @returns {object} Package bytes plus inspection and qualification records.\n */\n static buildEffect(input, options = {})\n {\n return buildEffectPackage(input, options);\n }\n\n /**\n * Static JSON-compatible conversion.\n *\n * @param {any} value Format output to convert.\n * @returns {any} Plain JSON-compatible data.\n */\n static toJSON(value)\n {\n return toJsonValue(value);\n }\n\n static OUTPUT_JSON = OUTPUT_JSON;\n static OUTPUT_RAW = OUTPUT_RAW;\n static type = Object.freeze([ \"shader\" ]);\n static mediaTypes = Object.freeze([ \"shader\" ]);\n static inputTypes = Object.freeze([ \"cewg\" ]);\n static outputTypes = Object.freeze([ OUTPUT_JSON ]);\n static debugOutputTypes = Object.freeze([ OUTPUT_RAW ]);\n static packageVersion = \"0.2.0\";\n\n}\n\nexport default CjsWebglFormat;\n"],"names":["FORMAT_NAME","CjsWebglFormat","DEFAULT_VALUES","emit","source","constructor","options","SetValues","values","normalizeValues","GetValues","Read","input","readWithValues","Inspect","inspectWithValues","Build","chunks","buildPackage","EmitGlsl","dxbcBytes","emitGlslWithOptions","BuildEffect","buildEffectPackage","ToJSON","value","toJsonValue","isCewg","read","inspect","build","emitGlsl","buildEffect","toJSON","OUTPUT_JSON","OUTPUT_RAW","type","Object","freeze","mediaTypes","inputTypes","outputTypes","debugOutputTypes","packageVersion"],"mappings":";;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgBA,MAAMA,WAAW,GAAG,gBAAgB;;AAEpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,cAAc,CAC3B;AAEI,EAAA,KAAK,GAAGC,cAAc,CAACC,IAAI;AAC3B,EAAA,OAAO,GAAGD,cAAc,CAACE,MAAM;;AAE/B;AACJ;AACA;AACA;AACA;AACIC,EAAAA,WAAWA,CAACC,OAAO,GAAG,EAAE,EACxB;AACI,IAAA,IAAI,CAACC,SAAS,CAACD,OAAO,CAAC;AAC3B,EAAA;;AAEA;AACJ;AACA;AACA;AACA;AACA;AACIC,EAAAA,SAASA,CAACD,OAAO,GAAG,EAAE,EACtB;AACI,IAAA,MAAME,MAAM,GAAGC,eAAe,CAAC,IAAI,CAACC,SAAS,EAAE,EAAEJ,OAAO,EAAEN,WAAW,CAAC;AAEtE,IAAA,IAAI,CAAC,KAAK,GAAGQ,MAAM,CAACL,IAAI;AACxB,IAAA,IAAI,CAAC,OAAO,GAAGK,MAAM,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