Commit Graph

1341 Commits

Author SHA1 Message Date
Maxim Solovyov
dc8def0492 backend: gl: address some clang-tidy issues 2023-07-22 00:16:31 +03:00
Maxim Solovyov
8eff87f2a3 backend: glx: address some clang-tidy issues, run clang-format 2023-07-22 00:11:21 +03:00
Yuxuan Shui
5c03f101f2 Merge pull request #1094 from absolutelynothelix/dual-kawase-optimizations 2023-07-16 13:44:38 +00:00
Maxim Solovyov
e8477e0a73 backend: fix resize factor calculation
the corresponding regions need to be resized once for each window in the
stack above the damaged window including the damaged window itself. we
were off by one.
2023-07-06 16:20:38 +03:00
Maxim Solovyov
5c00ccf4d1 backend: gl: bind default mask texture once in gl_dual_kawase_blur
and set it's uniforms once as well
2023-07-04 22:12:08 +03:00
Maxim Solovyov
0f4cd33b35 backend: gl: bind vertex array objects once in gl_dual_kawase_blur 2023-07-04 21:55:32 +03:00
Maxim Solovyov
7a45e35ca0 backend: gl: set usage of buffer objects to GL_STREAM_DRAW
it pretty much describes how we use buffer objects now

reference: https://docs.gl/gl3/glBufferData
2023-07-04 21:16:34 +03:00
Yuxuan Shui
6bd780f10f x: don't abort in release for double freeing a xrender picture
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-07-04 16:25:08 +01:00
Yuxuan Shui
1307d9ec70 core: isolate X connection with error handling into a struct
Part of the long running effort to reduce the prevalence of `session_t`.
After this, functions that communicate with X can make use of the error
handling machinary (set_ignore_cookie, set_cant_fail_cookie) without
needing to take a `session_t` parameter.

This commit converts everything to use the new struct `x_connection`,
most of the conversions are mechanical.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-07-04 16:24:53 +01:00
Monsterovich
4e6dddc76e win: don't re-bind mask image when there is already one
Co-authored-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-06-29 23:28:45 +01:00
Maxim Solovyov
d08b6092a3 win: don't include GL/gl.h
it seems unused and removing it addresses a fixme
2023-06-26 18:01:22 +03:00
Yuxuan Shui
f8cdc81635 core: add comment to set_rr_scheduling
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-06-26 13:25:53 +01:00
Yuxuan Shui
e0c14f63c6 core: don't use pthread functions
Don't use pthread_{set,get}schedparam, which requires -lpthread. Use
sched_setscheduler/sched_getparam instead, which is provided by libc.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-06-24 02:59:04 +01:00
Yuxuan Shui
9295f7e4c7 core: don't check RLIMIT_RTPRIO
FreeBSD doesn't have RLIMIT_RTPRIO. So instead we skip this check and
just always try to set our priority to the lowest SCHED_RR priority
available.

Fixes #1082

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-06-24 02:51:07 +01:00
Maxim Solovyov
15667d6b6e backend: gl: remove references to the glx backend 2023-06-18 19:34:53 +03:00
Maxim Solovyov
689321419b backend: egl: remove references to the glx backend 2023-06-18 19:30:01 +03:00
Maxim Solovyov
a377d12a66 x: add a comment on the _XSETROOT_ID root window property usage 2023-06-18 16:09:29 +03:00
Maxim Solovyov
550518c5d1 x: rewrite x_get_root_back_pixmap using root back pixmap atoms
and remove the now unused background_props_str constant
2023-06-18 15:45:06 +03:00
Maxim Solovyov
cbd2d4125c x: rewrite x_is_root_back_pixmap_atom using root back pixmap atoms 2023-06-18 15:32:15 +03:00
Maxim Solovyov
fea1dc794c atom: add atoms associated with the background pixmap 2023-06-18 14:57:50 +03:00
Maxim Solovyov
6b6a8da035 render: remove the unused background_props_str external constant 2023-06-18 14:55:22 +03:00
Monsterovich
043703e58f Merge remote-tracking branch 'upstream/next' into fix-event-handling 2023-06-17 01:25:12 +02:00
Nikolay Borodin
c065ad1b8d Refactored meson.build 2023-06-17 01:15:38 +02:00
Nikolay Borodin
56745b64d7 core: event code refactoring 2023-06-17 01:08:47 +02:00
Nikolay Borodin
07303ce2cb core: added proper event handling for XESetWireToEvent 2023-06-16 23:54:37 +02:00
Yuxuan Shui
01bb26012c Merge pull request #1000 from absolutelynothelix/set-texture-on-repeat 2023-06-16 19:02:27 +01:00
Maxim Solovyov
ecbc8b50ed backend: xrender: set created picture to repeat when binding a pixmap 2023-06-16 19:42:36 +03:00
Maxim Solovyov
9f9cff3b06 options: unify unavailability reporting of some options
unify unavailability reporting of the max-brightness, window-shader-fg
and window-shader-fg-rule options
2023-06-16 18:36:02 +03:00
Maxim Solovyov
4d724047ef options: handle max-brightness option better
allow it's use with the egl backend and report it's unavailability
better
2023-06-16 18:35:53 +03:00
Yuxuan Shui
ac55ce7b56 Merge pull request #1004 from absolutelynothelix/egl-allow-windows-shaders 2023-06-14 00:34:18 +01:00
Yuxuan Shui
9956844647 backend: log more timing info
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-06-14 00:26:30 +01:00
Yuxuan Shui
037fd4c07b Merge pull request #1022 from absolutelynothelix/xrescheck-xcb-composite-named-windows-pixmaps-test 2023-06-13 17:25:55 +01:00
Maxim Solovyov
223872bc7f backend: dummy: do not leak owned pixmaps
free pixmaps which ownership was transferred to the backend
2023-06-12 23:41:25 +03:00
Maxim Solovyov
1e398b9c24 backend: dummy: fix a typo in the dummy_get_blur_size function
"reisze_region" => "resize_region"
2023-06-12 23:11:20 +03:00
Maxim Solovyov
8245de27ed backend: gl: do not leak back and default mask textures
they're generated during backend initialization and now deleted during
deinitialization
2023-06-12 21:24:57 +03:00
Maxim Solovyov
5826adf853 backend: gl: remove gl_delete_texture function
it wasn't used and it's hard to call it a shortcut
2023-06-12 21:17:28 +03:00
Yuxuan Shui
5b6f6ecbf5 backend: egl: print egl error when eglCreateImage failed
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-06-12 12:03:37 +01:00
Yuxuan Shui
d0c121ec83 core: print some timing info from draw_callback_impl
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-06-10 23:23:24 +01:00
Yuxuan Shui
6a69cdb002 options: add a no-frame-pacing option
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-06-10 14:33:57 +01:00
Yuxuan Shui
7d9692360b core: use SCHED_RR scheduling
Make picom realtime to reduce latency, and make rendering times more
predictable to help pacing.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-06-10 14:33:45 +01:00
Yuxuan Shui
b6e7ea5639 core: don't update render statistics if we didn't actually render
Sometimes a scheduled render can end up doing nothing, e.g. if the
damage region is empty. In that case we don't have valid data to
collect and thus shouldn't update the statistics.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-06-10 14:33:36 +01:00
Yuxuan Shui
8e1f3c92f5 core: factor out code for estimating the rendering time budget
Add a render_statistics type to encapsulate all the statistics done on
rendering times. And use that to estimate the time budget for rendering
and frame pacing.

