Commit Graph

1097 Commits

Author SHA1 Message Date
Elias Naur b9d131409e gpu/gl: tolerate programs with no attributes
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur 0be4dd9af0 app/internal/cmd/convertshaders: use backend types directly
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur fd61c226d4 internal/cmd/convertshaders: move shader converter to separate package
To use the converter from other packages, make the converter a
runnable command.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur 5cd5d49108 gpu/backend: move backend interface types to a separate package
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur 50e98d1e13 app/headless: handle error from Framebuffer.ReadPixels
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur 2df50dda8e app/headless: remove unusued parameters to newContext
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur dfc1503c00 gpu: replace Backend.DefaultFramebuffer by Backend.CurrentFramebuffer
DefaultFramebuffer was set up at Backend creation time, which is
difficult to predict. Instead, let GPU query and cache the current
FBO when created.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur b4c163e437 gpu: Move Bind methods to Backend
Having Backend.Bind* methods better matches both opengl and d3d.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur 055fa97343 app/headless: Release Window after testing it
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur f305f71b20 app/headless: re-implement Screenshot on top of Backend
The new Framebuffer.ReadPixels method is enough to implement
Window.Screenshot. Use that instead of the OpenGL-specific
implementation.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur e4a927982d gpu: add Framebuffer.ReadPixels
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur 6fd545a4d8 gpu: add depthBits parameter to NewFramebuffer
Along with ReadPixels in the next change, a Framebuffer with depth is enough to
implement screenshot functionality on top of any Backend.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur 10484d26f3 gpu: return and handle errors from Backend.New... methods
"handling" means panicing, but at least the panicing is moved up
a layer, leaving future changes to do it properly in GPU.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur 9c984e03b8 gpu: drop Framebuffer.IsComplete in favour of an error from NewFramebuffer
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur eb7e11ee8e gpu: specify target Texture Backend.NewFramebuffer
OpenGL doesn't care if the texture to a framebuffer changes, but
Direct3D does. Change Backend to better match both APIs.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur cae97a9861 gpu: add binding flags to Backend.NewTexture
Direct3D needs to know the texture bind usage up front, in particular
whether the texture is going to be used as a render target.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur 411f566e3f gpu: rename BufferType to BufferBinding and make it a set
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur 744a962beb gpu: remove Backend.NilTexture
It serves no purpose other than paranoia. Perhaps buggy drivers exists that
require unused texture slots cleared before drawing to a texture, but if so the
workaround belongs in the GL backend.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur a4ee72ed28 gpu: remove Backend.Resize and fully specify format in Backend.NewTexture
Re-create textures instead to better match direct3d.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur 4e3bfd5b1b gpu: setup OpenGL ES texture uniforms automatically from shader metadata
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur 5c359bbf89 gpu/shaders: delete unused uniform
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur 5ba7854656 gpu/gl: fix offset calculation in DrawElements
The offset argument to DrawElements is in 16-bit shorts, while the
underlying DrawElements use byte offsets.

No users of DrawElements use a non-zero offset, so nothing changed.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur 646a767665 gpu,gpu/gl: implement shader uniform buffers
Emulate them for the OpenGL ES backend because 2.0 doesn't support uniform
buffers. The future d3d backend only supports uniform (constant) buffers.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur ef3e94e7a7 gpu: add NewBuffer and Buffer.Upload for creating mutable buffers
We're going to need them for shader uniform buffer storage.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur fbb7fffd46 gpu: rename NewBuffer to NewImmutableBuffer
Prepare for adding NewBuffer for mutable buffers.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur f5905b3ca8 gpu: rename BufferTypeData to less vague BufferTypeVertices
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur 826ab9e65b gpu,gpu/gl: specialize Buffer.Bind to Buffer.BindIndex
Direct3D can't support a generic Bind, and we don't need it now
BindVertex was added.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur 9cdc8e6182 gpu,gpu/gl: introduce InputLayout and use shader reflection data
InputLayout is the abstraction for the mapping between vertex data and
shader inputs. The mapping is implicit in OpenGL but explicit in
Direct3D.

