mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-03 08:25:34 +00:00
gpu,gpu/gl: introduce Backend
A recent change made the OpenGL functions an interface of the functions required for the implementation of GPU, a renderer for Gio operations. That allowed for running Gio on external systems where OpenGL is available. However, to allow for non-OpenGL flavored backends such as Vulkan, Metal and Direct3D, this change introduces Backend for the high-level operations required by GPU. This change also adds a concrete backend to package gl. Type Backend is a first cut heavily based on OpenGL. Future changes will add more backends, where the Backend interface quite possibly will need refinement. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -51,7 +51,13 @@ func NewWindow(width, height int) (*Window, error) {
|
||||
ctx.Release()
|
||||
return err
|
||||
}
|
||||
gpu, err := gpu.New(f)
|
||||
backend, err := gl.NewBackend(f)
|
||||
if err != nil {
|
||||
fbo.Release()
|
||||
ctx.Release()
|
||||
return err
|
||||
}
|
||||
gpu, err := gpu.New(backend)
|
||||
if err != nil {
|
||||
fbo.Release()
|
||||
ctx.Release()
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
syscall "golang.org/x/sys/windows"
|
||||
|
||||
"gioui.org/app/internal/glimpl"
|
||||
"gioui.org/gpu/gl"
|
||||
gunsafe "gioui.org/internal/unsafe"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -157,7 +157,7 @@ func eglTerminate(disp _EGLDisplay) bool {
|
||||
|
||||
func eglQueryString(disp _EGLDisplay, name _EGLint) string {
|
||||
r, _, _ := _eglQueryString.Call(uintptr(disp), uintptr(name))
|
||||
return gl.GoString(gl.SliceOf(r))
|
||||
return gunsafe.GoString(gunsafe.SliceOf(r))
|
||||
}
|
||||
|
||||
// issue34474KeepAlive calls runtime.KeepAlive as a
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"golang.org/x/sys/windows"
|
||||
|
||||
"gioui.org/gpu/gl"
|
||||
gunsafe "gioui.org/internal/unsafe"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -290,7 +291,7 @@ func (c *Functions) GetShaderInfoLog(s gl.Shader) string {
|
||||
}
|
||||
func (c *Functions) GetString(pname gl.Enum) string {
|
||||
s, _, _ := syscall.Syscall(_glGetString.Addr(), 1, uintptr(pname), 0, 0)
|
||||
return gl.GoString(gl.SliceOf(s))
|
||||
return gunsafe.GoString(gunsafe.SliceOf(s))
|
||||
}
|
||||
func (c *Functions) GetUniformLocation(p gl.Program, name string) gl.Uniform {
|
||||
cname := cString(name)
|
||||
|
||||
+7
-1
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"gioui.org/app/internal/window"
|
||||
"gioui.org/gpu"
|
||||
"gioui.org/gpu/gl"
|
||||
"gioui.org/op"
|
||||
)
|
||||
|
||||
@@ -66,7 +67,12 @@ func (l *renderLoop) renderLoop(glctx window.Context) error {
|
||||
initErr <- err
|
||||
return
|
||||
}
|
||||
g, err := gpu.New(glctx.Functions())
|
||||
ctx, err := gl.NewBackend(glctx.Functions())
|
||||
if err != nil {
|
||||
initErr <- err
|
||||
return
|
||||
}
|
||||
g, err := gpu.New(ctx)
|
||||
if err != nil {
|
||||
initErr <- err
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user