nish 0.47.0 → 0.48.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nish",
3
- "version": "0.47.0",
3
+ "version": "0.48.0",
4
4
  "description": "Nish: an ahead-of-time compiler from a static subset of TypeScript to LLVM IR",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -114,9 +114,9 @@
114
114
  "typescript": "^5.6.0"
115
115
  },
116
116
  "optionalDependencies": {
117
- "@amritk/nish-aarch64-darwin": "0.47.0",
118
- "@amritk/nish-aarch64-linux": "0.47.0",
119
- "@amritk/nish-x86_64-darwin": "0.47.0",
120
- "@amritk/nish-x86_64-linux": "0.47.0"
117
+ "@amritk/nish-aarch64-darwin": "0.48.0",
118
+ "@amritk/nish-aarch64-linux": "0.48.0",
119
+ "@amritk/nish-x86_64-darwin": "0.48.0",
120
+ "@amritk/nish-x86_64-linux": "0.48.0"
121
121
  }
122
122
  }
@@ -0,0 +1,55 @@
1
+ # runtime/gfx/
2
+
3
+ The C shim a Nish program draws through: `nish-gfx.h` and `nish-gfx.c`, a thin
4
+ synchronous layer over [wgpu-native](https://github.com/gfx-rs/wgpu-native)
5
+ (WebGPU) and [SDL3](https://libsdl.org/) (windows and input). Neither library
6
+ is vendored: `scripts/fetch-gfx.sh` downloads and pins them into
7
+ `build/gfx/<platform>/`, or `NISH_GFX_PREFIX` names an install made another
8
+ way.
9
+
10
+ | | wgpu-native | SDL |
11
+ | --- | --- | --- |
12
+ | Version | v29.0.1.1 | 3.4.20 |
13
+ | From | `wgpu-<platform>-release.zip` from <https://github.com/gfx-rs/wgpu-native/releases/tag/v29.0.1.1> | `SDL3-3.4.20.tar.gz` from <https://github.com/libsdl-org/SDL/releases/tag/release-3.4.20>, built by `fetch-gfx.sh` as a static library |
14
+ | SHA-256 | one per platform, in `scripts/fetch-gfx.sh` | `f3bb06f55bed9557227a700af2ea62e49497ebdf58037732a731a5fb3ef8581f` |
15
+ | Licence | MIT or Apache-2.0, at the user's choice; its `webgpu.h` is BSD-3-Clause (Copyright 2019-2023 WebGPU-Native developers) | zlib (Copyright (C) 1997-2026 Sam Lantinga) |
16
+
17
+ A binary that links the shim carries both libraries, statically, so whoever
18
+ ships it ships their notices too: SDL's zlib licence asks that its notice not
19
+ be removed from source distributions, and wgpu-native's MIT and Apache-2.0
20
+ terms ask that the notice travel with copies. Neither library's code is in
21
+ this repository, so neither is listed in `THIRD_PARTY_NOTICES.md`.
22
+
23
+ ## The shim's rules
24
+
25
+ - `nish-gfx.h` is what `nish c-import` reads, with
26
+ `nish-gfx.overrides.json` naming its buffers and nullable parameters. Every
27
+ parameter is a scalar, an opaque handle or a struct by pointer: no unions,
28
+ structs by value, callbacks or variadics. It does not include `webgpu.h`.
29
+ - Every WebGPU request that answers through a callback is made synchronous
30
+ with a bounded `wgpuInstanceProcessEvents` loop, never `wgpuInstanceWaitAny`
31
+ or a timed wait.
32
+ - Errors are queued, never called back into Nish: each device and instance
33
+ keeps a ring of 16 reports of at most 255 bytes, and counts the ones that
34
+ found it full.
35
+ - Offscreen targets read back through rows padded to 256 bytes and copy only
36
+ the unpadded rows into a buffer whose length is checked first.
37
+
38
+ The security record is [`docs/security/gfx.md`](../../docs/security/gfx.md).
39
+
40
+ ## How it is linked
41
+
42
+ `scripts/build.sh` compiles every `*.c` here for a link whose IR declares a
43
+ `nishgfx_*` function, and for no other link, and adds `-lSDL3 -lwgpu_native`
44
+ with the platform's system libraries. A link that needs the libraries and
45
+ finds none fails with a message naming `scripts/fetch-gfx.sh`. `wasm`,
46
+ `wasm-host` and `wasi` builds refuse the shim. `tests/gfx.js` ("gfx") draws
47
+ `tests/gfx/triangle.c` offscreen and checks its pixels.
48
+
49
+ ## Updating
50
+
51
+ 1. Change the versions and SHA-256 pins in `scripts/fetch-gfx.sh` and the
52
+ table above, then run `scripts/fetch-gfx.sh --force`.
53
+ 2. Rebuild against the new `webgpu.h`; its structs are filled through its
54
+ `WGPU_*_INIT` macros, so a field added upstream needs no change here.
55
+ 3. Run `node tests/run.js gfx`.