Commit Graph

468 Commits

Author SHA1 Message Date
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
Umang Jain
a933c7c4bd gsk: Move gsk_cairo_node_new_for_surface into public API
https://bugzilla.gnome.org/show_bug.cgi?id=788534
2017-10-08 18:22:34 +05:30
Umang Jain
74f8fc80d3 gsk: Fix serialization of cairo node
https://bugzilla.gnome.org/show_bug.cgi?id=788534
2017-10-08 18:22:34 +05:30
Matthias Clasen
b9b03cf570 gskrenderer: Make the window property not construct
We never set this, since it is assigned as a side-effect
of realizing the renderer. Make this a plain readonly property.
2017-10-06 19:29:42 -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
4e33be124d Add a forgotten rename
When I renamed blend to texture, I overlooked that the color
text pipeline also uses this shader. Fix it.
2017-09-30 17:58:23 -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
983e0b7956 Small simplification
Just keep the viewport as a graphene_rect_t, we don't need
to use the Vulkan type here.
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
3a37440be6 Cosmetics
Factor out a helper function.
2017-09-30 17:58:23 -04:00
Matthias Clasen
52afccb6a3 Fix a doc comment
It was missing a return.
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
e382f956f3 vulkan: Move sampler creation down
This is in preparation of allowing multiple samplers.
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
9e2e6c1115 gsk: Fix a typo
Repeating linear gradient nodes share most of the implementation
with linear gradient nodes, but they shouldn't share the class name.
2017-09-28 21:06:52 -04:00
Matthias Clasen
e45ab76664 gsk: remove gsk_blend_node_get_blend_mode from public api
We don't have any other such getters in the public api at
this point, so leave this one out as well.
2017-09-28 19:39:16 -04:00
Matthias Clasen
535529ca98 vulkan: Measure gpu time
Since this value is only meaningful if we wait for the rendering
to end, we only keep this timer if GSK_RENDERING_MODE=sync is
enabled.
2017-09-28 10:29:16 -04:00
Matthias Clasen
72d043d51f gsk: Change the profiler setup
Move away from the idea of intra-frame sampling, since we only
push samples once per frame, anyway. Instead, make the profiler
keep a rolling average of the last n frames.
2017-09-28 10:26:01 -04:00
Matthias Clasen
767966933d gsk: Redo the sampling in the profiler
Reset the min/max/average counters before calculating,
and only print the values if we have samples. In addition,
print the number of samples.
2017-09-28 10:25:49 -04:00
Matthias Clasen
4d8e7d71ca gsk: Add a profile counter for vulkan render passes
This is interesting now that we have multiple render passes.
2017-09-28 08:39:22 -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
85e4e0672a Add semaphores to the command buffer submit api
Allow to pass in semaphores to wait for before executing
and to signal after executing the command buffer. This
just exposes the capabilities of the underlying Vulkan
api. Update all callers to pass no semaphores, for now.

We will use this in the future.
2017-09-28 08:39:22 -04:00
Matthias Clasen
ff188f6bf0 Add an api to create intermediate textures
The new function creates a vulkan image that is suitable for
use as a framebuffer to render to and as a texture to read from.
2017-09-28 08:39:22 -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
145e4fde92 gsk: Fix Vulkan validation errors for image upload
I've finally figured out the right combination of src and dest
stage and access flags to make all validation warnings go away.
This commit only fixes the direct upload code.
2017-09-26 18:18:31 -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
cfbd6b4b99 gsk: Add a way to reset profiler counters
It is often useful to count things per-frame, and reset
the counter afterwards.
2017-09-25 20:58:10 -04:00
Matthias Clasen
b1e98d106d vulkan: add a frame counter to the profiler
This is just to match the gl renderer and to learn how
counters work.
2017-09-25 18:37:22 -04:00
Matthias Clasen
816b47d70d gsk: Make profiler counters more useful
Make it possible to have counters that get incremented
by values other than 1.
2017-09-25 17:03:06 -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
Rico Tzschichholz
d09f695172 gsk: Some g-i annotation fixes 2017-09-25 11:15:14 +02:00
Matthias Clasen
f6626a9e0e gsk: Documentation additions
Document newly added apis, and ensure that all public apis
are listed in the docs.
2017-09-24 22:26:39 -04:00
Matthias Clasen
b5ac277654 Plug a memory leak
A function with ensure in the name would better check if the
thing it is supposed to ensure already exists.
2017-09-24 21:48:07 -04:00
Matthias Clasen
4a5ac93762 gsk: Fix a prefix mishap
There shouldn't be any gst_ functions in here...
2017-09-23 13:15:30 -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
b192120f39 vulkan: fix a clip handling problem
We were looking at uninitialized memory here, instead
of the type of the source clip, as we should.

