Commit Graph

1419 Commits

Author SHA1 Message Date
Yuxuan Shui
fdbcd15975 backend: fix clang warning
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2024-01-29 23:57:11 +00:00
Yuxuan Shui
733113c691 Merge pull request #1171 from absolutelynothelix/corner-radius-rules-only 2024-01-29 23:53:24 +00:00
Yuxuan Shui
14a345a817 vblank: make init fallible
Improve error handling in sgi_video_sync_scheduler_init a bit.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2024-01-29 22:11:01 +00:00
Yuxuan Shui
5fba210ad6 vblank: make schedule fallible
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2024-01-29 22:07:04 +00:00
Yuxuan Shui
1bfb129985 backend: don't choose SGI_video_sync vblank if opengl is not enabled
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2024-01-29 21:02:36 +00:00
Maxim Solovyov
8ca66f8a00 win: allow corner-radius-rules without corner-radius
check if there is an override in corner-radius-rules even when
corner-radius is 0.
2024-01-29 23:16:51 +03:00
Yuxuan Shui
f3bdd01dc8 vblank: don't use symbols from backend/gl/glx.h
sgi video sync runs in a separate thread, we don't want to have
potential races between threads.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2024-01-29 17:52:44 +00:00
Yuxuan Shui
d87dd41f4c win: make sure window's client_win can't be XCB_NONE
This is a follow up to 81d137a3cc and
bug #704. Basically a window will have a `XCB_NONE` as `client_win` if its
previous client_win detached and then the window itself is immediately
destroyed. Because the window is destroyed we couldn't call
`win_recheck_client` so its `client_win` will remain `XCB_NONE`.

However, it turns out we have a convention of setting `client_win` to
the window itself if windows that don't have a client window. So make
sure this convention is followed even for destroyed windows.

Doesn't really fix anything, just to make sure an invariant holds.

Related: #704

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2024-01-21 19:58:29 +00:00
Yuxuan Shui
ce205d1591 win: add more debug logs for window updates
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2024-01-21 19:26:20 +00:00
Yuxuan Shui
56da153f1c Update copyright
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2024-01-21 17:35:18 +00:00
Yuxuan Shui
81d137a3cc core: fix debug window check in paint_preprocess
Fixes #704

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2024-01-21 17:27:05 +00:00
Yuxuan Shui
6e3c86226b core: improve debug log formatting around paint_preprocess
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2024-01-21 17:26:46 +00:00
Yuxuan Shui
dc2d7b2876 options: use of respect-prop-shadow is now an error
Deprecated in v8.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2024-01-14 17:06:34 +00:00
Yuxuan Shui
5e119123a7 options: use of sw-opti is now an error
Deprecated in v6, we forgot to remove it.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2024-01-14 17:04:58 +00:00
Yuxuan Shui
6d4eaec811 options: remove -F
Deprecated in compton, in distant history.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2024-01-14 16:58:56 +00:00
Yuxuan Shui
148e61a0b2 Merge pull request #1156 from yshui/pacing-fixes 2024-01-14 15:46:24 +00:00
Yuxuan Shui
d8f303761b core: reset msc counter if it went backwards
Otherwise we might be repeatedly hitting this condition and spam the
warning.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2024-01-14 15:41:41 +00:00
Maxim Solovyov
cacb45fbcd core: fix segfaults when the HOME environment variable is not set 2023-12-22 13:26:32 +03:00
Yuxuan Shui
b368072e12 Merge pull request #1002 from tryone144/fix/use-effective-texture-size-for-corner-radius 2023-12-20 10:48:14 +00:00
Yuxuan Shui
359d004b99 core: disable frame pacing when vsync is disabled
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-12-19 23:27:19 +00:00
Yuxuan Shui
6e0bad0034 core: make missing dpms extension non-fatal
We are not using it for anything at the moment, and it is breaking CI.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-12-19 23:27:16 +00:00
Yuxuan Shui
a28e221b83 driver: choose sgi_video_sync scheduler for NVIDIA
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-12-19 23:27:15 +00:00
Yuxuan Shui
b582d2989e core: add debug options to override the vblank scheduler
Useful for debugging.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-12-19 23:27:14 +00:00
Yuxuan Shui
db9b808bfb vblank: add GLX_SGI_video_sync based scheduler
Present extension based scheduler doesn't work well on NVIDIA drivers.
GLX_SGI_video_sync is less accurate, but is rumoured to work. See
[kwin's usage](https://invent.kde.org/plasma/kwin/-/blob/master/src/
backends/x11/standalone/x11_standalone_sgivideosyncvsyncmonitor.cpp)

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-12-19 23:27:12 +00:00
Yuxuan Shui
db6ed75b60 core: don't always delay schedule_render to vblank
It's kind of dumb anyway. If we get damage event right after a vblank
event, we would waste the whole vblank.

