Commit Graph

387 Commits

Author SHA1 Message Date
Arda Atci
a5c4095082 Merge remote-tracking branch 'yshui/next' into next 2023-07-14 02:45:02 +03: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
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
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
Arda Atci
15aa5014a6 Merge branch 'yshui:next' into next 2023-06-20 22:36:05 +03: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
ecbc8b50ed backend: xrender: set created picture to repeat when binding a pixmap 2023-06-16 19:42:36 +03:00
Arda Atci
4d624bbee5 Merge remote-tracking branch 'yshui/next' into next 2023-06-14 22:02:43 +03: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
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
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
Yuxuan Shui
2a4e32babf backend: add last_render_time interface.
Used for querying how long render takes to complete, used for frame
pacing.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-06-08 20:35:23 +01:00
Yuxuan Shui
62fcfe5d1a backend: remove unused parameter 'ignore_damage'
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-06-08 20:35:16 +01:00
Yuxuan Shui
3aed5599c3 glx: calculate residual in both directions
We only considered residual in the positive direction, i.e. we would set
dithering to zero if the color is (whole number + 0.0001). But we should
also set dithering to zero if color is (whole number - 0.0001).

Fixes #1064
2023-05-08 15:01:50 +01:00
Arda Atci
dc9d1fe248 Merge branch 'yshui:next' into next 2023-04-01 23:12:29 +03:00
Maxim Solovyov
ce7758a07b backend: fix leak in default_backend_render_shadow 2023-02-13 03:36:00 +03:00
Arda Atci
157ecd2077 shadow fix 2023-02-04 07:11:23 +03:00
Arda Atci
f5e8351507 shadow fix 2023-02-04 07:09:20 +03:00
Arda Atci
9f14c43989 Merge pull request #18 from yshui/next
merge yshui/next
2023-02-04 05:49:58 +03:00
Maxim Solovyov
986b3c1cb3 core: drop xinerama
there are two x extensions for working with monitors (especially
multiple): xinerama and randr. xinerama is old, feature-poor and in
general isn't used anymore compared to the randr: new, feature-rich and
widely-used. for some reason we were using both of them, so let's drop
xinerama to keep things simple, clean and small. and to be modern.

the drop was done in three steps:
* first step was to replace all the xinerama-based code with the
  randr-based one and to replace or remove all the xinerama mentions;
* second step was to replace the xinerama's terminology with the
  randr's one. xinerama was referring only to the word "screen", while
  randr refers to multiple words and i think the word "monitor" is the
  most suitable for us and, hopefully, clear both to a contributor and
  to an end user;
* third step was to refactor the new randr-based code if needed and to
  address related todo's (mostly about moving related functions
  elsewhere).

all the steps were done well except addressing a leftover todo about
moving the win_update_monitor function to the x.c which wasn't done.

the xinerama-shadow-crop option was renamed to crop-shadow-to-monitor,
but it's previous name is still accepted, has effect and the
deprecation message is printed to preserve backwards-compatibility.
2023-01-29 10:51:12 +03:00
Yuxuan Shui
102a0bc5e0 backend: mask can be null in blur()
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-01-29 06:35:28 +00:00
Arda Atci
d41a291fd6 fix lerping on shadows, closes #4 2023-01-23 07:34:35 +03:00
Maxim Solovyov
4be96a92c7 backend: egl: fix creating eglpixmap
according to the specification of the EGL_KHR_image_pixmap extension,
if target is EGL_NATIVE_PIXMAP_KHR then ctx must be EGL_NO_CONTEXT,
otherwise, the EGL_BAD_PARAMETER error is generated. source:
https://registry.khronos.org/EGL/extensions/KHR/EGL_KHR_image_pixmap.txt

fixes #981
2023-01-23 07:34:35 +03:00
Maxim Solovyov
349f2f37db backend: egl: simplify getting a framebuffer configuration
we're using the first available framebuffer configuration that
meets our needs so there is no need to ask for more than one
2023-01-23 07:34:35 +03:00
Maxim Solovyov
a667886959 xrender: make corner-radius respect inactive-dim
for the new xrender backend it's enough to clip with a rounded rectangle after dimming, not before

partially fixes #867
2023-01-23 07:34:35 +03:00
Maxim Solovyov
6c08650f3c xrender: fix leak in release_rounded_corner_cache
calling wrong free function did nothing and produced ton of x errors

fixes at least #892
2023-01-23 07:34:35 +03:00
Maxim Solovyov
7f533c0b23 xrender: fix leak in deinit
and check should we actually free something

fixes at least #960
2023-01-23 07:34:35 +03:00
Maxim Solovyov
efa3d9c227 xrender: fix leak in bind_pixmap 2023-01-23 07:34:35 +03:00
Yuxuan Shui
0278a1fb0b backend: xrender: fix using of invalid picture when vsync is disabled
Fixes #974

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-01-23 07:34:35 +03:00
Yuxuan Shui
227cb55ca5 backend: xrender: set update region for PresentPixmap request
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-01-23 07:34:35 +03:00
Yuxuan Shui
43d8d3ed5d backend: add a comment
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-01-23 07:34:35 +03:00
Yuxuan Shui
bc1f99f2ae backend: gl: fix use-after-scope
'format' was pointing to an array with a shorter lifetime

suggested by @tryone144

Co-authored-by: Bernd Busse <bernd@busse-net.de>
2023-01-23 07:34:35 +03:00
Yuxuan Shui
d21fb34e55 backend: gl: try different back buffer formats
Prefer RGB formats first, because they use less memory; but fallback to
RGBA formats, as they are formats required by OpenGL.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-01-23 07:34:35 +03:00
Yuxuan Shui
7f18e74b8f backend: gl: don't add dither where it's not needed
If a pixel is perfectly representable as an 8-bit number, don't add
dither. Reduce artifacts where dither is unnecessary.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-01-23 07:34:35 +03:00
Yuxuan Shui
2173654fbd options: add dithered-present option
See also 0a2cd0f14e

Related: #602

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-01-23 07:34:35 +03:00
Yuxuan Shui
123ef51210 backend: gl: add dither
Add bayer ordered dithering when presenting to screen. Reduce banding
when using a strong blur. Also use 16-bit intermediary textures to
preserve precision in the rendering pipeline.

Related: #602

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-01-23 07:34:35 +03:00
Yuxuan Shui
0a82f460e0 backend: egl: fix warning 2023-01-23 07:34:35 +03:00
Yuxuan Shui
49490ab99f backend: egl: fix undefined symbols on old systems
Users with an old EGL version won't be able to use the egl backend. OTOH
we shouldn't prevent them from running picom because of a feature they
won't even use.

Don't assume the existence of EGL 1.5 symbols.

Fixes #945

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-01-23 07:34:35 +03:00
Omar Polo
11a195747a backend: egl: don't assume glEGLImageTargetTexStorage exists
Use eglGetProcAddress instead.

Fixes #932
2023-01-23 07:34:35 +03:00
Yuxuan Shui
611f8b80c2 backend: gl: handle blur context creation failure
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-01-23 07:34:35 +03:00
Yuxuan Shui
8f848c2b1d backend: gl: fix crash when shadow radius is 0
Fixes #927

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-01-23 07:34:35 +03:00
Yuxuan Shui
fa21c44ee7 backend: gl: fix shadow from mask
The intermediate texture used for shadow from mask calculation did not
properly set the min/mag filter to linear, which is required by the blur
methods. Because they use texture interpolation to accelerate
the convolution calculation.

Fixes #916

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-01-23 07:34:35 +03:00