Tweak the rolling window utilities a bit so we can reuse one rolling
window for multiple statistics.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-06-10 14:33:24 +01:00
Yuxuan Shui
336cb0917a core: check we have both frame time and render time before pacing
We only checked render time. If we don't have frame time estimates, we
would divide by zero and end up with wild scheduling delays.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-06-08 20:35:33 +01:00
Yuxuan Shui
fcb9dc8cfd core: make sure unredirection happens when screen is off
So when the screen is off, we calls queue_redraw, hoping draw_callback
will be called and unredirects the screen. However, queue_redraw doesn't
queue another redraw when one is already queued. Redraws can be queued
in two ways: one is timer based, which is fine, because it will be
triggered no matter what; the other is frame based, which is triggered
by Present events.

When the screen is off, X server, depends on the driver, could send
abnormal Present events, which we ignore. But that also means queued
frame based redraw will stop being triggered.

Those two factors combined means sometimes unredirection does not happen
when the screen is off. Which means we aren't going to free the GL
context, which are still receiving Present events, but can't handle
them, because we are not rendering anything with GL. In the end all
these causes memory usage to balloon, until the screen is turned on and
we start rendering again.

And all these is not caught by leak checkers because this technically is
not a leak, as everything is eventually freed.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-06-08 20:35:31 +01:00
Yuxuan Shui
edeb17ad46 core: don't fully trust msc from present complete notify
Sometimes X sends bogus complete notifies with invalid msc number.
Instead use a saved msc number to get the next complete notify.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-06-08 20:35:30 +01:00
Yuxuan Shui
1899ef0d49 core: only check present timer alignment in the first frame
Timer can sometimes drift randomly, like when the system is suspended.
we don't want to disable frame pacing for that

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-06-08 20:35:29 +01:00
Yuxuan Shui
480fd24da6 core: stop sending NotifyMsc if frame pacing is disabled
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-06-08 20:35:28 +01:00
Yuxuan Shui
a4fae2b60a core: better frame pacing function
Details explained in the comments on schedule_render().

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-06-08 20:35:26 +01:00
Yuxuan Shui
47ffaf0a38 core: workaround X present event quirk
When the screen turns off, X sometimes sends present complete notify for
the same frame multiple times, or even events with invalid msc/ust
number.

This will cause us to ignore it and not send a subsequent NotifyMsc
request, causing the complete notify to stop.

Now we send NotifyMsc regardless to keep the events going.

Also detect when the complete notifies skip frames, divide the interval
by frame count to estimate frame time in that case.

Upstream bug report:
https://gitlab.freedesktop.org/xorg/xserver/-/issues/1418

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-06-08 20:35:25 +01:00
Yuxuan Shui
86d3739374 core: frame pacing
Use frame timing and render time statistic to pace frames.

Right now the criteria are simple:

* Don't render multiple frames in one vblank cycle. Otherwise the
  rendered frame will be delay multiple cycles, which isn't ideal.
* Start rendering as late as possible while still hitting vblank.

Refresh rate is estimated from a rolling average of frame timing. Render
time is predicted from the rolling maximum of past 128 frames. The
window size still needs to be investigated.

Remove glFinish calls and GL_MaxFramesAllowed=1, frame pacing superseeds
them.

Professionals might laugh at how rudimentary this is, but hopefully this
is better than what we had before. Which is absolutely nothing at all.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-06-08 20:35:24 +01:00