3159 Commits

Author SHA1 Message Date
Georges Basile Stavracas Neto
c6ecaf01c2 cogl/sampler-cache: Initialize variable
It's apparently harmless.

Coverity CID: #1511379

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4175>
2024-12-10 14:17:47 -03:00
Bilal Elmoussaoui
a2fdeac9e7 cogl/driver: Move various texture functions to TextureDriverGL
As they are now shared between GL3 and GLES3 texture driver, there is no
need anymore for having them in a separate header and included.

Cleanup the names of the functions while doing so.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4163>
2024-12-10 11:08:53 +00:00
Bilal Elmoussaoui
1401c745d7 cogl: Remove function declaration
No longer has an implementation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4163>
2024-12-10 11:08:53 +00:00
Bilal Elmoussaoui
f3430ff1c5 cogl: Add a TextureDriverGL
Abstract away the common bits between GL3 and GLES2 TextureDriver
implementations by sharing the common bits in a parent class.

Ideally, we would move the various vfuncs that are GL specific from the
abstract TextureDriver type but that can be done at a later stage once
there is actual work on adding a Vulkan driver.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4163>
2024-12-10 11:08:52 +00:00
Bilal Elmoussaoui
cde6a447b4 cogl: Move various vfuncs from DriverVtable to TextureDriver
As they make more sense there. Maybe we could have a common
OpenGLTextureDriver
that would share the common texture_2d_* vfuncs but that can be done
later.

By moving those vfuncs to the TextureDriver, we can get rid of the
texutre_2d
nop driver implementations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4163>
2024-12-10 11:08:52 +00:00
Bilal Elmoussaoui
4f16f6df3b cogl: Turn TextureDriver into an abstract object
The motivation is to ease sharing bits between the various texture
drivers implementations.
The same thing would be done for DriverVtable & WinsysVtable.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4163>
2024-12-10 11:08:51 +00:00
Bilal Elmoussaoui
9181fdf5c2 cogl: Don't expose FramebufferBits
Fixes 34f4b8064fb32da792e69cebb911c394ab1eb8b7

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4174>
2024-12-10 08:58:24 +01:00
Georges Basile Stavracas Neto
4e8da5304a cogl/pipeline-layer: Use G_DECLARE_FINAL_TYPE
Same deal

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4155>
2024-12-09 13:23:29 +00:00
Georges Basile Stavracas Neto
ac07f10de3 cogl/pipeline: Use G_DECLARE_FINAL_TYPE
Lets us get rid of the boilerplate.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4155>
2024-12-09 13:23:29 +00:00
Georges Basile Stavracas Neto
b0fd29ece2 cogl: Drop CoglNode
It's not necessary anymore.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4155>
2024-12-09 13:23:29 +00:00
Georges Basile Stavracas Neto
8540362d1d cogl/pipeline: Inherit from GObject
Same deal as CoglPipelineLayer.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4155>
2024-12-09 13:23:29 +00:00
Georges Basile Stavracas Neto
a88f0b72aa cogl/pipeline-layer: Inherit from GObject directly
Instead of inheriting from CoglNode, inherit from GObject and manually
manage children.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4155>
2024-12-09 13:23:29 +00:00
Bilal Elmoussaoui
b0219f0697 cogl: Add default impls for FramebufferDriver
Allowing to simplify the NopFramebufferDriver.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4165>
2024-12-09 13:12:29 +00:00
Bilal Elmoussaoui
195a9b5f87 cogl/driver: Make various vfuncs optional
Avoid having to provide an impl for the NopDriver.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4165>
2024-12-09 13:12:29 +00:00
Michel Dänzer
18fbea0b03 cogl: Do not call glFlush in cogl_gl_create_timestamp_query
SwapBuffers will implicitly flush the query along with the other GPU
work for the frame.

The comment was about this function being called for direct scanout,
which hasn't been the case since 56580ea7c941 ("backends/native: Assume
zero rendering time for direct scanout buffers").

