Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 3 additions & 2 deletions base/iox/imagex/wrapjs_js.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import (
"syscall/js"

"cogentcore.org/core/base/errors"
"cogentcore.org/core/base/jscp"
"cogentcore.org/core/colors/gradient"
"github.com/cogentcore/webgpu/jsx"
"github.com/oliverbestmann/webgpu/jsx"
)

// WrapJS returns a JavaScript optimized wrapper around the given
Expand Down Expand Up @@ -155,7 +156,7 @@ type JSImageData struct {

// setImageData sets the JavaScript pointers from given bytes.
func (im *JSImageData) SetImageData(src []byte, sbb image.Rectangle, options map[string]any) {
jsBuf := jsx.BytesToJS(src)
jsBuf := jscp.BytesToJS(src)
imageData := js.Global().Get("ImageData").New(jsBuf, sbb.Dx(), sbb.Dy())
im.Bounds = image.Rectangle{Max: sbb.Size()}
im.Data = imageData
Expand Down
19 changes: 19 additions & 0 deletions base/jscp/jscp.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//go:build js

// Package jscp provides functions for copying data to JavaScript
package jscp

import (
"syscall/js"
"unsafe"
)

// BytesToJS converts the given bytes to a js Uint8ClampedArray
// by using the global wasm memory bytes. This avoids the
// copying present in [js.CopyBytesToJS].
func BytesToJS(b []byte) js.Value {
ptr := uintptr(unsafe.Pointer(&b[0]))
// We directly pass the offset and length to the constructor to avoid calling subarray or slice,
// thereby improving performance and safety (this fixes a detached array buffer crash).
return js.Global().Get("Uint8ClampedArray").New(js.Global().Get("wasm").Get("instance").Get("exports").Get("mem").Get("buffer"), ptr, len(b))
}
4 changes: 2 additions & 2 deletions base/websocket/websocket_js.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ package websocket
import (
"syscall/js"

"github.com/cogentcore/webgpu/jsx"
"cogentcore.org/core/base/jscp"
)

// Client represents a WebSocket client connection.
Expand Down Expand Up @@ -51,7 +51,7 @@ func (c *Client) Send(typ MessageTypes, msg []byte) error {
c.ws.Call("send", string(msg))
return nil
}
array := jsx.BytesToJS(msg)
array := jscp.BytesToJS(msg)
c.ws.Call("send", array)
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion docs/content/gpu.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The main gpu code is in the top-level `gpu` package, with the following sub-pack

* [[doc:gpu/gpudraw]] implements GPU-accelerated texture-based versions of the Go [image/draw](https://pkg.go.dev/image/draw) api. This is used by the `Composer` framework for compositing images in the `core` GUI to construct the final rendered scene, and for drawing that scene on the actual hardware window (see [[render]] for details).

We maintain a separate [webgpu](https://github.com/cogentcore/webgpu) package that provides a Go and JS wrapper around the rust-based [wgpu](https://github.com/gfx-rs/wgpu) and [wgpu-native](https://github.com/gfx-rs/wgpu-native) packages that actually implement WebGPU itself on the desktop and mobile. This "native" version is just as performant as the much more difficult-to-use [Vulkan](https://www.vulkan.org/) framework, which we used to use.
There is a separate [webgpu](https://github.com/oliverbestmann/webgpu) package that provides a Go and JS wrapper around the rust-based [wgpu](https://github.com/gfx-rs/wgpu) and [wgpu-native](https://github.com/gfx-rs/wgpu-native) packages that actually implement WebGPU itself on the desktop and mobile. This "native" version is just as performant as the much more difficult-to-use [Vulkan](https://www.vulkan.org/) framework, which we used to use.

## Selecting a GPU Device

Expand Down
11 changes: 9 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ require (
github.com/bramvdbogaerde/go-scp v1.6.0
github.com/chewxy/math32 v1.11.1
github.com/cogentcore/reisen v0.0.0-20240814194831-4d884b6e7666
github.com/cogentcore/webgpu v0.23.1-0.20260410073005-a2ae7d757168
github.com/cogentcore/yaegi v0.0.0-20260116172027-700fbf8949f3
github.com/coreos/go-oidc/v3 v3.17.0
github.com/ericchiang/css v1.4.0
github.com/faiface/beep v1.1.0
github.com/fsnotify/fsnotify v1.9.0
github.com/go-fonts/latin-modern v0.3.3
github.com/go-gl/glfw/v3.4/glfw v0.1.0-pre.1
github.com/go-gl/glfw/v3.4/glfw v0.1.0-pre.1.0.20260406072232-3ac4aa2bb164
github.com/go-text/typesetting v0.3.5-0.20260418130854-c41d02a44bec
github.com/gomarkdown/markdown v0.0.0-20260417124207-7d523f7318df
github.com/gorilla/websocket v1.5.3
Expand All @@ -33,6 +32,7 @@ require (
github.com/mattn/go-shellwords v1.0.12
github.com/mitchellh/go-homedir v1.1.0
github.com/muesli/termenv v0.16.0
github.com/oliverbestmann/webgpu v1.33.2
github.com/pelletier/go-toml/v2 v2.2.4
github.com/stretchr/testify v1.11.1
github.com/tdewolff/parse/v2 v2.8.5
Expand Down Expand Up @@ -63,6 +63,11 @@ require (
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
github.com/oliverbestmann/webgpu/libs-android v0.0.0-20260509160813-48db59792a15 // indirect
github.com/oliverbestmann/webgpu/libs-darwin v0.0.0-20260509160802-b09403b07cd3 // indirect
github.com/oliverbestmann/webgpu/libs-ios v0.0.0-20260509160803-765e39d2a48b // indirect
github.com/oliverbestmann/webgpu/libs-linux v0.0.0-20260509160809-2fefaf7c9ead // indirect
github.com/oliverbestmann/webgpu/libs-windows v0.0.0-20260509160807-0bc32b12c7bc // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
Expand All @@ -75,3 +80,5 @@ require (
modernc.org/knuth v0.5.4 // indirect
modernc.org/token v1.1.0 // indirect
)

replace github.com/go-gl/glfw/v3.4/glfw v0.1.0-pre.1.0.20260406072232-3ac4aa2bb164 => github.com/oliverbestmann/go-gl-glfw/v3.4/glfw v0.0.0-20260510101646-c1f83c493fe1
18 changes: 14 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ github.com/chewxy/math32 v1.11.1 h1:b7PGHlp8KjylDoU8RrcEsRuGZhJuz8haxnKfuMMRqy8=
github.com/chewxy/math32 v1.11.1/go.mod h1:dOB2rcuFrCn6UHrze36WSLVPKtzPMRAQvBvUwkSsLqs=
github.com/cogentcore/reisen v0.0.0-20240814194831-4d884b6e7666 h1:gmXMw/Xcva/2V5qRO920q4am1odNE0xFEGBzG7y7cus=
github.com/cogentcore/reisen v0.0.0-20240814194831-4d884b6e7666/go.mod h1:HoDh/nWYrLffGjfVxUmbJHb0yZvcV3TwrN73WurddNs=
github.com/cogentcore/webgpu v0.23.1-0.20260410073005-a2ae7d757168 h1:K5en4IrBrolIAWvjrLuXRb9CvU1w+WMMi0Eu0KmcMfQ=
github.com/cogentcore/webgpu v0.23.1-0.20260410073005-a2ae7d757168/go.mod h1:DQLhF8pM/WkdaGpX6pKmZJPYsoR9x+hohhA1nnNuCa8=
github.com/cogentcore/yaegi v0.0.0-20260116172027-700fbf8949f3 h1:y3Djpt/g3QTjFdj8cpvy/r8FsZsEa7PqHGjgsKXbta0=
github.com/cogentcore/yaegi v0.0.0-20260116172027-700fbf8949f3/go.mod h1:XkOm++pRmWlk85p+hw71ZItfTeRdzqG23+2xjP9eb+M=
github.com/coreos/go-oidc/v3 v3.17.0 h1:hWBGaQfbi0iVviX4ibC7bk8OKT5qNr4klBaCHVNvehc=
Expand All @@ -56,8 +54,6 @@ github.com/go-audio/riff v1.0.0/go.mod h1:l3cQwc85y79NQFCRB7TiPoNiaijp6q8Z0Uv38r
github.com/go-audio/wav v1.0.0/go.mod h1:3yoReyQOsiARkvPl3ERCi8JFjihzG6WhjYpZCf5zAWE=
github.com/go-fonts/latin-modern v0.3.3 h1:g2xNgI8yzdNzIVm+qvbMryB6yGPe0pSMss8QT3QwlJ0=
github.com/go-fonts/latin-modern v0.3.3/go.mod h1:tHaiWDGze4EPB0Go4cLT5M3QzRY3peya09Z/8KSCrpY=
github.com/go-gl/glfw/v3.4/glfw v0.1.0-pre.1 h1:nIVzcwqIaO1mK8LFr0fGkKpgQD4wJDDHRyv4t5k40Ps=
github.com/go-gl/glfw/v3.4/glfw v0.1.0-pre.1/go.mod h1:T5Dn0JwIJOX1euPZ/iT4tq6nFYtmukjcYa7937HuYK8=
github.com/go-jose/go-jose/v4 v4.1.4 h1:moDMcTHmvE6Groj34emNPLs/qtYXRVcd6S7NHbHz3kA=
github.com/go-jose/go-jose/v4 v4.1.4/go.mod h1:x4oUasVrzR7071A4TnHLGSPpNOm2a21K9Kf04k1rs08=
github.com/go-text/typesetting v0.3.5-0.20260418130854-c41d02a44bec h1:qkk9+cZlaY8920dQrhY8GoI91N72f58XmJgGDkkDiaA=
Expand Down Expand Up @@ -124,6 +120,20 @@ github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc
github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
github.com/oliverbestmann/go-gl-glfw/v3.4/glfw v0.0.0-20260510101646-c1f83c493fe1 h1:NE2h8adQKd5RgELMJRDh6jk+w2AZGJnqiceettnqjAs=
github.com/oliverbestmann/go-gl-glfw/v3.4/glfw v0.0.0-20260510101646-c1f83c493fe1/go.mod h1:T5Dn0JwIJOX1euPZ/iT4tq6nFYtmukjcYa7937HuYK8=
github.com/oliverbestmann/webgpu v1.33.2 h1:uDs3Fx4uAiUs8E4QytblofDpLtqBRGX3pfnLZzlhWGY=
github.com/oliverbestmann/webgpu v1.33.2/go.mod h1:0UEcoJ8VnwnAqo3JfzdFptplxtjhaQasc3n/nYZOrPA=
github.com/oliverbestmann/webgpu/libs-android v0.0.0-20260509160813-48db59792a15 h1:HPxVSV8C8JaxGfa9hjDhzNmryoqPF3EwESBTFWpxNBo=
github.com/oliverbestmann/webgpu/libs-android v0.0.0-20260509160813-48db59792a15/go.mod h1:tczQXCdsoFy+FTJVsZSve/vF8cmWEkxhvjcyY2Rujp8=
github.com/oliverbestmann/webgpu/libs-darwin v0.0.0-20260509160802-b09403b07cd3 h1:NbBG2+pwqKcNfKUKtjWOj+02RkXSUWVkxY3hqzgyjSA=
github.com/oliverbestmann/webgpu/libs-darwin v0.0.0-20260509160802-b09403b07cd3/go.mod h1:XoHM/ZcjQqJQyEfQjU0ScDkxvQRWfZLxKP8IrEz4xyo=
github.com/oliverbestmann/webgpu/libs-ios v0.0.0-20260509160803-765e39d2a48b h1:j+uRWcmAl3Y4RPJ4rmxnc1DRHgZ6VNywZPsRHUEuD0M=
github.com/oliverbestmann/webgpu/libs-ios v0.0.0-20260509160803-765e39d2a48b/go.mod h1:IV+TkwmPA0yMzZZoz0Aj4X+22WLEQq2TOyN4/0k8lgs=
github.com/oliverbestmann/webgpu/libs-linux v0.0.0-20260509160809-2fefaf7c9ead h1:kkY04PFBq6I58BwK5cwJ3LRp+xy7Y5/jrkLHBdcBL68=
github.com/oliverbestmann/webgpu/libs-linux v0.0.0-20260509160809-2fefaf7c9ead/go.mod h1:SOeo2YWe2UxWxOeAHyZtwaSXkBbP78cGnm7I+6lIWV0=
github.com/oliverbestmann/webgpu/libs-windows v0.0.0-20260509160807-0bc32b12c7bc h1:YVCfgeByW1ibKniigozHCwF2wC26TDmAIJwQG40bCBM=
github.com/oliverbestmann/webgpu/libs-windows v0.0.0-20260509160807-0bc32b12c7bc/go.mod h1:58qRJHG2+mjEu/AKJFh026bz3xE1zEHYt41i4TBM8NE=
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
Expand Down
14 changes: 7 additions & 7 deletions gpu/buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import (
"fmt"

"cogentcore.org/core/base/errors"
"github.com/cogentcore/webgpu/wgpu"
"github.com/oliverbestmann/webgpu/wgpu"
)

// note: WriteBuffer is the preferred method for writing, so we only need to manage Read

// BufferMapAsyncError returns an error message if the status is not success.
func BufferMapAsyncError(status wgpu.BufferMapAsyncStatus) error {
if status != wgpu.BufferMapAsyncStatusSuccess {
func BufferMapAsyncError(status wgpu.MapAsyncStatus) error {
if status != wgpu.MapAsyncStatusSuccess {
return errors.New("gpu BufferMapAsync was not successful")
}
return nil
Expand All @@ -24,8 +24,8 @@ func BufferMapAsyncError(status wgpu.BufferMapAsyncStatus) error {
// BufferReadSync does a MapAsync on given buffer, waiting on the device
// until the sync is complete, and returning error if any issues.
func BufferReadSync(device *Device, size int, buffer *wgpu.Buffer) error {
var status wgpu.BufferMapAsyncStatus
err := buffer.MapAsync(wgpu.MapModeRead, 0, uint64(size), func(s wgpu.BufferMapAsyncStatus) {
var status wgpu.MapAsyncStatus
err := buffer.TryMapAsync(wgpu.MapModeRead, 0, uint64(size), func(s wgpu.MapAsyncStatus) {
status = s
})
if errors.Log(err) != nil {
Expand All @@ -44,9 +44,9 @@ func ValueReadSync(device *Device, values ...*Value) error {
return nil
}
var errs []error
status := make([]wgpu.BufferMapAsyncStatus, nv)
status := make([]wgpu.MapAsyncStatus, nv)
for i, vl := range values {
err := vl.readBuffer.MapAsync(wgpu.MapModeRead, 0, uint64(vl.AllocSize), func(s wgpu.BufferMapAsyncStatus) {
err := vl.readBuffer.TryMapAsync(wgpu.MapModeRead, 0, uint64(vl.AllocSize), func(s wgpu.MapAsyncStatus) {
status[i] = s
})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion gpu/cmd/webgpuinfo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

"cogentcore.org/core/base/reflectx"
"cogentcore.org/core/gpu"
"github.com/cogentcore/webgpu/wgpu"
"github.com/oliverbestmann/webgpu/wgpu"
)

func main() {
Expand Down
6 changes: 3 additions & 3 deletions gpu/compute.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"sync"

"cogentcore.org/core/base/errors"
"github.com/cogentcore/webgpu/wgpu"
"github.com/oliverbestmann/webgpu/wgpu"
)

// ComputeSystem manages a system of ComputePipelines that all share
Expand Down Expand Up @@ -111,7 +111,7 @@ func (sy *ComputeSystem) Config() {
// compute commands. This is automatically called by
// BeginRenderPass and the result maintained in [CommandEncoder].
func (sy *ComputeSystem) NewCommandEncoder() (*wgpu.CommandEncoder, error) {
cmd, err := sy.device.Device.CreateCommandEncoder(nil)
cmd, err := sy.device.Device.TryCreateCommandEncoder(nil)
if errors.Log(err) != nil {
return nil, err
}
Expand Down Expand Up @@ -150,7 +150,7 @@ func (sy *ComputeSystem) EndComputePass() error {
sy.ComputeEncoder = nil
sy.CommandEncoder = nil
ce.Release() // must happen before Finish
cmdBuffer, err := cmd.Finish(nil)
cmdBuffer, err := cmd.TryFinish(nil)
if errors.Log(err) != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions gpu/cpipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

"cogentcore.org/core/base/errors"
"cogentcore.org/core/base/fsx"
"github.com/cogentcore/webgpu/wgpu"
"github.com/oliverbestmann/webgpu/wgpu"
)

// ComputePipeline is a compute pipeline, which runs shader code on vars data.
Expand Down Expand Up @@ -192,7 +192,7 @@ func (pl *ComputePipeline) Config(rebuild bool) error {
defer play.Release()

sh := pl.EntryByType(ComputeShader)
cp, err := pl.System.Device().Device.CreateComputePipeline(&wgpu.ComputePipelineDescriptor{
cp, err := pl.System.Device().Device.TryCreateComputePipeline(&wgpu.ComputePipelineDescriptor{
Layout: play,
Compute: wgpu.ProgrammableStageDescriptor{
Module: sh.Shader.module,
Expand Down
18 changes: 8 additions & 10 deletions gpu/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"fmt"

"cogentcore.org/core/base/errors"
"github.com/cogentcore/webgpu/wgpu"
"github.com/oliverbestmann/webgpu/wgpu"
)

// Device holds Device and associated Queue info.
Expand Down Expand Up @@ -44,30 +44,28 @@ func NewComputeDevice(gpu *GPU) (*Device, error) {
// hardware, so we may need to detect that. OTOH it probably won't be useful for compute anyway,
// but we can just sort that out later
// note: on web / chromium / dawn, limited to 10: https://issues.chromium.org/issues/366151398?pli=1
limits.MaxStorageBuffersPerShaderStage = gpu.Limits.Limits.MaxStorageBuffersPerShaderStage
// fmt.Println("MaxStorageBuffersPerShaderStage:", gpu.Limits.Limits.MaxStorageBuffersPerShaderStage)
limits.MaxStorageBuffersPerShaderStage = gpu.Limits.MaxStorageBuffersPerShaderStage
// fmt.Println("MaxStorageBuffersPerShaderStage:", gpu.Limits.MaxStorageBuffersPerShaderStage)
// note: these limits are being processed and allow the MaxBufferSize to be the
// controlling factor -- if we don't set these, then the slrand example doesn't
// work above a smaller limit.
// TODO: converting these limits to int may cause issues on 32-bit systems
limits.MaxUniformBufferBindingSize = uint64(MemSizeAlignDown(int(gpu.Limits.Limits.MaxUniformBufferBindingSize), int(gpu.Limits.Limits.MinUniformBufferOffsetAlignment)))
limits.MaxUniformBufferBindingSize = uint64(MemSizeAlignDown(int(gpu.Limits.MaxUniformBufferBindingSize), int(gpu.Limits.MinUniformBufferOffsetAlignment)))

limits.MaxStorageBufferBindingSize = uint64(MemSizeAlignDown(int(gpu.Limits.Limits.MaxStorageBufferBindingSize), int(gpu.Limits.Limits.MinStorageBufferOffsetAlignment)))
limits.MaxStorageBufferBindingSize = uint64(MemSizeAlignDown(int(gpu.Limits.MaxStorageBufferBindingSize), int(gpu.Limits.MinStorageBufferOffsetAlignment)))
// note: this limit is not working properly:
g4 := uint64(0xFFFFFF00)
limits.MaxBufferSize = uint64(MemSizeAlignDown(int(min(gpu.Limits.Limits.MaxBufferSize, g4)), int(gpu.Limits.Limits.MinStorageBufferOffsetAlignment)))
limits.MaxBufferSize = uint64(MemSizeAlignDown(int(min(gpu.Limits.MaxBufferSize, g4)), int(gpu.Limits.MinStorageBufferOffsetAlignment)))
if limits.MaxBufferSize == 0 {
limits.MaxBufferSize = g4
}
// limits.MaxBindGroups = gpu.Limits.Limits.MaxBindGroups // note: no point in changing -- web constraint
// limits.MaxBindGroups = gpu.Limits.MaxBindGroups // note: no point in changing -- web constraint

if Debug {
fmt.Printf("Requesting sizes: MaxStorageBufferBindingSize: %X MaxBufferSize: %X\n", limits.MaxStorageBufferBindingSize, limits.MaxBufferSize)
}
desc := wgpu.DeviceDescriptor{
RequiredLimits: &wgpu.RequiredLimits{
Limits: limits,
},
RequiredLimits: &limits,
}
wdev, err := gpu.GPU.RequestDevice(&desc)
if errors.Log(err) != nil {
Expand Down
2 changes: 1 addition & 1 deletion gpu/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/*
Package gpu implements a convenient interface to the WebGPU
graphics and compute framework, in Go, using the
[github.com/cogentcore/webgpu] bindings.
[github.com/oliverbestmann/webgpu] bindings.

The Cogent Core GUI framework runs on top of this.
*/
Expand Down
2 changes: 1 addition & 1 deletion gpu/examples/drawidx/drawidx.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

"cogentcore.org/core/gpu"
"cogentcore.org/core/math32"
"github.com/cogentcore/webgpu/wgpu"
"github.com/oliverbestmann/webgpu/wgpu"
)

//go:embed indexed.wgsl
Expand Down
9 changes: 8 additions & 1 deletion gpu/examples/drawtri/drawtri.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
_ "embed"
"fmt"
"image"
"os"
"runtime"
"time"

Expand All @@ -20,6 +21,8 @@ var trianglelit string
func init() {
// must lock main thread for gpu!
runtime.LockOSThread()
gpu.Debug = true
os.Setenv("RUST_BACKTRACE", "full")
}

func main() {
Expand Down Expand Up @@ -63,7 +66,11 @@ func main() {
// rt := time.Now()

rp, err := sy.BeginRenderPass()
if err != nil {
if err != nil { // error here is fatal
panic(err)
}
if rp == nil { // nil indicates need to reconfig
sf.Reconfig()
return
}
pl.BindPipeline(rp)
Expand Down
2 changes: 1 addition & 1 deletion gpu/examples/offscreen/offscreen.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"cogentcore.org/core/gpu"
"cogentcore.org/core/gpu/gpudraw"
"cogentcore.org/core/math32"
"github.com/cogentcore/webgpu/wgpu"
"github.com/oliverbestmann/webgpu/wgpu"
)

//go:embed indexed.wgsl
Expand Down
2 changes: 1 addition & 1 deletion gpu/examples/phong/phong.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"cogentcore.org/core/gpu/phong"
"cogentcore.org/core/gpu/shape"
"cogentcore.org/core/math32"
"github.com/cogentcore/webgpu/wgpu"
"github.com/oliverbestmann/webgpu/wgpu"
)

func init() {
Expand Down
2 changes: 1 addition & 1 deletion gpu/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"image"
"log"

"github.com/cogentcore/webgpu/wgpu"
"github.com/oliverbestmann/webgpu/wgpu"
)

// TextureFormat describes the size and WebGPU format of a Texture.
Expand Down
4 changes: 2 additions & 2 deletions gpu/glfw.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (

"cogentcore.org/core/base/errors"
"cogentcore.org/core/system"
"github.com/cogentcore/webgpu/wgpu"
"github.com/cogentcore/webgpu/wgpuglfw"
"github.com/go-gl/glfw/v3.4/glfw"
"github.com/oliverbestmann/webgpu/wgpu"
"github.com/oliverbestmann/webgpu/wgpuglfw"
)

// note: this file contains the glfw dependencies, for desktop platform builds
Expand Down
2 changes: 1 addition & 1 deletion gpu/glfw_js.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

"cogentcore.org/core/base/errors"
"cogentcore.org/core/system/driver/web/jsfs"
"github.com/cogentcore/webgpu/wgpu"
"github.com/oliverbestmann/webgpu/wgpu"
)

// GLFWCreateWindow is a helper function intended only for use in simple examples that makes a
Expand Down
Loading