Commit Graph

803 Commits

Author SHA1 Message Date
Matthias Clasen
108eb43b01 gsk: Add some more proiler marks
These should help us determine if time is spent converting or
uploading textures.
2023-11-27 17:50:28 -05:00
Matthias Clasen
2bfd4a88d6 Fix some more static analysis warnings 2023-11-24 16:36:46 -05:00
Matthias Clasen
36314f28e2 gsk: Some more rect inlining 2023-11-24 10:35:57 -05:00
Benjamin Otte
1b08fda93e renderer: Remove offload argument from render()
It turns out it's not needed, because all relevant information for
subsurfaces is already available by querying the subsurface itself.
2023-11-14 21:54:35 +01:00
Benjamin Otte
f6b6176ec0 gl: Handle subsurfaces without GskOffload 2023-11-14 21:51:07 +01:00
Benjamin Otte
ef77a6fa73 gl: Don't punch hole if the subsurface is above
Saves some work.
2023-11-14 20:22:24 +01:00
Benjamin Otte
9185f15cd9 renderer: Add a supports_offload flag
This flag must be set when creating the class or offloading
will be disabled for this renderer.

Set that flag for the GL renderer.

Fixes the Cairo and Vulkan renderer not showing Video.
2023-11-14 13:06:05 +01:00
Matthias Clasen
904d44074f gsk gl: Handle subsurfaces during rendering
During rendering, restack offloaded subsurfaces below the main
surface, and clear the area so they peek through. After rendering,
raise the last subsurface if we haven't drawn over it.
2023-11-13 22:17:36 +01:00
Matthias Clasen
c636baf6f5 gsk gl: Make it possible to clear a rectangle
Add a blend mode to the draw command, so it can draw transparent
black. This will be used to erase the area on top of a subsurface
when we do passthrough.
2023-11-13 22:17:36 +01:00
Matthias Clasen
b7c2528ad1 gsk: Prepare subsurface offload
Use a GskOffloadInfo to update subsurfaces (and collect info about
them). Pass that info to both the diff and the render vfuncs.
2023-11-13 22:17:36 +01:00
Matthias Clasen
d0a675ab01 gsk: Add subsurface nodes
Also show them in the inspector recorder, with some information.
2023-11-13 22:17:35 +01:00
Matthias Clasen
e8894ad383 gsk: Robustness fix
I was seeing empty regions being passed as scissor.
2023-11-13 22:17:35 +01:00
Matthias Clasen
b766f92026 gsk: Use some more inline helpers 2023-11-13 22:17:35 +01:00
Matthias Clasen
b24ae31716 dmabuf: Improve consistency of debug messages
Make sure all our dmabuf debug messages are display-scoped so the
inspector doesn't trigger them, use the same formatting throughout,
and improve consistency of wording here and there.
2023-11-12 13:02:58 +01:00
Benjamin Otte
a9e4993184 Merge branch 'wip/otte/enable-debug' into 'main'
Remove G_ENABLE_DEBUG around debug checks

See merge request GNOME/gtk!6546
2023-11-07 15:12:11 +00:00
Benjamin Otte
cd7e1c1387 dmabuf: Modify gdk_gl_context_import_dmabuf()
Move a bunch of code - namely the target selection - into the function.

I want to use the same code in the NGL renderer, so no need to duplicate
it.
2023-11-07 05:12:57 +01:00
Benjamin Otte
310ab7b531 Remove G_ENABLE_DEBUG around debug checks
It started out as busywork, but it does many separate things. If I could
start over, I'd take them apart into multiple commits:

1. Remove G_ENABLE_DEBUG around GDK_DEBUG_*() calls
   This is not needed at all, the calls themselves take care of it.

2. Remove G_ENABLE_DEBUG around profiling code
   This now enables profiling support in release builds.

3. Stop poking _gdk_debug_flags and use GDK_DEBUG_CHECK()
   This was old code that was never updated.

4. Make !G_ENABLE_DEBUG turn off GDK_DEBUG_CHECK()
   The code used to
     #define GDK_DEBUG_CHECK(...) false
     #define GDK_DEBUG(...)
   which would compile away all the code inside those macros. This
   means a lot of variable definitions and debug utility functions
   would suddenly no longer be used and cause compiler errors.
2023-11-05 11:16:23 +01:00
Benjamin Otte
7ba4ba05e1 gl: Fix padding in icon library
The previous code would not pad the left side with the left column of
pixels but with the top row.

