After adding the following line to the import section into a go file, build will no longer complete, and instead report errors as shown below.
import _ "github.com/gogpu/wgpu/hal/allbackends" // Auto-register platform backends
Errors when building with go build:
# github.com/go-webgpu/goffi/ffi
/home/user/go/pkg/mod/github.com/go-webgpu/[email protected]/ffi/dl_unix.go:54:20: undefined: dl.Dlopen
/home/user/go/pkg/mod/github.com/go-webgpu/[email protected]/ffi/dl_unix.go:88:19: undefined: dl.Dlsym
/home/user/go/pkg/mod/github.com/go-webgpu/[email protected]/ffi/dl_unix.go:137:12: undefined: dl.Dlclose
Note that the go.mod file also reports errors once adding the import line, which are remedied by adding the following to it:
require (
github.com/go-webgpu/goffi v0.3.7 // indirect
github.com/gogpu/naga v0.8.4 // indirect
golang.org/x/sys v0.39.0 // indirect
)
The entire engine.go file I am using to try out this lib is below:
package engine
import (
"fmt"
"github.com/gogpu/wgpu/core"
_ "github.com/gogpu/wgpu/hal/allbackends" // Auto-register platform backends
"github.com/gogpu/wgpu/types"
)
// Since there can be only one engine, make all funcs static and just call them like regular functions.
var webGPUInstance *core.Instance
var webGPUAdapter core.AdapterID
var webGPURenderingDevice core.DeviceID
var webGPURenderingDeviceQueue core.QueueID
func Initialize() {
webGPUInstance := core.NewInstance(&types.InstanceDescriptor{
Backends: types.BackendsAll,
})
webGPUAdapter, err := webGPUInstance.RequestAdapter(&types.RequestAdapterOptions{
PowerPreference: types.PowerPreferenceHighPerformance,
})
if err != nil {
// TODO: Logging Lib
return
}
if info, err := core.GetAdapterInfo(webGPUAdapter); err == nil {
// TODO: Logging Lib
fmt.Printf("GPU: %s (%s) [%s]\n", info.Name, info.Backend, info.DriverInfo)
}
webGPURenderingDevice, err := core.RequestDevice(webGPUAdapter, &types.DeviceDescriptor{
Label: "Main Rendering Device",
})
if err != nil {
// TODO: Logging Lib
return
}
webGPURenderingDeviceQueue, err := core.GetDeviceQueue(webGPURenderingDevice)
if err != nil {
// TODO: Logging Lib
return
}
_ = webGPURenderingDeviceQueue
fmt.Println("Success!")
}
Please note I am using Arch linux.
Thanks!
After adding the following line to the import section into a go file, build will no longer complete, and instead report errors as shown below.
Errors when building with
go build:Note that the
go.modfile also reports errors once adding the import line, which are remedied by adding the following to it:The entire
engine.gofile I am using to try out this lib is below:Please note I am using Arch linux.
Thanks!