Ahjo.Wgpu
0.6.0
dotnet add package Ahjo.Wgpu --version 0.6.0
NuGet\Install-Package Ahjo.Wgpu -Version 0.6.0
<PackageReference Include="Ahjo.Wgpu" Version="0.6.0" />
<PackageVersion Include="Ahjo.Wgpu" Version="0.6.0" />
<PackageReference Include="Ahjo.Wgpu" />
paket add Ahjo.Wgpu --version 0.6.0
#r "nuget: Ahjo.Wgpu, 0.6.0"
#:package Ahjo.Wgpu@0.6.0
#addin nuget:?package=Ahjo.Wgpu&version=0.6.0
#tool nuget:?package=Ahjo.Wgpu&version=0.6.0
Ahjo.Wgpu
Idiomatic C# wrapper over wgpu-native,
the Rust implementation of WebGPU. Built for games: ref struct encoders,
readonly struct resource handles, polled futures instead of Task<T>,
zero heap allocations on per-frame paths.
Status: pre-1.0. The public surface may shift between 0.x releases as the wrapper fills in remaining wgpu-native coverage. Tag your
PackageReferenceto an exact version.
Install
dotnet add package Ahjo.Wgpu
The native binaries (wgpu_native.dll / libwgpu_native.so /
libwgpu_native.dylib) ship inside the Ahjo.Wgpu.Native dependency and
land in your bin/ automatically — no native-resolver setup required.
Hello triangle
using WgpuSharp;
using WgpuSharp.Native;
using var instance = Instance.Create();
using var adapter = instance.RequestAdapterBlocking();
using var device = adapter.RequestDeviceBlocking();
var queue = device.Queue;
using var encoder = device.CreateCommandEncoder();
// ... create pipeline, begin render pass, draw, submit.
using var cmd = encoder.Finish();
queue.Submit(cmd);
End-to-end examples live in the repo
(samples/HelloTriangle,
samples/HeadlessTriangle).
Platforms
Runs everywhere wgpu-native does: Windows, Linux, macOS on x64 and arm64.
TFM: net10.0.
Design principles
Games-first. Low allocation, raw-pointer friendly, minimal ceremony.
This is an opinionated wrapper over wgpu-native — not a SafeHandle-shaped .NET port. Three load-bearing idioms worth reading about before you build on it:
- Struct handles.
Buffer,Texture,Pipeline, etc. arereadonly structs holding one raw pointer. Copy-by-value, no finalizer,default(T)is a legal null handle, double-dispose is UB. - Polled futures. Per-frame async (
Buffer.BeginMap, work-done) returns a struct you drive viaInstance.ProcessEvents()— noTask<T>, no allocations. ref structencoders + span-parameter descriptors.CommandEncoder,RenderPassEncoder,ComputePassEncoderdon't escape methods; spans live on method parameters, not descriptor fields, to keep escape-analysis happy.
Full user guide: docs/using-the-wrapper.md. Contributor-side design rationale: CLAUDE.md.
Repository
Source, issues, samples: https://github.com/pekkah/wgpu-sharp
License
MIT. © Pekka Heikura.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Ahjo.Wgpu.Native (>= 0.6.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.