@aelionsdk/material-compiler 0.1.0-beta.1 → 1.1.0-rc.1
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/README.md +25 -4
- package/dist/codegen-common.d.ts +6 -0
- package/dist/codegen-common.d.ts.map +1 -0
- package/dist/codegen-common.js +18 -0
- package/dist/webgl2.d.ts.map +1 -1
- package/dist/webgl2.js +2 -19
- package/dist/webgpu.d.ts.map +1 -1
- package/dist/webgpu.js +2 -19
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,7 +1,28 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@aelionsdk/material-compiler`
|
|
2
2
|
|
|
3
|
-
Aelion Material Protocol graph compiler for WebGL2 and WebGPU
|
|
3
|
+
Typed Aelion Material Protocol graph compiler for WebGL2 and WebGPU.
|
|
4
4
|
|
|
5
|
-
Install
|
|
5
|
+
## Install
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
```bash
|
|
8
|
+
npm install @aelionsdk/material-compiler@next
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
`next` currently resolves to `1.1.0-rc.1`. Material authors should normally use
|
|
12
|
+
`@aelionsdk/material-sdk`; import this package directly to build a custom
|
|
13
|
+
compiler, renderer or validation host.
|
|
14
|
+
|
|
15
|
+
## Public surface
|
|
16
|
+
|
|
17
|
+
- Core Node registry and typed graph validation;
|
|
18
|
+
- graph compilation and resource-budget diagnostics;
|
|
19
|
+
- WebGL2 and WebGPU program generation;
|
|
20
|
+
- compiler input, output and backend types.
|
|
21
|
+
|
|
22
|
+
Treat generated Shader/WASM code as untrusted unless the host explicitly
|
|
23
|
+
authorizes its publisher and execution mode. Compilation success does not
|
|
24
|
+
bypass runtime resource budgets.
|
|
25
|
+
|
|
26
|
+
See the [Material guide](https://foyonaczy.github.io/AelionSDK/guides/materials/)
|
|
27
|
+
and [API reference](https://foyonaczy.github.io/AelionSDK/api/aelionsdk/material-compiler/overview/).
|
|
28
|
+
Licensed under MIT.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { JsonValue } from '@aelionsdk/core';
|
|
2
|
+
import type { MaterialGraph } from './types.js';
|
|
3
|
+
export declare function identifier(value: string): string;
|
|
4
|
+
export declare function literal(value: JsonValue, backend: string): string;
|
|
5
|
+
export declare function graphHash(graph: MaterialGraph): string;
|
|
6
|
+
//# sourceMappingURL=codegen-common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codegen-common.d.ts","sourceRoot":"","sources":["../src/codegen-common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAKjE;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,CAQtD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export function identifier(value) {
|
|
2
|
+
return value.replaceAll(/[^a-zA-Z0-9_]/gu, '_');
|
|
3
|
+
}
|
|
4
|
+
export function literal(value, backend) {
|
|
5
|
+
if (typeof value !== 'number' || !Number.isFinite(value)) {
|
|
6
|
+
throw new TypeError(`${backend} material expressions only support finite numeric literals`);
|
|
7
|
+
}
|
|
8
|
+
return Number.isInteger(value) ? `${value.toString()}.0` : value.toString();
|
|
9
|
+
}
|
|
10
|
+
export function graphHash(graph) {
|
|
11
|
+
const serialized = JSON.stringify(graph);
|
|
12
|
+
let hash = 2_166_136_261;
|
|
13
|
+
for (let index = 0; index < serialized.length; index += 1) {
|
|
14
|
+
hash ^= serialized.charCodeAt(index);
|
|
15
|
+
hash = Math.imul(hash, 16_777_619);
|
|
16
|
+
}
|
|
17
|
+
return (hash >>> 0).toString(16).padStart(8, '0');
|
|
18
|
+
}
|
package/dist/webgl2.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl2.d.ts","sourceRoot":"","sources":["../src/webgl2.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webgl2.d.ts","sourceRoot":"","sources":["../src/webgl2.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,sBAAsB,EAEtB,aAAa,EAEb,qBAAqB,EAEtB,MAAM,YAAY,CAAC;AAoRpB,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,aAAa,EACpB,OAAO,EAAE,sBAAsB,GAC9B,qBAAqB,CA+FvB"}
|
package/dist/webgl2.js
CHANGED
|
@@ -1,23 +1,6 @@
|
|
|
1
1
|
import { buildMaterialExecutionPlan, compileMaterialGraph } from './compiler.js';
|
|
2
|
+
import { graphHash, identifier, literal } from './codegen-common.js';
|
|
2
3
|
import { compileMaterialGraphToWebGpu } from './webgpu.js';
|
|
3
|
-
function identifier(value) {
|
|
4
|
-
return value.replaceAll(/[^a-zA-Z0-9_]/gu, '_');
|
|
5
|
-
}
|
|
6
|
-
function literal(value) {
|
|
7
|
-
if (typeof value !== 'number' || !Number.isFinite(value)) {
|
|
8
|
-
throw new TypeError('WebGL2 material expressions only support finite numeric literals');
|
|
9
|
-
}
|
|
10
|
-
return Number.isInteger(value) ? `${value.toString()}.0` : value.toString();
|
|
11
|
-
}
|
|
12
|
-
function graphHash(graph) {
|
|
13
|
-
const serialized = JSON.stringify(graph);
|
|
14
|
-
let hash = 2_166_136_261;
|
|
15
|
-
for (let index = 0; index < serialized.length; index += 1) {
|
|
16
|
-
hash ^= serialized.charCodeAt(index);
|
|
17
|
-
hash = Math.imul(hash, 16_777_619);
|
|
18
|
-
}
|
|
19
|
-
return (hash >>> 0).toString(16).padStart(8, '0');
|
|
20
|
-
}
|
|
21
4
|
function uniformFor(binding, uniforms) {
|
|
22
5
|
if ('parameter' in binding) {
|
|
23
6
|
const name = `u_parameter_${identifier(binding.parameter)}`;
|
|
@@ -37,7 +20,7 @@ function uniformFor(binding, uniforms) {
|
|
|
37
20
|
}
|
|
38
21
|
function bindingExpression(binding, nodeExpressions, inputPorts, uniforms) {
|
|
39
22
|
if ('value' in binding)
|
|
40
|
-
return literal(binding.value);
|
|
23
|
+
return literal(binding.value, 'WebGL2');
|
|
41
24
|
const uniform = uniformFor(binding, uniforms);
|
|
42
25
|
if (uniform !== undefined)
|
|
43
26
|
return uniform;
|
package/dist/webgpu.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu.d.ts","sourceRoot":"","sources":["../src/webgpu.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webgpu.d.ts","sourceRoot":"","sources":["../src/webgpu.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,sBAAsB,EAEtB,aAAa,EAEb,qBAAqB,EACtB,MAAM,YAAY,CAAC;AA6HpB,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,aAAa,EACpB,OAAO,EAAE,sBAAsB,GAC9B,qBAAqB,CA0EvB"}
|
package/dist/webgpu.js
CHANGED
|
@@ -1,22 +1,5 @@
|
|
|
1
1
|
import { buildMaterialExecutionPlan, compileMaterialGraph } from './compiler.js';
|
|
2
|
-
|
|
3
|
-
return value.replaceAll(/[^a-zA-Z0-9_]/gu, '_');
|
|
4
|
-
}
|
|
5
|
-
function literal(value) {
|
|
6
|
-
if (typeof value !== 'number' || !Number.isFinite(value)) {
|
|
7
|
-
throw new TypeError('WebGPU material expressions only support finite numeric literals');
|
|
8
|
-
}
|
|
9
|
-
return Number.isInteger(value) ? `${value.toString()}.0` : value.toString();
|
|
10
|
-
}
|
|
11
|
-
function graphHash(graph) {
|
|
12
|
-
const serialized = JSON.stringify(graph);
|
|
13
|
-
let hash = 2_166_136_261;
|
|
14
|
-
for (let index = 0; index < serialized.length; index += 1) {
|
|
15
|
-
hash ^= serialized.charCodeAt(index);
|
|
16
|
-
hash = Math.imul(hash, 16_777_619);
|
|
17
|
-
}
|
|
18
|
-
return (hash >>> 0).toString(16).padStart(8, '0');
|
|
19
|
-
}
|
|
2
|
+
import { graphHash, identifier, literal } from './codegen-common.js';
|
|
20
3
|
function uniformExpression(binding, uniforms) {
|
|
21
4
|
let source;
|
|
22
5
|
if ('parameter' in binding)
|
|
@@ -34,7 +17,7 @@ function uniformExpression(binding, uniforms) {
|
|
|
34
17
|
}
|
|
35
18
|
function bindingExpression(binding, nodeExpressions, inputPorts, uniforms) {
|
|
36
19
|
if ('value' in binding)
|
|
37
|
-
return literal(binding.value);
|
|
20
|
+
return literal(binding.value, 'WebGPU');
|
|
38
21
|
const uniform = uniformExpression(binding, uniforms);
|
|
39
22
|
if (uniform !== undefined)
|
|
40
23
|
return uniform;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aelionsdk/material-compiler",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0-rc.1",
|
|
4
4
|
"description": "Aelion Material Protocol graph compiler for WebGL2 and WebGPU",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -27,14 +27,14 @@
|
|
|
27
27
|
"!dist/.tsbuildinfo"
|
|
28
28
|
],
|
|
29
29
|
"engines": {
|
|
30
|
-
"node": ">=
|
|
30
|
+
"node": ">=24 <25"
|
|
31
31
|
},
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public",
|
|
34
34
|
"provenance": true
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@aelionsdk/core": "
|
|
37
|
+
"@aelionsdk/core": "1.1.0-rc.1"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"build": "tsc -b",
|