Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
8af03e3
wgpu/lib: Update headers to v24.0.0
obiwac May 2, 2025
bc605b5
wgpu/adapter: Update
obiwac May 2, 2025
a2e33fb
wgpu/buffer: Update
obiwac May 2, 2025
29bd2e7
wgpu/command_encoder: Update
obiwac May 2, 2025
f7d6783
wgpu/compute_pass_encoder: Update
obiwac May 2, 2025
0f2a518
wgpu/device: Update non shader-related stuff
obiwac May 2, 2025
a6b0ede
wgpu/device: Update shader-related stuff
obiwac May 2, 2025
9a258f9
wgpu/instance: Update
obiwac May 2, 2025
efd9502
wgpu/queue: Update
obiwac May 2, 2025
658d6f9
wgpu/render_pass_encoder: Update
obiwac May 2, 2025
0ac4a40
wgpu/surface: Update
obiwac May 2, 2025
ab6914d
wgpu/texture: Update
obiwac May 2, 2025
ad70c32
wgpu/wgpu_c_cb: Update
obiwac May 2, 2025
47a4d6e
wgpu: Update/fix last remaining stuff
obiwac May 2, 2025
9da7f2f
wgpu/instance: Fix request adapter callback
obiwac May 2, 2025
587e191
wgpuglfw: Fix on Darwin
obiwac May 2, 2025
0e95408
enums: Update all of them
obiwac May 2, 2025
8ef02e1
wgpu/adapter: Fix request device callback
obiwac May 2, 2025
4f29428
examples: Update
obiwac May 2, 2025
277d099
readme upstream
rcoreilly Aug 9, 2025
3380983
Merge pull request #4 from obiwac/feature/v24
rcoreilly Aug 9, 2025
69ae3f6
goal scripts for getting files from wgpu-native release -- all workin…
rcoreilly Aug 9, 2025
2456afc
v25: fix go pinned pointer issue for adapter with limits
rcoreilly Aug 10, 2025
de41c69
v25: Read value is not working because Device.Poll is not waiting; fi…
rcoreilly Aug 10, 2025
cbcf51f
v25: fix gowebgpu_buffer_map_callback_c to have the proper args; comp…
rcoreilly Aug 13, 2025
5ce7086
v25: compute example poll nil
rcoreilly Aug 13, 2025
ea6a46f
v25: rest of the include flags for other platforms
rcoreilly Aug 13, 2025
790b125
v25: rest of the surface source fixes
rcoreilly Aug 13, 2025
39ca346
v25: handle nil callback
rcoreilly Aug 13, 2025
cbaddee
v25: fixed error handling callback: stringview is not a pointer!
rcoreilly Aug 14, 2025
ebf8585
v25: update readme with install info
rcoreilly Aug 14, 2025
8469123
v25: fix Poll arg passthrough
rcoreilly Aug 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# WebGPU

Current upstream version: v25.0.2.1
* Use [getrelease.goal](getrelease.goal) for current mechanism to get the released `wgpu-native` libraries downloaded and installed. The libraries will be committed to this repo when v26 comes out, but for now, this is required.

