Commit Graph

19 Commits

Author SHA1 Message Date
Elias Naur 9366fce0f3 internal/scene: extract compute shader encoding to a separate package
We're about to encode clip.Paths with the format compatible with the
compute renderer. This change extracts the encoding to a re-usable
package.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-11 18:54:12 +01: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 4b377aa896 gpu: resize compute output when it becomes smaller
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-09 18:27:10 +01:00
Elias Naur 3a3ec711d3 gpu: [compute] cache rendered materials
This change tracks materials so that only the updated materials needs to
be rendered.

Materials are likely cheap to render each frame, at least compared to
the rest of the compute pipeline. However, the CPU fallback must
transfer all changed materials to CPU memory, and a cache is a great
improvement over fetching all materials every frame.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-09 13:25:24 +01:00
Elias Naur 1b142c07e0 gpu: separate the construction and placing of material quads
We're about to cache the transformed materials. It's easier to do when
quads can be constructed before determining their atlas position.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-08 20:10:11 +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 25a19481e3 gpu,gpu/backend: don't assume constant output framebuffer
Return the output framebuffer from BeginFrame, to make it clear that
it may change between frames. Delete CurrentFramebuffer which is no
longer needed.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-02 20:43:59 +01:00
Elias Naur f973b3f384 gpu,gpu/backend: [compute] handle loss of buffer contents during download
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-02-24 18:48:03 +01:00
Elias Naur c849c5b77f gpu: [compute] use correct usage flags for output image
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-02-22 17:19:15 +01:00
Elias Naur 2feec23561 gpu: [compute] fix path gaps by eliminating redundant path points
See https://github.com/linebender/piet-gpu/issues/62 for description
of the issue. The fix is the Gio copy of the piet-gpu fix.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-02-18 10:30:05 +01:00
Elias Naur b5d21b209c gpu: [compute] use array type for scene elements
All scene elements have a fixed size in uint32s. Model them accordingly.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-02-18 10:30:05 +01:00
Elias Naur c9a8265126 gpu: [compute] pre-transform images before rendering
We're about to change the last stage of the compute pipeline to only
accept images, not sampled textures. This change prepares materials
for pixel-aligned image copying by pre-rendering images to a texture,
applying transforms.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-02-18 10:30:05 +01:00
Elias Naur 8ec47dcae3 gpu: give compute.atlas a more precise name, reset atlas efficiently
Refactor only, in preparation for adding another atlas with pre-processed
materials.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-02-09 11:08:40 +01:00
Elias Naur 84b586ae6c gpu: don't automatically clear screen before rendering
Gio UI may be overlaid on top of custom graphics such as in the glfw example.
That will only work if Gio doesn't clear the screen (to white).

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-01-22 18:33:34 +01:00
Elias Naur 72a3248041 gpu: implement GPU profiling for compute
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-01-03 13:27:59 +01:00
Elias Naur 8662790f10 gpu: remove unused field
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-01-03 13:05:10 +01:00
Elias Naur bb9252f9d4 gpu: cache path data for compute
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-01-02 20:18:05 +01:00
Elias Naur 23f710910f gpu: reclaim stale images in atlas texture before resizing
Issue found by Anthony Starks.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-01-02 18:28:41 +01:00
Elias Naur d23514fd58 gpu: add compute implementation
The old renderer is still the default, so the new compute renderer will only be
used in the rare case the old renderer is not supported but the new is. That
happens on the Samsung J2 Prime and Moto C Android phones. Or set the
GIORENDERER environment variable to "forcecompute" to disable the old renderer:

$ GIORENDERER=forcecompute go run ...

Missing features:
- Gradients are not supported yet, and render as a solid color.
- Draw timers are not added, and profile.Events are not emitted.
- Stroked paths may in some cases appear corrupted because their clip
  outlines are not continuous when generated by Gio. Sebastien is
  working on a fix.
- The new renderer shares most CPU-side logic with the old renderer,
  resulting in several inefficient conversion steps between the old
  operations representation and the new. This is slower, but minimizes
  divergence in features and bugs between the two renderers.

Roadmap:
- The compute renderer supports features that Gio does not yet
exploit: stroked paths with round caps, transformations, lines,
cubic beziér curves.
- More stroke styles and maybe dashed strokes natively in shaders.
- Metal and Direct3D ports.

The most important feature is porting the renderer to run on the CPU. A
CPU renderer will both support Gio on devices with insufficient GPU
support, and allow us to remove the old renderer. Two renderers is twice
the maintenance but the feature set of the weakest implementation.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-31 17:21:35 +01:00