Commit Graph

76 Commits

Author SHA1 Message Date
Matthias Clasen
4d7b8f5a66 vulkan: Fix blendmode coordinate handling
We were node handling coordinates correctly when dealing
with differently sized child nodes in a blendmode node.
This was showing up in the gtk4-demo css blendmode example,
for blendmodes other than normal.
2017-10-08 09:02:35 -04:00
Matthias Clasen
fe6e80fdde vulkan: Fix repeat node coordinates
We were not treating non-trivial child bounds right at all.
This was visible in the css blendmode cmyk example in gtk4-demo,
for the normal blendmode.
2017-10-08 09:02:35 -04:00
Benjamin Otte
43c212ac28 build: Enable -Wswitch-enum and -Wswitch-default
This patch makes that work using 1 of 2 options:

1. Add all missing enums to the switch statement
  or
2. Cast the switch argument to a uint to avoid having to do that (mostly
   for GdkEventType).

I even found a bug while doing that: clearing a GtkImage with a surface
did not notify thae surface property.

The reason for enabling this flag even though it is tedious at times is
that it is very useful when adding values to an enum, because it makes
GTK immediately warn about all the switch statements where this enum is
relevant.
And I expect changes to enums to be frequent during the GTK4 development
cycle.
2017-10-06 21:23:39 +02:00
Benjamin Otte
c1e9869329 build: Don't turn off critical warnings
-Wint-conversion is important because it checks casts from ints to
pointers.

-Wdiscarded-qualifiers is important to catch cases where we don't
strings when we should.
2017-10-06 16:03:08 +02:00
Matthias Clasen
3aaea0ef40 Clip intermediate textures
In some cases, we were creating gigantic intermediate textures
only to clip out a small section afterwards (e.g. in the listbox
example in gtk4-demo). This is wasteful if we apply effects on
the texture, such as blur or color-matrix. So, clip the dimensions
of the intermediate texture with the current clip. To make this
feasible, we move the texture coordinate computation out of the
pipeline setup functions into the node_as_texture function where
this clipping happens.

One extra complication we encounter is that the node might get
clipped away completely. Since Vulkan does not allow to create
empty images, we bail out in this case and not draw anything.

With these changes, the listbox example in gtk4-demo goes from
32M pixels of intermediate texture to 320000.
2017-10-01 19:22:04 -04:00
Matthias Clasen
50bea37320 Reshuffle things a little bit
Instead of having a function with lots of arguments in
GskVulkanRender that we call from GskVulkanRenderPass which
then just calls back into GskVulkanRenderPass, just create
the new render pass object locally, and an api to add it
to the list that GskVulkanRender keeps. This makes it
a lot easier to preserve all the relevant parameters from
the parent render pass.
2017-09-30 17:58:23 -04:00
Matthias Clasen
4c29102753 vulkan: Add a counter for intermediate textures
Count how many pixels of intermediate textures we create.
If we can count it, we can optimize it.
2017-09-30 17:58:23 -04:00
Matthias Clasen
836e18cc96 Support repeat nodes in vulkan
We can use the texture pipeline for this, with a repeating sampler.
2017-09-29 23:08:14 -04:00
Matthias Clasen
31d8fe3a6a vulkan: Add a repeating sampler
None of the render ops use it, yet.
2017-09-29 23:08:14 -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
538e7c7982 vulkan: Allow to control scaling in the blend pipeline
Pass in a second rect that defines the size of the texture.
Update the sole caller to pass in the same rect, for unchanged
behavior.
2017-09-29 22:12:25 -04:00
Matthias Clasen
e91051a562 vulkan: Fix setup for dependent render passes
We were not correctly preserving the modelview transform.
2017-09-29 15:58:16 -04:00
Matthias Clasen
d61a715909 vulkan: Implement multiple render passes
Whenever we need a node as a texture, we now start a new render
pass that renders the node into a new intermediate texture, and
set up a semaphore to make the current render pass wait for it.

