Commit Graph

167 Commits

Author SHA1 Message Date
Benjamin Otte
3aa3816125 gsk: Add GskStrokeNode
Take a rendernode as source and a GskPath and GskStroke,
and fill the area that is covered when stroking the path
with the given stroke parameters, like cairo_stroke() would.
2023-08-07 13:02:57 -04:00
Benjamin Otte
fc4a464b47 gsk: Add GskFillNode
Take a rendernode as source and a GskPath and fill
the region inside the path with the source, just like
cairo_fill() would.
2023-08-06 21:01:11 -04:00
Benjamin Otte
e98ae233fc vulkan: Fix a memleak 2023-07-31 16:51:03 +02:00
Benjamin Otte
1bd820fc60 vulkan: Clean up renderpass/offscreen creation
Instead of scale and whatnot, pass:
1. The image size
2. The viewport to map to that image size
and compute everything else from there.

In particular, we set the Vulkan viewport to the image dimensions
instead of the viewport size.

All of this makes things a lot simpler while keeping the required
functionality.
2023-07-22 23:30:15 +02:00
Benjamin Otte
a4247f1358 vulkan: Plug a memleak
This one was introduced in 4d9e7d30b0.
2023-07-22 23:30:15 +02:00
Benjamin Otte
4d9e7d30b0 vulkan: Add premultiply step to texture upload
When a GdkMemoryFormat is not supported natively and there's
postprocessing required, add a way to mark a VulkanImage as such via the
new postprocess flags.

Also allow texting such iamges only with new_for_upload() and detect
when that is the case and then run a postprocessing step that converts
that image to a suitable format.
This is done with a new "convert" shader/op.

This now supports all formats natively, no conversions happen on the CPU
anymore (unless the GPU is old).
2023-07-19 21:30:35 +02:00
Benjamin Otte
11a0646281 vulkan: Pass rectangles where no regions are used
The API was using regions because it always had. But all the code ever
did was get the extents of the region.

So simplify everything by using rectangles everywhere.
2023-07-19 21:30:35 +02:00
Benjamin Otte
492507af11 vulkan: Stop keeping the context around
These days, we can query it with gsk_vulkan_render_get_context().

Makes quite a few functions require one less argument.
And it also makes the GskVulkanRenderPass empty. Gotta figure out what
to do with it.
2023-07-19 21:30:35 +02:00
Benjamin Otte
67a3929583 vulkan: Remove unused stuff fom renderpass
... and move it to the one place where it is used.
2023-07-19 21:30:35 +02:00
Benjamin Otte
a8ff291a12 vulkan: Make clip type an enum
and add gsk_vulkan_shader_op_alloc() that sets it properly.
2023-07-16 13:16:43 +02:00
Benjamin Otte
93db1cc89e vulkan: Add an UploadGlyphOp
Now all the uploads have their own op.
2023-07-16 13:16:43 +02:00
Benjamin Otte
822641c161 vulkan: Merge the two upload ops
Now they both use the same upload code.
2023-07-16 13:16:43 +02:00
Benjamin Otte
385ab74922 vulkan: Merge te 2 upload ops
They are about to share a ton of code, sothey should be in the same
source file.

This commit just does the copying, no functional changes.
2023-07-16 13:16:43 +02:00
Benjamin Otte
fcf65c7caa vulkan: Fold functions into only caller
Now that the VulkanOp does begin/end of render passes, there's no need
to have a renderpass function for it anymore.
2023-07-16 13:16:43 +02:00
Benjamin Otte
0edd7547c1 vulkan: Don't try that hard to use clear
For small regions, the optimization doesn't matter that much, so we
don't need to do lots of work on the CPU.

In particular, this should catch icons and their backgrounds (32x32),
but I was generous in selecting the number.

Gets my discrete AMD on widget-factory back to the 1900fps it had before
this optimization while making the driver clock the GPU's shader at
1.7GHz instead of the 2.1GHz it used before.
2023-07-16 13:16:43 +02:00
Benjamin Otte
ce042f7ba1 vulkan: Try really hard to use clear
Using clear avoids the shader engine (see last commit), so if we can get
pixels out of it, we should.

So we detect the overlap with the rounded corners of the clip region and
emit shaders for those, but then use Clear() for the rest.