Go bindings for WebGPU, a cross-platform, safe graphics API. It runs natively using [wgpu-native](https://github.com/gfx-rs/wgpu-native) on Vulkan, Metal, D3D12, and OpenGL ES based on https://github.com/rajveermalviya/go-webgpu. It also comes with web (JS) support based on https://github.com/mokiat/wasmgpu.

For more information, see:
Expand Down
4 changes: 2 additions & 2 deletions examples/boids/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func InitState(window *glfw.Window) (s *State, err error) {

computeShader, err := s.device.CreateShaderModule(&wgpu.ShaderModuleDescriptor{
Label: "compute.wgsl",
WGSLDescriptor: &wgpu.ShaderModuleWGSLDescriptor{
WGSLSource: &wgpu.ShaderSourceWGSL{
Code: compute,
},
})
Expand All @@ -121,7 +121,7 @@ func InitState(window *glfw.Window) (s *State, err error) {

drawShader, err := s.device.CreateShaderModule(&wgpu.ShaderModuleDescriptor{
Label: "draw.wgsl",
WGSLDescriptor: &wgpu.ShaderModuleWGSLDescriptor{
WGSLSource: &wgpu.ShaderSourceWGSL{
Code: draw,
},
})
Expand Down
8 changes: 4 additions & 4 deletions examples/capture/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ func main() {
// Copy the data from the texture to the buffer
encoder.CopyTextureToBuffer(
texture.AsImageCopy(),
&wgpu.ImageCopyBuffer{
&wgpu.TexelCopyBufferInfo{
Buffer: outputBuffer,
Layout: wgpu.TextureDataLayout{
Layout: wgpu.TexelCopyBufferLayout{
Offset: 0,
BytesPerRow: uint32(bufferDimensions.paddedBytesPerRow),
RowsPerImage: wgpu.CopyStrideUndefined,
Expand All @@ -151,8 +151,8 @@ func main() {

queue.Submit(cmdBuffer)

outputBuffer.MapAsync(wgpu.MapModeRead, 0, bufferSize, func(status wgpu.BufferMapAsyncStatus) {
if status != wgpu.BufferMapAsyncStatusSuccess {
outputBuffer.MapAsync(wgpu.MapModeRead, 0, bufferSize, func(status wgpu.MapAsyncStatus) {
if status != wgpu.MapAsyncStatusSuccess {
panic("failed to map buffer")
}
})
Expand Down
8 changes: 4 additions & 4 deletions examples/compute/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func main() {

shaderModule, err := device.CreateShaderModule(&wgpu.ShaderModuleDescriptor{
Label: "shader.wgsl",
WGSLDescriptor: &wgpu.ShaderModuleWGSLDescriptor{
WGSLSource: &wgpu.ShaderSourceWGSL{
Code: shader,
},
})
Expand Down Expand Up @@ -141,8 +141,8 @@ func main() {
}
queue.Submit(cmdBuffer)

var status wgpu.BufferMapAsyncStatus
err = stagingBuffer.MapAsync(wgpu.MapModeRead, 0, size, func(s wgpu.BufferMapAsyncStatus) {
var status wgpu.MapAsyncStatus
err = stagingBuffer.MapAsync(wgpu.MapModeRead, 0, size, func(s wgpu.MapAsyncStatus) {
status = s
})
if err != nil {
Expand All @@ -152,7 +152,7 @@ func main() {

device.Poll(true, nil)

if status != wgpu.BufferMapAsyncStatusSuccess {
if status != wgpu.MapAsyncStatusSuccess {
panic(status)
}

Expand Down
6 changes: 3 additions & 3 deletions examples/cube/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func InitState(window *glfw.Window) (s *State, err error) {
s.queue.WriteTexture(
texture.AsImageCopy(),
wgpu.ToBytes(texels[:]),
&wgpu.TextureDataLayout{
&wgpu.TexelCopyBufferLayout{
Offset: 0,
BytesPerRow: texelsSize,
RowsPerImage: wgpu.CopyStrideUndefined,
Expand All @@ -262,8 +262,8 @@ func InitState(window *glfw.Window) (s *State, err error) {
}

shader, err := s.device.CreateShaderModule(&wgpu.ShaderModuleDescriptor{
Label: "shader.wgsl",
WGSLDescriptor: &wgpu.ShaderModuleWGSLDescriptor{Code: shader},
Label: "shader.wgsl",
WGSLSource: &wgpu.ShaderSourceWGSL{Code: shader},
})
if err != nil {
return s, err
Expand Down
4 changes: 2 additions & 2 deletions examples/triangle/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ func InitState[T interface{ GetSize() (int, int) }](window T, sd *wgpu.SurfaceDe
s.queue = s.device.GetQueue()

shader, err := s.device.CreateShaderModule(&wgpu.ShaderModuleDescriptor{
Label: "shader.wgsl",
WGSLDescriptor: &wgpu.ShaderModuleWGSLDescriptor{Code: shader},
Label: "shader.wgsl",
WGSLSource: &wgpu.ShaderSourceWGSL{Code: shader},
})
if err != nil {
return s, err
Expand Down
63 changes: 63 additions & 0 deletions getrelease.goal
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env goal

// gets the prebuilt release files from wgpu-native and installs
// to wgpu/lib, moving exiting lib to lib_old.
// after doing this, use:
// * lib-old.goal to switch lib-> lib_new, lib_old -> lib
// * lib-new.goal to go the other way
// notes:
// requires gh tool: https://github.com/cli/cli with authentication configured.
// and goal: go install cogentcore.org/lab/goal/cmd/goal@main

[mkdir release]
cd release
[/bin/rm -rf wgpu-native]
[/bin/rm -rf zips]
[mkdir zips]
git clone https://github.com/gfx-rs/wgpu-native
cd wgpu-native
gh release download --dir ../zips -p "*-release.zip"
cd ../zips
zips := goalib.SplitLines($ls -1 "*.zip"$)
cd ../..
mv wgpu/lib wgpu/lib_old
[/bin/rm -rf wgpu/lib]
mkdir wgpu/lib
cd wgpu/lib
for _, f := range zips {
fmt.Println(f)
if strings.Contains(f, "-x86_64-msvc-") || strings.Contains(f, "-aarch64-simulator-") {
continue
}
sp := strings.Split(f, "-")
plt := strings.Join(sp[1:3], "-")
[mkdir {plt}]
cd {plt}
unzip {"../../../release/zips/" + f}
cd ../
}

/bin/cp ../lib_old/vendor.go .

type files struct {
zip, trg, arch string
}

fls := []files{{"macos-aarch64", "darwin", "arm64"},{"macos-x86_64", "darwin", "amd64"},{"ios-aarch64", "ios", "arm64"},{"ios-x86_64", "ios", "amd64"},{"windows-aarch64", "windows", "arm64"},{"windows-x86_64", "windows", "amd64"}, {"windows-i686", "windows", "386"}, {"linux-aarch64", "linux", "arm64"},{"linux-x86_64", "linux", "amd64"}, {"android-aarch64", "android", "arm64"}, {"android-x86_64", "android", "amd64"}, {"android-armv7", "android", "arm"},{"android-i686", "android", "386"}}

for _, f := range fls {
fmt.Println(f)
[mkdir {f.trg}]
cd {f.trg}
[mkdir {f.arch}]
cd {f.arch}
[/bin/cp -av {"../../" + f.zip + "/lib/libwgpu_native.a"} .]
if f.zip == "windows-aarch64" {
/bin/cp -av {"../../" + f.zip + "/lib/wgpu_native.lib"} libwgpu_native.a
}
/bin/cp -av {"../../" + f.zip + "/include/webgpu/*.h"} .
goalib.WriteFile("vendor.go", "package vendor")
cd ../../
/bin/rm -rf {f.zip}
}

8 changes: 8 additions & 0 deletions lib-new.goal
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env goal

// moves current wgpu/lib to wgpu/lib_old
// and restores wgpu/lib_new as wgpu/lib

mv wgpu/lib wgpu/lib_old
mv wgpu/lib_new wgpu/lib

8 changes: 8 additions & 0 deletions lib-old.goal
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env goal

// moves current wgpu/lib to wgpu/lib_new
// and restores wgpu/lib_old as wgpu/lib

mv wgpu/lib wgpu/lib_new
mv wgpu/lib_old wgpu/lib

Loading
Loading