![]() |
VOOZH | about |
dotnet add package WACS.WASI.GFX.Silk --version 0.2.1-preview
NuGet\Install-Package WACS.WASI.GFX.Silk -Version 0.2.1-preview
<PackageReference Include="WACS.WASI.GFX.Silk" Version="0.2.1-preview" />
<PackageVersion Include="WACS.WASI.GFX.Silk" Version="0.2.1-preview" />Directory.Packages.props
<PackageReference Include="WACS.WASI.GFX.Silk" />Project file
paket add WACS.WASI.GFX.Silk --version 0.2.1-preview
#r "nuget: WACS.WASI.GFX.Silk, 0.2.1-preview"
#:package WACS.WASI.GFX.Silk@0.2.1-preview
#addin nuget:?package=WACS.WASI.GFX.Silk&version=0.2.1-preview&prereleaseInstall as a Cake Addin
#tool nuget:?package=WACS.WASI.GFX.Silk&version=0.2.1-preview&prereleaseInstall as a Cake Tool
Silk.NET/SDL + wgpu-native backend for
WACS.WASI.GFX.
A single backend drives all four wasi-gfx WIT packages
(wasi:graphics-context, wasi:surface, wasi:frame-buffer,
wasi:webgpu) against one SDL window, mixing
Silk.NET (SDL2 +
WebGPU.NET) and wgpu-native.
Feature-complete across CPU and GPU paths. Verified through
both the interpreter component path and the transpiler
direct-link path against the parity fixtures shipped in
Spec.Test/components/fixtures/ (CPU wasi-gfx-rectangle /
-triangle; GPU wasi-webgpu-hello-compute /
-hello-render / -game-of-life; full swap-chain
wasi-webgpu-game-of-life-windowed).
wasi:io/poll.pollables on the surface
via ManualResetPollable.Signal().frame-buffer.buffer.set(RGBA8 bytes) → SDL_UpdateTexture
→ SDL_RenderCopy → SDL_RenderPresent.SilkContext.GetCurrentBuffer() returns a per-frame
SilkAbstractBuffer (a pooled byte[] sized to
width × height × 4) that the guest fills and Present()
blits.SilkGpuBackend wraps wgpu-native through Silk.NET.WebGPU.
All of the headless surface (adapter / device / buffer /
pipeline / queue / compute pass / render pass /
copy-texture-to-buffer / map-async readback) is covered.SilkGpuDevice.ConnectGraphicsContext(ctx) is the
swap-chain bridge: it reaches into the wasi-gfx-side
SilkSurface, drops the SDL renderer's hold on the window
(so the wgpu Metal layer can claim the CAMetalLayer),
dispatches SDL_Metal_CreateView + MetalGetLayer through
MainThreadDispatcher (AppKit requires NSView creation on
the main thread), and configures the wgpu surface against
the device.context.get-current-buffer() returns the swap-chain
texture; texture.from-graphics-buffer(buf) resolves it
back to a wgpu GPUTexture for the render pass; present()
calls wgpuSurfacePresent.# Interpreter component path:
wacs run --wasi-gfx --windowed --call start my.component.wasm
# Transpiler direct-link path (canonical wasip2 workflow):
wacs run --wasip2 --wasi-gfx --windowed --call start my.component.wasm
--wasi-gfx loads Wacs.WASI.GFX.Silk and registers it for
both the CPU host and the GPU host. --windowed reserves the
calling (main) thread for the SDL event loop and runs the guest
on a worker. --call start selects the wasi-gfx fixtures'
exported start: func() entrypoint (the cargo-component
convention, distinct from the WASI-cli _start the CLI
defaults to).
Or programmatically:
using var host = runtime.UseWasiGfx(b =>
b.WithBackend(new SilkGfxBackend()));
host.Backend!.RunMainLoop(ct); // call from main thread
See for programmatic-embedding details (interpreter + transpiler paths), the for the webgpu contract assembly, and for multi-host chaining.
Driving an OS window means owning the main thread on macOS
(AppKit hard requirement). Contract: embedder runs wasm on a
worker thread and calls host.Backend.RunMainLoop(ct) on the
main thread to pump the SDL event loop until ct fires.
wacs run --windowed does this automatically.
wgpu-native adapter / device / queue / pipeline / queue.submit
/ surface.configure / get-current-texture / present are
internally thread-safe and run from the worker. The exceptions
that route through MainThreadDispatcher are SDL window
creation (SilkSurface's ctor) and SDL_Metal_CreateView
(SilkGpuDevice.ConnectGraphicsContext).
| Platform | CPU path | GPU headless | GPU swap-chain |
|---|---|---|---|
| macOS arm64 (Metal) | ✅ | ✅ | ✅ |
| Windows / Linux | ✅ | ✅ | ❌ throws PlatformNotSupportedException |
Headless GPU works everywhere wgpu-native works; only the
SDL→wgpu swap-chain bridge is gated to macOS today. Wiring
SurfaceDescriptorFromWindowsHwnd /
SurfaceDescriptorFromXlibWindow /
SurfaceDescriptorFromWaylandSurface mirrors the macOS path;
the wgpu-native and Silk APIs are present, just not yet wired.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.2.1-preview | 63 | 5/28/2026 |
| 0.2.0-preview | 52 | 5/16/2026 |