@carbonenginejs/runtime-resource 0.11.1 → 0.12.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/formats/bnk/CjsBnkFormat.js +12 -2
- package/dist/formats/bnk/CjsBnkFormat.js.map +1 -1
- package/dist/formats/bnk/core/graph.js +3 -6
- package/dist/formats/bnk/core/graph.js.map +1 -1
- package/dist/formats/bnk/core/helpers.js +53 -11
- package/dist/formats/bnk/core/helpers.js.map +1 -1
- package/dist/formats/bnk/core/sfxNodes.js +532 -0
- package/dist/formats/bnk/core/sfxNodes.js.map +1 -0
- package/dist/formats/bnk/core/soundbanksInfo.js +59 -51
- package/dist/formats/bnk/core/soundbanksInfo.js.map +1 -1
- package/dist/formats/gr2/CjsGr2Format.js +256 -13
- package/dist/formats/gr2/CjsGr2Format.js.map +1 -1
- package/dist/formats/gr2/core/helpers.js +15 -15
- package/dist/formats/gr2/core/helpers.js.map +1 -1
- package/dist/formats/gr2/core/json.js +1 -1
- package/dist/formats/gr2/core/json.js.map +1 -1
- package/dist/formats/gr2/core/targets.js +1 -1
- package/dist/formats/gr2/core/targets.js.map +1 -1
- package/dist/formats/gr2/index.js +0 -1
- package/dist/formats/gr2/index.js.map +1 -1
- package/dist/formats/hlsl/core/analysis.js +1 -1
- package/dist/formats/hlsl/index.js +1 -0
- package/dist/formats/hlsl/index.js.map +1 -1
- package/dist/formats/index.js +3 -6
- package/dist/formats/index.js.map +1 -1
- package/dist/formats/webgl/core/cewg/binary.js +3 -3
- package/dist/formats/webgl/core/cewg/binary.js.map +1 -1
- package/dist/formats/webgl/core/effectPackage.js +4 -1
- package/dist/formats/webgl/core/effectPackage.js.map +1 -1
- package/dist/formats/webgl/core/errors.js +3 -3
- package/dist/formats/webgl/core/errors.js.map +1 -1
- package/docs/formats/dxbc/README.md +68 -0
- package/docs/formats/dxbc/architecture.md +80 -0
- package/docs/formats/dxbc/reference/api.md +77 -0
- package/docs/formats/dxbc/reference/classes/README.md +76 -0
- package/docs/formats/dxbc/reference/decoded-output.md +122 -0
- package/docs/formats/gr2.md +3 -4
- package/docs/formats/hlsl/README.md +54 -0
- package/docs/formats/hlsl/architecture.md +67 -0
- package/docs/formats/hlsl/guides/hydrating-json-output.md +62 -0
- package/docs/formats/hlsl/guides/reading-effects.md +64 -0
- package/docs/formats/hlsl/reference/advanced-analysis.md +66 -0
- package/docs/formats/hlsl/reference/api.md +97 -0
- package/docs/formats/hlsl/reference/classes/README.md +16 -0
- package/docs/formats/hlsl/reference/classes/carbon-compatibility.md +66 -0
- package/docs/formats/hlsl/reference/classes/public-api.md +26 -0
- package/docs/formats/hlsl/reference/classes/tr2-effect-model.md +150 -0
- package/docs/formats/hlsl/reference/json-graph.md +100 -0
- package/docs/formats/hlsl/reference/portable-reflection.md +141 -0
- package/docs/formats/provenance.md +9 -4
- package/docs/formats/webgl/README.md +57 -0
- package/docs/formats/webgl/architecture.md +70 -0
- package/docs/formats/webgl/carbon-constant-layouts.md +326 -0
- package/docs/formats/webgl/decl-io.md +1234 -0
- package/docs/formats/webgl/effect-reflection.md +127 -0
- package/docs/formats/webgl/memory-structured.md +871 -0
- package/docs/formats/webgl/reference/classes/README.md +96 -0
- package/docs/formats/webgl/texture-sample.md +964 -0
- package/docs/formats/webgpu/README.md +81 -0
- package/docs/formats/webgpu/architecture.md +93 -0
- package/docs/formats/webgpu/formats/cewgpu.md +479 -0
- package/docs/formats/webgpu/guides/effect-packaging.md +199 -0
- package/docs/formats/webgpu/reference/api.md +197 -0
- package/docs/formats/webgpu/reference/classes/README.md +66 -0
- package/docs/formats/webgpu/reference/wgsl-compatibility.md +1442 -0
- package/docs/formats/wwise.md +16 -1
- package/docs/reference/classes/formats.md +10 -10
- package/format-notices/bnk/NOTICE +5 -4
- package/format-notices/webgl/NOTICE +1 -1
- package/package.json +1 -1
- package/dist/formats/gr2/core/CjsFormatGr2.js +0 -273
- package/dist/formats/gr2/core/CjsFormatGr2.js.map +0 -1
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
# Build a CEWGPU package from compiled effect bytes
|
|
2
|
+
|
|
3
|
+
Status: Evolving
|
|
4
|
+
Scope: `@carbonenginejs/runtime-resource/formats/webgpu`
|
|
5
|
+
Audience: Shader-tool authors and engine integrators
|
|
6
|
+
Summary: Shows how to package the complete supported pass scope of one selected compiled-effect body as CEWGPU data.
|
|
7
|
+
|
|
8
|
+
## Purpose
|
|
9
|
+
|
|
10
|
+
Use `buildEffect` when an application or build tool already has compiled
|
|
11
|
+
effect bytes and needs one structurally valid CEWGPU package for a selected
|
|
12
|
+
effect body. The operation performs effect analysis, exact selection,
|
|
13
|
+
DXBC-to-IR lowering, pass-global binding allocation, WGSL emission, package
|
|
14
|
+
assembly, and structural qualification.
|
|
15
|
+
|
|
16
|
+
## Prerequisites
|
|
17
|
+
|
|
18
|
+
- Caller-supplied compiled `.sm_*` effect bytes.
|
|
19
|
+
- An exact technique, pass index, and complete stage list when deterministic
|
|
20
|
+
selection matters.
|
|
21
|
+
- Permutation assertions for every axis whose value must not depend on effect
|
|
22
|
+
defaults.
|
|
23
|
+
- A complete, internally consistent source permutation header: every ordered
|
|
24
|
+
axis must have valid names/options/defaults, and every Cartesian permutation
|
|
25
|
+
must have one correctly indexed, in-bounds body record. PGRF construction
|
|
26
|
+
validates the whole header even though only one body is translated. The
|
|
27
|
+
synchronous builder accepts at most 65,536 Cartesian permutations.
|
|
28
|
+
|
|
29
|
+
## Build one pass
|
|
30
|
+
|
|
31
|
+
```js
|
|
32
|
+
import { CjsWebgpuFormat } from "@carbonenginejs/runtime-resource/formats/webgpu";
|
|
33
|
+
|
|
34
|
+
const result = CjsWebgpuFormat.buildEffect(effectBytes, {
|
|
35
|
+
source: "res:/graphics/effect.dx11/example.sm_hi",
|
|
36
|
+
mode: "selected",
|
|
37
|
+
permutation: [
|
|
38
|
+
{ name: "QUALITY", value: "HIGH" }
|
|
39
|
+
],
|
|
40
|
+
selection: {
|
|
41
|
+
techniqueName: "Main",
|
|
42
|
+
passIndex: 0,
|
|
43
|
+
stageNames: [ "vertex", "pixel" ]
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const packageBytes = result.bytes;
|
|
48
|
+
const emittedShaders = result.wgsl;
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The `source` value is diagnostic provenance only. The method does not open
|
|
52
|
+
that path. Callers may separately provide `sourceIdentity` with a canonical
|
|
53
|
+
`logicalPath` plus optional `game`, `client`, `build`, `md5`, and `sha256`
|
|
54
|
+
fields. Its logical path need not equal the diagnostic label. `BuildEffect`
|
|
55
|
+
always computes the lower-case SHA-256 digest over the exact input byte view;
|
|
56
|
+
when a caller supplies `sha256`, the build fails if it does not match.
|
|
57
|
+
|
|
58
|
+
Version-15 packages use INFO schema version 3 while the binary CEWGPU
|
|
59
|
+
container remains version 1. INFO v3 identifies the `webgpu` target, the
|
|
60
|
+
producing `@carbonenginejs/runtime-resource/formats/webgpu` package version, and the
|
|
61
|
+
`dxbc-js-wgsl` translator version. Versions 8-14 use INFO v2 without
|
|
62
|
+
reflection. The reader continues to accept legacy INFO v1 packages, INFO v2
|
|
63
|
+
packages without PGRF, and INFO v2 packages with selected-body RFLX v1.
|
|
64
|
+
|
|
65
|
+
Every new selected-effect package also includes a complete source permutation
|
|
66
|
+
graph in `PGRF`. This preserves every axis, Cartesian permutation index,
|
|
67
|
+
option-index tuple, compiler alias, and unique raw body identity even though
|
|
68
|
+
only one selected body's WGSL is currently packaged. INFO v3 binds the exact
|
|
69
|
+
PGRF bytes with SHA-256.
|
|
70
|
+
|
|
71
|
+
For version-15 input, the package also includes complete portable reflection
|
|
72
|
+
for every unique source body in RFLX v2 and its exact immutable byte payloads
|
|
73
|
+
in one shared `RBLB`. These include authored parameter/resource metadata,
|
|
74
|
+
constant defaults, stage/library source programs, signatures, static samplers,
|
|
75
|
+
annotations, and the opaque native source hash. Earlier source versions keep
|
|
76
|
+
the legacy package surface because portable reflection version 1 is
|
|
77
|
+
intentionally version-15-only.
|
|
78
|
+
|
|
79
|
+
## Result
|
|
80
|
+
|
|
81
|
+
The returned record contains:
|
|
82
|
+
|
|
83
|
+
| Field | Purpose |
|
|
84
|
+
| --- | --- |
|
|
85
|
+
| `bytes` | Encoded CEWGPU package bytes. |
|
|
86
|
+
| `info` | Translator and package information. |
|
|
87
|
+
| `metadata` | Selection and caller provenance. |
|
|
88
|
+
| `permutationGraph` | Complete source permutation topology and identity-only body table. |
|
|
89
|
+
| `reflection` | Complete all-unique portable source reflection for version-15 input, otherwise `null`. |
|
|
90
|
+
| `reflectionBlobs` | Exact RBLB bytes for reflected programs/defaults/native hash, otherwise `null`. |
|
|
91
|
+
| `analysis` | Compact selected-body diagnostic binding/stage data; not lossless effect reflection. |
|
|
92
|
+
| `wgsl` | Portable shader set and pass layouts. |
|
|
93
|
+
| `inspection` | Summary produced by reading the built package. |
|
|
94
|
+
| `qualification` | Structural conversion outcome. |
|
|
95
|
+
|
|
96
|
+
`mode: "selected"` is the default and currently the only supported backend
|
|
97
|
+
body mode. The package retains normalized analysis for that resolved body while
|
|
98
|
+
emitting WGSL for the selected complete passes. PGRF retains the complete
|
|
99
|
+
source permutation graph and RFLX/RBLB retain every unique version-15 body's
|
|
100
|
+
portable source reflection. `META.bodyIndex` selects a PGRF variant; its
|
|
101
|
+
`bodyKey` selects the matching RFLX body. A raw reader exposes that join as
|
|
102
|
+
`GetPortableEffectReflection(permutationIndex)`, returning a freshly owned,
|
|
103
|
+
format-hlsl-validated single-body document with every byte reference expanded
|
|
104
|
+
to `Uint8Array`. `runtime-resource` `Tr2EffectRes` consumes that document,
|
|
105
|
+
hydrates a canonical device-free `Tr2Shader`, and caches it by selected body
|
|
106
|
+
index. Engines still own prepared pipelines and GPU realization.
|
|
107
|
+
|
|
108
|
+
`mode: "all"` additionally packages translated programs, layouts, and resource
|
|
109
|
+
transforms for every unique body in a `WGSB` chunk, and
|
|
110
|
+
`GetBackendBodyPrograms(permutationIndex)` resolves any permutation to them.
|
|
111
|
+
Because one pass of one body is the translation unit, bodies whose pass is
|
|
112
|
+
byte-identical share a single stored unit rather than duplicating its WGSL.
|
|
113
|
+
Bodies the compiler cannot lower stay in the package as explicitly unsupported
|
|
114
|
+
records with a reason, and never remove that body's source reflection.
|
|
115
|
+
|
|
116
|
+
JSON `Read` output exposes `reflection` with byte references and
|
|
117
|
+
`reflectionBlobByteLength`. Consumers that need exact defaults or source
|
|
118
|
+
program bytes use `Read(bytes, { emit: "raw" })`, then call
|
|
119
|
+
`GetPortableEffectReflection(permutationIndex)`. Omit the index to use
|
|
120
|
+
`META.bodyIndex`. For individual payload access,
|
|
121
|
+
`GetReflectionBlob(referenceOrKey)` returns an owned `Uint8Array`; an object
|
|
122
|
+
reference must exactly match its RFLX inventory entry.
|
|
123
|
+
|
|
124
|
+
Raw stage bytecode, decoded DXBC instruction trees, and compiler IR are
|
|
125
|
+
transient build inputs and are not embedded in `ANLS`. Use `AnalyzeEffect`
|
|
126
|
+
when return-only DXBC/IR diagnostics are required.
|
|
127
|
+
|
|
128
|
+
The qualification record distinguishes structural package validity from
|
|
129
|
+
broader completeness. `packageValid` means only that the selected CEWGPU
|
|
130
|
+
container passed required-chunk, schema, cross-document, key, layout, and
|
|
131
|
+
selection reconciliation. Version-15 INFO v3 reports `sourceComplete: true`
|
|
132
|
+
because PGRF plus RFLX/RBLB cover every unique body's portable reflection and
|
|
133
|
+
immutable exact defaults for that exact input file. This does not embed raw
|
|
134
|
+
body records or make CEWGPU an archive of the original `.sm_*` bytes.
|
|
135
|
+
`backendComplete` would additionally require every required translated
|
|
136
|
+
program, layout, and transform. `runtimeComplete` would require
|
|
137
|
+
complete-resource hydration and selection. None of these fields is
|
|
138
|
+
prepared-pipeline or rendered evidence. The same four booleans are retained
|
|
139
|
+
under `INFO.completeness` in the package.
|
|
140
|
+
|
|
141
|
+
Shader-tier and permutation evidence remain orthogonal to source reflection.
|
|
142
|
+
High is `.sm_depth`; Medium is `.sm_hi`; Low is `.sm_lo`. Source completeness
|
|
143
|
+
applies only to the exact input tier. For unpacked Quad ship gates, explicitly
|
|
144
|
+
select `SPACE_OBJECT_PPT_ENABLED=SOPPT_ENABLED`: an all-unique RFLX does not
|
|
145
|
+
turn a PPT-disabled selected WGSL body into PPT-on backend evidence.
|
|
146
|
+
|
|
147
|
+
When exact semantic metadata and shader use prove an allowed physical resource
|
|
148
|
+
coalescing, the returned WGSL document is a `CJS_WGSL_SET` version 3 record.
|
|
149
|
+
Its `resourceTransforms` recipes are required runtime work, not optional
|
|
150
|
+
diagnostics: the consumer must build the described resource and bind it through
|
|
151
|
+
the matching transformed layout entry. See the package-format contract before
|
|
152
|
+
passing version 3 output to an engine. Packages without transforms remain WGSL
|
|
153
|
+
set version 2.
|
|
154
|
+
|
|
155
|
+
## Binding scope
|
|
156
|
+
|
|
157
|
+
A D3D resource tuple is stage-local unless the caller has authoritative
|
|
158
|
+
metadata proving that the vertex and fragment declarations name one compatible
|
|
159
|
+
resource. Build one binding plan from the complete stage set; do not build
|
|
160
|
+
independent stage plans and combine them afterward.
|
|
161
|
+
|
|
162
|
+
When compatible sharing is proven, pass the base binding identity through
|
|
163
|
+
`sharedIdentities`:
|
|
164
|
+
|
|
165
|
+
```js
|
|
166
|
+
const plan = CjsWebgpuFormat.buildWgslBindingPlan(
|
|
167
|
+
[ vertexIr, fragmentIr ],
|
|
168
|
+
{ sharedIdentities: [ "uniform-buffer:0:0" ] }
|
|
169
|
+
);
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Unshared identities receive distinct `@vertex` or `@fragment` scopes and
|
|
173
|
+
numeric binding slots.
|
|
174
|
+
|
|
175
|
+
## Errors
|
|
176
|
+
|
|
177
|
+
Conversion fails explicitly when:
|
|
178
|
+
|
|
179
|
+
- a permutation assertion is unknown or unresolved;
|
|
180
|
+
- any axis/default/option or positional body record in the complete source
|
|
181
|
+
permutation header is malformed, out of bounds, partially overlapping, or
|
|
182
|
+
inconsistent, even when the selected body itself is translatable;
|
|
183
|
+
- the Cartesian permutation product exceeds the 65,536-entry synchronous-build
|
|
184
|
+
limit;
|
|
185
|
+
- the technique, pass, or requested stage does not exist;
|
|
186
|
+
- the requested stage list is incomplete or duplicated;
|
|
187
|
+
- the selected shader uses unsupported semantics;
|
|
188
|
+
- resource declarations cannot form one unambiguous pass layout; or
|
|
189
|
+
- emitted package records fail structural validation.
|
|
190
|
+
|
|
191
|
+
An unsupported requested shader aborts selected-pass packaging; no partially
|
|
192
|
+
translated pass is emitted. This fail-closed behavior does not imply
|
|
193
|
+
whole-effect completeness.
|
|
194
|
+
|
|
195
|
+
## Related documentation
|
|
196
|
+
|
|
197
|
+
- [Public API reference](../reference/api.md)
|
|
198
|
+
- [CEWGPU package format](../formats/cewgpu.md)
|
|
199
|
+
- [WGSL compatibility](../reference/wgsl-compatibility.md)
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
# Public API reference
|
|
2
|
+
|
|
3
|
+
Status: Evolving
|
|
4
|
+
Scope: `@carbonenginejs/runtime-resource/formats/webgpu`
|
|
5
|
+
Audience: Shader-tool authors and engine integrators
|
|
6
|
+
Summary: Lists the public `CjsWebgpuFormat` profile, one-shot helpers, options, and output contracts.
|
|
7
|
+
|
|
8
|
+
## Export
|
|
9
|
+
|
|
10
|
+
The package root exports `CjsWebgpuFormat` as both a named and default export:
|
|
11
|
+
|
|
12
|
+
```js
|
|
13
|
+
import CjsWebgpuFormat, {
|
|
14
|
+
CjsWebgpuFormat as WebgpuFormat
|
|
15
|
+
} from "@carbonenginejs/runtime-resource/formats/webgpu";
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Reusable profile
|
|
19
|
+
|
|
20
|
+
Construct a profile when several operations share output, source, permutation,
|
|
21
|
+
schema, or class-registration options:
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
const reader = new WebgpuFormat({
|
|
25
|
+
emit: "json",
|
|
26
|
+
source: "example.cewgpu",
|
|
27
|
+
decodeInstructions: true,
|
|
28
|
+
permutation: null
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
| Instance method | Purpose |
|
|
33
|
+
| --- | --- |
|
|
34
|
+
| `SetValues(options)` | Merges reusable profile defaults. |
|
|
35
|
+
| `GetValues(options?)` | Returns effective values with optional per-call overrides. |
|
|
36
|
+
| `SetClasses(classes)` | Registers several package-shape constructors. |
|
|
37
|
+
| `SetClass(type, Class)` | Registers or removes one constructor. |
|
|
38
|
+
| `GetClass(type)` | Returns one registered constructor. |
|
|
39
|
+
| `HasClass(type)` | Reports whether a constructor is registered. |
|
|
40
|
+
| `Read(bytes, options?)` | Reads CEWGPU bytes as JSON or a raw package. |
|
|
41
|
+
| `Inspect(bytes, options?)` | Returns a package summary. |
|
|
42
|
+
| `Build(chunks)` | Builds CEWGPU bytes from ordered chunks. |
|
|
43
|
+
| `AnalyzeEffect(bytes, options?)` | Builds normalized analysis from compiled effect bytes. |
|
|
44
|
+
| `BuildEffect(bytes, options?)` | Converts one selected effect body/pass scope into CEWGPU data. |
|
|
45
|
+
| `BuildShaderIr(input, options?)` | Builds validated shader IR from DXBC bytes or decoded input. |
|
|
46
|
+
| `BuildWgsl(input, options?)` | Emits a supported typed shader as WGSL. |
|
|
47
|
+
| `BuildWgslBindingPlan(programs, options?)` | Allocates one binding layout across a complete pass. |
|
|
48
|
+
| `BuildWgslSet(entries)` | Assembles emitted shaders and pass layouts. |
|
|
49
|
+
| `ToJSON(value)` | Converts format output to JSON-compatible data. |
|
|
50
|
+
|
|
51
|
+
`Read` currently returns plain data. Class registrations are validated and
|
|
52
|
+
stored for forward compatibility but do not hydrate the returned package.
|
|
53
|
+
Raw output is an internal zero-copy package view; callers must treat its chunk
|
|
54
|
+
bytes as immutable and reread/rebuild after any byte change.
|
|
55
|
+
|
|
56
|
+
## One-shot static helpers
|
|
57
|
+
|
|
58
|
+
The static helpers use lower camel case and share the implementation of the
|
|
59
|
+
instance methods:
|
|
60
|
+
|
|
61
|
+
| Static helper | Purpose |
|
|
62
|
+
| --- | --- |
|
|
63
|
+
| `isCewgpu(bytes)` | Checks the `CWGP` package magic. |
|
|
64
|
+
| `read(bytes, options?)` | Reads one package. |
|
|
65
|
+
| `inspect(bytes, options?)` | Inspects one package. |
|
|
66
|
+
| `build(chunks)` | Builds one package. |
|
|
67
|
+
| `analyzeEffect(bytes, options?)` | Analyzes one compiled effect. |
|
|
68
|
+
| `buildEffect(bytes, options?)` | Builds one selected effect body/pass scope. |
|
|
69
|
+
| `buildShaderIr(input, options?)` | Builds shader IR. |
|
|
70
|
+
| `buildWgsl(input, options?)` | Emits WGSL. |
|
|
71
|
+
| `buildWgslBindingPlan(programs, options?)` | Allocates a pass binding plan. |
|
|
72
|
+
| `buildWgslSet(entries)` | Builds a portable shader set. |
|
|
73
|
+
| `toJSON(value)` | Converts output to JSON-compatible data. |
|
|
74
|
+
|
|
75
|
+
## Profile options
|
|
76
|
+
|
|
77
|
+
| Option | Meaning |
|
|
78
|
+
| --- | --- |
|
|
79
|
+
| `emit` | `"json"` by default or `"raw"` for the internal package object. |
|
|
80
|
+
| `source` | Caller-owned diagnostic label; it is never opened. |
|
|
81
|
+
| `decodeInstructions` | Includes decoded instruction and shader IR detail during analysis. |
|
|
82
|
+
| `permutation` | Exact NAME=VALUE assertions as an array or `Map`. |
|
|
83
|
+
| `schema` | Optional caller schema record retained by the profile. |
|
|
84
|
+
| `classes` | Optional constructor registrations keyed by `CLASS_KEYS`. |
|
|
85
|
+
|
|
86
|
+
`AnalyzeEffect` decodes real selected-body stage bytes for return-only
|
|
87
|
+
diagnostics. `decodeInstructions: false` retains compact DXBC program metadata
|
|
88
|
+
without instruction or IR trees. `BuildEffect` keeps those bytes transient for
|
|
89
|
+
WGSL compilation and writes compact selected-body `ANLS` diagnostics instead.
|
|
90
|
+
Both `AnalyzeEffect` and `BuildEffect` reject malformed, duplicate, unknown, or
|
|
91
|
+
unresolved permutation assertions rather than silently selecting a default.
|
|
92
|
+
|
|
93
|
+
## Effect-package options
|
|
94
|
+
|
|
95
|
+
`BuildEffect` and `buildEffect` accept `mode: "selected"`, which remains the
|
|
96
|
+
default. They resolve one permutation body and emit complete passes within the
|
|
97
|
+
requested stage selection.
|
|
98
|
+
|
|
99
|
+
`mode: "all"` additionally translates every unique source body into a `WGSB`
|
|
100
|
+
chunk and reports `backendBodyCoverage: "all-unique"`, or `"partial"` when some
|
|
101
|
+
body could not be lowered. It requires complete version-15 source reflection and
|
|
102
|
+
fails closed on versions 8-14, which carry no validated body inventory. The
|
|
103
|
+
orchestration compatibility option `allPermutations: true` selects the same
|
|
104
|
+
mode, and `allPermutations: false` means selected mode.
|
|
105
|
+
|
|
106
|
+
`CewgpuPackage.GetBackendBodyPrograms(permutationIndex)` resolves any
|
|
107
|
+
permutation to its translated passes, defaulting to `META.bodyIndex`. It returns
|
|
108
|
+
null when the package carries no all-body graph, and an explicitly unsupported
|
|
109
|
+
record when that body could not be lowered.
|
|
110
|
+
|
|
111
|
+
Both `GetBackendBodyPrograms` and `GetPortableEffectReflection` return null
|
|
112
|
+
until the package has passed canonical envelope validation. Every documented
|
|
113
|
+
read entry point validates, so this is transparent to normal consumers; it
|
|
114
|
+
prevents a hand-assembled or tampered container from being hydrated as though
|
|
115
|
+
it had been checked.
|
|
116
|
+
|
|
117
|
+
`source` remains a caller-owned diagnostic label. An optional
|
|
118
|
+
`sourceIdentity.logicalPath` records the canonical resource identity
|
|
119
|
+
independently and may differ from that label. The builder records the exact
|
|
120
|
+
source byte length and computes a lower-case SHA-256 digest over the active
|
|
121
|
+
input byte view. A caller-supplied `sourceIdentity.sha256` is accepted only
|
|
122
|
+
when it matches that digest.
|
|
123
|
+
|
|
124
|
+
For version-15 input, `BuildEffect` emits INFO schema version 3 with explicit
|
|
125
|
+
WebGPU target, backend-package name/version, translator provenance, and
|
|
126
|
+
source/backend body coverage. Versions 8-14 emit INFO v2 without reflection.
|
|
127
|
+
The CEWGPU binary container remains version 1. The reader retains legacy INFO
|
|
128
|
+
v1, pre-PGRF INFO v2, and selected-body INFO v2/RFLX v1 support.
|
|
129
|
+
|
|
130
|
+
New packages also emit a `PGRF` permutation graph and expose it as
|
|
131
|
+
`result.permutationGraph`, JSON-read `permutationGraph`, and raw
|
|
132
|
+
`CewgpuPackage.permutationGraph`. The graph contains every ordered axis,
|
|
133
|
+
Cartesian permutation index, option-index tuple, source record, and
|
|
134
|
+
package-local unique-body key/digest. `Inspect` reports `permutationCount` and
|
|
135
|
+
`uniqueBodyCount`. This is complete source topology with identity-only bodies;
|
|
136
|
+
it does not provide backend translation by itself.
|
|
137
|
+
|
|
138
|
+
For version-15 input, new packages emit complete all-unique source reflection
|
|
139
|
+
in RFLX v2 and exact referenced byte payloads in one shared `RBLB`. Build
|
|
140
|
+
results expose
|
|
141
|
+
these as `result.reflection` and `result.reflectionBlobs`. JSON reads expose
|
|
142
|
+
`reflection` plus `reflectionBlobByteLength`; raw reads expose
|
|
143
|
+
`CewgpuPackage.reflection`, `reflectionBlobBytes`, and
|
|
144
|
+
`GetReflectionBlob(referenceOrKey)`. Raw reads also expose
|
|
145
|
+
`GetPortableEffectReflection(permutationIndex)`: it performs the PGRF/RFLX
|
|
146
|
+
join, expands every referenced payload to fresh owned `Uint8Array` values, and
|
|
147
|
+
reruns the format-hlsl portable validator. Its optional index defaults to
|
|
148
|
+
`META.bodyIndex`; legacy selected-body RFLX v1 accepts only its selected
|
|
149
|
+
permutation. `GetReflectionBlob` remains the lower-level accessor and requires
|
|
150
|
+
an object reference to match its stored key, offset, byte length, and digest
|
|
151
|
+
exactly. `Inspect` reports reflection body/source-program/blob counts and blob
|
|
152
|
+
byte length. The body count covers every PGRF unique body. The selector joins
|
|
153
|
+
`META.bodyIndex -> PGRF.variants[index].bodyKey -> RFLX.bodies[].bodyKey`.
|
|
154
|
+
Earlier source versions omit both chunks.
|
|
155
|
+
|
|
156
|
+
The returned structural qualification separates preservation from execution.
|
|
157
|
+
`packageValid` reports successful container construction. Version-15 INFO v3
|
|
158
|
+
reports `sourceComplete: true` for the exact input's portable semantic graph
|
|
159
|
+
while `backendComplete` and `runtimeComplete` remain false. Versions 8-14
|
|
160
|
+
report all three completeness flags false. Source completeness does not embed
|
|
161
|
+
raw body records, translate every body, construct a live `Tr2EffectRes`, or
|
|
162
|
+
prove prepared pipelines/rendering. `GetPortableEffectReflection` reconstructs
|
|
163
|
+
and validates fresh owned plain portable data; `runtime-resource`
|
|
164
|
+
`Tr2EffectRes` performs canonical runtime-class hydration and selection. The
|
|
165
|
+
accessor does not construct renderer-owned handles, layouts, resource sets, or
|
|
166
|
+
stage programs.
|
|
167
|
+
|
|
168
|
+
## Static metadata
|
|
169
|
+
|
|
170
|
+
The class exposes output-mode constants, accepted class keys, media and input
|
|
171
|
+
type metadata, implementation status, the CEWGPU format label, analysis format,
|
|
172
|
+
and package version.
|
|
173
|
+
|
|
174
|
+
## Errors
|
|
175
|
+
|
|
176
|
+
Malformed package input and unsafe analysis paths throw or report a
|
|
177
|
+
`CjsWebgpuReadError` internally. Unsupported WGSL semantics fail closed with
|
|
178
|
+
the operation, stage, and source context needed to identify the boundary.
|
|
179
|
+
Duplicate/non-ASCII chunk tags are rejected. A declared
|
|
180
|
+
`tr2-effect-webgpu` package also fails closed on missing or malformed JSON
|
|
181
|
+
chunks, unsupported document versions, or inconsistent INFO/META/ANLS/WGSL
|
|
182
|
+
identity, counts, keys, layouts, selection, and completeness fields. Declared
|
|
183
|
+
PGRF pointers, exact INFO-v3 chunk digests, schemas, counts, variant tuples,
|
|
184
|
+
body references, and the selected index/options are reconciled as part of the
|
|
185
|
+
same gate. Optional
|
|
186
|
+
INFO/RFLX/RBLB reflection units additionally reconcile the exact RFLX digest,
|
|
187
|
+
every PGRF body and representative, portable closed schemas, exact blob
|
|
188
|
+
references/digests, and the selected body's ANLS pass/stage source identities.
|
|
189
|
+
Strict effect validation is activated by the `INFO.packageKind` marker;
|
|
190
|
+
effect-only consumers must require that marker because unmarked CEWGPU
|
|
191
|
+
containers intentionally remain generic.
|
|
192
|
+
|
|
193
|
+
## Related documentation
|
|
194
|
+
|
|
195
|
+
- [Effect packaging guide](../guides/effect-packaging.md)
|
|
196
|
+
- [CEWGPU package format](../formats/cewgpu.md)
|
|
197
|
+
- [Class-purpose catalog](classes/README.md)
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Class catalog
|
|
2
|
+
|
|
3
|
+
Status: Evolving
|
|
4
|
+
Scope: `@carbonenginejs/runtime-resource/formats/webgpu` maintained classes
|
|
5
|
+
Audience: Users, maintainers, and automated readers
|
|
6
|
+
Summary: Provides one-sentence purpose descriptors for every maintained class in the WebGPU format package.
|
|
7
|
+
|
|
8
|
+
<!-- class:CjsWebgpuFormat -->
|
|
9
|
+
## `CjsWebgpuFormat`
|
|
10
|
+
|
|
11
|
+
CarbonEngineJS-facing format surface for `.cewgpu` WebGPU packages, plus an offline effect-analysis helper built on `format-hlsl` and `format-dxbc`.
|
|
12
|
+
|
|
13
|
+
- Export: `@carbonenginejs/runtime-resource/formats/webgpu`
|
|
14
|
+
- Source: `src/CjsWebgpuFormat.js`
|
|
15
|
+
- Visibility: Public
|
|
16
|
+
- Kind: CarbonEngineJS
|
|
17
|
+
|
|
18
|
+
<!-- class:CjsWebgpuReadError -->
|
|
19
|
+
## `CjsWebgpuReadError`
|
|
20
|
+
|
|
21
|
+
Error raised when a CEWGPU package or WebGPU analysis pass cannot be completed safely.
|
|
22
|
+
|
|
23
|
+
- Export: None
|
|
24
|
+
- Source: `src/core/errors.js`
|
|
25
|
+
- Visibility: Internal
|
|
26
|
+
- Kind: Internal implementation
|
|
27
|
+
|
|
28
|
+
<!-- class:CjsBinaryReader -->
|
|
29
|
+
## `CjsBinaryReader`
|
|
30
|
+
|
|
31
|
+
Minimal little-endian binary reader for the flat CEWGPU chunk container.
|
|
32
|
+
|
|
33
|
+
- Export: None
|
|
34
|
+
- Source: `src/core/cewgpu/binary.js`
|
|
35
|
+
- Visibility: Internal
|
|
36
|
+
- Kind: Internal implementation
|
|
37
|
+
|
|
38
|
+
<!-- class:CewgpuPackage -->
|
|
39
|
+
## `CewgpuPackage`
|
|
40
|
+
|
|
41
|
+
Reader for CarbonEngineJS CEWGPU shader packages.
|
|
42
|
+
|
|
43
|
+
- Export: None
|
|
44
|
+
- Source: `src/core/cewgpu/CewgpuPackage.js`
|
|
45
|
+
- Visibility: Internal
|
|
46
|
+
- Kind: Internal implementation
|
|
47
|
+
|
|
48
|
+
<!-- class:CewgpuPackageBuilder -->
|
|
49
|
+
## `CewgpuPackageBuilder`
|
|
50
|
+
|
|
51
|
+
Builds CarbonEngineJS CEWGPU package bytes.
|
|
52
|
+
|
|
53
|
+
- Export: None
|
|
54
|
+
- Source: `src/core/cewgpu/CewgpuPackageBuilder.js`
|
|
55
|
+
- Visibility: Internal
|
|
56
|
+
- Kind: Internal implementation
|
|
57
|
+
|
|
58
|
+
<!-- class:ReflectionBlobStore -->
|
|
59
|
+
## `ReflectionBlobStore`
|
|
60
|
+
|
|
61
|
+
Builds the deterministic deduplicated byte arena for complete source reflection.
|
|
62
|
+
|
|
63
|
+
- Export: None
|
|
64
|
+
- Source: `src/core/effectReflectionPackage.js`
|
|
65
|
+
- Visibility: Internal
|
|
66
|
+
- Kind: Internal implementation
|