Commit Graph

3355 Commits

Author SHA1 Message Date
Matthijs Velsink
b9f83265b6 gsk: Fix wrong bt709_oetf
And use the format from `gdkcolordefs.h` for good measure.
2024-10-30 23:41:47 +01:00
Benjamin Otte
a84cbe22d1 Merge branch 'wip/otte/win32-fixes' into 'main'
win32: Various fixes

See merge request GNOME/gtk!7848
2024-10-21 21:39:30 +00:00
Benjamin Otte
07a5f75fe4 gpu: Make definition match declaration 2024-10-21 20:18:46 +02:00
Matthias Clasen
0170f8e261 Drop expandtab from vim modelines
This is already covered by our editorconfig.
2024-10-21 11:39:04 -04:00
Benjamin Otte
a74457697e build: Fix MSVC warning due to Pango bug
Pango unconditionally defines STRICT, which we use, see
https://learn.microsoft.com/en-us/windows/win32/winprog/enabling-strict

And that causes a duplicate definition, so we undefined it before
including the offending Pango header.

See also https://gitlab.gnome.org/GNOME/pango/-/merge_requests/749
2024-10-21 07:35:42 +02:00
Benjamin Otte
5637b3ba20 gpu: Avoid duplicated name with Windows API
CacheData is an enum value, see
https://learn.microsoft.com/en-us/windows/win32/api/winnt/ne-winnt-processor_cache_type
2024-10-21 07:35:42 +02:00
Benjamin Otte
67a34ac1d2 build: Fix MSVC warning about type mismatch
G_STRUCT_OFFSET() returns a long.
long is a 32bit type on 64bit Windows.
Casting int to pointer of different size causes a warning.
2024-10-21 07:35:42 +02:00
Benjamin Otte
be08be2fa9 renderer: Remove unneeded headers 2024-10-21 07:35:42 +02:00
Benjamin Otte
591bc5edc0 build: Work around duplicated define of APIENTRY
epoxy defines it if windows.h hasn't been included.
So include windows.h before epoxy.

See also https://github.com/anholt/libepoxy/issues/299
2024-10-21 07:35:41 +02:00
Benjamin Otte
35c0068345 rendernodeparser: Implement font loading on Windows 2024-10-19 22:33:54 +02:00
Barnabás Pőcze
3b0a4386a8 gsk: gsk_border_node_new(): Fix dead cleanup code
The `gdk_color_finish()` calls are currently after the `return`,
so they are never executed. Move the `return` below the cleanup
code to avoid that.

Fixes: bd3d1f7715 ("gsk: Add private border node api")
2024-10-12 23:06:02 +02:00
Matthias Clasen
06b8863bf7 Merge branch 'oklab-support' into 'main'
oklab and oklch support

See merge request GNOME/gtk!7801
2024-10-12 18:44:03 +00:00
Matthias Clasen
d754f5c1b4 Merge branch 'css-color-hookup-6' into 'main'
Make non-srgb css colors work for gradients

See merge request GNOME/gtk!7584
2024-10-12 18:29:31 +00:00
Benjamin Otte
39686daa23 gpu: Remove warning
The warning gets triggered by rounding errors.