This eliminates one GPU work flush to the kernel per frame with the
Mesa radeonsi driver, leaving only a single flush per frame.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4158>
2024-12-06 11:22:05 +00:00
Michel Dänzer
33a9a1cace cogl/onscreen: Call _cogl_context_update_sync after the buffer swap
Indirectly via cogl_framebuffer_flush, since we also need to call
glFlush now. Need to do it in cogl_onscreen_egl_swap_* because
meta_onscreen_native_swap_buffers_with_damage uses
cogl_context_get_latest_sync_fd.

Doing it before the swap was problematic because the swap may do GPU
work of its own, which wasn't covered by the EGL sync object created in
_cogl_context_update_sync. This could result in visual artifacts. See
the discussion starting at
https://gitlab.freedesktop.org/mesa/mesa/-/issues/11996#note_2678104 for
details.

For similar reasons, move the cogl_framebuffer_finish calls after the
swap as well.

As a bonus, this eliminates one of 3 GPU work flushes to the kernel per
frame with the Mesa radeonsi driver, because the glFlush/glFinish call
in cogl_framebuffer_flush/finish doesn't have any GPU work to flush
after SwapBuffers.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4158>
2024-12-06 11:22:05 +00:00
Jonas Ådahl
2205181da8 cogl/renderer: Add API to get the implicit modifier
This allows avoiding having to depend on libdrm in places that are
otherwise independent of the backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3900>
2024-12-05 19:12:09 +00:00
Jonas Ådahl
01dcec31b0 cogl/renderer: Add way to filter modifiers by external-only
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3900>
2024-12-05 19:12:09 +00:00
Jonas Ådahl
e3f743facc cogl/renderer: Add API to query DRM format modifiers
Will be used to do explicit modifier buffer allocation via the Cogl API.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3900>
2024-12-05 19:12:09 +00:00
Jonas Ådahl
78cfbb57eb cogl/renderer: Remove stray newline
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3900>
2024-12-05 19:12:09 +00:00
Jonas Ådahl
8509b74532 Make DMA buffer allocation format and modifier aware
This makes DMA buffer allocation in all layers take an array of possible
modifiers to allocate using, or zero modifiers if implicit modifiers
should be used.

The format hard coding previously used is moved to the screen cast code,
or in case of the (unused by default) shadow buffer buffers use the same
format as the the CoglOnscreen.

This also means the CoglDmaBufHandle and MetaDrmBuffer got taught how to
distinguish between planes. It's mostly unused in practice, so rather
untested.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3900>
2024-12-05 19:12:09 +00:00
Jonas Ådahl
a4ddba44e9 onscreen/native: Move DRM modifier querying to MetaRenderDevice
It's only implemented by the GBM render device backend, and uses EGL,
thus does not distinguish scanout capable modifiers.

A filter enum is added to Cogl, since it'll be used via the Cogl API,
but the actual Cogl API isn't added yet.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3900>
2024-12-05 19:12:09 +00:00
Bilal Elmoussaoui
03c36f94bb cogl/buffer: Don't store "vfuncs" in the struct
This was done during the move to a GObjectified Buffer instance, but in
the future when we will move the DriverVtable to an abstract class, this
would annoy us.

Given that those functions are only used internally in three instances,
just replace them with the actual logic of checking whether tu use
malloc fallback path or not.

Helps https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4132

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4137>
2024-12-04 23:51:18 +02:00
Bilal Elmoussaoui
6d37dbdc40 cogl/winsys: Drop unnused functions
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4162>
2024-11-30 17:05:02 +00:00
Jonas Ådahl
85d2d49499 wayland/surface: Unconditionally set scanout destination rect
The cogl_scanout_get_dst_rect() fell back on the buffer dimensions as
the destination rectangle when nothing was explicitly set. This,
however, is not necessarily correct. For example, if a buffer is larger
the CRTC resolution, but the surface is scaled to exactly match the CRTC view,
the expected destination size should match the CRTC resolution, not the
buffer dimension, which would be the case if no explicit destination was
set.