This showed up as mispositioned clip in the first frame
of a crossfade stack transition, and also as overdraw in
sliding stack transitions.
2017-09-22 22:16:10 -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
5ff6481310 Add a getter to the pipeline layout directly from the pipeline
This is a step towards allowing multiple pipeline layouts.
2017-09-22 22:16:09 -04:00
Matthias Clasen
4c7a51f88a vulkan: Move descriptor set layout to the render object
We want to maintain a single descriptor set layout while introducing
multiple pipeline layouts, so split this off.
2017-09-22 22:16:09 -04:00
Matthias Clasen
e97a78840f gsk: vulkan: Drop an unused api
We don't use the upload-single-region api anymore.
No need to keep it around.
2017-09-21 13:47:17 -04:00
Matthias Clasen
dbc0caf27d vulkan: Batch uploads from the glyph cache
This uses the new api that was introduced in the previous
commit.
2017-09-21 13:45:01 -04:00
Matthias Clasen
64322a2c41 vulkan: Add an api to update multiple image regions
Instead of doing multiple copy commands with a tiny buffer
for each glyph, we can just batch them all together. This
also avoids the issue of creating multiple barriers for the
same image.
2017-09-21 13:42:57 -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
8e26864778 vulkan: Quiet another validation error 2017-09-20 23:46:16 -04:00
Matthias Clasen
75bf6db5e0 Cosmetic change 2017-09-20 23:26:15 -04:00
Matthias Clasen
ce06c4b840 gsk: Make repeat nodes deserializable
This was just a simple oversight.
2017-09-20 23:26:15 -04:00
Matthias Clasen
b18ab9761a gsk: Fix serialization of text nodes 2017-09-20 23:26:15 -04:00
Matthias Clasen
b5eeb98374 Add simple aging for the glyph cache
This should prevent the cache from growing out of bounds.
2017-09-20 23:26:14 -04:00
Lionel Landwerlin
7d7f8e5f8e gsk vulkan: Use new api in the glyph cache
Use the newly introduced gsk_vulkan_image_new_for_atlas.
2017-09-20 23:26:14 -04:00
Lionel Landwerlin
b97fb75146 gsk: vulkan: rework image layout/access transitions
By tracking the last transition we can build the appropriate barriers.
Also use the most appropriate initial layout/access at creation :