In particular when using fractional scales, the final tile may end up
not accurately matching the computed final value (in the example I was
debugging it was computing 1 vs 1.00000036 for the final tile index,
but that result computed a 0px wide tile size.
And for that tile size we hit that exit condition.
2024-10-07 11:31:34 +02:00
Matthias Clasen
df31bbf9e5 gsk: Support hue interpolation in cairo
Since cairos gradient code isn't flexible enough to let us
interpolate in oklch, add additional color stops and let cairo
interpolate in the ccs. This isn't as accurate as interpolating
in oklch, but it gets an ok result for fallback situations.
2024-10-05 13:32:16 -04:00
Matthias Clasen
965fd476a5 node parser: handle oklab and oklch 2024-10-04 21:16:36 -04:00
Matthias Clasen
3bce60c433 gsk: Handle hue-interpolation in ops
Make all our gradient ops adjust the hue according to
the hue interpolation.

This is currently modifying the values in the vertex array.
If reading those values back is bad, we may need to change that.
2024-10-04 21:16:36 -04:00
Matthias Clasen
8083456599 gsk: Handle oklab and oklch color states 2024-10-04 21:16:35 -04:00
Matthias Clasen
4368583cbe gsk: Make non-default interpolation cs work
If the interpolation color state is not a default one, use the
offscreen we already for rendering big gradients, interpolate
the gradient into it, and then use a cicp convert shader to
convert the result to the ccs.
2024-10-04 15:08:34 -04:00
Matthias Clasen
b43294c1c3 nodeparser: Handle color states for gradients
Test included.
2024-10-04 15:08:34 -04:00
Matthias Clasen
5d8e801d80 gsk: Use new gradient node apis
This requires changing the gradient ops again too,
so we can pass GskColorStop2 arrays to them.
2024-10-04 14:51:33 -04:00
Matthias Clasen
4c7631a645 gsk: Add new private gradient node api
These new apis take GskColorStop2 instead of GskColorStop.
2024-10-04 14:50:23 -04:00
Matthias Clasen
9a7d84b441 gsk: Change gradient op apis
Pass the ccs, opacity, interpolation color state and hue
interpolation explicitly, and change the argument order to
match other ops.

Since we now apply opacity in the op, change the node processor
to pass colors as-is. For now, it always passes GDK_COLOR_STATE_SRGB
for ics and GSK_HUE_INTERPOLATION_SHORTER for hue interpolation.
2024-10-04 14:50:11 -04:00
Matthias Clasen
1fe9918f3c gsk: Add GskHueInterpolation enum
This will be used in gradient-related apis.
2024-10-04 14:48:50 -04:00
Matthias Clasen
cd04aa1cd4 gsk: Change a precondition
It is nicer if gsk_gpu_color_states_create_explicit (a, a) works
regardless of whether the two are default colorstates or not.

The gradient shaders will rely on this when the ics is a non-default
color state and we use ccs == ics.
2024-10-04 14:48:50 -04:00
Benjamin Otte
5a11ee7b9c gpu: Add GSK_GPU_DISABLE=repeat
This is useful for testing of repeat nodes - both performance
and conformance, and potentially even driver issues with GL_REPEAT.

We have code for manual repeating anyway, so adding a flag to force
always using it is easy.
2024-10-03 20:11:00 -04:00
Matthias Clasen
fdea496883 gsk: Allow Vulkan software rendering as fallback
There is no reason to exclude lavapipe when we accept llvmpipe,
and lavapipe has the advantage that it supports dmabufs.
2024-10-01 20:57:49 -04:00
Matthias Clasen
02297138f3 gsk: Tweak renderer selection debug spew
Print a message for every get_renderer function that returns
FALSE, so the debug spew lets us get a clear picture of what
possibilities were tried.
2024-10-01 20:12:17 -04:00
Matthias Clasen
bfb7573810 gsk: Prefer ngl over cairo
Now that the gl renderer is no longer in our fallback sequence, use
ngl instead. With current ngl, llvmpipe is still better than cairo.
2024-10-01 19:42:08 -04:00
Matthias Clasen
eb4fb2af0e gsk: Stop falling back to the gl renderer
The GL renderer is going away. For now, it is still possible
to use it explicitly, with GSK_RENDERER=gl.
2024-09-30 19:22:54 -04:00
Matthias Clasen
9b2b5ebb65 gsk: Stop supporting gl shaders
The GL shader code uses the GL renderer for compilation, and that
renderer is going away.
2024-09-30 19:22:54 -04:00
Matthias Clasen
1624455a32 gsk: Use the ngl renderer for serializing to png
This is a step towards dropping the GL renderer.
2024-09-30 18:58:33 -04:00
Matthias Clasen
1013874de8 gpu: Drop get_dmabuf_formats
This vfunc is no longer needed.
2024-09-30 18:37:20 -04:00
Matthias Clasen
c397460c11 Drop gdk_dmabuf_downloader_supports
It is not used anymore.
2024-09-30 18:37:20 -04:00
Matthias Clasen
d0b409d349 Make gsk_gpu_frame_download_texture return status
Importing a dmabuf can fail, even if the format is supported
in princicple, In these cases, gsk_gpu_frame_download_texture
will return FALSE.
2024-09-30 18:37:20 -04:00
Matthias Clasen
279a5f7825 Make gdk_dmabuf_downloader_download failable
This will enable us to try multiple downloaders in a row.
2024-09-30 18:37:20 -04:00
Matthias Clasen
6fa87d4f37 gsk renderer: Add a debug message
Add a debug message so we can see what downloaders are used
for dmabufs.
2024-09-30 18:37:20 -04:00
Benjamin Otte
c3b836951a gl: ref the previous context
The current context might be the last reference to the context, which
would make it go away when the renderer calls make_current().

See commit 0fa2ae48d4 for a similar case.
2024-09-30 23:54:08 +02:00
Matthias Clasen
ec10f1fe16 gsk: Don't lose context during download
When we use download in the middle of an upload operation (or the
other way around), we may end up making a different GL context
current. The downloader code is reponsible for reestablishing
the previous context when it is done. The old GL renderer was
doing that, NGL wasn't, until now.
2024-09-30 23:49:59 +02:00
Benjamin Otte
ae741a06c0 gpu: Compare fourccs, not GdkMemoryFormat
For dmabufs, the format is not an exact description of the data, it only
gives the closest memory format for a given fourcc.
This of course means that multiple different fourccs may report the same
format.

So when deciding if we need to copy the image to get the right data to
download, we need to check if the fourcc is correct, not if the format
is.

Related: #7046
2024-09-30 22:14:38 +02:00
Benjamin Otte
754c9cb323 gpu: Don't use copies for dmabuf downloads
When we want to download a dmabuf, we want to download the actual
dmabuf.

If we just grab the cached image and use that, we might get the
(reuploaded) copy of the dmabuf. This happens when this renderer
doesn't support downloading this dmabuf but has used it before.

Worse, this is a reentrancy issue, where this renderer is trying to
render the dmabuf and has already scheduled the upload but the upload
has not finished. We will then download from an empty image, which is
very wrong.

The way to check that we have the actual dmabuf is a bit brittle, but it
should work.

Fixes #7046
2024-09-30 19:52:30 +02:00
Benjamin Otte
a3683a080b Merge branch 'wip/otte/global-globals' into 'main'
ngl: Use a single buffer for globals

See merge request GNOME/gtk!7753
2024-09-30 17:09:52 +00:00
Matthias Clasen
f2f219f304 Cosmetics
Make the debug message match the rest: FORMAT:MODIFIER.
2024-09-30 07:40:48 -04:00
Benjamin Otte
e18c553457 gpu: Consider scissor when intersecting with recangle
The clip might be different from the scissor due to incompatible
intersections.

But the resulting intersection might be fully clipped, so we should
consider it.

Testsuite with longer explanation attached.

Fixes #7044
2024-09-29 06:29:47 +02:00
Matthias Clasen
cb682c759d Cosmetics
No newlines in g_warning.
2024-09-27 20:54:46 -04:00
Benjamin Otte
b154c9caf4 ngL: Use a single buffer for globals
Instead of using glBuffer(Sub)Data() every time we set new globals, fill
a single buffer with all the globals and use glBindBufferRange() on that
buffer to set the current globals.
2024-09-28 02:25:40 +02:00
Benjamin Otte
6d3c333208 gpu: Actually ensure a downloadable dmabuf
For some formats, we could not download the dmabuf directly - in
particular YUV formats.
For those, do a copy on the GPU into the correct format.

While we're at it, also check the desired format and colorstate and if
they don't match, do the conversion on the GPU instead of using
gdk_memory_convert().
Reserve the CPU conversion for situations where the GPU doesn't support
the final format - like for example G8A8 (or often also RGB16).
2024-09-26 22:06:18 +02:00
Benjamin Otte
62c3923e5a gpu: Handle all colorstates in cache
Make gsk_gpu_cache_cache_texture_image() API safer by accepting all
color states as input and just not caching the images for colorstates we
don't care about.
2024-09-26 22:06:18 +02:00
Benjamin Otte
3be8b1d927 gpu: Check if the image is cached in right colorstate
This is most likely not a very likely check, but just to be sure, check
if the image exists in the cache in the desired colorstate already.
2024-09-26 22:06:18 +02:00
Benjamin Otte
27a61e221f gpu: Shuffle function arguments
Instead of passing down the depth and extracting format/srgb from it at
the end, extract format/srgb in the nodeprocessor and pass it down.

This allows creating offscreens for weirder formats in the future.
2024-09-26 22:06:18 +02:00