Commit Graph

139 Commits

Author SHA1 Message Date
Benjamin Otte
8d19db6732 vulkan: Update the cross-fade shader
This also fixes it rendering weird things when the bounds of start and
end node don't match.
2023-06-04 19:42:01 +02:00
Benjamin Otte
0f1b039306 vulkan: Implement bindless texture rendering
Instead of having a descriptor set per operation, we just have one
descriptor set and bind all our images into it.

Then the shaders get to use an index into the large texture array
instead.

Getting this to work - because it's a Vulkan extension that needs to be
manually enabled, even though it's officially part of Vulkan 1.2 - is
insane.
2023-06-04 19:42:01 +02:00
Benjamin Otte
b791aa0301 vulkan: Clip using scissors
If we have a rectangular clip without transforms, we can use
scissoring. This works particularly well because it allows intersecting
rounded rectangles with regular rectangles in all cases:
Use the scissor rect for the rectangle and the normal clipping code for
the rounded rectangle.
2023-06-04 19:42:01 +02:00
Benjamin Otte
7fd94c1828 vulkan: Make scissoring an explicit operation
The idea is to use it for clip nodes when they are integer-aligned.

To do that, we need to track the scissor rect in the parse state, so we
do that, too.

Also move the viewport offset out of the projection matrix, as it is
part of the transform between clip and scissor, so it needs to live in
the offset.
2023-06-04 19:42:01 +02:00
Benjamin Otte
dd4c1167b2 vulkan: Remove unneeded struct member
We can use gsk_vulkan_pipeline_get_vertex_stride() whenever we need that
value.
2023-06-04 19:42:01 +02:00
Benjamin Otte
d411912396 vulkan: Bind vertex buffers only once
We can index into the same buffer from every pipeline due to the aligned
buffer writes (see previous commit).

So we do that.
2023-06-04 19:42:01 +02:00
Benjamin Otte
0e93ad8671 vulkan: Align vertex data
We align the data to a multiple of vertex stride, that way we use more
memory, but we could compute an offset into the vertex buffer without
changing the offset.
2023-06-04 19:42:01 +02:00
Benjamin Otte
d98991a0ad vulkan: Set offsets when counting
We can set the vertex offset while counting the data, this gets rid of
the need of passing all the counting machinery into the actual data
collection code.
2023-06-04 19:42:01 +02:00
Benjamin Otte
1f7dcc1286 vulkan: Simplify switch statement
All branches do the same thing now, so pull them all into the same
branch.
2023-06-04 19:42:01 +02:00
Benjamin Otte
328cdf7b2a vulkan: Simplify collect_vertex_data()
We don't have any size arguments to it, so don't use them.
2023-06-04 19:42:01 +02:00
Benjamin Otte
79a227bc64 vulkan: Remove a function from pipeline impls
That function is available already in the structs we feed to Vulkan.

Store it from there and reuse it.
2023-06-04 19:42:01 +02:00
Benjamin Otte
0fee26252c vulkan: Don't draw fully clipped nodes
... if they are container nodes. Other nodes will get culled by the
vertex shader.
2023-06-04 19:42:01 +02:00
Benjamin Otte
d48b6b9ad5 vulkan: Add optimization for transforms
When attempting a complex transform, check if the clip can be ignored
and do that if possible.

That way we don't cause fallbacks when transforming the clip is too
complex.
2023-06-04 19:42:01 +02:00
Benjamin Otte
d4618ea8a6 vulkan: Don't crash with overly large nodes
... when these nodes are used as children of a complex transform nodes
and we lose the clip.
2023-06-04 19:42:01 +02:00
Benjamin Otte
a73530f952 vulkan: Update texture shader to do AA 2023-06-04 19:42:01 +02:00
Benjamin Otte
3e620a8fe5 vulkan: Split generic code off
No need to duplicate code in shaders when it can be shared.
2023-06-04 19:42:01 +02:00
Benjamin Otte
6d8c8199d9 vulkan: Use rounded rect APIs to improve clips
There are a bunch of intersection APIs available these days.
Let's use them.
2023-06-04 19:42:01 +02:00
Benjamin Otte
7f5504bea4 vulkan: Set the initial clip rect
Instead of rendering unclipped, set the clip region to the extents of
the current clip region.
2023-06-04 19:42:01 +02:00
Benjamin Otte
4b2b239550 vulkan: Only draw one rect
Instead of emitting the render commands once per rectangle of the clip
region, just emit them once with the region's extents.

This is generally faster because it emits fewer commands to the GPU,
even though it may touch significantly more pixels.

For a proper method, we'd need to record the commands per clip rectangle
instead of emitting all of them all the time.
2023-06-04 19:42:01 +02:00
Benjamin Otte
23c10d434c vulkan: Use CLAMP_TO_EDGE in sampler
We don't want to clamp to the border, that causes fade-outs at the
edges.
2023-06-04 19:42:01 +02:00
Benjamin Otte
87c9503293 vulkan: Rewrite AA shaders to respect scale
The border and color shaders - the ones that do AA - now multiply their
coordinates by the scale factor, which gives them better rounding
capabilities.

This in particular improves the case where they are used in fractional
scaling situations, where the scale is defined at the root element.
2023-06-04 19:42:01 +02:00
Benjamin Otte
76634cb68b vulkan: Don't allocate no descriptor sets
If we don't need them, exit early.

