3142 Commits

Author SHA1 Message Date
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
Bilal Elmoussaoui
f5a4309f3c cogl/pango: Mark get_renderer as private
Nothing uses it externally

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4004>
2024-10-08 16:00:57 +00:00
Bilal Elmoussaoui
022977e7ba cogl/pango: Remove private cogl headers usage
As we will be merging CoglPango inside Clutter, so prepare for that
Note this removes the Cogl shared atlas debug usage, as it is private to Cogl

The usage of cogl_c_args was replaced with cogl_debug_c_args to avoid COGL_COMPILATION
pre-moving to clutter. The whole meson file will be removed later anyways.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4004>
2024-10-08 16:00:57 +00:00
Bilal Elmoussaoui
7c6effecb7 cogl/pango: Don't check if parent has a constructed override
There is always one

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4004>
2024-10-08 16:00:57 +00:00
Bilal Elmoussaoui
24af7ffc16 cogl/pango: Make Renderer private & final
Nothing uses it externally, so simplify pre-merging with clutter

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4004>
2024-10-08 16:00:57 +00:00
Bilal Elmoussaoui
2955b4b855 cogl/pango: Remove unused functions & declarations
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4004>
2024-10-08 16:00:57 +00:00
Sebastian Wick
077eb80a8d gir: Correct usage of the closure annotation
Quoting Ebassi https://www.bassi.io/articles/2023/02/20/bindable-api-2023/:

    Whenever you’re describing a function that takes a callback, you
    should always annotate the callback argument with the argument that
    contains the user data using the (closure argument) annotation

    You should not annotate the data argument with a unary (closure).

    The unary (closure) is meant to be used when annotating the callback
    type

Recently gobject-introspection became a bit more strict with this and
that generated some warnings:

    Warning: Cogl: invalid "closure" annotation: only valid on callback
    parameters

This commit fix all the closure annotations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4058>
2024-10-01 15:39:18 +02:00
Robert Mader
8e912a09d1 build: Disable asserts and cast checks in Mutter
For non-debug and non-plain cases - i.e. mainly release builds.

This ensures we use the same options in all places and draws a cleaner
distinction between g_assert() and g_return_if_fail() - the later will
still be done in release build while the former are meant for debug
only.

One advantage of doing this is that it allows us to use non-trivial
asserts more generously, such as calling `g_list_length()`.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3424>
2024-09-24 14:07:23 +00:00
Joan Torres
be39717639 cogl/pipeline/glsl: Display uniform updates on debug "show-uniforms"
When running with COGL_DEBUG=show-uniforms, display the values of the
uploaded uniforms.

This helps because it's not possible to know the uniform values only from
the shader source.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3965>
2024-09-23 20:50:31 +00:00
Joan Torres
9c0200570a cogl/boxed-value: Add function _cogl_boxed_value_to_string
This function returns a string of the boxed value considering type, size
and count; and adds a name.
e.g:

  vec2 scale = vec2(1.0000, 1.0000)

Also handle NULL cases on _cogl_boxed_value_equal.

This will be used by the next commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3965>
2024-09-23 20:50:31 +00:00
Joan Torres
1eba07f64f cogl/boxed-value: On _cogl_boxed_value_set_x, simplify mem alloc
Use _cogl_boxed_value_destroy to free the correspondent array instead of
free, which was only freeing float_array.

Add a new func _cogl_boxed_value_array_alloc to allocate the
corresponding array considering the type.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3965>
2024-09-23 20:50:31 +00:00
Joan Torres
3e629256ce cogl/boxed-value: On _cogl_boxed_value_set_x, update copying values
_cogl_boxed_value_transpose is only used for the matrix type.
Now is named _cogl_boxed_value_copy_transposed_value.
Gets the transposed value considering count (to store in array type or not).
The caller doesn't have to worry about count anymore.

Instead of calling memcpy, add function _cogl_boxed_value_copy_value
which copies the value to the corresponding boxed value property
considering type and count.
The caller doesn't have to worry about type and count anymore.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3965>
2024-09-23 20:50:31 +00:00
Joan Torres
afdd0be161 cogl/boxed-value: Use array types properly
There are three array properties, considering type:
1. float *float_array
2. int *int_array
3. void *array

Drop using array. This was inteded to be used when type is matrix and
count > 1, however some functions use it and others use
float_array. Fix this using always float_array, this starts to make all funcs
consistent handling the properties.

There's a mem leak when destroying the boxed value, only freeing the array
prop. Free the corresponding array considering the boxed value type to fix it.

_cogl_boxed_value_set_x func is still inconsistent, the next commits
will solve it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3965>
2024-09-23 20:50:31 +00:00
Daniel van Vugt
338bd62708 cogl/gles: Don't initialize glGetStringi
We never use it for ES, and for good reason: It only exists in ES 3.0
while our ES path only supports 2.0.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4019>
2024-09-20 15:29:06 +00:00
Daniel van Vugt
010d68ed5a cogl/gl: Don't initialize potentially unused/unsupported functions
`_cogl_context_get_gl_extensions` is their only user and it only uses
them for GL 3.0 so do the GL version check first.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4019>
2024-09-20 15:29:06 +00:00
Daniel van Vugt
390dd63341 cogl: Don't _cogl_context_get_gl_extensions before check_gl_version
Because for `COGL_DRIVER_GL3`, `_cogl_context_get_gl_extensions` needs to
know that the GL version *really* is >= 3.0 before it calls `glGetStringi`
which didn't exist prior to GL 3.0 or ES 3.0.

This was causing crashes on Xilinx Mali implementations that only support
ES 2.0 (hence `glGetStringi` == NULL), but were being forced to call
that function before the GL version check which should tell you the
function isn't supported.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4019>
2024-09-20 15:29:05 +00:00
Daniel van Vugt
656b836c62 cogl/egl: Restore support for EGL 1.4
It was dropped in 46.0 (683e917854) but we've now found that Xilinx Mali
only implements a strict interpretation of 1.4 [1] which doesn't support
looking up core functions [2] such as `glGetString`.

[1] https://github.com/Xilinx/mali-userspace-binaries/blob/master/Standards.txt
[2] https://registry.khronos.org/EGL/specs/eglspec.1.4.pdf § 3.10

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4019>
2024-09-20 15:29:05 +00:00
Sebastian Wick
2ce64ac0c3 cogl/gles: Use unsized internal formats for RGB8, RGBA8 in GLES 2.0
GLES 2.0 does not have RGB8 and RGBA8 as sized internal formats. There
is OES_rgb8_rgba8 which adds RGB8 and RGBA8 but only for
RenderbufferStorageOES and not for TexImage2D which I wrongly assumed.
It seems like there is currently no GLES2 extension which adds RGB8 and
RGBA8 to TexImage2D so we have no choice but to fall back to unsized
internal formats in those cases as long as we don't want to drop GLES2
support.

This should be fine in practice and we should get our 8bpc textures.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3680
Fixes: 7f943613a8 ("cogl: Use sized internal renderable formats")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4036>
2024-09-19 04:48:03 +00:00