Add wgpu-mojo - #341
Open
Hundo1018 wants to merge 1 commit into
Open
Conversation
Pure Mojo bindings for wgpu-native (WebGPU): RAII GPU objects, strongly-typed handle newtypes, and a high-level GPU facade. Builds for linux-64 and osx-arm64. wgpu-native and glfw are declared host/run dependencies from conda-forge, so the build script downloads nothing; it compiles the two C callback bridges from source and links against the host environment. wgpu-native is pinned exactly because upstream renumbered the whole 0x0003xxxx SType enum in a patch release, and the build script additionally compares the installed wgpu.h byte-for-byte against the copy vendored in the source repository.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
wgpu-mojo— pure Mojo bindings for wgpu-native (WebGPU).Compute and graphics on every backend Vulkan / Metal / DX12 supports, from a single
Mojo program: RAII wrappers that release their native handle on scope exit,
strongly-typed handle newtypes instead of raw pointers, a high-level
GPUfacadethat does compile + dispatch + read-back in a few lines, and a GLFW-backed
RenderCanvasfor windowed rendering.Checklist
recipe.yamlfile specifies which version(s) of MAX is compatible with my project. — This package does not depend onmaxat all. It pinsmojo-compiler =1.0.0in build/host and usespin_compatible('mojo-compiler')at run time, per the packaging guide. The MAX interop bridge lives in a separate top-level package that is deliberately excluded from the build, precisely somaxstays off every consumer's dependency path.license_file: LICENSE; verified present asinfo/licenses/LICENSEin the built artifact.0. — New package.Notes for reviewers
Platforms. The recipe skips everything except
linux-64andosx-arm64,including the
linux-aarch64this repo's CI builds. Nothing in the binding isarchitecture-specific and conda-forge ships
wgpu-nativefor aarch64, but no onehas run wgpu-mojo there, so I would rather not publish a package nobody has
exercised. I checked that the skip expression resolves correctly on all five
targets, so the aarch64 leg exits cleanly rather than failing your build.
Native dependency.
wgpu-nativeandglfware declared host/rundependencies resolved from conda-forge — the build script downloads nothing. It
compiles the two C callback bridges from source in the repo (wgpu-native's async
API needs real C function pointers, which Mojo cannot yet produce) and links
against the host environment.
ABI pin.
wgpu-nativeis pinned exactly, not as a range. Upstream renumberedthe whole
0x0003xxxxSType enum in the v29.0.0.0 → v29.0.1.1 patch release; amismatched library still loads and still runs, it just misreads every extras
chain. Beyond the version constraint,
conda.recipe/build.shcompares theinstalled
$PREFIX/include/wgpu.hbyte-for-byte against the copy vendored in thesource repo and fails the build on any difference.
CodeQL is enabled on the source repository (it contains C and Python
alongside Mojo) and the badge is in the README.
Test.
test_package.mojoruns in a bare environment and asserts three things:that
lib/mojo/wgpu.mojocis discoverable without an-Iflag, that both nativelibraries load, and that the installed wgpu-native exports the drift-prone entry
points this binding targets. It requests no adapter, so it passes on a build
machine with no GPU and no display server.
Verification performed
Built from this exact recipe and revision, then installed from a local channel
into a throwaway pixi project with no source checkout on the path, no
-Iflagand no inherited
LD_LIBRARY_PATH:The same was repeated against the published
.condadownloaded back from theGitHub Release, and the package test passes standalone via
rattler-build test --package-file. Both checks run in the source repo's CI onubuntu-latestandmacos-14.