Commit Graph

273 Commits

Author SHA1 Message Date
Benjamin Otte
e4d0459d52 vulkan: Reallocate descriptor sets
Because wee now reset the descriptor pool, we also need to reallocate
the descriptor sets.
2017-01-06 18:10:12 +01:00
Benjamin Otte
5a6ead8760 vulkan: Keep vertex buffer around until cleanup
Don't just free it while the command buffer using it is still pending.
2017-01-06 17:16:38 +01:00
Benjamin Otte
639b5ffb9b vulkan: Reset descriptor pool
We don't want the pool to reference images we're gonna destroy. Drivers
don't like that at all.
2017-01-06 16:31:53 +01:00
Benjamin Otte
833607c19e gsk: Don't use wildcards
Explicitly list all the shaders, so new ones get picked up properly and
cause the resource file to be regenerated (due to Makefile.am changing).
2017-01-06 16:31:53 +01:00
Benjamin Otte
078902e8b0 gsk: Have variables for resources
Instead of relying on --generate-dependencies and the resource file,
actually list the resources in Make variables.

Fixes make not building new shaders because they're not inside the
resource file.
2017-01-06 16:31:53 +01:00
Georges Basile Stavracas Neto
33a6347766 vulkanrender: Create descriptor pools with correct descriptor number 2017-01-06 02:46:27 -02:00
Georges Basile Stavracas Neto
67894ace64 vulkanpushconstants: Don't report invalid ranges
Vulkan doesn't accept empty ranges, so simply don't report
them.
2017-01-04 18:40:42 +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
b993acfe2c gsk: Add GskRepeatNode
Also add gtk_snapshot_push_repeat() and use that to draw backgrounds.

With that change, CSS background snapshots are created without Cairo
nodes.
2017-01-01 19:53:36 +01:00
Benjamin Otte
2571036c07 gsk: Turn GskTexture into a GObject 2017-01-01 19:53:36 +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
7540702cf0 gsk: Add GskColorMatrixNode
This node essentially implements the feColorMatrix SVG filter. I got the
idea yesterday after looking at the opacity implementation.

It can be used for opacity (not sure if we want to) and to implement a
bunch of the CSS filters.
2016-12-31 02:49:47 +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
391ea68671 Visual Studio builds: Include Vulkan sources in GSK
...but disable them for now.  Configs will be added for the projects to
support Vulkan-enabled builds which will then enable the builds of these
sources.  Extra commands and items will be needed for the GSK resources
along with ensuring GSK_RENDERER_GSK being defined for the build of GDK,
GDK-Win32 and GSK so that the builds of Vulkan-enabled builds can be done
properly.

Filter out the Vulkan sources from the 'dist hook' rules in
gsk/Makefile.am as we don't want to in turn include them twice in the
projects when the 'make dist' is performed on a system with Vulkan
builds enabled.
2016-12-30 01:08:07 +08: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
Chun-wei Fan
1e084567f9 gsk/gskrendernodeimpl.c: Avoid VLAs
Use g_newa() instead of VLAs, as VLAs may never be supported by some
compilers as it became optional in C11 and there are concerns about their
implementations in compilers that do support it.

https://bugzilla.gnome.org/show_bug.cgi?id=773299
2016-12-29 17:41:59 +08:00
Benjamin Otte
68b39a4727 gsk: Add GSK_RENDERING_MODE=full-redraw
Forces a full redraw every frame.
This is done generically, so it's supported on every renderer.

For widget-factory first page (with the spinner spinning and progressbar
pulsing), I get these numbers per frame:

action                  clipped         full redraw
snapshot                   0ms           7-10ms
cairo rendering            0ms          10-15ms
Vulkan rendering         3-5ms          18-20ms
Vulkan expected *          0ms            1-2ms
GL rendering            unsupported     55-62ms

* expected means disabling rendering of unsupported render nodes,
instead of doing fallback drawing. So it overestimates the performance,
because borders and box-shadows are disabled.
2016-12-27 00:48:00 +01:00
Benjamin Otte
a5f8a74ec1 vulkan: Only render minimal region
It's faster to render once for every rectangle in the clip region than
rendering the outline of the clip region.
Especially because this reduces the time necessary to build up the frame
data.