With this in place, widget-factory on my integrated Intel TigerLake gets
a 60% performance boost.
2023-07-16 13:16:41 +02:00
Benjamin Otte
bb2cd7225e vulkan: Add a clear op
The op emits a vkCmdClearAttachments() with a given color. That can be
used with color nodes that are pixel-aligned and opaque to significantly
speed up rendering when the window background is a solid color.

However, currently this fails a bit outside of fullscreen when rounded
clip rectangles are in use to draw rounded corners.
2023-07-16 13:16:15 +02:00
Benjamin Otte
5e1fd56345 vulkan: Adapt a function
I want to use it for more operations when we can break those down to
operations on the pixels directly, and this function is what's needed
for that.
2023-07-16 12:13:00 +02:00
Benjamin Otte
0bf16d738e vulkan: Rename offscreenp to renderpassop
They should be used for all renderpasses, not just offscreens.
2023-07-16 12:13:00 +02:00
Benjamin Otte
2aba50efa0 vulkan: Move the render ops to the Render
This is a massive refactoring because it collects all the renderops
of all renderpasses into one long array in the Render object.

Lots of code in there is still flaky and needs cleanup. That will
follow in further commits.

Other than that it does work fine though.
2023-07-16 12:13:00 +02:00
Benjamin Otte
c0b185bee9 vulkan: Make Op->command() return the next op
This way, ops can batch themselves.

They don't dothat yet, but you know where this is going...
2023-07-16 12:13:00 +02:00
Benjamin Otte
d7764cc6b3 vulkan: Bind descriptor sets early
Simplfies the code and doesn't change anything.
2023-07-16 12:13:00 +02:00
Benjamin Otte
a6b2bcbf24 vulkan: Remove unused arguments from Op vfuncs
Makes code a lot simpler.
2023-07-16 12:13:00 +02:00
Benjamin Otte
7fa159e94a vulkan: Cache VkRenderPasses in render object
Instead of recreating the same renderpass object in every frame and for
every offscreen, just reuse it.

Technically, we can save this per-renderer or even per-display (it
should really be cached by VkDevice), but we have no infrastructure for
that.
2023-07-16 12:13:00 +02:00
Benjamin Otte
05c9f3442c vulkan: Rename function
The function name gsk_vulkan_render_get_pipeline() had been used for
GskVulkanPipeline. Since those are gone now, we can use that name for
VkPipelines.
2023-07-16 12:13:00 +02:00
Benjamin Otte
cef87b102c vulkan: Cache framebuffer in image
Instead of recreating them every frame for every render pass, reuse the
same framebuffer.
2023-07-16 12:13:00 +02:00
Benjamin Otte
70c9521cae vulkan: Put the vertex buffer into the render object
Renderpasses get recreated every frame, but we keep render objects
around. So if we keep the vertex buffer in the render object, we can
also keep it around and just reuse it.

Also, we only need one buffer for all the render passes, which is
another bonus.

The initial buffer size is chosen at 128kB. Maximized Nautilus,
gnome-text-editor with an open file and widget-factory take ~100kB when
doing a full redraw. Other apps are between 30-50kB usually.

So I chose a value that is not too big, but catches ~90% of cases.
2023-07-16 12:13:00 +02:00
Benjamin Otte
6363f27f95 vulkan: Don't intern strings
Interning strings is slow, especially if we can instead do direct
pointer compares.

Also refactor the pipeline lookup code a bit to make use of the
refactored code.
2023-07-16 12:13:00 +02:00
Benjamin Otte
f35053b837 vulkan: Add VulkanOp->next
Set it after creating all the ops and then use it for iterating.

Note that we cannot set it while creating the ops because the array may
be realloc()ed into a different memory region which would invalidate all
the pointers.

It currently has no use, but that will come later.

Also put the typedefs into headers in gsk/vulkan, they have nthing to do
outside that directory.
2023-07-16 12:13:00 +02:00
Benjamin Otte
d669e3ab6a vulkan: Remove all the semaphores
They aren't necessary with just one queue.
2023-07-16 12:13:00 +02:00
Benjamin Otte
a7c247bccd vulkan: Pass the node when setting up
Remove the function to add a node from both the GskVulkanRender and the
GskVulkanRenderPass.

