Commit Graph

7 Commits

Author SHA1 Message Date
Viktor cee045bf92 gpu: build gpu data also when outside window
This commit fixes a bug where a shape first drawn off-screen
and later moved into screen would not display properly. Since we
cache CPU operations (vertex transform / construction) we need to
upload the constructed data to the GPU after it was build, or a later
frame will use non-initialized memory for it's draw call.

Note that this fix removes the optimization of not processing clip
paths outside the screen - but this is assumed to be uncommon except
when it is first drawn off screen to later be moved in (e.g. in a scrolling list)
in which case we do want to upload the data and prepare for that later
call.

This commit also does a few minor clean ups and adds a test case.

Signed-off-by: Viktor <viktor.ogeman@gmail.com>
2020-06-21 11:20:36 +02:00
Viktor 901478d102 gpu: avoid pointers of pathData
Save allocations by using pathData instead of *pathData.

Signed-off-by: Viktor <viktor.ogeman@gmail.com>
2020-06-21 11:20:36 +02:00
Viktor 062cb210ea gpu: optimize opCache to avoid expensive map lookups
Benchmarking showed that the double map access calls
were a bottleneck. Rework the cache to avoid half of them.

The simplest, naive approach would have been to store a
pointer to a struct with a keep field in the map, allowing cheap
update and frame() operation. Benchmarking showed that the
increased GC pressure of that approach decreased performance
however.

Signed-off-by: Viktor <viktor.ogeman@gmail.com>
2020-06-21 11:20:36 +02:00
Viktor f11a656426 gpu: exploit pathCache in collectOps
Previously the cache was only filled during gpu-buffer creation,
resulting in extra work on the CPU to transform vertices if the same
shape was used multiple times in the same frame. Cases such as font
rendering was cached already before this change as it is drawn in it's
own op.Ops that is never reset - and thus re-used from one frame
to the next.

Since we are now calling put() twice per frame an update should no
longer panic.

Signed-off-by: Viktor <viktor.ogeman@gmail.com>
2020-06-21 11:20:36 +02:00
Viktor 380938c602 gpu: cache quad splitting and transform
Cache also CPU operations by moving pathCache into
drawOps and use it in collectOps to avoid splitting and
transformation of quads if in cache. In order to support
this use a concrete type in opCache instead of interface.

Signed-off-by: Viktor <viktor.ogeman@gmail.com>
2020-06-21 11:20:36 +02:00
Elias Naur 3ae5a37c24 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>
2020-02-10 18:22:57 +01:00
Elias Naur 3b6646933d gpu: expose the rendering implementation
The rendering implementation is needed for using Gio UI with external
window libraries such as GLFW. Expose it in the new package gpu.

Updates #26

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