As part of this reorganization, much of the setup and drawing
code moved from gskvulkanrender.c to gskvulkanrenderpass.c.
2017-09-28 08:39:22 -04:00
Matthias Clasen
cbf897ab22 Add an api to get the vertex data for a render pass 2017-09-28 08:39:22 -04:00
Matthias Clasen
ae2c645a2a gsk: report fallback pixels as a profile counter
This makes the value show up in the inspector without
any extra work. We report the number per-frame, since
that makes the most sense.
2017-09-25 21:02:21 -04:00
Matthias Clasen
4970404d33 gsk: count fallback pixels
Always helps to have some measure of progress.
2017-09-25 09:28:18 -04:00
Matthias Clasen
a7f077a3a9 Cosmetics
Go back to a single GskVulkanOpRender that can
handle 0, 1 or 2 sources.
2017-09-23 09:47:05 -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
8ad0539cf7 vulkan: Drop GskVulkanPipelineLayout
We already move the descriptor set layout out of it,
so we can just as well keep the pipeline layouts in
the render object as well, and get rid of this extra
object. Update all callers.
2017-09-22 22:16:09 -04:00
Matthias Clasen
9b0ee4ac99 Allow different pipeline layouts
These are differentiated by the number of textures; currently
we have shaders with 0 and 1 textures.
2017-09-22 22:16:09 -04:00
Matthias Clasen
baeff2a49b Make the glyph cache grow as needed
Make it possible to have more than one texture in the
glyph cache, and create new ones when we run out of space
in the existing ones.
2017-09-20 23:26:14 -04:00
Matthias Clasen
4d4a0212fb vulkan: Better glyph cache api
Move the glyph caching api to something that can support using
multiple textures. We now split the text render ops into multiple
ops for different textures, and make each op render just a substring
of the text node's glyph string.
2017-09-20 23:26:14 -04:00
Matthias Clasen
47cf17c70c vulkan: Add a primitive glyph cache
This is just a proof of concept - we use a single 1024x1024 surface,
and just give up when we run out of space. The cache is populated
incrementally, and items are never removed.
2017-09-10 21:56:37 -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
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
2101f26b49 vulkan: Add more debug spew 2017-09-03 11:34:41 -04:00
Emmanuele Bassi
9442ef055d gsk: Mark internal symbol as static
Nothing uses this function outside of GskVulkaneRenderPass.
2017-04-26 17:27:24 +01:00
Benjamin Otte
bd24ca5b18 vulkan: Add support for unblurred box-shadow 2017-01-18 04:13:56 +01:00
Benjamin Otte
01d16524da vulkan: Add fallback message for node-as-texture
This is mainly to motivate me to implement it.
2017-01-17 06:38:36 +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
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
2fe01a5b57 vulkan: Optimize getting textures
When we already have a texture or know we need to upload, just do that
instead of rendering to Cairo.
2017-01-01 19:53:36 +01:00
Benjamin Otte
e18d5ca835 vulkan: Add support for color matrix nodes
@keyframes weee {
    100% { filter: hue-rotate(1turn); }
}

.background {
    animation: linear infinite 3s weee;
}
2016-12-31 14:37:20 +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
Chun-wei Fan
49a782413c gsk: Fix build on Visual Studio
One cannot use #if...#endif within macro calls in Visual Studio and
possibly other compilers, and there are more uses of VLAs that need to be
replaced with g_newa().

There were also checks for the clip type in gskvulkanrenderpass.c which
were possibly not done right (using the address of the type value to check
for a type value), which triggered errors as one is attempting to compare
a pointer type to an enum/int type.

https://bugzilla.gnome.org/show_bug.cgi?id=773299
2016-12-29 17:52:52 +08: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
5878f9d8af vulkan: Add shader for color drawing with rectangle clip 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
18b65a2378 vulkan: Change handling of push constants
Instead of storing the wire format, store the true structs and only
convert to the wire format when needed.
2016-12-24 06:19:16 +01:00
Benjamin Otte
b11b7dfb1a gsk: Add debug category for fallbacks
... and use it for the cases in Vulkan where we fall back to Cairo.
2016-12-24 06:19:16 +01:00
Benjamin Otte
2bca24c455 gsk: Add GskVulkanClip
This is now tracking the clips added by the clip nodes.
If any particular node can't deal with a clip, it falls back to Cairo
rendering. But if it can, it will render it directly.
2016-12-24 06:19:16 +01:00
Benjamin Otte
89d38ae93f vulkan: Try combining draw calls
This gives a 5-7% speedup in the case where we're just drawing N colors
and nothing else. So it;s not tremendously useful, but noticeable.
2016-12-24 06:19:16 +01:00
Rico Tzschichholz
2b4dfeec7c gsk: Fix build of 22110ef5a4 2016-12-21 18:15:50 +01:00
Alexander Larsson
22110ef5a4 gsk: Add bounds member to RenderNode
Instead of constantly recalculating this (especially recursively for
parents!) we do it only on construction, because everything is
immutable anyway. Also, most nodes had a bounds already and can
use the new parent member instead.

We also do direct access to the node bounds rather than calling
gsk_render_node_get_bounds in various places, which means
we do less copying.
2016-12-21 14:01:34 +01:00
Benjamin Otte
1b90ce6b33 vulkan: Remove color from push constants
It's now handled by the color pipeline.
2016-12-20 18:01:11 +01:00