@gasm-compiler/core 0.3.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +17 -0
- package/README.md +69 -2
- package/dist/browser.d.ts +2 -2
- package/dist/browser.js +7 -7
- package/dist/chunk-NQJKL2KQ.js +9 -0
- package/dist/chunk-R6SXLNEJ.js +5 -0
- package/dist/compiler.js +1 -1
- package/dist/{error_codes-D6RsiZ33.d.ts → error_codes-Cdy_3FNo.d.ts} +27 -13
- package/dist/gasm_core_rs.wasm +0 -0
- package/dist/mod.d.ts +89 -3
- package/dist/mod.js +1 -1
- package/package.json +11 -12
- package/dist/chunk-PS4NV6ZB.js +0 -5
- package/dist/chunk-VSCQDCQR.js +0 -9
package/LICENSE
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Copyright (c) 2025-present Gasm Compiler Authors
|
|
2
|
+
|
|
3
|
+
All rights reserved.
|
|
4
|
+
|
|
5
|
+
This software and associated documentation files (the "Software") are the
|
|
6
|
+
proprietary property of the copyright holder(s). No permission is granted to
|
|
7
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
8
|
+
of the Software, except as expressly permitted in a separate written license
|
|
9
|
+
agreement with the copyright holder(s).
|
|
10
|
+
|
|
11
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
12
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
13
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
14
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
15
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
16
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
17
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
Transform WebAssembly binaries into WGSL (WebGPU Shading Language) compute shaders. Write your GPU kernels in any language that compiles to WebAssembly (C, C++, Rust, Go, AssemblyScript, or hand-written WAT), then run them on the GPU via WebGPU.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Gasm v0.2 is the default through the Rust/Wasm compiler backend. Archived
|
|
8
|
+
Gasm v0.1 behavior remains available through an explicit compatibility option.
|
|
8
9
|
|
|
9
10
|
---
|
|
10
11
|
|
|
@@ -49,6 +50,69 @@ const shaderModule = device.createShaderModule({ code: wgslCode });
|
|
|
49
50
|
|
|
50
51
|
## Usage
|
|
51
52
|
|
|
53
|
+
### Specification Versions
|
|
54
|
+
|
|
55
|
+
Gasm v0.2 is the default:
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
const wgsl = compile(wasmBytes);
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
The default enables strict v0.2 validation and lowering. Existing consumers can
|
|
62
|
+
keep the archived v0.1 compiler behavior explicitly:
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
const wgsl = compile(wasmBytes, { specVersion: "0.1" });
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Compile a v0.2 artifact and metadata sidecar through the Rust/Wasm compiler:
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
import {
|
|
72
|
+
compileToArtifact,
|
|
73
|
+
validateGasmMetadataSchema,
|
|
74
|
+
} from "@gasm-compiler/core";
|
|
75
|
+
|
|
76
|
+
const result = compileToArtifact(wasmBytes);
|
|
77
|
+
if (!result.ok) {
|
|
78
|
+
throw new Error(
|
|
79
|
+
`${result.diagnostics.errors[0]?.code}: ` +
|
|
80
|
+
`${result.diagnostics.errors[0]?.message}`,
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const schema = validateGasmMetadataSchema(result.metadata);
|
|
85
|
+
if (!schema.valid) throw new Error(schema.errors.join(", "));
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Gasm v0.2 semantics are implemented only in `packages/core-rs` and distributed
|
|
89
|
+
through its Wasm artifact. The TypeScript compiler implementation is retained
|
|
90
|
+
at v0.1 for compatibility. Deno remains the runtime for the CLI and the live
|
|
91
|
+
core/CLI test suites, including headless WebGPU execution.
|
|
92
|
+
|
|
93
|
+
The CLI also defaults to v0.2:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
gasm-compiler compile input.wasm \
|
|
97
|
+
--output output.wgsl \
|
|
98
|
+
--metadata output.gasm.json
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Use `--spec-version 0.1` when compiling archived v0.1 inputs.
|
|
102
|
+
|
|
103
|
+
#### Migrating from 0.3.x
|
|
104
|
+
|
|
105
|
+
- Compilation now defaults to strict Gasm v0.2 validation.
|
|
106
|
+
- Pass `{ specVersion: "0.1" }` to retain archived v0.1 behavior.
|
|
107
|
+
- Gasm v0.2 extensions must be declared in the module's
|
|
108
|
+
`gasm.extensions` custom section.
|
|
109
|
+
- Math extension scalar imports use explicit type suffixes such as
|
|
110
|
+
`sin_f32`. Legacy unsuffixed imports remain accepted for compatibility.
|
|
111
|
+
|
|
112
|
+
Required extensions are declared by the module's `gasm.extensions` custom
|
|
113
|
+
section. The CLI does not inject extensions, so validation reflects the exact
|
|
114
|
+
module that will be distributed.
|
|
115
|
+
|
|
52
116
|
### Basic Compilation
|
|
53
117
|
|
|
54
118
|
```typescript
|
|
@@ -82,7 +146,10 @@ const wgslCode = compile(wasmBytes, {
|
|
|
82
146
|
});
|
|
83
147
|
```
|
|
84
148
|
|
|
85
|
-
When enabled, WebAssembly imports like
|
|
149
|
+
When enabled, WebAssembly imports like
|
|
150
|
+
`(import "gasm" "sin_f32" (func ...))` compile to direct WGSL built-in calls
|
|
151
|
+
(`sin(...)`) with zero overhead. Unsuffixed scalar names such as `sin` remain
|
|
152
|
+
accepted as legacy aliases.
|
|
86
153
|
|
|
87
154
|
**Math Levels:**
|
|
88
155
|
- **M0 (Core):** sin, cos, sqrt, abs, min, max, clamp, floor, ceil, etc.
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { b as CompileError,
|
|
1
|
+
import { a as CompileDiagnostics, D as DispatchInfo$1, C as CompileOptions } from './error_codes-Cdy_3FNo.js';
|
|
2
|
+
export { b as CompileError, c as DEFAULT_SPEC_VERSION, j as ErrorCode, E as ErrorCodes, d as SPEC_VERSION_V01, e as SPEC_VERSION_V02, S as SpecVersion, f as isCompileError, h as isParseError, i as isV02Mode, g as parseWasmModule, r as resolveSpecVersion } from './error_codes-Cdy_3FNo.js';
|
|
3
3
|
export { BrowserGPUExecutor } from './browser-executor.js';
|
|
4
4
|
export { BufferData, ExecuteOptions, ExecutionError, ExecutorConfig, IGPUExecutor, OutputBufferSpec, isExecutionError } from './executor.js';
|
|
5
5
|
|