That means they are both now meant to draw exactly one node.
2023-07-16 12:13:00 +02:00
Benjamin Otte
d86d4c5597 vulkan: Add infrastructure for printing ops
... and add a GSK_DEBUG=verbose setting making use of it.
2023-07-16 12:13:00 +02:00
Benjamin Otte
73f1dfc762 vulkan: Repurpose mask shader
Use if for mask nodes to do the generic source image + mask image
operation with the 4 available mask modes.
2023-07-16 12:13:00 +02:00
Benjamin Otte
a621bd066b vulkan: Remove op.get_pipeline()
It's unused now that GskVulkanPipeline is gone.
2023-07-16 12:13:00 +02:00
Benjamin Otte
58c318a4dc vulkan: Add gskvulkanprivate.h
It's the new place for all the common stuff.

Because the old place is about to go away.
2023-07-16 12:13:00 +02:00
Benjamin Otte
210cb3eecd vulkan: Turn push constants into an op
This removes the last remaining original op from the gskvulkanrenderpass.c,
so that file got some cleanup, too.
2023-07-16 12:13:00 +02:00
Benjamin Otte
6e6fa3daed vulkan: Make glyphs use new node ops
This is a rudimentary - but working - port.
Glyph uploads are still using the old machinery, a bunch of functions
still exist that probably aren't necessary anymore and each glyph emits
its own node.

This will need to be improved in further commits.
2023-07-16 12:13:00 +02:00
Benjamin Otte
2d6ebbb4d5 vulkan: Add a glyph shader
This shader is an updated version of the mask shader, but I want to use
the mask name for the mask node and that's a different functionality.

Also, add an operation for it and partially implement the mask node
using it, so we can test that this shader works.

Replacing the shader used for text rendering is the next step.
2023-07-16 12:12:59 +02:00
Benjamin Otte
efa4cae949 vulkan: Remove hacky function arguments
They're unused now that we removed the old render ops.
2023-07-16 12:12:36 +02:00
Benjamin Otte
5e72914c48 vulkan: Port linear gradient to new ops
This was the last user of GskVulkanOpRender, so delete that one, too.
2023-07-16 12:12:36 +02:00
Benjamin Otte
f3aab662c3 vulkan: Make border shader use new ops 2023-07-16 12:12:36 +02:00
Benjamin Otte
c598fa9147 vulkan: Add a blur op and use it
This removes the last old user of offscreens, so those functions are now
gone, too.
2023-07-16 12:12:36 +02:00
Benjamin Otte
b2296a1918 vulkan: Port inset and outset shadow to new ops 2023-07-16 12:12:36 +02:00
Benjamin Otte
594595d9cd vulkan: Port blend mode to new ops 2023-07-16 12:12:36 +02:00
Benjamin Otte
9ac36aeb42 vulkan: Add cross-fade op
The benefit here is that we can now properly cross-fade when one of
start/end is fully clipped out by just replacing it with an opacity op
for the other.

This was not possible with the old way we did things.
2023-07-16 12:12:36 +02:00
Benjamin Otte
a61fe61318 vulkan: Factor out call to opacity op
I want to reuse it for crossfades (see next commit).
2023-07-16 12:12:36 +02:00
Benjamin Otte
99085605a8 vulkan: Convert color op to new method
This is a straightforward and simple port.
2023-07-16 12:12:36 +02:00
Benjamin Otte
9da1055575 vulkan: Create pipeline differently for ops
Instead of creating a pipeline GObject, just ask for the VkPipeline.

And instead of having the Op handle it, just let the renderpass look
up/create the relevant pipeline while creating commands so that it can
insert vkCmdBindPipeline calls as-needed.
2023-07-16 12:12:36 +02:00
Benjamin Otte
8207c548cc vulkan: Combine textures and samplers again
This reverts most of commit f420c143e0
again because it turns out GPUs like combined images and samplers.

But: The one thing we don't revert is allowing the C code to select any
combination of sampler and image:
gsk_vulkan_render_get_image_descriptor() now takes a 2nd argument
specifying the sampler.

This allows the same flexibility as before, we just combine things
early.

This change was inspired by
https://developer.nvidia.com/blog/vulkan-dos-donts/
2023-07-16 12:12:36 +02:00
Benjamin Otte
7cf7870254 vulkan: Initialize ops differently
Instead of creating the op manually, just pass in the renderpass and
have the op created from there.

This way ops aren't really initialized anymore, they are more appended
to the queue, so instead of foo_op_init() we can just call the function
foo_op().
2023-07-16 12:12:36 +02:00