Repository navigation
refactor(webgpu): build the software backend through the public wgpu API - #157
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
.pm/ holds the private project state (STATUS, HANDOFF, kanban) under the workspace layout standard. It must never be published, like .claude/ and docs/dev/.
newSoftwareBackend built its device from wgpu/hal/software via hal.InstanceDescriptor and wgpu.NewDeviceFromHAL. gogpu/wgpu is moving core/ and hal/ under internal/, and against current wgpu the hand-built device no longer passed the compute availability probe, so every GPU test skipped silently under GOGPU_GRAPHICS_API=software. The software adapter now comes from CreateInstance(nil) plus RequestAdapterOptions.ForceFallbackAdapter, as in Rust wgpu, and its AdapterInfo from the adapter itself. Only the blank hal/allbackends import remains; a test fails on any other wgpu/hal or wgpu/core import (ADR-005). The deprecated wgpu.Backends* aliases become gputypes.Backends*. With the software tests running again, TestLazyModeAdd's 100ms bound no longer holds there: the SPIR-V interpreter executes the dispatch inside Add (7.96s Add, 10ms Realize). The bound is skipped on CPU adapters.
kolkov
force-pushed
the
refactor/webgpu-public-software-backend
branch
from
November 6, 2026 07:50
db9e15c to
89d298b
Compare
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.
Summary
The WebGPU software backend (
GOGPU_GRAPHICS_API=software, the automatic fallback when no GPU is usable, and the path the GPU tests take in CI) built its device by hand fromgithub.com/gogpu/wgpu/hal/softwarethroughhal.InstanceDescriptorandwgpu.NewDeviceFromHAL. Two problems came out of that:hal/andcore/are wgpu's implementation, and they are moving underinternal/, so this code would stop compiling on a future wgpu update.GOGPU_GRAPHICS_API=software, every GPU test skipped without a sound.The software adapter now comes through the public API, the way Rust wgpu does it:
Changes
internal/backend/webgpu/backend.go:newSoftwareBackendnow usesCreateInstance,ForceFallbackAdapterandRequestDevice. Thewgpu/halandwgpu/hal/softwareimports are gone. Only the blankhal/allbackendsimport that registers the backends is left. The adapter info comes from the adapter instead of a hard-coded struct.wgpu.Backends*aliases are replaced withgputypes.Backends*.software_backend_test.gochecks two things:GOGPU_GRAPHICS_API=softwareyields a CPU adapter;wgpu/hal/...orwgpu/core/.... This check fails on the old code.TestLazyModeAdd's 100 ms bound no longer holds there: the SPIR-V interpreter runs the dispatch insideAdd. The bound is skipped on CPU adapters..gitignore: ignore a local project-management directory.Test plan
go build ./...,go vetGOGPU_GRAPHICS_API=software go test ./internal/backend/webgpu/ -count=1vulkananddx12on a real GPUgolangci-lint run