for linear image : predefined (we prepare the content ourself through memcpy)
for everything else : undefined (we don't care about the content, will most likely be erase)
2017-09-20 23:26:14 -04:00
Lionel Landwerlin
28bd26ca06 gsk: vulkan: silence anisotropy validation warning 2017-09-20 23:26:14 -04:00
Matthias Clasen
b321b26a73 glyph cache: Upload glyphs incrementally
This does not work yet.
2017-09-20 23:26:14 -04:00
Matthias Clasen
7bbd4d41e0 vulkan: pass the context when creating a glyph cache 2017-09-20 23:26:14 -04:00
Matthias Clasen
5ee5af9bc8 vulkan: Add an upload_region api to GskVulkanImage
This will let us update larger textures incrementally.
Sadly, it does not work yet.
2017-09-20 23:26:14 -04:00
Matthias Clasen
6dbec5e4fc Add some debug output for the glyph cache
Print out some statistics and dump the glyph caches to a png,
for now.
2017-09-20 23:26:14 -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
cead00757d vulkan: Move glyph cache to a separate file
Otherwise things will get too messy.
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
ff45a86a1c Fix rendering glyphs from the cache
We were not quite using all the right dimensions.
2017-09-11 14:45:36 -04:00
Matthias Clasen
b0d108291b Some fixes for the glyph cache
Copy the way cogl does its glyph caching some more.
At the minimum, this fixes problems where we were getting
wrong-sized Emoji inserted.
2017-09-11 14:02:44 -04:00
Matthias Clasen
40031930b2 Cosmetic changes
Make sure the cache size does not get out of sync with the
actual surface size.
2017-09-11 11:22:59 -04:00
Matthias Clasen
31ca709e23 Cosmetic changes
Use Pango macros for handling PANGO_SCALE.
2017-09-11 11:22:10 -04:00
Matthias Clasen
781821bae4 rate-limit the glyph cache dumping
Writing the file out every frame really isn't necessary.
Do it once per second.
2017-09-11 11:15:00 -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
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
4800a248bd Typo fix 2017-09-04 23:32:31 -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
e2869853dc gsk: Add a blur node
For now, this has just a fallback implementation using
the typical box filter approximation.
2017-09-04 14:28:16 -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
Matthias Clasen
59b1206468 Avoid empty nodes another way
Make gsk_text_node_new return NULL if the extents are empty.
2017-09-03 19:35:02 -04:00
Matthias Clasen
2101f26b49 vulkan: Add more debug spew 2017-09-03 11:34:41 -04:00
Matthias Clasen
a05895e029 Record node names for debug output
This is useful for GSK_NOTE output as well.
2017-09-03 11:32:09 -04:00
Matthias Clasen
8db13c3362 gsk: Improve debug output
If we don't have node names, we can still print class names.
2017-09-03 10:32:55 -04:00
Matthias Clasen
440e534053 gsk: add a has_color boolean to text nodes
Currently, this information is not used since cairo_show_glyphs
deals with color glyphs for us. But when we get to uploading
glyphs to a texture atlas, we will need it to do the right thing.

We don't look at individual glyphs here, but just whether the
font has the has-color flag set. In practice, all glyphs in
such a font will be color glyphs, and we can avoid loading all
the glyphs this way.
2017-09-02 11:09:03 -04:00
Matthias Clasen
4975aa7920 Add a render node for text
This is just a wrapper around a PangoGlyphString + PangoFont.
Basically, the arguments that are passed to pango_renderer_draw_glyphs.
2017-09-01 13:30:03 -04:00
Daniel Boles
97b5f3d029 gskenums: Fix typo/grammar in GskRenderNodeType doc 2017-08-31 19:59:25 +01:00
Timm Bäder
c18d2872f2 GskRenderNode: Fix fallback border drawing 2017-08-29 11:48:42 +02:00
Timm Bäder
9a43881a19 gskrendernode: Fix inset shadow drawing 2017-08-28 17:50:34 +02:00
Timm Bäder
4045794801 gskrendernode: Constify some parameters 2017-08-28 17:50:34 +02:00
Lionel Landwerlin
48df19287b gsk: vulkan: fix image uploading
The memory alignment requirements are different from the image layout.
We want the rowPitch to know where to upload the lines.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>

https://bugzilla.gnome.org/show_bug.cgi?id=786485
2017-08-18 19:41:36 -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
7685d157bc build: Remove more wrong kwargs
declare_dependency does not take a depends: kwarg and meson 0.42.0
started warning about that.
2017-08-15 14:56:13 +02:00
Emmanuele Bassi
391d1a04ec Drop Autotools build
We are officially switching to Meson as the default build system for
GTK+.
2017-08-14 22:23:09 +01:00
Timm Bäder
2eaf416062 gsk: Add color shader sources to meson build files 2017-08-13 18:01:58 +02:00
Daniel Boles
0740fb5c64 gskrendernodeimpl: Fix leak of cairo_pattern_t
It was not destroyed after setting it on the cairo_context_t, as it is
in every other case.

https://bugzilla.gnome.org/show_bug.cgi?id=785793
2017-08-04 00:59:33 +01:00
Emmanuele Bassi
6728f45aa0 build: Ensure that Vulkan shaders are rebuilt if glslc is found
If glslc is found, rebuild the shaders from GLSL to SPIR-V; otherwise,
we're just going to use the built files we have committed in the source
repository.
2017-05-03 15:10:57 +01:00
Emmanuele Bassi
d35d82fb35 build: Rename GSK resource generator script
Maintain the naming convention, since we have similar scripts for GDK
and GTK already.
2017-05-03 15:10:57 +01:00
Emmanuele Bassi
e18d9a85ca build: Use the common linker flags in GDK and GSK
Instead of hard-coding `-Bsymbolic`.
2017-05-03 15:10:56 +01:00
Emmanuele Bassi
68039b610b build: Add compiler warnings and errors
We don't want to build buggy code.
2017-05-03 15:10:56 +01:00