Commit Graph

191 Commits

Author SHA1 Message Date
Benjamin Otte
62eb9d42aa vulkan: Add infrastructure for push constants
THe code includes fragment push constants for colors, but that code is
so far unused.
2016-12-20 18:01:10 +01:00
Benjamin Otte
23e35706b4 gsk: Add support for rounded clip rectangles
Also add support to GtkSnapshot, so people can push rounded clips.
2016-12-20 18:01:10 +01:00
Benjamin Otte
59d638a09f gsk: Add GskRoundedRect
It's essentially a port of GtkRoundedBox to graphene.
2016-12-20 18:01:10 +01:00
Benjamin Otte
1f988d8b05 gsk: Add gsk_clip_node_new()
The node is a simple clipping node: It does a rectangular clip of its
contents.
2016-12-20 18:01:10 +01:00
Benjamin Otte
07d39299ea gsk: Replace gsk_render_node_set_opacity()
... with gsk_opacity_node_new().

Also implement support for opacity in gtk_widget_snapshot() using this
new node.
2016-12-20 18:01:10 +01:00
Benjamin Otte
e6d423e0e2 gsk: Remove gsk_renderer_create_fallback()
Use gsk_render_node_draw() instead.
2016-12-20 18:01:10 +01:00
Benjamin Otte
ee9aca882d gsk: Add fallback code to renderers
This code makes renderers fall back to Cairo rendering if they don't
know how to handle a render node's type.

This allows adding new render nodes with impunity.
2016-12-20 18:01:10 +01:00
Benjamin Otte
6129daf29b gsk: Add gsk_color_node_new() 2016-12-20 18:01:10 +01:00
Benjamin Otte
361e2cda27 Call gsk_render_node_draw() instead of creating fallback renderers 2016-12-20 18:01:10 +01:00
Benjamin Otte
e82d02432e gsk: Add gsk_render_node_draw()
Draws a node to a given cairo_t. This is mostly intended for fallback
usage.
2016-12-20 18:01:10 +01:00
Benjamin Otte
02131d590e snapshot: Change how gtk_snapshot_push/pop works
Instead of appending a container node and adding the nodes to it as they
come in, we now collect the nodes until gtk_snapshot_pop() is called and
then hand them out in a container node.

The caller of gtk_snapshot_push() is then responsible for doing whatever
he wants with the created node.

