@carbonenginejs/runtime-resource 0.11.0 → 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 +6 -3
- package/dist/formats/webgl/core/effectPackage.js.map +1 -1
- package/dist/formats/webgl/core/effectPackageValidation.js +1 -1
- package/dist/formats/webgl/core/effectPackageValidation.js.map +1 -1
- package/dist/formats/webgl/core/errors.js +3 -3
- package/dist/formats/webgl/core/errors.js.map +1 -1
- package/dist/formats/webgpu/core/packageMetadata.js +2 -2
- package/dist/formats/webgpu/core/packageMetadata.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
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Error raised when a CEWG package or a DXBC-to-GLSL emission cannot be
|
|
3
3
|
* completed safely.
|
|
4
4
|
*
|
|
5
|
-
* This
|
|
6
|
-
* `DxbcReadError` class (that
|
|
7
|
-
* boundary). Emitter/package failures raised from this
|
|
5
|
+
* This format has no dependency on the sibling `formats/dxbc` internal
|
|
6
|
+
* `DxbcReadError` class (that format only exports its public `CjsDxbcFormat`
|
|
7
|
+
* boundary). Emitter/package failures raised from this format's own code
|
|
8
8
|
* use this class instead, while thrown messages that document a specific
|
|
9
9
|
* failure mode (see README/tests) are kept identical to their origin in
|
|
10
10
|
* `hlslreader`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sources":["../../../../../src/formats/webgl/core/errors.js"],"sourcesContent":["/**\n * Error raised when a CEWG package or a DXBC-to-GLSL emission cannot be\n * completed safely.\n *\n * This
|
|
1
|
+
{"version":3,"file":"errors.js","sources":["../../../../../src/formats/webgl/core/errors.js"],"sourcesContent":["/**\n * Error raised when a CEWG package or a DXBC-to-GLSL emission cannot be\n * completed safely.\n *\n * This format has no dependency on the sibling `formats/dxbc` internal\n * `DxbcReadError` class (that format only exports its public `CjsDxbcFormat`\n * boundary). Emitter/package failures raised from this format's own code\n * use this class instead, while thrown messages that document a specific\n * failure mode (see README/tests) are kept identical to their origin in\n * `hlslreader`.\n */\nexport class WebglReadError extends Error\n{\n /**\n * Creates a read/emit error with structured location details.\n *\n * @param {string} message Human-readable failure reason.\n * @param {object} [details] Extra reader state such as source, offset, or opcode.\n */\n constructor(message, details = {})\n {\n super(message);\n this.name = \"WebglReadError\";\n this.details = details;\n }\n}\n"],"names":["WebglReadError","Error","constructor","message","details","name"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,cAAc,SAASC,KAAK,CACzC;AACI;AACJ;AACA;AACA;AACA;AACA;AACIC,EAAAA,WAAWA,CAACC,OAAO,EAAEC,OAAO,GAAG,EAAE,EACjC;IACI,KAAK,CAACD,OAAO,CAAC;IACd,IAAI,CAACE,IAAI,GAAG,gBAAgB;IAC5B,IAAI,CAACD,OAAO,GAAGA,OAAO;AAC1B,EAAA;AACJ;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const FORMAT_WEBGPU_PACKAGE_NAME = "@carbonenginejs/
|
|
2
|
-
const FORMAT_WEBGPU_PACKAGE_VERSION = "0.
|
|
1
|
+
const FORMAT_WEBGPU_PACKAGE_NAME = "@carbonenginejs/runtime-resource/formats/webgpu";
|
|
2
|
+
const FORMAT_WEBGPU_PACKAGE_VERSION = "0.11.1";
|
|
3
3
|
const WEBGPU_BACKEND_NAME = "webgpu";
|
|
4
4
|
const DXBC_WGSL_TRANSLATOR_NAME = "dxbc-js-wgsl";
|
|
5
5
|
const DXBC_WGSL_TRANSLATOR_VERSION = FORMAT_WEBGPU_PACKAGE_VERSION;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageMetadata.js","sources":["../../../../../src/formats/webgpu/core/packageMetadata.js"],"sourcesContent":["export const FORMAT_WEBGPU_PACKAGE_NAME = \"@carbonenginejs/
|
|
1
|
+
{"version":3,"file":"packageMetadata.js","sources":["../../../../../src/formats/webgpu/core/packageMetadata.js"],"sourcesContent":["export const FORMAT_WEBGPU_PACKAGE_NAME = \"@carbonenginejs/runtime-resource/formats/webgpu\";\nexport const FORMAT_WEBGPU_PACKAGE_VERSION = \"0.11.1\";\nexport const WEBGPU_BACKEND_NAME = \"webgpu\";\nexport const DXBC_WGSL_TRANSLATOR_NAME = \"dxbc-js-wgsl\";\nexport const DXBC_WGSL_TRANSLATOR_VERSION = FORMAT_WEBGPU_PACKAGE_VERSION;\n"],"names":["FORMAT_WEBGPU_PACKAGE_NAME","FORMAT_WEBGPU_PACKAGE_VERSION","WEBGPU_BACKEND_NAME","DXBC_WGSL_TRANSLATOR_NAME","DXBC_WGSL_TRANSLATOR_VERSION"],"mappings":"AAAO,MAAMA,0BAA0B,GAAG;AACnC,MAAMC,6BAA6B,GAAG;AACtC,MAAMC,mBAAmB,GAAG;AAC5B,MAAMC,yBAAyB,GAAG;AAClC,MAAMC,4BAA4B,GAAGH;;;;"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# DXBC format documentation
|
|
2
|
+
|
|
3
|
+
Status: Evolving
|
|
4
|
+
Scope: `@carbonenginejs/runtime-resource/formats/dxbc`
|
|
5
|
+
Audience: Shader-tool authors, lowering-backend authors, and maintainers
|
|
6
|
+
Summary: Explains the pure-JavaScript DXBC reader, its decoded output, and its boundary with effect and shader-lowering packages.
|
|
7
|
+
|
|
8
|
+
## Purpose
|
|
9
|
+
|
|
10
|
+
`@carbonenginejs/runtime-resource/formats/dxbc` owns pure-JavaScript reading of Microsoft DXBC
|
|
11
|
+
containers. It validates the chunk directory, decodes input/output/patch
|
|
12
|
+
signatures, reads SM4/SM5 program headers, and converts instruction tokens into
|
|
13
|
+
structured records.
|
|
14
|
+
|
|
15
|
+
The package preserves unfamiliar declaration payload words as `tailTokens`
|
|
16
|
+
where the framing is valid. Executable instructions decode strictly and reject
|
|
17
|
+
malformed operand lengths.
|
|
18
|
+
|
|
19
|
+
## Use this package when
|
|
20
|
+
|
|
21
|
+
Use `format-dxbc` when you need:
|
|
22
|
+
|
|
23
|
+
- cheap DXBC identification and container inspection;
|
|
24
|
+
- plain JSON-compatible signatures and instruction records;
|
|
25
|
+
- internal decoder objects for an advanced shader backend; or
|
|
26
|
+
- a browser-safe byte decoder with no native executable or filesystem
|
|
27
|
+
dependency.
|
|
28
|
+
|
|
29
|
+
Do not place target-language lowering rules here. GLSL emission belongs to
|
|
30
|
+
`@carbonenginejs/runtime-resource/formats/webgl`, and WGSL emission belongs to
|
|
31
|
+
`@carbonenginejs/runtime-resource/formats/webgpu`.
|
|
32
|
+
|
|
33
|
+
## Where it fits
|
|
34
|
+
|
|
35
|
+
```text
|
|
36
|
+
compiled effects
|
|
37
|
+
|
|
|
38
|
+
v
|
|
39
|
+
format-hlsl
|
|
40
|
+
|
|
|
41
|
+
| opaque DXBC stage bytes
|
|
42
|
+
v
|
|
43
|
+
format-dxbc
|
|
44
|
+
|
|
|
45
|
+
+---- decoded records ----> format-webgl
|
|
46
|
+
|
|
|
47
|
+
+---- decoded records ----> format-webgpu
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The public decoder contract is Microsoft DXBC data. Package-local binary
|
|
51
|
+
utilities are internal implementation details and are not public npm subpaths.
|
|
52
|
+
|
|
53
|
+
## Start here
|
|
54
|
+
|
|
55
|
+
```js
|
|
56
|
+
import { CjsDxbcFormat } from "@carbonenginejs/runtime-resource/formats/dxbc";
|
|
57
|
+
|
|
58
|
+
const decoded = CjsDxbcFormat.read(shaderBytes, {
|
|
59
|
+
source: "example.dxbc"
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Documentation map
|
|
64
|
+
|
|
65
|
+
- [Architecture and boundaries](architecture.md)
|
|
66
|
+
- [Public API reference](reference/api.md)
|
|
67
|
+
- [Decoded output contract](reference/decoded-output.md)
|
|
68
|
+
- [Class-purpose catalog](reference/classes/README.md)
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Architecture and boundaries
|
|
2
|
+
|
|
3
|
+
Status: Evolving
|
|
4
|
+
Scope: `@carbonenginejs/runtime-resource/formats/dxbc`
|
|
5
|
+
Audience: Shader-tool authors, lowering-backend authors, and maintainers
|
|
6
|
+
Summary: Defines DXBC decoding ownership, strictness, dependency direction, and target-language non-goals.
|
|
7
|
+
|
|
8
|
+
## Purpose
|
|
9
|
+
|
|
10
|
+
`format-dxbc` turns caller-supplied DXBC bytes into validated container,
|
|
11
|
+
signature, program, operand, declaration, and instruction records. It stops
|
|
12
|
+
before target-language code generation.
|
|
13
|
+
|
|
14
|
+
## Dependency direction
|
|
15
|
+
|
|
16
|
+
```text
|
|
17
|
+
caller or format-hlsl
|
|
18
|
+
|
|
|
19
|
+
| DXBC bytes
|
|
20
|
+
v
|
|
21
|
+
format-dxbc
|
|
22
|
+
/ \
|
|
23
|
+
v v
|
|
24
|
+
format-webgl format-webgpu
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
The package has no runtime dependency and its public source works in browsers
|
|
28
|
+
and Node. Lowering packages depend on its decoded records; it does not import
|
|
29
|
+
them.
|
|
30
|
+
|
|
31
|
+
## Owned responsibilities
|
|
32
|
+
|
|
33
|
+
- DXBC magic, header, checksum field, total-size, and chunk-directory parsing.
|
|
34
|
+
- Bounds-checked access to chunk payloads.
|
|
35
|
+
- `ISGN`, `ISG1`, `OSGN`, `OSG1`, `OSG5`, `PCSG`, and `PSG1` signature
|
|
36
|
+
records.
|
|
37
|
+
- `SHEX` and `SHDR` program version and token-stream reading.
|
|
38
|
+
- SM4/SM5 opcode, operand, declaration, control, and extension-token decoding.
|
|
39
|
+
- SM5.1 binding-range and resource-reference records.
|
|
40
|
+
- JSON-compatible output and an internal raw-object mode.
|
|
41
|
+
- Structured decode errors with source and offset details.
|
|
42
|
+
|
|
43
|
+
## Ownership elsewhere
|
|
44
|
+
|
|
45
|
+
- Compiled effect containers, permutations, techniques, and binding manifests
|
|
46
|
+
belong to `format-hlsl`.
|
|
47
|
+
- GLSL ES generation and WebGL-specific register/storage policy belong to
|
|
48
|
+
`format-webgl`.
|
|
49
|
+
- WGSL generation, pass-global WebGPU binding allocation, and CEWGPU assembly
|
|
50
|
+
belong to `format-webgpu`.
|
|
51
|
+
- GPU shader-module and pipeline realization belongs to engine packages.
|
|
52
|
+
|
|
53
|
+
## Strictness
|
|
54
|
+
|
|
55
|
+
The reader validates container and chunk bounds before exposing data.
|
|
56
|
+
Executable instructions must consume exactly their declared token length.
|
|
57
|
+
Declarations decode the payload forms implemented by the package and retain
|
|
58
|
+
remaining valid words in `tailTokens`, allowing unusual stages to remain
|
|
59
|
+
inspectable without pretending every declaration payload has a specialized
|
|
60
|
+
projection.
|
|
61
|
+
|
|
62
|
+
The opcode-name table covers the SM4/SM5 vocabulary used for framing. That does
|
|
63
|
+
not imply every opcode has a target-language implementation in every lowering
|
|
64
|
+
package.
|
|
65
|
+
|
|
66
|
+
## Output stability
|
|
67
|
+
|
|
68
|
+
`emit: "json"` is the stable integration surface. It returns plain data and
|
|
69
|
+
converts typed arrays into number arrays.
|
|
70
|
+
|
|
71
|
+
`emit: "raw"` exposes package-internal class instances for advanced backends.
|
|
72
|
+
Those classes are not public npm exports; consumers should treat their concrete
|
|
73
|
+
constructors as internal and depend only on the fields used by the owning
|
|
74
|
+
lowering package.
|
|
75
|
+
|
|
76
|
+
## Related documentation
|
|
77
|
+
|
|
78
|
+
- [Package documentation](README.md)
|
|
79
|
+
- [Public API reference](reference/api.md)
|
|
80
|
+
- [Decoded output contract](reference/decoded-output.md)
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Public API reference
|
|
2
|
+
|
|
3
|
+
Status: Evolving
|
|
4
|
+
Scope: `@carbonenginejs/runtime-resource/formats/dxbc`
|
|
5
|
+
Audience: Shader-tool authors and lowering-backend authors
|
|
6
|
+
Summary: Defines the public `CjsDxbcFormat` profile, one-shot helpers, options, and failure behavior.
|
|
7
|
+
|
|
8
|
+
## Export
|
|
9
|
+
|
|
10
|
+
The package root exports `CjsDxbcFormat` as both a named and default export:
|
|
11
|
+
|
|
12
|
+
```js
|
|
13
|
+
import CjsDxbcFormat, {
|
|
14
|
+
CjsDxbcFormat as DxbcFormat
|
|
15
|
+
} from "@carbonenginejs/runtime-resource/formats/dxbc";
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
No internal container, signature, program, decoder, or error class is exposed
|
|
19
|
+
through the package export map.
|
|
20
|
+
|
|
21
|
+
## Reusable profile
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
const reader = new DxbcFormat({
|
|
25
|
+
emit: "json",
|
|
26
|
+
source: "example.dxbc",
|
|
27
|
+
decodeInstructions: true
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const decoded = reader.Read(shaderBytes);
|
|
31
|
+
const summary = reader.Inspect(shaderBytes);
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
| Instance method | Purpose |
|
|
35
|
+
| --- | --- |
|
|
36
|
+
| `SetValues(options)` | Merges reusable profile defaults and returns the profile. |
|
|
37
|
+
| `GetValues(options?)` | Returns effective values with optional per-call overrides. |
|
|
38
|
+
| `Read(bytes, options?)` | Reads one DXBC payload using the effective profile. |
|
|
39
|
+
| `Inspect(bytes, options?)` | Returns container, stage, shader-model, and signature counts without instruction decoding. |
|
|
40
|
+
|
|
41
|
+
## One-shot helpers
|
|
42
|
+
|
|
43
|
+
| Static helper | Purpose |
|
|
44
|
+
| --- | --- |
|
|
45
|
+
| `isDxbc(bytes)` | Returns `true` when input starts with the DXBC magic; invalid input returns `false`. |
|
|
46
|
+
| `read(bytes, options?)` | Reads one DXBC payload. |
|
|
47
|
+
| `inspect(bytes, options?)` | Inspects one payload without instruction decoding. |
|
|
48
|
+
| `toJSON(value)` | Deep-converts supported values to JSON-compatible data. |
|
|
49
|
+
|
|
50
|
+
The class also exposes `OUTPUT_JSON`, `OUTPUT_RAW`, input/output media metadata,
|
|
51
|
+
and the format's supported input type.
|
|
52
|
+
|
|
53
|
+
## Options
|
|
54
|
+
|
|
55
|
+
| Option | Default | Meaning |
|
|
56
|
+
| --- | --- | --- |
|
|
57
|
+
| `emit` | `"json"` | `"json"` returns plain data; `"raw"` returns internal decoder objects. |
|
|
58
|
+
| `source` | `"memory"` | Caller-owned label included in error details; no path is opened. |
|
|
59
|
+
| `decodeInstructions` | `true` | When false, reads the container, signatures, and program header without decoding instructions. |
|
|
60
|
+
|
|
61
|
+
Inputs may be `Uint8Array`, `ArrayBuffer`, Node `Buffer`, `DataView`, or another
|
|
62
|
+
array-buffer view.
|
|
63
|
+
|
|
64
|
+
## Errors
|
|
65
|
+
|
|
66
|
+
Invalid options and unsupported input types throw `TypeError`. Malformed DXBC
|
|
67
|
+
throws an internal `DxbcReadError` carrying a stable human-readable message and
|
|
68
|
+
a `details` record with relevant source, offset, size, chunk, or opcode
|
|
69
|
+
information.
|
|
70
|
+
|
|
71
|
+
`isDxbc` is the non-throwing sniff operation.
|
|
72
|
+
|
|
73
|
+
## Related documentation
|
|
74
|
+
|
|
75
|
+
- [Decoded output contract](decoded-output.md)
|
|
76
|
+
- [Architecture and boundaries](../architecture.md)
|
|
77
|
+
- [Class-purpose catalog](classes/README.md)
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Class catalog
|
|
2
|
+
|
|
3
|
+
Status: Evolving
|
|
4
|
+
Scope: `@carbonenginejs/runtime-resource/formats/dxbc` maintained classes
|
|
5
|
+
Audience: Users, maintainers, and automated readers
|
|
6
|
+
Summary: Provides one-sentence purpose descriptors for every maintained class in the DXBC format package.
|
|
7
|
+
|
|
8
|
+
<!-- class:CjsDxbcFormat -->
|
|
9
|
+
## `CjsDxbcFormat`
|
|
10
|
+
|
|
11
|
+
CarbonEngineJS-facing DXBC (Direct3D shader bytecode) reader.
|
|
12
|
+
|
|
13
|
+
- Export: `@carbonenginejs/runtime-resource/formats/dxbc`
|
|
14
|
+
- Source: `src/CjsDxbcFormat.js`
|
|
15
|
+
- Visibility: Public
|
|
16
|
+
- Kind: CarbonEngineJS
|
|
17
|
+
|
|
18
|
+
<!-- class:CjsBinaryReader -->
|
|
19
|
+
## `CjsBinaryReader`
|
|
20
|
+
|
|
21
|
+
Little-endian binary reader with optional shared string-table references.
|
|
22
|
+
|
|
23
|
+
- Export: None
|
|
24
|
+
- Source: `src/carbon/CjsBinaryReader.js`
|
|
25
|
+
- Visibility: Internal
|
|
26
|
+
- Kind: Internal implementation
|
|
27
|
+
|
|
28
|
+
<!-- class:DxbcContainer -->
|
|
29
|
+
## `DxbcContainer`
|
|
30
|
+
|
|
31
|
+
DirectX shader bytecode container reader.
|
|
32
|
+
|
|
33
|
+
- Export: None
|
|
34
|
+
- Source: `src/core/container.js`
|
|
35
|
+
- Visibility: Internal
|
|
36
|
+
- Kind: Internal implementation
|
|
37
|
+
|
|
38
|
+
<!-- class:DxbcInstructionDecoder -->
|
|
39
|
+
## `DxbcInstructionDecoder`
|
|
40
|
+
|
|
41
|
+
SM4/SM5 instruction-stream decoder over a `DxbcShaderProgram` token array.
|
|
42
|
+
|
|
43
|
+
- Export: None
|
|
44
|
+
- Source: `src/core/decoder.js`
|
|
45
|
+
- Visibility: Internal
|
|
46
|
+
- Kind: Internal implementation
|
|
47
|
+
|
|
48
|
+
<!-- class:DxbcReadError -->
|
|
49
|
+
## `DxbcReadError`
|
|
50
|
+
|
|
51
|
+
Error raised when DirectX shader bytecode cannot be decoded safely.
|
|
52
|
+
|
|
53
|
+
- Export: None
|
|
54
|
+
- Source: `src/core/errors.js`
|
|
55
|
+
- Visibility: Internal
|
|
56
|
+
- Kind: Internal implementation
|
|
57
|
+
|
|
58
|
+
<!-- class:DxbcShaderProgram -->
|
|
59
|
+
## `DxbcShaderProgram`
|
|
60
|
+
|
|
61
|
+
DXBC shader program chunk reader for `SHEX`/`SHDR` token streams.
|
|
62
|
+
|
|
63
|
+
- Export: None
|
|
64
|
+
- Source: `src/core/program.js`
|
|
65
|
+
- Visibility: Internal
|
|
66
|
+
- Kind: Internal implementation
|
|
67
|
+
|
|
68
|
+
<!-- class:DxbcSignatureChunk -->
|
|
69
|
+
## `DxbcSignatureChunk`
|
|
70
|
+
|
|
71
|
+
DXBC input/output signature chunk reader for `ISGN`-family chunks.
|
|
72
|
+
|
|
73
|
+
- Export: None
|
|
74
|
+
- Source: `src/core/signature.js`
|
|
75
|
+
- Visibility: Internal
|
|
76
|
+
- Kind: Internal implementation
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# Decoded output contract
|
|
2
|
+
|
|
3
|
+
Status: Evolving
|
|
4
|
+
Scope: `@carbonenginejs/runtime-resource/formats/dxbc` JSON output
|
|
5
|
+
Audience: Shader-tool authors and lowering-backend authors
|
|
6
|
+
Summary: Defines the stable top-level JSON fields and the decoder records consumed by shader-lowering packages.
|
|
7
|
+
|
|
8
|
+
## Top-level result
|
|
9
|
+
|
|
10
|
+
`CjsDxbcFormat.read(bytes)` returns:
|
|
11
|
+
|
|
12
|
+
| Field | Meaning |
|
|
13
|
+
| --- | --- |
|
|
14
|
+
| `source` | Caller-provided diagnostic label. |
|
|
15
|
+
| `container` | Container version, declared size, and chunk summaries. |
|
|
16
|
+
| `program` | Shader stage, shader model, chunk tag, and token count, or `null`. |
|
|
17
|
+
| `inputSignature` | Input signature elements, or `null`. |
|
|
18
|
+
| `outputSignature` | Output signature elements, or `null`. |
|
|
19
|
+
| `patchSignature` | Patch-constant signature elements, or `null`. |
|
|
20
|
+
| `instructions` | Decoded instruction records, or `null` when disabled or absent. |
|
|
21
|
+
|
|
22
|
+
`Inspect` returns a smaller record containing the container/chunk summary,
|
|
23
|
+
stage name, shader model, and input/output element counts.
|
|
24
|
+
|
|
25
|
+
## Container records
|
|
26
|
+
|
|
27
|
+
The container summary includes `version`, `totalSize`, and ordered `chunks`.
|
|
28
|
+
Each chunk record includes its four-character code, byte offset, and payload
|
|
29
|
+
size. JSON output omits raw chunk bytes.
|
|
30
|
+
|
|
31
|
+
## Program records
|
|
32
|
+
|
|
33
|
+
Program metadata includes:
|
|
34
|
+
|
|
35
|
+
- `fourCC`: `SHEX` or `SHDR`;
|
|
36
|
+
- numeric and named program type;
|
|
37
|
+
- major and minor shader-model version; and
|
|
38
|
+
- declared program length in 32-bit words.
|
|
39
|
+
|
|
40
|
+
Recognized program names are pixel, vertex, geometry, hull, domain, and
|
|
41
|
+
compute. An unknown numeric type remains observable as `"unknown"`.
|
|
42
|
+
|
|
43
|
+
## Signature elements
|
|
44
|
+
|
|
45
|
+
Each signature element records its semantic name/index, system-value and
|
|
46
|
+
component types, register index, masks, stream, and minimum-precision value
|
|
47
|
+
when that signature layout provides one.
|
|
48
|
+
|
|
49
|
+
The reader supports the SM4 and SM5 signature chunk layouts used by `ISGN`,
|
|
50
|
+
`ISG1`, `OSGN`, `OSG1`, `OSG5`, `PCSG`, and `PSG1`.
|
|
51
|
+
|
|
52
|
+
## Instruction records
|
|
53
|
+
|
|
54
|
+
Each instruction begins with its source token offset, opcode number/name,
|
|
55
|
+
declared length, and decoded control bits. Depending on the opcode, the record
|
|
56
|
+
may also include:
|
|
57
|
+
|
|
58
|
+
- destination and source operands with component selection and index records;
|
|
59
|
+
- opcode and operand extensions;
|
|
60
|
+
- declaration-specific fields;
|
|
61
|
+
- resource dimensions and return types;
|
|
62
|
+
- sampler, interpolation, precision, topology, or system-value metadata;
|
|
63
|
+
- custom-data payloads; and
|
|
64
|
+
- unprojected declaration words in `tailTokens`.
|
|
65
|
+
|
|
66
|
+
Executable instructions reject leftover or missing operand words. Declaration
|
|
67
|
+
records may preserve unfamiliar trailing payload words when their instruction
|
|
68
|
+
framing is valid.
|
|
69
|
+
|
|
70
|
+
### Compute shared memory and synchronization
|
|
71
|
+
|
|
72
|
+
Compute thread-group shared-memory declarations expose their register and
|
|
73
|
+
complete allocation shape:
|
|
74
|
+
|
|
75
|
+
| Declaration | Fields |
|
|
76
|
+
| --- | --- |
|
|
77
|
+
| `dcl_thread_group_shared_memory_raw` | `registerIndex`, `byteCount` |
|
|
78
|
+
| `dcl_thread_group_shared_memory_structured` | `registerIndex`, `structureStride`, `structureCount` |
|
|
79
|
+
|
|
80
|
+
The declaration operand must identify one immediate thread-group shared-memory
|
|
81
|
+
register. Byte counts and structure strides are positive and DWORD-aligned;
|
|
82
|
+
structured element counts are positive. Any additional well-framed declaration
|
|
83
|
+
words remain observable through `tailTokens`.
|
|
84
|
+
|
|
85
|
+
The `sync` instruction exposes its numeric `syncFlags` mask and a canonical
|
|
86
|
+
bit-order `syncFlagNames` array. The recognized names are
|
|
87
|
+
`threads_in_group`, `thread_group_shared_memory`,
|
|
88
|
+
`thread_group_uav_memory`, and `global_uav_memory`. These control bits are
|
|
89
|
+
separate from arithmetic result controls, so `sync` never reports saturation.
|
|
90
|
+
Unknown bits remain set in the numeric eight-bit mask even though they have no
|
|
91
|
+
entry in the recognized-name array. Reserved operand and opcode-control bits
|
|
92
|
+
are rejected rather than projected onto the canonical records.
|
|
93
|
+
|
|
94
|
+
## Shader Model 5.1 bindings
|
|
95
|
+
|
|
96
|
+
SM5.1 resource declarations may include `bindingRange`:
|
|
97
|
+
|
|
98
|
+
| Field | Meaning |
|
|
99
|
+
| --- | --- |
|
|
100
|
+
| `rangeId` | Class-local binding-range identity. |
|
|
101
|
+
| `lowerBound` / `upperBound` | Declared register bounds. |
|
|
102
|
+
| `unbounded` | Whether the upper bound represents an unbounded range. |
|
|
103
|
+
| `registerCount` | Finite range size, otherwise `null`. |
|
|
104
|
+
| `registerSpace` | D3D register space. |
|
|
105
|
+
|
|
106
|
+
Executable resource, sampler, UAV, and constant-buffer operands may include a
|
|
107
|
+
`resourceReference` retaining the range identity, index records, and
|
|
108
|
+
non-uniform flag. Range identity remains separate from the actual register
|
|
109
|
+
index needed by an explicit-binding backend.
|
|
110
|
+
|
|
111
|
+
SM5.0 declarations keep their direct-register shape.
|
|
112
|
+
|
|
113
|
+
## JSON conversion
|
|
114
|
+
|
|
115
|
+
Typed arrays become number arrays, arrays are converted recursively, maps
|
|
116
|
+
become plain objects, sets become arrays, and objects with `toJSON` use that
|
|
117
|
+
projection.
|
|
118
|
+
|
|
119
|
+
## Related documentation
|
|
120
|
+
|
|
121
|
+
- [Public API reference](api.md)
|
|
122
|
+
- [Architecture and boundaries](../architecture.md)
|
package/docs/formats/gr2.md
CHANGED
|
@@ -32,10 +32,9 @@ const summary = CjsGr2Format.inspect(bytes);
|
|
|
32
32
|
const asynchronousGraph = await CjsGr2Format.readAsync(bytes);
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
`isSupported(bytes)` magic probe.
|
|
37
|
-
|
|
38
|
-
`CjsGr2Format`.
|
|
35
|
+
`CjsGr2Format` is the one public class: the reader engine plus the normal
|
|
36
|
+
runtime-resource format metadata and the `isSupported(bytes)` magic probe.
|
|
37
|
+
The barrel exports nothing else.
|
|
39
38
|
|
|
40
39
|
Register it with `CjsResMan` when GR2/GSF should participate in ordinary
|
|
41
40
|
resource loading:
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Package documentation
|
|
2
|
+
|
|
3
|
+
Status: Evolving
|
|
4
|
+
Scope: `@carbonenginejs/runtime-resource/formats/hlsl`
|
|
5
|
+
Audience: Users and integrators
|
|
6
|
+
Summary: Documentation home for the compiled Carbon/Trinity effect-container reader.
|
|
7
|
+
|
|
8
|
+
## Purpose
|
|
9
|
+
|
|
10
|
+
`@carbonenginejs/runtime-resource/formats/hlsl` reads versions 8 through 15 of the compiled
|
|
11
|
+
effect container used by Carbon/Trinity. It resolves a permutation and exposes
|
|
12
|
+
techniques, passes, stage metadata, render states, signatures, and opaque
|
|
13
|
+
shader bytecode as JavaScript data.
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import CjsHlslFormat from "@carbonenginejs/runtime-resource/formats/hlsl";
|
|
17
|
+
|
|
18
|
+
const metadata = CjsHlslFormat.read(bytes, {
|
|
19
|
+
emit: "metadata"
|
|
20
|
+
});
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Where it fits
|
|
24
|
+
|
|
25
|
+
- Use this package for the effect container and its metadata.
|
|
26
|
+
- Use `@carbonenginejs/runtime-resource/formats/dxbc` to decode supported embedded Direct3D
|
|
27
|
+
shader bytecode.
|
|
28
|
+
- Translation backends such as `@carbonenginejs/runtime-resource/formats/webgpu` can consume
|
|
29
|
+
the metadata and bytecode through their own integration layers.
|
|
30
|
+
- `@carbonenginejs/runtime-resource` consumes packaged portable reflection and
|
|
31
|
+
owns canonical `Tr2EffectRes`/`Tr2Shader` hydration, selection, and caching.
|
|
32
|
+
- `@carbonenginejs/runtime-trinity` consumes that shader graph through its
|
|
33
|
+
mutable effect/material facade, parameters, options, and sampler overrides.
|
|
34
|
+
|
|
35
|
+
The package does not compile HLSL source, translate shader instructions,
|
|
36
|
+
construct canonical runtime model instances, or provide a rendering runtime.
|
|
37
|
+
|
|
38
|
+
## Start here
|
|
39
|
+
|
|
40
|
+
- [Architecture](architecture.md)
|
|
41
|
+
- [Reading effects](guides/reading-effects.md)
|
|
42
|
+
- [Hydrating JSON output](guides/hydrating-json-output.md)
|
|
43
|
+
- [API reference](reference/api.md)
|
|
44
|
+
- [Advanced analysis exports](reference/advanced-analysis.md)
|
|
45
|
+
- [JSON graph reference](reference/json-graph.md)
|
|
46
|
+
- [Portable body reflection](reference/portable-reflection.md)
|
|
47
|
+
- [Class catalog](reference/classes/README.md)
|
|
48
|
+
|
|
49
|
+
## Compatibility
|
|
50
|
+
|
|
51
|
+
Supported input types are `.sm_hi`, `.sm_lo`, and `.sm_depth` compiled effect
|
|
52
|
+
bodies. Unsupported headers, invalid offsets, truncated data, and invalid
|
|
53
|
+
permutation selections fail with an error rather than returning a partial
|
|
54
|
+
success value.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Architecture
|
|
2
|
+
|
|
3
|
+
Status: Evolving
|
|
4
|
+
Scope: `@carbonenginejs/runtime-resource/formats/hlsl` implementation boundaries
|
|
5
|
+
Audience: Integrators and maintainers
|
|
6
|
+
Summary: Explains the package boundary, parsing flow, output modes, and platform adapters.
|
|
7
|
+
|
|
8
|
+
## Ownership boundary
|
|
9
|
+
|
|
10
|
+
The package owns the compiled Carbon/Trinity effect-container boundary:
|
|
11
|
+
headers, string tables, permutation selection, effect descriptions,
|
|
12
|
+
techniques, passes, render states, stage metadata, signatures, and the
|
|
13
|
+
packaging of opaque shader bytecode.
|
|
14
|
+
|
|
15
|
+
It does not decode shader instructions, compile source code, or own runtime
|
|
16
|
+
resource binding. Those responsibilities remain with bytecode-format,
|
|
17
|
+
translation, and runtime packages.
|
|
18
|
+
|
|
19
|
+
## Read flow
|
|
20
|
+
|
|
21
|
+
```text
|
|
22
|
+
caller bytes
|
|
23
|
+
-> input and option normalization
|
|
24
|
+
-> effect header, strings, and permutation axes
|
|
25
|
+
-> selected compiled body
|
|
26
|
+
-> techniques, passes, and stage metadata
|
|
27
|
+
-> json | metadata | raw output
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
`src/CjsHlslFormat.js` is the supported reader boundary. Binary utilities and
|
|
31
|
+
format-shaped compatibility models live below `src/core` and `src/carbon`.
|
|
32
|
+
Their same-named `Tr2*` classes are internal parser DTOs, not canonical runtime
|
|
33
|
+
model identity, and are not independent package entry points.
|
|
34
|
+
|
|
35
|
+
## Output modes
|
|
36
|
+
|
|
37
|
+
- `json` is the default interoperable data graph and may include opaque
|
|
38
|
+
bytecode and constant-value bytes.
|
|
39
|
+
- `metadata` is a compact, bytecode-free graph for inspection and pipeline
|
|
40
|
+
planning.
|
|
41
|
+
- `raw` exposes internal effect-model instances for advanced tooling and is
|
|
42
|
+
not a stable schema.
|
|
43
|
+
- `@carbonenginejs/runtime-resource/formats/hlsl/portable` copies one exact body into a versioned,
|
|
44
|
+
runtime-neutral source-reflection contract. Authored defaults and programs stay
|
|
45
|
+
separate from mutable renderer realization.
|
|
46
|
+
|
|
47
|
+
`runtime-resource` owns canonical `Tr2EffectRes`/`Tr2Shader` hydration,
|
|
48
|
+
permutation selection, and caching. `runtime-trinity` owns the mutable
|
|
49
|
+
effect/material facade, parameters, authored options, and sampler overrides.
|
|
50
|
+
Engines own GPU realization.
|
|
51
|
+
|
|
52
|
+
The graph shapes are documented in
|
|
53
|
+
[reference/json-graph.md](reference/json-graph.md).
|
|
54
|
+
|
|
55
|
+
## Platform boundary
|
|
56
|
+
|
|
57
|
+
`read`, `inspect`, and `toJSON` operate on caller-provided bytes and work
|
|
58
|
+
without filesystem access. `readFile` and the CLI are Node-specific adapters.
|
|
59
|
+
The package has no runtime dependencies.
|
|
60
|
+
|
|
61
|
+
## Error boundary
|
|
62
|
+
|
|
63
|
+
Structural failures include the source label and read context where available.
|
|
64
|
+
The reader rejects unsupported versions and unsafe reads instead of silently
|
|
65
|
+
guessing a layout. A selected compiled body can record its own decode failure
|
|
66
|
+
in raw or JSON-oriented inspection data where the format model supports that
|
|
67
|
+
state.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Hydrating JSON output
|
|
2
|
+
|
|
3
|
+
Status: Evolving
|
|
4
|
+
Scope: `@carbonenginejs/runtime-resource/formats/hlsl` JSON node hydration
|
|
5
|
+
Audience: Advanced users and integrators
|
|
6
|
+
Summary: Explains how callers can replace selected plain JSON nodes with their own constructors.
|
|
7
|
+
|
|
8
|
+
## Register constructors
|
|
9
|
+
|
|
10
|
+
The default `json` output uses plain objects. The `classes` option can
|
|
11
|
+
instantiate selected node kinds with caller-provided constructors:
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
import CjsHlslFormat from "@carbonenginejs/runtime-resource/formats/hlsl";
|
|
15
|
+
|
|
16
|
+
const effect = CjsHlslFormat.read(bytes, {
|
|
17
|
+
classes: {
|
|
18
|
+
Technique: MyTechnique,
|
|
19
|
+
StageInput: MyStageInput
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Supported keys are exposed as `CjsHlslFormat.CLASS_KEYS`:
|
|
25
|
+
|
|
26
|
+
```text
|
|
27
|
+
Root
|
|
28
|
+
Permutation
|
|
29
|
+
EffectDescription
|
|
30
|
+
Technique
|
|
31
|
+
Pass
|
|
32
|
+
StageInput
|
|
33
|
+
Constant
|
|
34
|
+
Resource
|
|
35
|
+
Sampler
|
|
36
|
+
ShaderBytecode
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Reuse a profile
|
|
40
|
+
|
|
41
|
+
```js
|
|
42
|
+
const reader = new CjsHlslFormat();
|
|
43
|
+
|
|
44
|
+
reader.SetClass("Technique", MyTechnique);
|
|
45
|
+
reader.SetClasses({ StageInput: MyStageInput });
|
|
46
|
+
|
|
47
|
+
reader.HasClass("Technique");
|
|
48
|
+
reader.GetClass("Technique");
|
|
49
|
+
|
|
50
|
+
const effect = reader.Read(bytes);
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Hydration changes object prototypes, not the documented field shape. Nested
|
|
54
|
+
records without a class key remain plain JSON-compatible data. Depending on
|
|
55
|
+
the caller's constructors as a serialization schema is discouraged; persist
|
|
56
|
+
the documented graph fields instead.
|
|
57
|
+
|
|
58
|
+
This feature is caller-selected JSON projection only. It does not consume the
|
|
59
|
+
versioned portable-reflection contract and does not construct canonical
|
|
60
|
+
runtime `Tr2EffectRes` or `Tr2Shader` instances. Canonical
|
|
61
|
+
`CJS_EFFECT_BODY_REFLECTION` hydration belongs to
|
|
62
|
+
`@carbonenginejs/runtime-resource`.
|