Commit Graph

121 Commits

Author SHA1 Message Date
Timm Bäder
2d3e87da46 gl renderer: Try to fix border rendering 2017-12-21 19:12:32 +01:00
Timm Bäder
fd0b7caa7c gl renderer: Fix shadow shader
We need to take the alpha of the shadow color into account as well.
2017-12-21 19:12:32 +01:00
Timm Bäder
3b7cfd068b gl renderer: Implement simple border nodes 2017-12-21 19:12:31 +01:00
Timm Bäder
e95b356465 gl renderer: Implement simple shadow nodes 2017-12-21 19:12:31 +01:00
Timm Bäder
8c9e203458 gl renderer: Fix inset shadow offset calculation 2017-12-21 19:12:31 +01:00
Timm Bäder
47c4bf5be0 gl renderer: Implement unblurred outset shadows 2017-12-21 19:12:31 +01:00
Timm Bäder
5c7838e168 gl renderer: Rework program creation
Make sure all uniform names have to match between the shader names and
the _location integers we save in every Program struct.
2017-12-21 19:12:31 +01:00
Timm Bäder
388157b995 gl renderer: Implement unblurred inset shadows 2017-12-21 19:12:31 +01:00
Timm Bäder
6a1a70c677 gl renderer: Implement blur nodes 2017-12-21 19:12:31 +01:00
Timm Bäder
f4304336ea gl renderer: Don't pass MVP to shaders
We already pass both modelview and projection matrix individually.
2017-12-21 19:12:30 +01:00
Timm Bäder
4cf2a482ea gl: Add glyph cache
Based on the one used by the vulkan renderer
2017-12-21 19:12:30 +01:00
Timm Bäder
9b400134d5 gl renderer: Remove unused shaders 2017-12-21 19:12:30 +01:00
Timm Bäder
33aa61ef2c gl renderer: Save clip in every node 2017-12-21 19:12:30 +01:00
Timm Bäder
24e69bb877 gl renderer: Implement rounded clip nodes
mostly a proof of concept
2017-12-21 19:12:30 +01:00
Timm Bäder
4aa3f51016 test-render-nodes: Add color matrix test 2017-12-21 18:25:52 +01:00
Timm Bäder
6bce14bee2 Rework the GL renderer 2017-12-21 18:25:52 +01:00
Benjamin Otte
9048d40bc2 vulkan: Fix mask shader to premultiply color
The inColor wasn't premultiplied, so the resulting colors were wrong
with translucent borders.
2017-12-02 16:21:58 +01:00
Benjamin Otte
abc8d61730 vulkan: Fix border shader to premultiply color
The inColor wasn't premultiplied, so the resulting colors were wrong
with translucent borders.
2017-12-02 16:21:58 +01:00
Benjamin Otte
e1572e003a vulkan: No need to redefine gl_PerVertex
The compiler has those predefined, so use them.
2017-10-24 01:29:28 +02:00
Benjamin Otte
e4dbff6bfc vulkan: Delete unused shaders
These have been renamed to .frag/.vert, apparently the originals weren't
deleted.
2017-10-24 01:29:28 +02:00
Matthias Clasen
b564dd853c Avoid super-luminous pixels
The color-matrix shader was creating pixels with r,g,b > a in
some cases, which leads to unexpected test failures. In particular
this as visible the opacity render node test for opacity 0.
2017-10-19 15:16:54 +02:00
Matthias Clasen
76aa237cce Fix blendmode shader
My reading of the spec formulas was imperfect.
2017-10-08 21:12:22 -04:00
Matthias Clasen
5577fde990 vulkan: Rename blend pipeline to texture
This is what it does, and the name blend is easily
confused with blend-mode.
2017-09-29 23:08:09 -04:00
Matthias Clasen
485470511f vulkan: Update the outset-shadow fragment shaders
These were missing the blur-radius parameter that is written
by the vertex shader, causing Vulkan validation to complain.
2017-09-26 18:24:52 -04:00
Matthias Clasen
3c98b90fc6 vulkan: Implement nonseparable blendmodes
This is a directly-from-the-spec, unoptimized implementation.
2017-09-23 09:16:58 -04:00
Matthias Clasen
d61f6ff393 vulkan: Implement blend modes
This is another example for a 2-texture shader.
So far, only separable blend modes are implemented.
The implementation is not optimized, with an
if-else cascade in the shader.
2017-09-23 01:59:50 -04:00
Matthias Clasen
a75d995bd4 vulkan: Implement crossfade
This is the first shader using two textures. It almost works.
2017-09-22 22:16:10 -04:00
Matthias Clasen
9a1460218c vulkan: Quiet another validation warning
It complains if a vertex shader has an out that is not matched
to an in of the fragment shader.
2017-09-21 12:05:00 -04:00
Matthias Clasen
b0e8d8483d More work on text nodes
This commit takes several steps towards rendering text
like we want to.

The creation of the cairo surface and texture is moved
to the backend (in GskVulkanRenderer). We add a mask
shader that is used in the next text pipeline to use
the texture as a mask, like cairo_mask_surface does.
There is a separate color text pipeline that uses the
already existing blend shaders to use the texture as
a source, like cairo_paint does.