Shuts up the validation layers when running simple denos without
textures.
2023-06-04 19:42:01 +02:00
Benjamin Otte
52eefdb7d9 vulkan: Only use a single pipeline layout
There's no need to use 3 different ones when they are compatible.
2023-06-04 19:42:01 +02:00
Benjamin Otte
ea9f0a3372 vulkan: Don't cull vertices
We end up with the backside, when we scale(-1) and we still want it to
be visible, just flipped.
2023-06-04 19:42:01 +02:00
Benjamin Otte
8561ff37c4 vulkan: Use scale factor for offscreens and fallbacks
Previously, we just used the defaultscale factor, but now that we're
having it available in push constants, we can read it back for creating
offscreens and rendering fallbacks.

So do that.
2023-06-04 19:42:01 +02:00
Benjamin Otte
a09580b9ef vulkan: Split scale from matrix
Now, the scale is no longer part of the matrix. This allows shaders to
transform points by the scale which increases accuracy for antialiasing.
2023-06-04 19:42:01 +02:00
Benjamin Otte
0511227379 vulkan: Keep the modelview as a GskTransform
This allows doing more optimized math on it.
2023-06-04 19:42:01 +02:00
Benjamin Otte
4183ce0b52 vulkan: Split modelview and projection
This is adding extra work, but the benefits should become visible
in future commits.
2023-06-04 19:42:01 +02:00
Benjamin Otte
57222cc64c vulkan: Add scale to push constants
This way, it can be pushed to the shaders
2023-06-04 19:42:01 +02:00
Benjamin Otte
b3c1284382 vulkan: Move scale into the state object 2023-06-04 19:42:01 +02:00
Benjamin Otte
b02e054592 vulkan: Add offset to the Vulkan clip checks
This was forgotten when tracking the offset was added, so code was
actually selecting the wrong shaders.
2023-06-04 19:42:01 +02:00
Benjamin Otte
870ee06d1f vulkan: Move offset into the state object 2023-06-04 19:42:01 +02:00
Benjamin Otte
8d586be693 vulkan: Add a new GskVulkanParseState
It's a 1:1 replacement for GskVulkanPushConstants, just without the
indirection through a different file.

GskVulkanPushConstants as a struct is gone now.
The file still exists to handle the push_constants operation.
2023-06-04 19:42:01 +02:00
Benjamin Otte
94ab11b999 vulkan: Don't store push constants in RenderOp
Instead, only store the values that are needed.
2023-06-04 19:42:01 +02:00
Benjamin Otte
9b1dcd3872 vulkan: Split out gsk_vulkan_render_pass_append_push_constants()
Simplifies the code and makes future refactoring easier
2023-06-04 19:42:01 +02:00
Benjamin Otte
c37171f4d6 vulkan: Pass values to push directly
Don't require a GskVulkanPushConstants there.
2023-06-04 19:42:01 +02:00
Benjamin Otte
c479f93372 vulkan: Add a static assert
We don't want to make the push constants larger than what the spec
guarantees. And that is 128 bytes, see value for
maxPushConstantsSize in table 55 of
https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#limits-minmax
2023-06-04 19:42:01 +02:00
Benjamin Otte
186e056c56 vulkan: Handle clip properly for offscreens
This was broken in the last commit.
2023-06-04 19:42:01 +02:00
Benjamin Otte
d8b9c3ae96 vulkan: Track offset in the renderpass
This avoids emitting lots of push constant updates as most of the
transforms we have are simple translations to adjust drawing for the
next widget.
2023-06-04 19:42:01 +02:00
Benjamin Otte
5de6f12e88 vulkan: Pass scale to offscreens
Create offscreens with enough pixels for the given scale and ensure
the scale is passed on.

This improves text rendering on offscreens quite a bit.
2023-06-04 19:42:01 +02:00
Benjamin Otte
5422c12577 vulkan: Clean up scale handling
1. Use a graphene_vec2_t
2. Ensure it's always positive
3. Don't break with fallback

The scale value is nothing more than an indication of how many pixels to
assume per unit of a node.
2023-06-04 19:42:01 +02:00
Benjamin Otte
bb145b9bc1 vulkan: Fix typo 2023-06-04 19:42:01 +02:00
Benjamin Otte
a55fda0b49 vulkan: Don't store unused matrices
We can compute it when needed, so do that.
2023-06-04 19:42:01 +02:00
Benjamin Otte
5b93a32f90 vulkan: Remove unneeded argument
The initial matrix can be computed as needed, so we don't need to
precompute it.
2023-06-04 19:42:01 +02:00
Benjamin Otte
495ee1be3d vulkan: Don't explode without vertex data
If no buffer has any vertex data (read: if nothing gets drawn), don't
try to allocate a 0 bytes buffer.
2023-06-04 19:42:01 +02:00
Benjamin Otte
7f1bd1f047 vulkan: Handle empty child bounds in repeat node
Also add test to the testsuite for it.
2023-06-04 19:42:01 +02:00
Benjamin Otte
da147dca92 vulkan: Fix repeat nodes 2023-06-04 19:42:01 +02:00
Benjamin Otte
8ba5ff98aa vulkan: Don't transform the viewport rect
We don't want to render the offscreen trnsformed, we want to render it
as-is.

We lose the correct scale factor, but that requires some separate work,
so for now it gets a bit blurry on hidpi.
2023-06-04 19:42:01 +02:00
Benjamin Otte
34f4493c36 vulkan: Make quarks global variables
I don't want to ensure there's a RenderPass available everywhere and
recreate the quarks in each, I just want to use them.
2023-06-04 19:42:01 +02:00
Benjamin Otte
314923d4b5 vulkan: Split out a function
We can now create offscreens explicitly.
2023-06-04 19:42:00 +02:00