ui/app: add GL buffer caches

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-05-16 21:47:30 +02:00
parent 642318842c
commit da598663f7
5 changed files with 33 additions and 43 deletions
+1
View File
@@ -105,6 +105,7 @@ func newContext(w *window) (*context, error) {
c := &context{
driver: w,
eglCtx: eglCtx,
c: new(gl.Functions),
}
return c, nil
}
+1
View File
@@ -46,6 +46,7 @@ func newContext(w *window) (*context, error) {
ctx: ctx,
owner: w,
layer: C.CFTypeRef(w.contextLayer()),
c: new(gl.Functions),
}
return c, nil
}
+1
View File
@@ -34,6 +34,7 @@ func newContext(w *window) (*context, error) {
ctx := C.gio_contextForView(w.contextView())
c := &context{
ctx: ctx,
c: new(gl.Functions),
}
return c, nil
}
+17 -25
View File
@@ -113,7 +113,11 @@ __attribute__((constructor)) static void gio_loadGLFunctions() {
*/
import "C"
type Functions struct{}
type Functions struct {
// Query caches.
uints [100]C.GLuint
ints [100]C.GLint
}
func (f *Functions) ActiveTexture(texture Enum) {
C.glActiveTexture(C.GLenum(texture))
@@ -317,31 +321,23 @@ func (f *Functions) GetError() Enum {
}
func (f *Functions) GetRenderbufferParameteri(target, pname Enum) int {
// Hope this is enough room.
var buf [100]C.GLint
C.glGetRenderbufferParameteriv(C.GLenum(target), C.GLenum(pname), &buf[0])
return int(buf[0])
C.glGetRenderbufferParameteriv(C.GLenum(target), C.GLenum(pname), &f.ints[0])
return int(f.ints[0])
}
func (f *Functions) GetFramebufferAttachmentParameteri(target, attachment, pname Enum) int {
// Hope this is enough room.
var buf [100]C.GLint
C.glGetFramebufferAttachmentParameteriv(C.GLenum(target), C.GLenum(attachment), C.GLenum(pname), &buf[0])
return int(buf[0])
C.glGetFramebufferAttachmentParameteriv(C.GLenum(target), C.GLenum(attachment), C.GLenum(pname), &f.ints[0])
return int(f.ints[0])
}
func (f *Functions) GetInteger(pname Enum) int {
// Hope this is enough room.
var buf [100]C.GLint
C.glGetIntegerv(C.GLenum(pname), &buf[0])
return int(buf[0])
C.glGetIntegerv(C.GLenum(pname), &f.ints[0])
return int(f.ints[0])
}
func (f *Functions) GetProgrami(p Program, pname Enum) int {
// Hope this is enough room.
var buf [100]C.GLint
C.glGetProgramiv(C.GLuint(p.V), C.GLenum(pname), &buf[0])
return int(buf[0])
C.glGetProgramiv(C.GLuint(p.V), C.GLenum(pname), &f.ints[0])
return int(f.ints[0])
}
func (f *Functions) GetProgramInfoLog(p Program) string {
@@ -357,17 +353,13 @@ func (f *Functions) GetProgramInfoLog(p Program) string {
}
func (f *Functions) GetQueryObjectuiv(query Query, pname Enum) uint {
// Hope this is enough room.
var buf [100]C.GLuint
C.gio_glGetQueryObjectuiv(C.GLuint(query.V), C.GLenum(pname), &buf[0])
return uint(buf[0])
C.gio_glGetQueryObjectuiv(C.GLuint(query.V), C.GLenum(pname), &f.uints[0])
return uint(f.uints[0])
}
func (f *Functions) GetShaderi(s Shader, pname Enum) int {
// Hope this is enough room.
var buf [100]C.GLint
C.glGetShaderiv(C.GLuint(s.V), C.GLenum(pname), &buf[0])
return int(buf[0])
C.glGetShaderiv(C.GLuint(s.V), C.GLenum(pname), &f.ints[0])
return int(f.ints[0])
}
func (f *Functions) GetShaderInfoLog(s Shader) string {
+13 -18
View File
@@ -86,7 +86,10 @@ var (
_glViewport = LibGLESv2.NewProc("glViewport")
)
type Functions struct{}
type Functions struct {
// Query caches.
int32s [100]int32
}
func (c *Functions) ActiveTexture(t Enum) {
syscall.Syscall(_glActiveTexture.Addr(), 1, uintptr(t), 0, 0)
@@ -252,16 +255,12 @@ func (c *Functions) GetFramebufferAttachmentParameteri(target, attachment, pname
return int(p)
}
func (c *Functions) GetInteger(pname Enum) int {
// Hopefully enough room.
var params [100]int32
syscall.Syscall(_glGetIntegerv.Addr(), 2, uintptr(pname), uintptr(unsafe.Pointer(&params[0])), 0)
return int(params[0])
syscall.Syscall(_glGetIntegerv.Addr(), 2, uintptr(pname), uintptr(unsafe.Pointer(&c.int32s[0])), 0)
return int(c.int32s[0])
}
func (c *Functions) GetProgrami(p Program, pname Enum) int {
// Hopefully enough space.
var params [100]int32
syscall.Syscall(_glGetProgramiv.Addr(), 3, uintptr(p.V), uintptr(pname), uintptr(unsafe.Pointer(&params[0])))
return int(params[0])
syscall.Syscall(_glGetProgramiv.Addr(), 3, uintptr(p.V), uintptr(pname), uintptr(unsafe.Pointer(&c.int32s[0])))
return int(c.int32s[0])
}
func (c *Functions) GetProgramInfoLog(p Program) string {
var n uintptr
@@ -274,17 +273,13 @@ func (c *Functions) GetProgramInfoLog(p Program) string {
syscall.Syscall6(_glGetProgramInfoLog.Addr(), 4, uintptr(p.V), uintptr(len(buf)), uintptr(unsafe.Pointer(&n)), uintptr(unsafe.Pointer(&buf[0])), 0, 0)
return string(buf[:len(buf)-1])
}
func (f *Functions) GetQueryObjectuiv(query Query, pname Enum) uint {
// Hope this is enough room.
var buf [100]int32
syscall.Syscall(_glGetQueryObjectuiv.Addr(), 3, uintptr(query.V), uintptr(pname), uintptr(unsafe.Pointer(&buf[0])))
return uint(buf[0])
func (c *Functions) GetQueryObjectuiv(query Query, pname Enum) uint {
syscall.Syscall(_glGetQueryObjectuiv.Addr(), 3, uintptr(query.V), uintptr(pname), uintptr(unsafe.Pointer(&c.int32s[0])))
return uint(c.int32s[0])
}
func (c *Functions) GetShaderi(s Shader, pname Enum) int {
// Hopefully enough room.
var params [100]int32
syscall.Syscall(_glGetShaderiv.Addr(), 3, uintptr(s.V), uintptr(pname), uintptr(unsafe.Pointer(&params[0])))
return int(params[0])
syscall.Syscall(_glGetShaderiv.Addr(), 3, uintptr(s.V), uintptr(pname), uintptr(unsafe.Pointer(&c.int32s[0])))
return int(c.int32s[0])
}
func (c *Functions) GetShaderInfoLog(s Shader) string {
var n uintptr