The text node api is simplified to have just a single
offset, which determines the left end of the text baseline,
like all our other text drawing APIs.
2017-09-10 14:36:26 -04:00
Patrick Griffis
a55b57caff build: Improve vulkan resource handling
This fixes the proper dependencies getting set up for generating
the shaders and only the necessary things getting rebuilt on
resources changing in gsk.
2017-09-05 15:18:56 -04:00
Matthias Clasen
7bb5b8df0b A somewhat working blur shader
This is a very direct implementation of a Gaussian blur,
without any optimizations.
2017-09-04 23:32:31 -04:00
Matthias Clasen
86c0c243a0 Add rules to regenerate all shader variants
We were missing rules to build the clip variants of
the shaders.
2017-09-03 19:58:41 -04:00
Emmanuele Bassi
4904491b77 build: Move Vulkan shader handling to its own directory
Spooky action at a distance is not really allowed in Meson, so the rules
to generate the SPV files should go in their own directory.

Tested by: Rico Tzschichholz <ricotz@ubuntu.com>
2017-08-15 17:07:21 +01:00
Timm Bäder
fbada8e758 glrenderer: Handle color nodes 2017-03-31 09:50:39 +02:00
Benjamin Otte
ee9828d49c vulkan: Fix copy/paste error 2017-01-18 16:46:04 +01:00
Benjamin Otte
12637195de vulkan: Add compiled shaders
I forgot to include them when adding the shaders.
2017-01-18 16:42:01 +01:00
Benjamin Otte
cde933ebd9 vulkan: Compute right size for outset shadow
We were emitting the box and not the shadow box as the rectangle. So we
didn't draw any shadows. Oops.
2017-01-18 16:39:27 +01:00
Benjamin Otte
bd24ca5b18 vulkan: Add support for unblurred box-shadow 2017-01-18 04:13:56 +01:00
Benjamin Otte
6bec7aae89 vulkan: Generate clip shaders from same source
Instead of having 3 different shaders for the different clipping
versions, just have one shader and use a preprocessor define to use
different clip functions.

That preprocessor define is set in the Makefile.

Also use foo.frag and foo.vert as the file extensions instead of using
foo.frag.glsl and foo.vert.glsl, as that's what glslc suggests as
extension.
2017-01-17 06:17:55 +01:00
Benjamin Otte
3768c676c6 vulkan: Add clip.vert.glsl
Implement clipping the same way as in the last commit for the
fragment shaders.
2017-01-17 06:17:55 +01:00
Benjamin Otte
cf65443fb3 vulkan: Add a clip.frag.glsl include
This include is supposed to handle clipping for the different clipping
methods.

So far, we only use it in the rounded rect cases.
2017-01-17 06:17:55 +01:00
Benjamin Otte
6a60e335cd vulkan: Add push constants to fragment shader
That way we don't need to move the clip rounded rect manually through
the vertex shader into the fragment shader but can just look at the push
constants.

Simplifies shaders a lot.
2017-01-17 06:17:55 +01:00
Benjamin Otte
c7d899c535 vulkan: Move push constants into their own header
This is the first step towards easing maintenance of the Vulkan shaders
by moving common code into headers.
2017-01-17 06:17:55 +01:00
Benjamin Otte
b186bce7ff vulkan: Add shader for border rendering 2017-01-11 18:33:09 +01:00
Benjamin Otte
f05f0377df vulkan: Modernize blend pipeline
- Rename from blit => blend
- Use instances
- Add clip versions
2017-01-04 13:22:57 +01:00
Benjamin Otte
1aa0f79e8b vulkan: Make the effect renderer take matrix + offset
This is in preparation for the new color matrix node.

I don't think keeping support for a separate opacity shader is worth it.
2016-12-31 14:37:20 +01:00
Benjamin Otte
91741f6b63 vulkan: Handle opacity nodes
Well, "handle" them actually. We still draw the node's child using
Cairo, but we apply the opacity manually now.
2016-12-31 02:49:47 +01:00
Benjamin Otte
af917c4ade vulkan: Handle linear gradients
Note: We interpolate premultiplied colors as per the CSS spec. This i
different from Cairo, which interpolates unpremultiplied.

So in testcases with translucent gradients, it's actually Cairo that is
wrong.
2016-12-26 17:22:02 +01:00
Benjamin Otte
3c8518dce3 gsk: Add missing Mozilla copyright header
I stole one of their shader functions, and if I steal, I might as well
do it right.
2016-12-26 17:22:01 +01:00
Benjamin Otte
5878f9d8af vulkan: Add shader for color drawing with rectangle clip 2016-12-25 06:23:12 +01:00
Benjamin Otte
b30225e67c vulkan: We use VK_FORMAT_B8G8R8A8_UNORM
... not SRGB. SRGB messes up alpha compositing, GdkRGBA and everything
else.
2016-12-25 06:23:12 +01:00
Benjamin Otte
aa0ec774bf vulkan: Add proof-of-concept clip implementation
We can now clip to cicular rounded rectangles when drawing colors.
2016-12-24 06:19:16 +01:00
Benjamin Otte
81c487b841 vulkan: Fold clip into push constants
As a side effect, the clipping data is now available inside shaders.