Another addigion is the keep_coordinates flag to gtk_snapshot_push()
which allows callers to keep the current offset and clip region or
discard it. Discarding is useful when doing transforms, keeping it is
useful when inserting effect nodes (like the ones I'm about to add).
2016-12-20 18:01:10 +01:00
Benjamin Otte
67fb129ed7 gsk: gsk_render_node_set_transform() => GskTransformNode
Instead of having a setter for the transform, have a GskTransformNode.

Most of the oprations that GTK does do not require a transform, so it
doesn't make sense to have it as a primary attribute.

Also, changing the transform requires updating the uniforms of the GL
renderer, so we're happy if we can avoid that.
2016-12-20 18:01:10 +01:00
Benjamin Otte
19753062c4 gsK: Move children handling to GskContainerNode 2016-12-20 18:01:09 +01:00
Benjamin Otte
e2625f8649 gsk: Remove GskRenderNode::parent
... and all related APIs.
2016-12-20 18:01:09 +01:00
Benjamin Otte
a8f2b3e75e gsk: Remove world matrix support
Use the real transform and compute it manually.
2016-12-20 18:01:09 +01:00
Benjamin Otte
3eb7c4719b gsk: Remove gsk_render_node_set_bounds()
gsk_render_node_get_bounds() still exists and is computed via vfunc
call:
- containers dynamically compute the bounds from their children
- surface and texture nodes get bounds passed on construction
2016-12-20 18:01:09 +01:00
Benjamin Otte
4d376c80f3 gsk: Remove gsk_render_node_get_size()
In the brave new world of refactored render nodes, this function doesn't
really make any sense anymore. We could turn it into a vfunc, but I
don't think it's useful.

Especially because even in the brave old world, this function was
causing a vastl overallocation of nodes when the GL renderer needed render
targets.
2016-12-20 18:01:09 +01:00
Benjamin Otte
d907f60843 gsk: Add GskRenderNodeClass.make_immutable() 2016-12-20 18:01:09 +01:00
Benjamin Otte
e4ee65fd19 gsk: Remove gsk_render_node_set_opaque()
If we ever feel, we need this function again, we can readd it later.

But nobody is using it other than for overriding opactiy. And you can
just override opacity directly if you care.
2016-12-20 18:01:09 +01:00
Benjamin Otte
684d25bd1a gsk: Add custom structs to RenderNode subclasses
So now we don't need to keep a texture pointer and a surface pointer and
so on in the base struct.
2016-12-20 18:01:09 +01:00
Benjamin Otte
be8b9406e5 gsk: Add GskRenderNodeClass.finalize() 2016-12-20 18:01:09 +01:00
Benjamin Otte
a97b819b81 gsk: Add gsk_container_node_new()
It replaces gsk_renderer_create_render_node() which was doing the eact
same thing, only taking an unused extra argument.
2016-12-20 18:01:09 +01:00
Benjamin Otte
f16d523cb2 gsk: Introduce GskRenderNodeClass
This is modeled after GtkCssValueClass. So far it doesn't do anything.
2016-12-20 18:01:09 +01:00
Benjamin Otte
3af4fba895 gsk: Split render node subclasses out into their own file 2016-12-20 18:01:09 +01:00
Benjamin Otte
abd184efc9 gsk: Remove gsk_render_node_is_surface/texture()
Use gsk_render_node_get_node_type() instead.
2016-12-20 18:01:09 +01:00
Benjamin Otte
cb5c5170f4 gsk: Remove unneeded children modifiers
Creating render nodes is fire-and-forget, so all one should do is create
a container, append, append, append and then send it off to the
renderer. So there's no need to replace, insert between or anything
else.
2016-12-20 18:01:09 +01:00
Benjamin Otte
52d2faef88 gsk: Add gsk_cairo_node_new()
Split off Cairo drawn content nodes and require you to allocate them
using this new function.
2016-12-20 18:01:09 +01:00
Benjamin Otte
8c8691b469 gsk: Add gsk_texture_node_new()
Start the transition into the different node types.
2016-12-20 18:01:09 +01:00
Benjamin Otte
ac5e277a71 gsk: Add GskRenderNodeType
For now, this is unused.
2016-12-20 18:01:09 +01:00
Benjamin Otte
f258af9cce gsk: Remove GskRenderNodeIter 2016-12-20 18:01:09 +01:00
Benjamin Otte
6fb46e3943 gsk: Make GskRenderNode a boxed type 2016-12-20 18:01:09 +01:00
Benjamin Otte
9bff1c12d4 gsk: Remove custom GValue API for GskRenderNode 2016-12-20 18:01:09 +01:00
Benjamin Otte
ff884385c0 gsk: Remove GskRenderNode::hidden
If you want to hide something, don't render it.
2016-12-20 18:01:09 +01:00
Benjamin Otte
04a2c1499a gsk: Remove RenderNode::anchor-point 2016-12-20 18:01:09 +01:00
Matthias Clasen
438ad208e7 Use the new defines
It is no longer GDK_WINDOWING_VULKAN.
2016-12-09 15:51:58 -05:00
Benjamin Otte
2faad03f2f gsk: Improve GSK_RENDERER env var handling
- Recognize "gl" as well as "opengl" for the GL renderer
- GSK_RENDERER=help now works
- g_warning() for an unrecognized renderer (typo detection!)
- g_print() the actual renderer that is used (and error messages when
  selecting) when a GSK_RENDERER is given, so you'll notice if your
  renderer isn't taken.
2016-12-09 21:27:55 +01:00
Benjamin Otte
f52dd12569 vulkan: Implement texture caching
And with this change, the GPU looks bored again.
2016-12-09 18:35:52 +01:00
Benjamin Otte
6525fbe90f vulkan: Don't create more than one render object
By creating unlimited render objects, we would never wait on the GPU.

This would mean that if the GPU was the bottleneck, we would fill its
queue with render commands faster than it could process them.

And because the nvidia binary driver and my code work surprisingly well
and bugfree, this lead to exhaustion of RAM. I had 50GB of swap
configured and my hard disk was quicker as swap storage than my GPU was
at processing the commands, so stuff still filled up.

At that point my computer became rather unresponsive and I decided to
reboot it, so I that could write this patch.
2016-12-09 18:35:52 +01:00
Benjamin Otte
b3388aaca9 vulkan: Don't limit number of descriptor sets
If we need more than we have reserved as maximum, recreate the
descriptor pool with a higher maximum.
2016-12-09 18:35:52 +01:00
Benjamin Otte
35d1dc6dd5 vulkan: Add more node operations
Add SURFACE and TEXTURE operations. This way, we actually render more
than one node every frame because not everything is a fallback node
anymore that gets composited with its children into a cairo surface.
2016-12-09 18:35:52 +01:00
Benjamin Otte
cf470f31ca vulkan: Push the correct matrix when drawing
Instead of pushing the root matrix, push the world matrix for the
current node. That way, the bounds we emit as vertices are actually
properly transformed.
2016-12-09 18:35:52 +01:00
Benjamin Otte
93448b8c7e vulkan: Enable alpha blending
We will need that once we actually composite stuff.
2016-12-09 18:35:52 +01:00
Benjamin Otte
b3a1732a3e vulkan: Redo descriptor set handling
First, we collect all the info about descriptor sets into a hash table,
then we use its size to determine the amount of sets and allocate those
before we finally go ahead and use the hash table's contents to
initialize the descriptor sets.

And then we're ready to render.
2016-12-09 18:35:52 +01:00
Benjamin Otte
f4685e0291 vulkan: Move remaining structs to VulkanRender object
It now gets to maintain things.
2016-12-09 18:35:52 +01:00
Benjamin Otte
e989375c04 vulkan: Create framebuffers from GskVulkanRender object
Also create them on-demand, as they need to be created per-image and
per-framebuffer, so we don't want to create loads of them.
2016-12-09 18:35:52 +01:00
Benjamin Otte
8756deec58 vulkan: Turn swapchain image targets into GskVulkanImages
This gives us proper refcounting here, too. And there's no longer a
difference between the different types of images.
2016-12-09 18:35:52 +01:00
Benjamin Otte
17c11dd97b vulkan: Store width/height of GskVulkanImage
This is to enable lazy framebuffer creation later.
2016-12-09 18:35:51 +01:00
Benjamin Otte
c160ef16c1 vulkan: Turn GskVulkanImage into a GObject
This way, we can do real refcounting on them.
2016-12-09 18:35:51 +01:00
Benjamin Otte
85bc9ff36b vulkan: Hook up image upload mechanism to env variables
Instead of having to decie at compile-time, check if
GSK_RENDERING=staging-image was given, and if so, select the staging
image upload mode.
2016-12-09 18:35:51 +01:00
Benjamin Otte
b2e30fb66e vulkan: Don't wait until graphics are done computing
We can let the GPU do its stuff without waiting. The GPU knows what it's
doing.

Which means we now get a lot of time to spend on doing CPU things (read:
we're way better in benchmarks).

The old behavior is safer, so we want to keep it around for debugging.
It can be reenabled with GSK_RENDERING_MODE=sync.
2016-12-09 18:35:51 +01:00