Test attached.
2023-10-31 00:50:00 +01:00
Matthias Clasen
06dda4e12b Merge branch 'memory-format-swizzle-check' into 'main'
gl: Check all swizzle values

See merge request GNOME/gtk!6524
2023-10-26 02:38:35 +00:00
Matthias Clasen
358779dfb2 dmabuf: No mipmaps for dmabuf textures
Calling glGenerateMipmap on imported dmabufs does not work, so
don't do it.
2023-10-24 22:03:31 -04:00
Benjamin Otte
2d874e601c Merge branch 'wip/otte/for-main' into 'main'
gl: Remove optimization that does the wrong thing

See merge request GNOME/gtk!6528
2023-10-24 02:51:02 +00:00
Benjamin Otte
dd7a38069f gl: Remove optimization that does the wrong thing
Drawing a texture-scale node like a texture node when the filter is set
to "linear" doesn't work, because the texture node switches to
trilinear when mipmaps are available.
2023-10-24 01:37:38 +02:00
Benjamin Otte
51a181af7a Merge branch 'wip/otte/for-main' into 'main'
dmabuf: Seek back to the start

See merge request GNOME/gtk!6526
2023-10-23 19:57:21 +00:00
Benjamin Otte
8fcd9bc0c4 gl: Make sure render_texture() sets the right format for high depth
Setting the format got lost when converting this coe to the texture
builder, because that codepaths avods the texture sniffing and always
uses RGBA8.
2023-10-23 21:22:17 +02:00
Matthias Clasen
677e78bdce gl: Check all swizzle values
There is no reason not check the alpha swizzle for being different
from its default value. I am thinking about implementing RGBx
upload with a swizzle of rgb1, and that would break here.
2023-10-23 07:55:39 -04:00
Matthias Clasen
4d1ef63009 gsk: Ensure dmabuf formats are initialized
We just poking at display members here, there is no guarantee that
dmabuf formats have been initialized. So do it explicitly.

This prevents a crash in the inspector when viewing a recorded frame
containing a dmabuf texture, since the inspector uses a separate
display connection.
2023-10-22 22:48:18 -04:00
Matthias Clasen
33bc276639 Merge branch 'dmabuf-texture-gl-downloader' into 'main'
dmabuf: Add an EGL downloader

See merge request GNOME/gtk!6489
2023-10-22 21:13:58 +00:00
Matthias Clasen
06822581f7 gsk: Use external textures
When we are running under GLES, we can use GL_TEXTURE_EXTERNAL_OES
to support YUV formats.

Since we don't want to deal with the combinatorial explosion of
compiling all our shaders with all combinations  of sampler2D vs
samplerExternalOES for all their textures, we copy the external
textures to a regular texture before using them.
2023-10-22 16:50:43 -04:00
Matthias Clasen
976143fbe9 gsk: Add a shader for external textures
This shader uses samplerExternalOES to sample an external texture
and blit it into a 'normal' texture. It only works in GLES, but
we won't use it outside of GLES.
2023-10-22 16:42:17 -04:00
Matthias Clasen
9fd4feef0c gsk: Use some GLES extensions
Allow our shaders to use samplerExternalOES, by declaring
that we use the relevant extension. Unfortunately, this
only works for gles, and requires different extensions for
gles2 and gles3. Yay
2023-10-22 16:42:17 -04:00
Matthias Clasen
5eed13bd07 gsk: Define GSK_GLES3 if we have gles3
The compiler defines GSK_GLES only for gles2. Add another define
for gles3, so we can differentiate where we need to.

This took a week to find!
2023-10-22 16:42:17 -04:00
Matthias Clasen
d02d45dd8d gsk: Allow shaders without clip variants
Add a GSK_GL_DEFINE_PROGRAM_NO_CLIP, which is like
GSK_GL_DEFINE_PROGRAM but compiles the shader just once,
with NO_CLIP defined.

This will be used in the future for shaders that do
texture conversion.
2023-10-22 16:42:17 -04:00
Matthias Clasen
13d0e311b7 gsk: Prepare for external textures
Prepare the plumbing in the GL renderer for textures that use
target GL_TEXTURE_EXTERNAL_OES. These need to use a special sampler,
so make sure our sampler machinery does not run over it.
2023-10-22 16:42:17 -04:00
Matthias Clasen
52254f755f gsk: Support dmabuf textures
Defer handling of dmabuf textures to the driver,
and add the necessary code in load_texture.
2023-10-22 16:42:17 -04:00
Matthias Clasen
f581280811 gsk: Restore bigendian support
Restore the bigendian support that was lost in b0e26873f6,
by just not using GL_BGRA with GLES on bigendian. Should be a
very rare combination, but still.
2023-10-22 16:19:31 -04:00
Matthias Clasen
f4722289f7 Merge branch 'more-bgra' into 'main'
gsk: Use has_bgra in more places