In meta_wayland_try_aquire_scanout() we're in a good position to
determine the destination rect in the CRTC primary plane, since we have
all the prerequisits, i.e. that the surface effectively covers the whole
CRTC, the actor allocation box (the non-black border part), the scale
and transform of the view.

This tweaks the CoglScanout API a bit to make it explicit that the
dst_rect must be unconditionally provided, and removes the fallback to
the buffer dimension as the destination rectangle, which sometimes
resulted in a destination rectangle being larger than the primary plane
itself, resulting in clipping and incorrect scaling.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3773
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4147>
2024-11-27 20:18:31 +00:00
Jocelyn Falempe
18085b0e40 cogl/egl: Choose config only if needed
In try_create_context(), if COGL_EGL_WINSYS_FEATURE_NO_CONFIG_CONTEXT
is set, don't try to choose an egl config.

Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4088>
2024-11-22 14:21:31 +00:00
Sebastian Wick
f467a31d56 onscreen: Get device and window handle for onscreens
This adds a new method which returns the device and window handle for
onscreen framebuffers. Renderdoc uses those handles to target what it
is going to capture.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4061>
2024-11-15 14:04:35 +00:00
Bilal Elmoussaoui
d92bb351da clutter: Remove duplicated ShaderType
As we have the exact same one in Cogl.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4127>
2024-11-12 10:01:29 +00:00
Bilal Elmoussaoui
1ba28bc6b4 cogl: Get rid of remaining MetaTexture usages
As that pseudo-interface no longer exists since the migration to
GObjectified CoglTexture.
Also moves cogl_meta_texture_foreach_in_region to the correct namespace.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4127>
2024-11-12 10:01:29 +00:00
Bilal Elmoussaoui
c143e8e303 cogl: Move get_rectangle_indices to it correct namespace
Keep the implementation in cogl-indices.c though as it is too much of
implementation details to be in cogl-context.c.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4127>
2024-11-12 10:01:29 +00:00
Bilal Elmoussaoui
45296416df cogl: Move blit_framebuffer to it correct namespace
As it belongs into CoglFramebuffer.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4127>
2024-11-12 10:01:29 +00:00
Sebastian Keller
80f92e0a20 cogl/boxed-value: Set size on initialization
Since 1eba07f6 the size of a boxed value is read when calling
_cogl_boxed_value_set_x(). This results in an uninitialized read when
setting uniforms using cogl_pipeline_set_uniform_*() since the size was
not initialized by _cogl_pipeline_override_uniform() when these
functions call _cogl_boxed_value_set_*().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4125>
2024-11-11 15:37:33 +00:00
Bilal Elmoussaoui
a02aa42a9f cogl: Mark various types as final
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4100>
2024-11-11 12:18:28 +00:00
Bilal Elmoussaoui
2a3e6a2df5 cogl/texture: Use macros for generating subclassing boilerplate
We can't unfortunately use the macros for the sub-types as the whole GL
variant of the texture wants access to the struct fields even when using
a macro like COGL_DECLARE_INTERNAL_TYPE. So we would have to re-do the
whole driver integration first.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4100>
2024-11-11 12:18:28 +00:00
Bilal Elmoussaoui
34f4b8064f cogl: Move types definition to a common header
Avoids re-defining the types and cyclic dependencies between headers.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4100>
2024-11-11 12:18:28 +00:00
Bilal Elmoussaoui
80316eb1d6 cogl/texture: Add a is-primitive property
Avoids accessing texture's private struct from sub-types.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4100>
2024-11-11 12:18:28 +00:00
Bilal Elmoussaoui
cc3bf059e6 cogl/texture: Add a is_allocated helper
Reduce the usage of direct access of Texture struct fields, so we can
migrate to using macros in the future.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4100>
2024-11-11 12:18:28 +00:00
Bilal Elmoussaoui
7d5f1b5898 cogl: Mark helper as static
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4100>
2024-11-11 12:18:28 +00:00
Bilal Elmoussaoui
09198db2e6 cogl/indices: Remove unused Indices.set_offset
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4100>
2024-11-11 12:18:28 +00:00
Bilal Elmoussaoui
30ed9c05de cogl/primitive: Mark as a final type
Also removes a function declaration.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4100>
2024-11-11 12:18:28 +00:00
Jonas Ådahl
c8fc1edea6 cogl/onscreen: Pass regions instead
Go one step further and pass regions. Sometimes the rectangles were
already a region, e.g. the swap-buffer case, and sometimes it still
potentially needs to pass through a rectangle array, e.g. damage with a
view transform.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4103>
2024-11-07 11:53:22 +00:00
Jonas Ådahl
3548faed03 cogl/onscreen: Pass rectangle arrays as MtkRectangle arrays
Only before passing to EGL does it need to become a int tuple array.
It's used in non-EGL places which now become more easy to read. While at
it, make use of the new (and tweaked) helper function for flipping
rectangles from "cogl space" to "GL space".

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4103>
2024-11-07 11:53:22 +00:00
Jonas Ådahl
5deef6accb cogl/onscreen: Pass damage regions unflipped
The other similar API all operate with the assumptions that (0,0) is at
the top left, so lets make damage regions behave this way too. Add a
helper to flip the rectangles, to make it a bit more convenient. It'll
be used in more places in a follow up.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4103>
2024-11-07 11:53:22 +00:00
Sebastian Wick
5e98ee5dbe cogl: Add pipeline hooks to user program pipelines
Instead of just adding the cogl header boilerplate, we'll redirect the
main function with #define and #undef to cogl_main(). The real main
calls the hooks-generated cogl_hooks() which chains up to the users
main() which is now called cogl_main().

    <boilerplate>
    #define main cogl_main
    <user shader>
    <hook functions>
    void
    cogl_hooks () {
      cogl_main ();
      <hook code>
    }
    #undef main
    void main () { cogl_hooks(); }

