Commit Graph

2647 Commits

Author SHA1 Message Date
Fernando Monteiro
ca25c5543a cogl: Remove cogl_material_set_layer_matrix
This function is deprecated and must be replaced to the alternative.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2058>
2021-12-07 15:32:21 +00:00
Fernando Monteiro
29c62fabac cogl: Remove cogl_material_set_layer_point_sprite_coords_enabled
This function is deprecated and must be replaced to the alternative.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2058>
2021-12-07 15:32:21 +00:00
Fernando Monteiro
8285091585 cogl: Remove material_set_layer_filters
This function is deprecated and must be replaced to the alternative.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2058>
2021-12-07 15:32:21 +00:00
Fernando Monteiro
913458381f cogl: Remove usages of framebuffer_draw_primitive
We were already returning cogl_primitive_draw in framebuffer_draw_primitive,
so replace all usages and remove it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2058>
2021-12-07 15:32:21 +00:00
Fernando Monteiro
b8925ef3d4 cogl: Remove deprecated backface_culing API
They are unused.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2058>
2021-12-07 15:32:21 +00:00
Fernando Monteiro
74fe57b018 cogl: Remove deprecated depth_test API
They are unused.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2058>
2021-12-07 15:32:21 +00:00
Simon McVittie
a49c98d8d8 tests: Don't continue if setup commands fail
Because POSIX sh was, with hindsight, not a particularly well-designed
programming language, if we don't 'set -e', then we'll respond to failure
of a setup command such as cd by carrying on regardless.