Not that any shader would use them yet, but they could!
2016-12-24 06:19:16 +01:00
Benjamin Otte
1760e0d3f3 vulkan: Get rid of color in push constants
The color comes in instance data now, no need to abuse push constants
for it.
2016-12-20 18:01:11 +01:00
Benjamin Otte
b04eecf860 vulkan: Pass color rects in instance data
This way, we don't need push constants or per-vertex data, we can render
colored rectangles completely via instance data.
2016-12-20 18:01:11 +01:00
Benjamin Otte
4c74695a85 vulkan: Don't pass texture coordinates to the color pipeline 2016-12-20 18:01:11 +01:00
Benjamin Otte
08a2a29c26 vulkan: Add infrastructure for multiple pipelines
And use it to draw solid colors with a 2nd pipeline.
2016-12-20 18:01:11 +01:00
Benjamin Otte
583956266e vulkan: Make MVP matrix available to vertex shader
We use push constants for this.
2016-12-09 18:35:51 +01:00
Benjamin Otte
3c4b952256 vulkan: Make GskVulkanRenderer work
We now create a Cairo renderer, render to an image surface and upload
and retnder it with Vulkan.
2016-12-09 18:35:51 +01:00
Benjamin Otte
a7cbbaf8fc gsk: Pass texture coordinates to Vulkan renderer
We just render the coordinates as color, we don't do anything with them
yet.
2016-12-09 18:35:51 +01:00
Benjamin Otte
2a0e7f8829 gsk: Loads of work on Vulkan backend
We can now upload vertices.

And we use this to draw a yellow background. Which is clearly superior
to not drawing anything.

Also, we have shaders now. If you modify them, you need glslc installed
so they can be recompiled into Spir-V bytecode.
2016-12-09 18:35:51 +01:00
Emmanuele Bassi
1ab1fd4391 Use the projection to flip around the content
Since we use an FBO to render the contents of the render node tree, the
coordinate space is going to be flipped in GL. We can undo the flip by
using an appropriate projection matrix, instead of changing the sampling
coordinates in the shaders and updating all our coordinates at render
time.
2016-10-18 11:49:10 +01:00
Emmanuele Bassi
03ab560fae gsk: Rename uniforms and attributes in shaders
Use appropriate names, and annotate the names with the types — 'u' for
uniforms, 'a' for attributes. The common preambles for shaders are split
from the bodies, so we need some way to distinguish the uniforms and the
attributes just from their name.
2016-10-18 11:49:09 +01:00
Emmanuele Bassi
c052443633 gsk: Use consistent naming for blend fragment shader
This should make it immediately clear if we're doing something wrong.
2016-10-18 11:49:08 +01:00
Emmanuele Bassi
0fbf638999 gsk: Add 'blit' program
For the root node we do not need to use blending, as it does not have
any backdrop to blend into. We can use a simpler 'blit' program that
only takes the content of the source and fills the texture quad with
it.
2016-10-18 11:49:08 +01:00
Emmanuele Bassi
a840c7f00c gsk: Add more modes to the blend shader
Use the compositing CSS spec at:

  https://www.w3.org/TR/compositing-1/#blending

For the implementation.
2016-10-18 11:49:07 +01:00
Emmanuele Bassi
28b490f14f gsk: Rework how GLSL shaders are built
The GL renderer should build the GLSL shaders using GskShaderBuilder.
This allows us to separate the common parts into separate files, and
assemble them as necessary, instead of shipping one big shader per type
of GL API (GL3, GL legacy, and GLES).
2016-10-18 11:49:07 +01:00
Emmanuele Bassi
638297a22e gsk: Allow sampling between parent and child nodes 2016-10-18 11:49:07 +01:00
Emmanuele Bassi
9d3ca22b4c gsk: Port GskGLRenderer to GLES
Use the appropriate API and shaders if the GdkGLContext was created for
OpenGL ES instead of OpenGL.
2016-10-18 11:29:34 +01:00
Emmanuele Bassi
eb9c0920ab gsk: Rename shaders for OpenGL 2016-10-18 11:29:34 +01:00
Emmanuele Bassi
7afdd3fdb5 Initial implementation of GSK rendering pipeline
GSK is conceptually split into two scene graphs:

 * a simple rendering tree of operations
 * a complex set of logical layers

The latter is built on the former, and adds convenience and high level
API for application developers.

The lower layer, though, is what gets transformed into the rendering
pipeline, as it's simple and thus can be transformed into appropriate
rendering commands with minimal state changes.

The lower layer is also suitable for reuse from more complex higher
layers, like the CSS machinery in GTK, without necessarily port those
layers to the GSK high level API.

This lower layer is based on GskRenderNode instances, which represent
the tree of rendering operations; and a GskRenderer instance, which
takes the render nodes and submits them (after potentially reordering
and transforming them to a more appropriate representation) to the
underlying graphic system.
2016-10-18 11:29:34 +01:00