Instead improve the frame scheduling logic to target the right vblank
interval. This only affects smart_frame_pacing anyway.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-12-19 23:27:11 +00:00
Yuxuan Shui
dd83f550e1 core: always check if render is finished at next vblank
Right now we rely on `reschedule_render_at_vblank` being scheduled for
the render finish check. Which means we will only know if a frame has
finished rendering the next time we queue a render. And we only check at
vblank boundary, which means when a render is queued we have to wait for
the next vblank, when had we checked earlier, we will be able to start
rendering immediately

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-12-19 23:27:10 +00:00
Yuxuan Shui
c42e6cef0a vblank: winding down vblank events instead of stopping immediately
I noticed sometimes full frame rate video is rendered at half frame rate
sometimes. That is because the damage notify is sent very close to
vblank, and since we request vblank events when we get the damage, we
miss the vblank event immediately after, despite the damage happening
before the vblank.

       request  next  ......  next next
damage  vblank vblank          vblank
   |    |       |     ......      |
   v    v       v                 v
---------------------->>>>>>---------

`request vblank` is triggered by `damage`, but because it's too close to
`next vblank`, that vblank is missed despite we requested before it
happening, and we only get `next next vblank`. The result is we will
drop every other frame.

The solution in this commit is that we will keep requesting vblank
events, right after we received a vblank event, even when nobody is
asking for them. We would do that for a set number of vblanks before
stopping (currently 4).

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-12-19 23:27:08 +00:00
Yuxuan Shui
25d16b0352 x: fix x_request_vblank_event
present_notify_msc with divisor == 0 has undocumented special meaning,
it means async present notify, which means we could receive MSC
notifications from the past.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-12-19 23:27:07 +00:00
Yuxuan Shui
3838b45e2c core: simplify pacing logic a bit more
Also, vblank event callback should call schedule_render to queue renders
instead of starting the draw timer directly, so that the CPU time
calculation will be correct.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-12-19 23:27:06 +00:00
Yuxuan Shui
4b57e3aa4c config: add debug options to enable timing based pacing
Disable timing estimation based pacing by default, as it might not work
well across drivers, and might have subtle bugs.

You can try setting `PICOM_DEBUG=smart_frame_pacing` if you want to try
it out.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-12-19 23:27:04 +00:00
Yuxuan Shui
1430d28116 core: refactor frame pacing
Factored out vblank event generation, add abstraction over how vblank
events are generated. The goal is so we can request vblank events in
different ways based on the driver we are running on.

Tried to simplify the frame scheduling logic, we will see if I succeeded
or not.

Also, the logic to exclude vblank events for vblank interval estimation
when the screen off is dropped. It's too hard to get right, we need to
find something robust.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-12-19 23:26:59 +00:00
Yuxuan Shui
147561a313 config: add a debug environment variable
This is where we keep temporary, short living, private debug options.

Adding and removing command line and config file options are
troublesome, and we don't want people adding these to their config
files.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-12-19 22:36:35 +00:00
Yuxuan Shui
23eb3d5f52 core: don't unredir when display is turned off
We unredirect because we receive bad vblank events, and also vblank
events at a different interval compared to when the screen is on. But it
is enough to just not record the vblank interval statistics when the
screen is off.

