Commit Graph

29 Commits

Author SHA1 Message Date
Elias Naur 78b6268f9b gpu/headless: plug resource leaks in tests
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-09-20 13:26:43 +02:00
Elias Naur 414be0a0b3 gpu: Merge GPU.Collect and GPU.Frame
There's no meaningful reason to have them separate. The intention was to
enable rendering concurrent with other processing, but that's gaining
framerate at the expense of input latency and complicating ImageOp
semantics.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-08-24 08:30:52 +02:00
Elias Naur 3b2992c37e gpu,app/internal/wm: add Metal port
The OpenGL (ES) implementations on Apple platforms are deprecated and
don't support GPU compute programs. This change adds support for the
replacement, the Metal GPU API.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-08-21 08:31:46 +02:00
Elias Naur 58cc817e5f gpu,gpu/internal: move vertex buffer stride to pipeline state
Metal needs the vertex stride at pipeline creation.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-08-21 08:31:46 +02:00
Elias Naur 1af910959b gpu: fold buffer clearing into framebuffer bind
In Metal, clearing a framebuffer is most efficiently done during bind.
Modify our driver accordingly.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-08-21 08:31:46 +02:00
Elias Naur d38c78d7ac gpu,gpu/internal: move InputDesc back from gioui.org/shader module
It was moved to gioui.org/shader by mistake.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-08-21 08:31:46 +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 6b537f0d4e gpu/headless: remove useless framebuffer bind
GPU.Frame now takes an explicit RenderTarget and it is no longer
necessary to bind the target.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-08-16 15:47:23 +02:00
Elias Naur 6c3711d95a gpu/headless: remove useless headless_gl.go abstraction
There is no longer any shared code between OpenGL backends (unlike
EGL backends).

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-08-16 15:47:23 +02:00
Elias Naur 6aee543234 all: switch to external shaders in the gioui.org/shaders module
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-08-08 13:47:41 +01:00
Elias Naur 18b4442393 all: remove Z buffer support
It is no longer needed by any rendering backend.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-08-08 13:47:37 +01:00
Elias Naur 2059862416 all: merge .m files with their .go counterparts
The only reason for separate files is Objective-C callbacks into Go,
or when the Go side is common, yet the Objective-C side differs from
macOS to iOS.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-08-08 13:46:16 +01:00
Elias Naur 7d84e419c9 gpu,gpu/headless,app/internal/wm: add explicit RenderTarget API
Both the OpenGL and the Direct3D API are stateful and gpu.GPU renders to
the render target current when Frame is called.

Modern GPU API such as Metal don't have a concept of a current render
target, and the target even changes each frame.

Add RenderTarget and add an explicit target argument to GPU.Frame as
well as the underlying driver.Device.BeginFrame.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-08-08 13:45:23 +01:00
Elias Naur b3a8c24334 gpu/internal/driver: rename TextureFormatSRGB to TextureFormatSRGBA
The format implies an alpha channel; name it accordingly.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-07-29 08:37: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 200957f924 gpu/headless: remove macOS context preparation no longer necessary
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-06-11 09:48:25 +02:00
Elias Naur 39775f555a gp/internal/opengl: support sRGB emulation for embedded content
Programs such as gio-example/glfw rely on Gio drawing blending with
the framebuffer background. This change makes it so when sRGB emulation
is active.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-05-16 18:17:00 +02: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 2c07b2dc0e headless: clear background to transparent, not white
The clear background is the most useful, and the old behaviour can
be achieved by filling the entire viewport with a white paint.ColorOp.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-05-03 11:31:45 +02:00
Elias Naur 23e0c898ef gpu/internal/driver: use strings for generated DXIL assembly
Literal strings are a more compact than literal byte slices. A future
change will switch to go:embed to save even more space.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-04-12 12:44:06 +02:00
Elias Naur fbee13a07d gpu/internal/convertshaders,gpu: represent converted shaders with raw literals
Raw strings with linebreaks are easier to read and produce smaller
diffs.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-04-12 12:43:46 +02:00
Elias Naur 2328ddfeca internal/byteslice: rename package unsafe
All functions left in the old package unsafe were provided byte slice
views of other types. Rename the package accordingly and avoid a name
clash with the standard library package unsafe.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-11 11:27:02 +01:00
Elias Naur 57750fc8a0 gpu/headless,gpu/internal: rename "backend" files and names to "driver"
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-08 18:20:11 +01:00
Elias Naur 69cff4b96b gpu/internal/driver,gpu/headless: don't y-axis flip OpenGL ReadPixels images
The CPU fallback of the compute renderer needs ReadPixels data in OpenGL
format (origin at bottom left). Unfortunately, the OpenGL driver
automatically mirrors images in the Y-axis to match the top left origin
image.RGBA.

Remove the mirroring from the driver and introduce a DownloadImage to
restore the old behaviour.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-08 18:12:33 +01:00
Elias Naur 26d9e7fe5f gpu/headless: rename "backend" to "dev"
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-06 14:27:44 +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
Elias Naur c799452c57 gpu/internal/driver: rename gpu/backend
There are no longer any importers of package backend outside of
gioui.org/gpu. Move it internally, and rename it to the slightly more
specific "driver" while we're at it.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-06 14:27:34 +01:00
Elias Naur 2c7aba9e7c gpu/internal/convertshaders: move internal/cmd/convertshaders
The convert program is only used by the shaders from package gpu, and
we're about to make the backend package imported by the program internal
to package gpu. Move the converter below package gpu.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-06 14:26:47 +01:00
Elias Naur 2a66bfb2b4 gpu/headless: move package app/headless
Package headless is more about rendering that windows. Move it
accordingly.

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