mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 18:35:34 +00:00
app,gpu,internal/vk: add Vulkan port for Wayland, X11, Android
This change implements a Vulkan port for the two renderers, old and compute. Run with GIORENDERER=forcecompute to test the compute renderer. To shake out bugs faster, it is also made the default on systems that support it. To disable Vulkan and force the use of OpenGL, use the `novulkan` tag: $ go run -tags novulkan gioui.org/example/kitchen Don't forget to file an issue describing the issue that prompted the use of the tag. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -220,6 +220,11 @@ var callbackMap sync.Map
|
||||
// order of preference.
|
||||
var clipboardMimeTypes = []string{"text/plain;charset=utf8", "UTF8_STRING", "text/plain", "TEXT", "STRING"}
|
||||
|
||||
var (
|
||||
newWaylandEGLContext func(w *window) (context, error)
|
||||
newWaylandVulkanContext func(w *window) (context, error)
|
||||
)
|
||||
|
||||
func init() {
|
||||
wlDriver = newWLWindow
|
||||
}
|
||||
@@ -1476,6 +1481,28 @@ func (w *window) SetInputHint(_ key.InputHint) {}
|
||||
// Close the window. Not implemented for Wayland.
|
||||
func (w *window) Close() {}
|
||||
|
||||
func (w *window) NewContext() (context, error) {
|
||||
var firstErr error
|
||||
if f := newWaylandVulkanContext; f != nil {
|
||||
c, err := f(w)
|
||||
if err == nil {
|
||||
return c, nil
|
||||
}
|
||||
firstErr = err
|
||||
}
|
||||
if f := newWaylandEGLContext; f != nil {
|
||||
c, err := f(w)
|
||||
if err == nil {
|
||||
return c, nil
|
||||
}
|
||||
firstErr = err
|
||||
}
|
||||
if firstErr != nil {
|
||||
return nil, firstErr
|
||||
}
|
||||
return nil, errors.New("wayland: no available GPU backends")
|
||||
}
|
||||
|
||||
// detectUIScale reports the system UI scale, or 1.0 if it fails.
|
||||
func detectUIScale() float32 {
|
||||
// TODO: What about other window environments?
|
||||
|
||||
Reference in New Issue
Block a user