Infer the attribute name location index using shader reflection data,
and get rid of a parameter to NewProgram.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur ac7029fa24 gpu/internal/shaders: generate shader variants
We're about to add Direct3D support, where shaders are written in
HLSL. Rather than write shaders twice (or more), convert them to
a GLSL variant understood by the glslcc cross-compiler and generate
the OpenGL ES 2.0 and HLSL variants. The HLSL is used by a future
change.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur 1f43bfa0e4 app/internal/egl: remove Windows error message dialog when EGL fails to load
The error message is not appropriate where there are multiple backends,
and there's a much better chance Gio will run with the direct3d backend
where no external DLLs are required.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur cf7d702a39 app/internal/window: remove unsafe cast
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur 05485a79a6 app/internal/srgb: rename NewSRGBFBO to New and SRGBFBO to FBO
The srgb package was recently created to contain just the sRGB
emulation, but the names weren't shortened accordingly.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur b34216c124 app/headless: remove OpenGL assumptions
To prepare package headless for multiple backends, refactor the common headless
driver to no longer assume an OpenGL context. Instead, introduce a headless
backend type and the OpenGL implementation, glBackend.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:21 +01:00
Elias Naur 94fdc26cb5 app,app/headless: expose Backends from window and headless contexts
This is a refactoring change to prepare for another gpu.Backend
implementations.

Notably, app/loop.go no longer imports gpu/gl.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:21 +01:00
Elias Naur f62725ea77 gpu: make Buffers immutable
The GPU implementation only uses immutable buffers so far, so let's
make it easy and performant for the backends.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:21 +01:00
Elias Naur 49365dbcc5 gpu: allocate path draw index buffer once
Before this change, the index buffer would start empty and grow up to the
maximum size (128kb). It would never shrink. We're about to tighten the GPU
buffer API to be immutable for performance and to better match Direct3D, so
allocate the index buffer once at startup, and limit it to a reasonable size.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:21 +01:00
Elias Naur 8a2837531e io/router: add pointer routing test
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 09:22:48 +01:00
Elias Naur 5a3ffad00a io/router: expand Router.Add to accept multiple events
Niver API and useful for testing.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 09:08:56 +01:00
Elias Naur a995e9ea6c widget: remove unused Button.prevClicks
It was left over from a previous approach to enable the program
to decide the ordering between calls to Layout vs Clicked.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 08:35:08 +01:00
Elias Naur e3f8d1a1af app/internal/window: (Windows) report pressed buttons for Move events
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-26 10:57:30 +01:00
Elias Naur 5406a13257 README.md: move COPYING license verbiage back to the README.md file
Now that pkg.go.dev supports the UNLICENSE, the COPYING file confuses
the automatic license detection. Move the license text back to README.md.

This is merely a cosmetic change, there are no licensing changes to
the project.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-25 12:13:24 +01:00
Elias Naur 73b99a80e2 widget: flush ChangeEvents even if no key events are available
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-23 08:51:47 +01:00
Daniel Martí 150b34aede .builds: re-add sway on Debian
It passes now, thanks to the recent work to add retries to screenshots.

If it turns out to still not be reliable enough, we can look at this
again.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-02-20 09:12:02 +01:00
Larry Clapp 0dd77be975 widget/material: allow button Inset to be customizable
Signed-off-by: Larry Clapp <larry@theclapp.org>
2020-02-17 15:37:08 +01:00
Roy Lee ae6161dfb6 app/internal/wayland: Added header dir for wayland in openSUSE
Added a cflag -I to provide wayland header files in openSUSE.

Fixes gio#76

Signed-off-by: Roy Lee <royyhlee@gmail.com>
2020-02-16 21:44:29 +01:00
Elias Naur 60904dd9a6 layout: fix typos
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-14 21:17:44 +01:00
Elias Naur 69dfd2e3a5 op/paint: add support for efficient ImageOp subimages
The new field ImageOp.Rect is initialized to cover the entire source
image, but can be modified to draw only a section of it.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-13 13:15:32 +01:00
steverusso fd5dfacb40 io/pointer: minor documentation update.
The `image.Rectangle` object should be passed to the `pointer.Rect` function.

Signed-off-by: steverusso <steverusso@protonmail.com>
2020-02-12 09:04:47 +01:00
Elias Naur e8add40440 example: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-11 15:41:01 +01:00
Elias Naur 6945a9062b gpu/gl: add detail to the float FBO error message
Updates gio#49

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-11 15:38:19 +01:00