Commit Graph

1998 Commits

Author SHA1 Message Date
Yuxuan Shui
0b45b3415b driver: choose sgi_video_sync scheduler for NVIDIA
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-12-19 10:00:04 +00:00
Yuxuan Shui
d7a2f8ade6 core: add a few debug logs
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-12-19 10:00:03 +00:00
Yuxuan Shui
ffaa42a019 core: add debug options to override the vblank scheduler
Useful for debugging.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-12-19 10:00:02 +00:00
Yuxuan Shui
e7c00108d1 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 10:00:01 +00:00
Yuxuan Shui
72693b7550 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 09:59:59 +00:00
Yuxuan Shui
6986ba919a 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 09:59:58 +00:00
Yuxuan Shui
79bf7cd5c3 vblank: use table of function pointers instead of switch
Makes conditional compilation easier in the future.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-12-19 09:59:57 +00:00
Yuxuan Shui
91667d7747 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 09:59:56 +00:00
Yuxuan Shui
c6b48d7cbc 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 09:59:54 +00:00
Yuxuan Shui
8384890d3a 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 09:59:53 +00:00
Yuxuan Shui
f7b578dd54 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 09:59:52 +00:00
Yuxuan Shui
40ca6d7146 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 09:59:50 +00:00
Yuxuan Shui
b3c12b8724 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 09:59:48 +00:00
Yuxuan Shui
3e8af9fb88 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 09:59:47 +00:00
Yuxuan Shui
2bc180c2a7 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 09:59:46 +00:00
Yuxuan Shui
580889488f 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 09:59:43 +00:00
Yuxuan Shui
ce160cf432 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-18 04:37:03 +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
40d5f42f00 Merge pull request #1110 from colonelpanic8/nix_flake 2023-12-16 21:25:40 +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
Maxim Solovyov
e07b1d7a12 backend: gl: convert the shadow color to the premultiplied format
to respect the globally set glBlendFunc and thus get the correct and
expected result
2023-09-24 01:16:15 +03:00
Maxim Solovyov
44800ed845 backend: remove default implementations of obsolete backend operations 2023-09-24 01:15:42 +03:00
Maxim Solovyov
bd3134efd9 backend: xrender: remove obsolete commented out backend operations 2023-09-24 01:15:42 +03:00
Maxim Solovyov
8bf82857c4 backend: name default backend operation implementations consistently 2023-09-24 01:15:42 +03:00
Maxim Solovyov
156423c010 backend: dummy: change type of ps parameter to session_t in dummy_init 2023-09-24 01:14:55 +03:00
Maxim Solovyov
825cc563e1 backend: egl: simplify usage of the target window parameter in egl_init 2023-09-24 01:14:55 +03:00
Maxim Solovyov
249f681857 backend: make target window a parameter of the init backend operation
to address a todo
2023-09-24 01:14:55 +03:00
Maxim Solovyov
751f30578e readme: update the discord badge's link 2023-09-23 00:36:19 +03:00
Maxim Solovyov
fbc803b983 c2: address some clang-tidy issues, run clang-format 2023-09-15 00:57:33 +03:00
Maxim Solovyov
a9914cda11 log: address some clang-tidy issues, run clang-format 2023-09-15 00:47:41 +03:00
Maxim Solovyov
0cd72bf61a opengl: address some clang-tidy issues 2023-09-15 00:43:15 +03:00
Maxim Solovyov
c6abb4e270 picom.sample.conf: remove the dbus option duplicate
closes #1128
2023-09-15 00:20:59 +03:00
Maxim Solovyov
d9e5795818 Merge pull request #1106 from absolutelynothelix/use-root-visual-and-depth-directly-in-xrender-init
backend: xrender: don't use root picture format in backend_xrender_init
2023-09-10 22:46:48 +03:00
Maxim Solovyov
9e6842c607 Merge pull request #1102 from absolutelynothelix/drop-kawase-blur-method
config: drop kawase blur method
2023-09-10 22:44:56 +03:00
Maxim Solovyov
8cc5090a6c string_utils: address some clang-tidy issues 2023-08-11 01:47:43 +03:00
Maxim Solovyov
f773e723be options: address some clang-tidy issues 2023-08-11 01:40:47 +03:00
Maxim Solovyov
34024092d7 picom: address some clang-tidy issues 2023-08-11 01:38:22 +03:00
Maxim Solovyov
ae3c77b1a5 render: address some clang-tidy issues 2023-08-11 01:15:20 +03:00
Maxim Solovyov
c8627989ad win: address some clang-tidy issues, run clang-format 2023-08-11 01:09:56 +03:00
Maxim Solovyov
72ede90147 dbus: address some clang-tidy issues 2023-08-11 01:04:58 +03:00