Commit Graph

19 Commits

Author SHA1 Message Date
Elias Naur c9970cb8e3 gpu,gpu/internal,internal/gl: replace BlitFramebuffer with CopyTexture
OpenGL ES 2.0 doesn't support glBlitFramebuffer, but does support
glCopyTexSubImage2D. Fortunately, we don't need the extra features of
glBlitFramebuffer anyway.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-08-21 11:16:28 +02:00
Elias Naur afaa31eca8 gpu: introduce pipeline abstraction
Modern API such as Metal and Vulkan want clients to compile expensive
state changes into pipeline objects. Change our GPU driver abstraction
to match, thereby paving the way for future drivers.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-08-21 08:31:46 +02:00
Elias Naur c49fe63d56 internal/gl: use libGLESv2.so.2 for Unix platforms
The unprefixed library names are for development, and Android.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-08-08 15:54:00 +02:00
Elias Naur 60a47e7de5 gpu/internal,internal/gl: add support for strided texture uploads
The CPU fallback of the compute renderer needs to upload subtextures
from a larger image.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-07-27 14:34:18 +02:00
Elias Naur 060ae1cdf9 all: add //go:build lines
They're automatically added by Go 1.17 source formatters. This change
adds them all now.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-07-26 15:17:51 +02:00
Elias Naur 9b5e9ae607 gpu/internal/opengl: restore BeginFrame state in EndFrame
To ease the integration with foreign OpenGL contexts, carefully save the
context state before rendering a frame and restore it afterwards. Gio
rendering can then be mixed with OpenGL code that expects exclusive
control over context state.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-06-11 21:02:18 +02:00
Inkeliz 965792c1a9 internal/gl: fix WebGL 1 support
Fixes gio#231

Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2021-06-04 09:28:59 +02:00
Elias Naur 476d2269a6 gpu/internal/opengl,app/internal/wm: generalize desktop OpenGL support
This changes moves the macOS specific setup for desktop OpenGL to the
portable opengl package. The opengl package already takes care of the
desktop OpenGL setup for sRGB framebuffers, and by moving the code we
avoid calling the wrong OpenGL functions in case both OpenGL.framework
and ANGLE libGLESv2.dylib is linked into the program.

Remove the interface casting expressions for gl.Functions; it wasn't
worth the trouble to keep updated.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-06-01 18:26:11 +02:00
Elias Naur d1f2f61ebf internal/gl: [Windows] fix two incorrect OpenGL call signatures
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-05-18 14:26:45 +01:00
Elias Naur 03ee75fd72 gpu/internal/opengl: support sRGB emulation for desktop OpenGL
Desktop OpenGL implements a GL_FRAMEBUFFER_SRGB setting; query that instead
of the frambuffer color encoding.

With this change it is no longer necessary to enable FRAMEBUFFER_SRGB
in the macOS setup; remove it.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-05-18 14:26:45 +01:00
Elias Naur b622412ac6 gpu: support forced OpenGL ES mode, for ANGLE on macOS
macOS is the only platform where desktop OpenGL is used. To support
foreign ANGLE contexts add a setting to override Gio's selection of
OpenGL implementation.

The bulk of this change is making all function pointers per-context
instead of global, and loading the OpenGL library dynamically. As a side
effect we're closer to Gio tolerating a platform without any OpenGL
implementation. For example, Apple has deprecated OpenGL and OpenGL ES
on its platforms and may remove them in the future.

Note that as a side-effect of this change, Gio needs Go 1.16 or newer to
run on iOS.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-05-18 14:26:45 +01:00
Elias Naur 21c319ace5 gpu/internal/opengl,internal: move sRGB emulation to OpenGL driver
There is only one driver but several backends (EGL, WebGL).

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-05-16 10:44:45 +02:00
Elias Naur d6859744ba internal/gl: unexport GetStringi
It's only used for the backwards incompatible macOS GL core profile.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-05-13 20:37:39 +02:00
Elias Naur 551c43b502 internal/gl: tigthen C symbol visibility from hidden to static
Apparently, Cgo can link to static C functions from the preamble.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-05-13 20:27:39 +02:00
Elias Naur f930e3f3d7 internal/gl: implement glGetProgramBinary
Useful for debugging shader compiler issues, such as those that may
cause

https://github.com/linebender/piet-gpu/issues/83

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-04-18 17:20:19 +02:00
Elias Naur eeb045c59f internal/gl: use dlsym(3) to load ES 3 symbols
There was a special case for optional symbols for macOS/iOS. It turns out
dlsym(3) works as expected, so this change deletes the special case.

The change is required to make Gio work with ANGLE, which emulates
OpenGL ES on top of Metal.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-16 18:15:37 +01:00
Elias Naur c4850e876d internal/gl: remove redundant parentheses
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-11 19:04:34 +01:00
Elias Naur 5894127204 internal/unsafe: get rid of GoString
The only users were GOOS=windows code, which can use
golang.org/x/sys/windows.BytePtrToString instead.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-11 11:19:53 +01:00
Elias Naur 7bc0603d7e internal/gl: rename internal/glimpl
Now that the OpenGL driver package is named "opengl", we can finally get
rid of the ugly "glimpl" name.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-06 14:27:44 +01:00