In widget-factory (where we have 3 rectangles), this leads to a 5x
speedup in the rendering time rendering alone.
Snapshotting time goes from 10ms to ~1ms, which is another huge
improvement.
2016-12-27 00:31:33 +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
5017c3be65 gsk: Insist on ordered color stops
I don't want to sort them later for the shader preparation, so make
sure they come in ordered.
2016-12-26 17:22:01 +01:00
Benjamin Otte
3a79b17309 vulkan: Fix coordinate setup
This makes rendering textures work when the top left of the rendered
texture is not at (0, 0).
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
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
Garrett Regier
23d10df6c6 gsk: Fix memory leak in gsk_render_node_write_to_file() 2016-12-23 07:22:41 -08:00
Benjamin Otte
4bb0c70c11 gsk: Add docs and error handling to serialization API 2016-12-23 08:11:01 +01:00
Benjamin Otte
5e089c4345 gsk: Add gsk_render_node_write_to_file()
For when you're in a debugger and need to have a closer look at this
node...
2016-12-23 08:11:01 +01:00
Benjamin Otte
087ea8e531 gsk: Warn on cairo errors during gsk_render_node_draw()
It's the same warning we use inside GTK for when stuff weirdly goes
wrong.
2016-12-23 08:11:01 +01:00
Benjamin Otte
08f9a6078b gsk: Include config.h
The more you know:
Not including config.h causes the public API implemented in this file to
not be exported in the resulting library.
2016-12-23 08:11:01 +01:00
Benjamin Otte
adcde3034e gsk: Implement gsk_renderer_render_texture() on GL 2016-12-23 08:11:01 +01:00
Benjamin Otte
786d3a013e vulkan: Implement gsk_renderer_render_texture() 2016-12-23 08:11:01 +01:00
Benjamin Otte
6c56793147 gsk: Add gsk_texture_download() API
Now users can download pixels and make everything slooooooow.
2016-12-23 08:11:01 +01:00
Benjamin Otte
2d2209859e gsk: Rename to gsk_texture_download_surface()
I want to reuse the name gsk_texture_download() for downloading the
actual bytes.
2016-12-23 08:11:01 +01:00
Benjamin Otte
373e08d6d4 gsk: Add gsk_renderer_render_texture()
... and implement it for the Cairo renderer.

It's an API that instructs a renderer to render to a texture.
So far this is mostly meant to be used for testing, but I could imagine
it being useful for rendering DND icons.
2016-12-23 08:11:01 +01:00
Benjamin Otte
98086014d8 gskcairo: Don't store the viewport in the global struct
Just query it locally.
2016-12-23 08:11:01 +01:00
Benjamin Otte
d2622d93ad gsk: Don't overdraw with transparent
That code doesn't do anything.

And what the code should be doing (clearing the abckground) isn't
necessary as cairo drawing is guaranteed to clear the surface.
2016-12-23 08:11:01 +01:00
Benjamin Otte
df5e12fc1d rendernode: Fix typo 2016-12-23 08:11:00 +01:00
Benjamin Otte
814b66e1a8 gsk: Remove nonexisting functions
The function was removed when gsk_render_node_draw() was and
gsk_renderer_realize() was refactored respectively.
2016-12-23 08:11:00 +01:00
Benjamin Otte
735846cc82 gsk: Export gsk_render_node_get_bounds()
I'll need it in tests/testsuite soon.
2016-12-23 08:11:00 +01:00
Benjamin Otte
c88d279416 gsk: Add gsk_render_node_serialize/deserialize()
This does a conversion to/from GBytes and is intended for writing tests.

It's really crude but it works.
And that probably means Alex will (ab)use it for broadway.
2016-12-23 08:11:00 +01:00
Benjamin Otte
3a38bc9bf7 gsk: Remove spread member from GskShadow
I had originally thought I'd use GskShadow for box-shadow, but didn't in
the end.

So now it's only used for text-shadow and icon-shadow, and those don't
have a spread.
2016-12-23 08:11:00 +01:00
Matthias Clasen
a2f0c860ee Fix distcheck 2016-12-21 14:12:31 -05:00