Signed-off-by: Simon McVittie <smcv@debian.org>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2009>
2021-11-17 09:04:07 +00:00
Simon McVittie
7af1043865 tests: Don't use TestEnvironment
The assumption here seems to be that it's an overlay onto the
current environment which would make sense; but the implementation in
gnome-desktop-testing currently removes all other environment variables
(see GNOME/gnome-desktop-testing#1). This causes test failure when the
tests are run in Debian's autopkgtest framework, possibly because PATH
is cleared.

Signed-off-by: Simon McVittie <smcv@debian.org>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2009>
2021-11-17 09:04:07 +00:00
Erico Nunes
87965b5ce2 cogl: Add support for partial update
Add support for a cogl function to set the damage_region on an onscreen
framebuffer.
The goal of this is to enable using the EGL_KHR_partial_update extension
which can potentially reduce memory bandwidth usage by some GPUs,
particularly on embedded GPUs that operate on a tiling rendering model.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2023>
2021-10-26 16:56:39 +00:00
Carlos Garnacho
c869b92d5d cogl: Plug leak in error path
If the renderer fails to connect, we were leaking the renderer.

CID: #1505882
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2061>
2021-10-25 15:45:35 +02:00
Carlos Garnacho
f6726c61ca cogl: Plug leak on error path
If we don't pass the gles version check, the gl_extensions string
is leaked.

CID: #1505846
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2061>
2021-10-25 15:45:35 +02:00
Carlos Garnacho
ed9650ff42 cogl: Plug possible GString leaks
These strings are leaked if there are no changes to log. This is
perhaps never true, but this anyway good for clarity.

CIDs: #1505840, #1505884
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2061>
2021-10-25 15:45:35 +02:00
Carlos Garnacho
4dc07999c6 cogl: Plug GString leak
In some error paths, this string was being leaked. Make it g_autoptr
so it's done for us.

CID: #1505903
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2061>
2021-10-25 15:45:35 +02:00
Carlos Garnacho
774f120ac4 cogl: Fix broken check for COGL_DISABLE_GL_EXTENSION envvar
This check was always true since the variable is already set in the
if() condition above. Presumably this was meant to check for empty
strings, so do that.

CID: #1491518
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2061>
2021-10-25 15:45:35 +02:00
Jonas Ådahl
259a906b8c cogl/winsys: Remove 'multiple-onscreen' feature
It was always set, and is no longer used; remove it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
9bd2c5c6f2 cogl/context: Report error if allocating fallback texture failed
Error out if we fail to allocate the 1x1 all white fallback texture. If
we don't do this, and instead continue, any future (likely) allocation
failure will end up in obscure places that assumes the fallback texture
exists.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=1989726
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1994>
2021-09-20 16:37:37 +00:00
Robert Mader
daace1aac5 cogl: Add XRGB_FP_16161616 and XBGR_FP_16161616 formats
These match their alpha counterparts, apart from not setting the
alpha bit. This allows our internal mashinery to more easily
distinguish whether we need a slow alpha-pass during rendering or not.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1810>
2021-09-20 14:39:20 +00:00
Robert Mader
dc442e7a75 cogl: Add XRGB_2101010 and XBGR_2101010 formats
These match their alpha counterparts, apart from not setting the
alpha bit. This allows our internal mashinery to more easily
distinguish whether we need a slow alpha-pass during rendering or not.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1810>
2021-09-20 14:39:20 +00:00
Erico Nunes
420a17d12e cogl: Fix GL_EXT_discard_framebuffer extension check
Using "framebuffer_discard" in the list refers to an invalid extension.
The extension which introduces glDiscardFramebufferEXT is
"GL_EXT_discard_framebuffer".

With this fix, cogl_gl_framebuffer_fbo_discard_buffers can actually call
glDiscardFramebufferEXT.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1974>
2021-08-24 18:33:09 +02:00
Florian Müllner
8158e96004 cogl: Remove conditional g_type_init() call
glib 2.36 hasn't met our minimum requirements for years.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1957>
2021-08-22 17:32:12 +00:00
Jonas Ådahl
6d64a43b1f cogl/trace: Add getter for trace enabled state
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1700>
2021-07-29 15:16:48 +02:00
Jonas Ådahl
8bd75747b1 cogl/trace: Add scoped trace anchors
A trace "anchor" is a trace head (CoglTraceHead) that is placed in a
certain scope (e.g. function scope), but then only triggered in another
scope, e.g. a condition.

This makes it possible to have optional trace instrumentation, that is
enabled only given e.g. a debug flag.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1700>
2021-07-29 15:16:48 +02:00
Jonas Ådahl
b1ac1327cd cogl/trace: Add way to add a description to trace
This is useful to pass more complex information, generated at runtime.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1700>
2021-07-29 15:16:48 +02:00
Jonas Ådahl
dd40e35ab2 cogl/trace: Fix argument naming
The argument passed to COGL_TRACE() and friends is the "name", not the
optional "description". Clean this up so we can add description handling
too.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1700>
2021-07-29 15:16:48 +02:00
Jonas Ådahl
e4375046e0 cogl/gl: Handle bogus glGetString(GL_RENDERER) return values
Seems glGetString(GL_RENDERER) in the wild can return NULL, causing
issues with strstr(). Handle this more gracefully by using
g_return_val_if_fail(), that assumes a NULL renderer means software
rendering.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1931>
2021-07-16 18:17:04 +02:00
Ivan Molodetskikh
f1024564a2 cogl: Store CPU and GPU rendering timestamps in frame info
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1762>
2021-07-13 08:09:42 +00:00
Ivan Molodetskikh
8c258d1de1 cogl: Add CPU swap time and GPU rendering query to CoglFrameInfo
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1762>
2021-07-13 08:09:42 +00:00
Ivan Molodetskikh
fbe6740df1 cogl: Add GPU timestamp querying utilities
Add utilities that allow getting the current GPU timestamp and creating
a query which completes upon completion of all operations currently
submitted on a framebuffer. Combined, these two allow measuring how long
it took the GPU to finish rendering something to a framebuffer.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1762>
2021-07-13 08:09:42 +00:00
Ivan Molodetskikh
cc08af48f6 cogl: Add prototypes for getting timestamp queries
Will be used for measuring GPU rendering duration.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1762>
2021-07-13 08:09:42 +00:00
Jonas Ådahl
5e45dc15b6 cogl/renderer: Add API to bind the right EGL API
We need to call eglBindAPI() with GLES before we setup the secondary
GPU blit. We've been lucky not really needing this, as it has been
GLES default, which is what the secondary blit uses, in order to not
depend on the default, or if we want to create the secondary blit
objects after initializing cogl, we must make sure to bind the right API
at the right time.

As we need to bind the GLES API when setting up the secondary blit, we
need to make sure that cogl gets the right API bound when that's done,
so Cogl can continue working. For this, add a "bind_api()" method on the
CoglRenderer object, that will know what API is correct to bind.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:26 +02:00
Zander Brown
cfe6cda694 cogl: Export cogl_blend_string_error_quark
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1916>
2021-07-05 23:01:37 +01:00
Daniel van Vugt
936696afcf cogl/winsys-glx: Request 2 stencil bits
Just like we do on EGL. Two bits are required because
`cogl-clip-stack-gl.c` needs each stencil buffer element to be able to
count from 0 to 2.

This mistake probably went unnoticed because:

 * Drivers usually provide more than 1 anyway; and

 * Optimizations in `cogl-clip-stack-gl.c` avoid calling the code that
   needs to count past 1 in most cases.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1873>
2021-06-01 15:44:05 +08:00
Daniel van Vugt
216bb7f960 cogl/clip-stack-gl: Set glStencilMask correctly for clip regions
Previously we were using a mask of 0x1 for the lifetime of the stencil.
This was wrong for two reasons:

  * The intersection algorithm needs to count up to a maximum 2, so a
    mask of 1 would clamp to 1 instead. Then decrementing all pixels
    resulted in all pixels being zero even though we want some to be 1.
    So the stencil then blocked some color buffer pixels being rendered.

  * The lifetime of the mask was too long. By leaving it non-zero at
    the end of the function we could accidentally end up modifying the
    stencil contents during our later color buffer paints.

This fixes faulty rendering of some actors seen in gnome-shell with
test case: `env COGL_DEBUG=stencilling`

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1873>
2021-06-01 15:44:01 +08:00
Daniel van Vugt
5991f53c84 cogl/clip-stack-gl: Set glStencilMask correctly for clip rectangles
Previously we were using a mask of 0x1 for the lifetime of the stencil.
This was wrong for two reasons:

  * The intersection algorithm needs to count up to a maximum 2, so a
    mask of 1 would clamp to 1 instead. Then decrementing all pixels
    resulted in all pixels being zero even though we want some to be 1.
    So the stencil then blocked some color buffer pixels being rendered.

  * The lifetime of the mask was too long. By leaving it non-zero at
    the end of the function we could accidentally end up modifying the
    stencil contents during our later color buffer paints.

This fixes missing rendering of some actors seen in gnome-shell with
test case: `env COGL_DEBUG=stencilling CLUTTER_PAINT=disable-clipped-redraws`

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1873>
2021-06-01 15:43:33 +08:00
Daniel van Vugt
c3d64cc05b cogl: Add new option COGL_DEBUG=stencilling to disable optimizations
This means stencilling every clip stack entry even when stencilling could
be skipped. This visibly reveals some bugs in the stencilling logic.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1873>
2021-06-01 15:42:52 +08:00
Daniel van Vugt
f390340da5 cogl/clip-stack-gl: Remove unused code: #define GL_CLIP_PLANEn
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1873>
2021-06-01 15:42:52 +08:00
Marco Trevisan (Treviño)
7d88386ee1 mutter-cogl.test: Use xvfb-run to run the cogl tests
The cogl tests need to run with a display server set, however since we
use TestEnvironment, only the listed env variables will be exposed to
the test and so no DISPLAY will be set when launching it with
gnome-desktop-testing-runner.

As per this, just run the tests using xvfb-run so that we match what's
happening in CI and we ensure that the tests are run in a safe
environment.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1876>
2021-05-26 21:03:45 +02:00
Jonas Ådahl
72f03e9c74 cogl: Remove ability to bind Wayland EGL display
We do that in the Wayland infrastructure code now, so remove Cogl's
ability to do the same.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1863>
2021-05-18 14:03:22 +00:00
Carlos Garnacho
9e10d2fa88 cogl: Drop "volatile" from static GTypes in manual registration
As documented in g_once_init_enter(): "While @location has a volatile qualifier,
this is a historical artifact and the pointer passed to it should not be
volatile.". And effectively this now warns with modern glibc.

Drop the "volatile" qualifier from these static variables as it's expected.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1785>
2021-03-22 10:47:51 +00:00
Jonas Ådahl
ec14f51ae3 cogl/onscreen/egl: Remove platform pointer
It's not used anymore, so remove it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1759>
2021-03-08 15:02:30 +00:00
Ivan Molodetskikh
47183a94eb cogl/frame-info: Add VSYNC flag
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:11 +00:00
Ivan Molodetskikh
9123aa4e84 cogl/frame-info: Add ZERO_COPY flag
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:11 +00:00
Ivan Molodetskikh
c96fb181ab cogl/frame-info: Add sequence
It will be used for the presentation-time Wayland protocol.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:11 +00:00
Ivan Molodetskikh
5d8cb2786b cogl: Remove get_monotonic_time_ns()
It's no longer needed. Everything else uses and assumes
g_get_monotonic_time().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:11 +00:00
Ivan Molodetskikh
4ba2df0bd2 cogl: Remove cogl_get_clock_time()
It's no longer used.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:11 +00:00
Ivan Molodetskikh
4810164885 cogl: Make presentation time always MONOTONIC
This concerns only the cases when the presentation timestamp is received
directly from the device (from KMS or from GLX). In the majority of
cases this timestamp is already MONOTONIC. When it isn't, after this
commit, the current value of the MONOTONIC clock is sampled instead.

The alternative is to store the clock id alongside the timestamp, with
possible values of MONOTONIC, REALTIME (from KMS) and GETTIMEOFDAY (from
GLX; this might be the same as REALTIME, I'm not sure), and then
"convert" the timestamp to MONOTONIC when needed. An example of such a
conversion was done in compositor.c (removed in this commit). It would
also be needed for the presentation-time Wayland protocol. However, it
seems that the vast majority of up-to-date systems are using MONOTONIC
anyway, making this effort not justified.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:11 +00:00
Ivan Molodetskikh
d8606829c4 cogl: Report presentation time in microseconds
KMS and GLX device timestamps have microsecond precision, and whenever
we sample the time ourselves it's not the real presentation time anyway,
so nanosecond precision for that case is unnecessary.

The presentation timestamp in ClutterFrameInfo is in microseconds, too,
so this commit makes them have the same precision.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:10 +00:00
Ivan Molodetskikh
9d54ef3994 cogl/frame-info: Add HW_CLOCK flag
A flag indicating whether the presentation timestamp was provided by the
display hardware (rather than sampled in user space).

It will be used for the presentation-time Wayland protocol.

This is definitely the case for page_flip_handler(), and I'm assuming
this is also the case for the two instances in the GLX code.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:10 +00:00
Robert Mader
df4508e8cf cogl: Stop using GSlice
It has been inofficially deprecated for years, is known to cause issues
with valgrind and potentially hides memory corruption.
Lets stop using it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1512>
2021-02-22 13:51:30 +01:00
Jonas Ådahl
7ddbcd1fd2 cogl/journal: Don't sometimes hold a ref on the framebuffer
d42f1873fc introduced a semi circular
reference between the CoglFramebuffer, and CoglJournal, where
CoglJournal would keep a reference on the CoglFramebuffer when there
were any entries in the journal log.

To avoid risking leaking these objects indefinitely, when freeing
objects without doing anything that triggered a flush, CoglFramebuffer
had a "filter" on cogl_object_unref() calls, which knew
about under what conditions CoglJournal had a reference to it. When it
could detect that there were only the journal itself holding such a
reference, it'd flush the journal, effectively releasing the reference
the journal held, thus freeing itself, as well as the journal.

When CoglFramebuffer was ported to be implemented using GObject instead
of CoglObject, this "filter" was missed, causing not only awkward but
infrequent leaks, but also situations where we'd flush journals when
only the journal itself held the last reference to the framebuffer,
meaning the journal would free the framebuffer, thus itself, in the
middle of flushing, causing memory corruption and crashes.

A way to detect this, by asserting on CoglObject reference count during
flush, is by adding the `g_assert()` as described below, which will
assert instead cause memory corruption.

void
_cogl_journal_flush (CoglJournal *journal
{
   ...
   _cogl_journal_discard (journal);
+  g_assert (journal->_parent.ref_count > 0);
   ...
}

Fix this by making CoglFramebuffer the owner of the journal, which it
already was, and remove any circle referencing that was there before, as
it is not needed given that the CoglFramebuffer pointer is guaranteed to
be valid for the lifetime of CoglJournal as the framebuffer is the owner
of the journal.

However, to not miss flushing before tearing down, which is important as
this flushes painting calls to the driver that is important for e.g.
using the result of those journal entries, flush the journal the first
time cogl_framebuffer_dispose() is called, before doing anything else.

This also adds a test case. Without having broken the circular
reference, the test would fail on g_assert_null (offscreen), as it would
have been "leaked" at this point, but the actual memory corruption would
be a result of the `cogl_texture_get_data()` call, which flushes the
framebuffer, and causes the 'mid-flush' destruction of the journal
described above. Note that the texture keeps track of dependent
framebuffers, but it does not hold any references to them.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1474
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1735>
2021-02-18 16:59:00 +00:00