See merge request GNOME/gtk!6500
2023-10-20 13:43:51 +00:00
Matthias Clasen
b0e26873f6 gsk: Use has_bgra in more places
The glyph and icon libaries were also checking for GLES to
decide if data needs to be transformed from BGRA to RGBA.

Use the new has_bgra getter instead.

This will probably break on bigendian, because the
GL_BGRA + GL_UNSIGNED_BYTE combination is not equivalent
to the cairo format on bigendian, but this was already
broken for the gl format information that we get from
gdk_memory_format_gl_format.
2023-10-20 07:39:08 -04:00
Matthias Clasen
000c876953 gsk: Use vertex arrays when we can
Use the new has_vertex_arrays api to determine
whether we can use vertex arrays in GL.`

Fixes: #6173
2023-10-19 22:43:20 -04:00
Matthias Clasen
b95d8ebdd3 memoryformat: Change some private API
Make gdk_memory_format_gl_format take the GdkGLContext,
instead of just a gles boolean. This will let us
check for extensions that may be needed for certain
formats.

Update all callers.
2023-10-19 16:44:18 -04:00
Matthias Clasen
31abe56b7a gsk: Cosmetics 2023-10-16 23:32:37 -04:00
Matthias Clasen
b5149a483f Merge branch 'wip/chergert/update-stb' into 'main'
gsk/gl: update stb_rect_pack()

See merge request GNOME/gtk!6466
2023-10-11 00:38:36 +00:00
Christian Hergert
05b51af2d5 gsk/gl: update stb_rect_pack() 2023-10-09 22:42:57 -07:00
Christian Hergert
c1417d3d4a gsk/gl: add fast path for texture masking color
This is useful for colorizing in the same fashion we do for the glyph
texture atlas. In fact, for small GdkTexture, you will end up in something
like the icon texture atlas.

The primary motivator for this optimization is to draw various glyph-like
features from VTE such as many forms of boxes, lines, arrows, etc.
2023-10-05 20:30:00 -07:00
Christian Hergert
b010e46d13 gsk/gl: remove TypeNode conformity checking for renderjob
We don't need to be calling type node conformity checking from the tight
loop of the renderjob. Hoist that into the private header and use that
intead through via the Class pointer.
2023-09-26 18:36:56 -07:00
Christian Hergert
089c34fa03 gsk/gl: use GdkArrayImpl for tracking modelview
Like the previous change, this uses GdkArrayImpl instead of GArray for
tracking modelview changes. This is less important than clip tracking
simple due to being used less, but it keeps the implementation synchronous
with the Clip tracking code.
2023-09-26 13:58:38 -07:00
Christian Hergert
c846f8d745 gsk/gl: use GdkArrayImpl for Clip tracking
We can end up spending a lot of time in g_array_maybe_expand() through the
use of g_array_set_size() for clip tracking. That is somewhat due to the
simple nature of GArray being size-dynamic. Instead, we can use
GdkArrayImpl and let the compiler do what it does best to elide some
work and hoist other work into the calling function.

This also fixes a potential UAF in gsk_gl_render_job_push_contained_clip().
2023-09-26 13:58:35 -07:00
Benjamin Otte
0b813de72a gl: gradients should transition in unpremultiplied space
So make the gradient shaders do that.
2023-09-18 07:53:03 +02:00
Benjamin Otte
e9089f65e3 gl: Change rounded_rect_shrink()
The code now follows gsk_rounded_rect_shrink() and with it the behavior
of the Cairo renderer and Webkit.

The old code did what the GL renderer and Cairo do, but I consider that
wrong.

I did not test Chrome.

Test attached
2023-09-15 16:34:00 +02:00
Benjamin Otte
1c971c595f glrenderer: Shadows without offset do exist
Not for opaque contents, but stuff can be semi-transparent.

Testcase included.
2023-09-15 03:46:27 +02:00
Matthias Clasen
ec1a1d0e34 gl renderer: Don't assume an atlas
The source uniform may or may not point
to a glyph atlas. The optimization we do
for color nodes is only possible if it does,
so check this.

Fixes: #6094
2023-09-13 16:56:47 -04:00