This allows the user shader to continue using shaders which seem like
they define the main function and output to the framebuffer but also
gives the CoglPipeline a chance to add hooks.

This in particular makes our ClutterColorState transform hooks work on
user programs which are used by ClutterShaderEffects.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7804
Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7805
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3662
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4037>
2024-11-06 10:51:55 +00:00
Michel Dänzer
20b730c76c cogl: Remove unused found_egl_config field
Unused since 812aba31e700 ("winsys: Drop xlib_get_visual_info from the
vtable").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4105>
2024-10-22 12:40:01 +00:00
Michel Dänzer
0348913afa cogl: Update latest sync fd also in cogl_onscreen_swap_region
Same as in cogl_onscreen_swap_buffers_with_damage.

Fixes: 99209958b90b ("cogl: Store latest GPU work completed sync fd")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4057>
2024-10-21 11:38:26 +00:00
Bilal Elmoussaoui
76b2655495 cogl: Remove pango debug flag
As there is no pango usage as part of cogl anymore

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4004>
2024-10-08 16:00:57 +00:00
Bilal Elmoussaoui
fe3192169a Merge CoglPango inside of Clutter
As that is where the whole text rendering integration happens
And would allow us to get rid of some over-abstraction in cogl-pango,
simplify
ClutterSnapshot integration as well

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4004>
2024-10-08 16:00:57 +00:00
Bilal Elmoussaoui
b6b004b437 cogl/pango: Make FontMap type private
It is an implementation detail, nothing really makes use of any of it
specific APIs

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4004>
2024-10-08 16:00:57 +00:00
Bilal Elmoussaoui
cdc43065e0 cogl/pango: Remove font map helper
It only calls into pangocairo API and only used inside clutter
so just call pangocairo API directly

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4004>
2024-10-08 16:00:57 +00:00