Although, unredirecting when display is off can also fix the problem
where use-damage causes the screen to flicker when the display is turned
off then back on. So we need something else for that.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-12-19 22:36:32 +00:00
Yuxuan Shui
2e1c4e51b3 core: don't request vblank events when we are not rendering
Previously everytime we receive a vblank event, we always request a new
one. This made the logic somewhat simpler. But this generated many
useless vblank events, and wasted power. We only need vblank events for
two things:

1. after we rendered a frame, we need to know when it has been displayed
   on the screen.
2. estimating the refresh rate.

This commit makes sure we only request vblank events when it's actually
needed.

Fixes #1079

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-12-19 22:36:31 +00:00
Yuxuan Shui
827380e1e3 core: simplify the pacing logic a little bit
Make it simpler to stop requesting PresentCompleteNotify when there is
nothing to render.

Related: #1079

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-12-19 22:36:28 +00:00
Yuxuan Shui
8d98b7d639 core: don't call schedule_render too early
I mistakenly assumed that PresentCompleteNotify event signifies the end
of a vblank (or the start of scanout). But actually this event can in
theory in sent at any point during a vblank, with its timestamp pointing
to when the end of vblank is. (that's why we often find the timestamp to
be in the future).

Add a delay so schedule_render is actually called at the end of vblank,
so it doesn't mistakenly think the render is too slow to complete.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-12-19 22:36:17 +00:00
Yuxuan Shui
e76cf43f02 backend: gl: adjust some log levels
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-12-19 11:30:42 +00:00
Bernd Busse
fd9c52d0ee backend: xrender: force 32bit ARGB visual when adding rounded corners
Force the temporary picture to a 32-bit ARGB visual when masking it for
rounded corners to keep the transparency information. Otherwise, windows
with a 24-bit visual would get black corners instead.

Authored-by: Bernd Busse <bernd@busse-net.de>
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-12-19 05:04:09 +00:00
Yuxuan Shui
e60cb65672 log: give verbose log level a color
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-12-18 04:18:18 +00:00
Yuxuan Shui
c7ec4c2c16 log: fix printing and parsing of the verbose log level
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-12-18 04:15:27 +00:00
Yuxuan Shui
aed2a205ed log: add a new log level, verbose
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-12-18 04:11:18 +00:00
Yuxuan Shui
7366553be2 core: distinguish preprocess failure and no window to render
paint_process would return NULL for both of these cases, but we should exit in
the failure case, and continue going in the other.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-12-17 23:44:56 +00:00
Yuxuan Shui
268e1d890a core: exit if paint_preprocess fails
This usually means there is another compositor running. If we don't do
this picom will spin forever.

Fixes #1104

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-12-17 23:34:34 +00:00
Yuxuan Shui
e92745671b compiler: use C23 auto when available
One annoying thing is C23 still defines auto as a storage class despite
it now being used for type inference. As a consequence we must write
"auto const" instead of the more natural "const auto".

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-12-17 08:55:23 +00:00
Yuxuan Shui
1b97f18e5f compiler: bring the unreachable macro in line with C23
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-12-17 08:51:22 +00:00
Yuxuan Shui
47bb825b2c backend: glx: don't return false from a function returning void *
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-12-17 08:51:20 +00:00
Yuxuan Shui
e90757a6ec Merge pull request #1107 from absolutelynothelix/name-default-backend-operation-implementations-consistently 2023-12-16 22:03:14 +00:00
Yuxuan Shui
a26e4df85d Merge pull request #1105 from absolutelynothelix/backend-init-target-window-parameter 2023-12-16 17:28:24 +00:00
Yuxuan Shui
8b7c3ffb8b Merge pull request #1124 from absolutelynothelix/premultiply-shadow-color 2023-12-16 17:27:22 +00:00
Maxim Solovyov
a6b4e285f8 backend: xrender: don't leak the mask picture in the blur function 2023-10-17 01:10:27 +03:00