Skip to content

Commit 50e2259

Browse files
committed
Remove xrender-sync and xrender-sync-fence
This was a dubious "fix" for a Nvidia driver problem. The problem was never fully understood, and the then developers took a shotgun approach and implemented xsync fences as a fix. Which somehow fixed the problem. Again, I don't see any indication that the developers understood why this "fix" worked. (for details, see chjj/compton#152 and chjj/compton#181) The driver problem should have been fixed almost 5 years ago. So this shouldn't be needed anymore. In addition the way compton uses xsync fences is apparently wrong according to the xsync spec (fences are attached to screen, but compton uses them as if they were attached to drawables). So, I will try removing it and see if anyone will complain. If there are real concrete reasons why fences are needed, it will be brought back. Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
1 parent 5694e75 commit 50e2259

11 files changed

+17
-215
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ stamp-h1
1212
compton
1313
*.o
1414
build/
15+
compile_commands.json
16+
build.ninja
1517

1618
# CMake files
1719
compton-*.deb
@@ -45,3 +47,4 @@ doxygen/
4547
.ycm_extra_conf.pyc
4648
/src/backtrace-symbols.[ch]
4749
/compton*.trace
50+
*.orig

compton.sample.conf

-2
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ invert-color-include = [ ];
7777
# glx-no-rebind-pixmap = true;
7878
glx-swap-method = "undefined";
7979
# glx-use-gpushader4 = true;
80-
# xrender-sync = true;
81-
# xrender-sync-fence = true;
8280

8381
# Window type settings
8482
wintypes:

man/compton.1.asciidoc

+1-7
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ May also be one of the predefined kernels: `3x3box` (default), `5x5box`, `7x7box
242242
+
243243
--
244244
* `xrender` backend performs all rendering operations with X Render extension. It is what `xcompmgr` uses, and is generally a safe fallback when you encounter rendering artifacts or instability.
245-
* `glx` (OpenGL) backend performs all rendering operations with OpenGL. It is more friendly to some VSync methods, and has significantly superior performance on color inversion (`--invert-color-include`) or blur (`--blur-background`). It requires proper OpenGL 2.0 support from your driver and hardware. You may wish to look at the GLX performance optimization options below. `--xrender-sync` and `--xrender-sync-fence` might be needed on some systems to avoid delay in changes of screen contents.
245+
* `glx` (OpenGL) backend performs all rendering operations with OpenGL. It is more friendly to some VSync methods, and has significantly superior performance on color inversion (`--invert-color-include`) or blur (`--blur-background`). It requires proper OpenGL 2.0 support from your driver and hardware. You may wish to look at the GLX performance optimization options below.
246246
* `xr_glx_hybrid` backend renders the updated screen contents with X Render and presents it on the screen with GLX. It attempts to address the rendering issues some users encountered with GLX backend and enables the better VSync of GLX backends. `--vsync-use-glfinish` might fix some rendering issues with this backend.
247247
--
248248

@@ -258,12 +258,6 @@ May also be one of the predefined kernels: `3x3box` (default), `5x5box`, `7x7box
258258
*--glx-use-gpushader4*::
259259
GLX backend: Use 'GL_EXT_gpu_shader4' for some optimization on blur GLSL code. My tests on GTX 670 show no noticeable effect.
260260

261-
*--xrender-sync*::
262-
Attempt to synchronize client applications' draw calls with `XSync()`, used on GLX backend to ensure up-to-date window content is painted.
263-
264-
*--xrender-sync-fence*::
265-
Additionally use X Sync fence to sync clients' draw calls. Needed on nvidia-drivers with GLX backend for some users. May be disabled at compile time with `NO_XSYNC=1`.
266-
267261
*--glx-fshader-win* 'SHADER'::
268262
GLX backend: Use specified GLSL fragment shader for rendering window contents. See `compton-default-fshader-win.glsl` and `compton-fake-transparency-fshader-win.glsl` in the source tree for examples.
269263

src/common.h

-95
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,6 @@
4949
// #define CONFIG_OPENGL 1
5050
// Whether to enable DBus support with libdbus.
5151
// #define CONFIG_DBUS 1
52-
// Whether to enable X Sync support.
53-
// #define CONFIG_XSYNC 1
54-
// Whether to enable GLX Sync support.
55-
// #define CONFIG_GLX_XSYNC 1
56-
57-
#if (!defined(CONFIG_XSYNC) || !defined(CONFIG_OPENGL)) && defined(CONFIG_GLX_SYNC)
58-
#error Cannot enable GL sync without X Sync / OpenGL support.
59-
#endif
6052

6153
#ifndef COMPTON_VERSION
6254
#define COMPTON_VERSION "unknown"
@@ -82,9 +74,6 @@
8274

8375
#include <X11/Xlib-xcb.h>
8476
#include <X11/Xlib.h>
85-
#ifdef CONFIG_XSYNC
86-
#include <X11/extensions/sync.h>
87-
#endif
8877

8978
#include <xcb/composite.h>
9079
#include <xcb/render.h>
@@ -460,11 +449,6 @@ typedef struct options_t {
460449
char *display_repr;
461450
/// The backend in use.
462451
enum backend backend;
463-
/// Whether to sync X drawing to avoid certain delay issues with
464-
/// GLX backend.
465-
bool xrender_sync;
466-
/// Whether to sync X drawing with X Sync fence.
467-
bool xrender_sync_fence;
468452
/// Whether to avoid using stencil buffer under GLX backend. Might be
469453
/// unsafe.
470454
bool glx_no_stencil;
@@ -740,9 +724,6 @@ typedef struct session {
740724
xcb_render_picture_t tgt_picture;
741725
/// Temporary buffer to paint to before sending to display.
742726
paint_t tgt_buffer;
743-
#ifdef CONFIG_XSYNC
744-
XSyncFence tgt_buffer_fence;
745-
#endif
746727
/// Window ID of the window we register as a symbol.
747728
Window reg_win;
748729
#ifdef CONFIG_OPENGL
@@ -904,14 +885,6 @@ typedef struct session {
904885
region_t *xinerama_scr_regs;
905886
/// Number of Xinerama screens.
906887
int xinerama_nscrs;
907-
#endif
908-
#ifdef CONFIG_XSYNC
909-
/// Whether X Sync extension exists.
910-
bool xsync_exists;
911-
/// Event base number for X Sync extension.
912-
int xsync_event;
913-
/// Error base number for X Sync extension.
914-
int xsync_error;
915888
#endif
916889
/// Whether X Render convolution filter exists.
917890
bool xrfilter_convolution_exists;
@@ -1491,20 +1464,6 @@ free_all_damage_last(session_t *ps) {
14911464
pixman_region32_clear(&ps->all_damage_last[i]);
14921465
}
14931466

1494-
#ifdef CONFIG_XSYNC
1495-
/**
1496-
* Free a XSync fence.
1497-
*/
1498-
static inline void
1499-
free_fence(session_t *ps, XSyncFence *pfence) {
1500-
if (*pfence)
1501-
XSyncDestroyFence(ps->dpy, *pfence);
1502-
*pfence = None;
1503-
}
1504-
#else
1505-
#define free_fence(ps, pfence) ((void) 0)
1506-
#endif
1507-
15081467
/**
15091468
* Check if a rectangle includes the whole screen.
15101469
*/
@@ -1743,60 +1702,6 @@ glx_mark_frame(session_t *ps) {
17431702

17441703
///@}
17451704

1746-
#ifdef CONFIG_XSYNC
1747-
#define xr_sync(ps, d, pfence) xr_sync_(ps, d, pfence)
1748-
#else
1749-
#define xr_sync(ps, d, pfence) xr_sync_(ps, d)
1750-
#endif
1751-
1752-
/**
1753-
* Synchronizes a X Render drawable to ensure all pending painting requests
1754-
* are completed.
1755-
*/
1756-
static inline void
1757-
xr_sync_(session_t *ps, Drawable d
1758-
#ifdef CONFIG_XSYNC
1759-
, XSyncFence *pfence
1760-
#endif
1761-
) {
1762-
if (!ps->o.xrender_sync)
1763-
return;
1764-
1765-
x_sync(ps->c);
1766-
#ifdef CONFIG_XSYNC
1767-
if (ps->o.xrender_sync_fence && ps->xsync_exists) {
1768-
// TODO: If everybody just follows the rules stated in X Sync prototype,
1769-
// we need only one fence per screen, but let's stay a bit cautious right
1770-
// now
1771-
XSyncFence tmp_fence = None;
1772-
if (!pfence)
1773-
pfence = &tmp_fence;
1774-
assert(pfence);
1775-
if (!*pfence)
1776-
*pfence = XSyncCreateFence(ps->dpy, d, False);
1777-
if (*pfence) {
1778-
Bool __attribute__((unused)) triggered = False;
1779-
/* if (XSyncQueryFence(ps->dpy, *pfence, &triggered) && triggered)
1780-
XSyncResetFence(ps->dpy, *pfence); */
1781-
// The fence may fail to be created (e.g. because of died drawable)
1782-
assert(!XSyncQueryFence(ps->dpy, *pfence, &triggered) || !triggered);
1783-
XSyncTriggerFence(ps->dpy, *pfence);
1784-
XSyncAwaitFence(ps->dpy, pfence, 1);
1785-
assert(!XSyncQueryFence(ps->dpy, *pfence, &triggered) || triggered);
1786-
}
1787-
else {
1788-
printf_errf("(%#010lx): Failed to create X Sync fence.", d);
1789-
}
1790-
free_fence(ps, &tmp_fence);
1791-
if (*pfence)
1792-
XSyncResetFence(ps->dpy, *pfence);
1793-
}
1794-
#endif
1795-
#ifdef CONFIG_GLX_SYNC
1796-
xr_glx_sync(ps, d, pfence);
1797-
#endif
1798-
}
1799-
18001705
/** @name DBus handling
18011706
*/
18021707
///@{

src/compton.c

+8-68
Original file line numberDiff line numberDiff line change
@@ -701,9 +701,6 @@ win_build_shadow(session_t *ps, win *w, double opacity) {
701701
assert(!w->shadow_paint.pict);
702702
w->shadow_paint.pict = shadow_picture_argb;
703703

704-
// Sync it once and only once
705-
xr_sync(ps, w->shadow_paint.pixmap, NULL);
706-
707704
xcb_free_gc(ps->c, gc);
708705
xcb_image_destroy(shadow_image);
709706
xcb_free_pixmap(ps->c, shadow_pixmap);
@@ -1445,8 +1442,6 @@ paint_one(session_t *ps, win *w, const region_t *reg_paint) {
14451442
w->paint.pixmap = xcb_generate_id(ps->c);
14461443
set_ignore_cookie(ps,
14471444
xcb_composite_name_window_pixmap(ps->c, w->id, w->paint.pixmap));
1448-
if (w->paint.pixmap)
1449-
free_fence(ps, &w->fence);
14501445
}
14511446

14521447
Drawable draw = w->paint.pixmap;
@@ -1463,9 +1458,6 @@ paint_one(session_t *ps, win *w, const region_t *reg_paint) {
14631458
draw, XCB_RENDER_CP_SUBWINDOW_MODE, &pa);
14641459
}
14651460

1466-
if (IsViewable == w->a.map_state)
1467-
xr_sync(ps, draw, &w->fence);
1468-
14691461
// GLX: Build texture
14701462
// Let glx_bind_pixmap() determine pixmap size, because if the user
14711463
// is resizing windows, the width and height we get may not be up-to-date,
@@ -1846,12 +1838,9 @@ paint_all(session_t *ps, region_t *region, const region_t *region_real, win * co
18461838
glFlush();
18471839
glXWaitX();
18481840
assert(ps->tgt_buffer.pixmap);
1849-
xr_sync(ps, ps->tgt_buffer.pixmap, &ps->tgt_buffer_fence);
18501841
paint_bind_tex(ps, &ps->tgt_buffer,
18511842
ps->root_width, ps->root_height, ps->depth,
18521843
!ps->o.glx_no_rebind_pixmap);
1853-
// See #163
1854-
xr_sync(ps, ps->tgt_buffer.pixmap, &ps->tgt_buffer_fence);
18551844
if (ps->o.vsync_use_glfinish)
18561845
glFinish();
18571846
else
@@ -2079,11 +2068,6 @@ unmap_win(session_t *ps, win **_w) {
20792068

20802069
if (w->destroyed) return;
20812070

2082-
// One last synchronization
2083-
if (w->paint.pixmap)
2084-
xr_sync(ps, w->paint.pixmap, &w->fence);
2085-
free_fence(ps, &w->fence);
2086-
20872071
// Set focus out
20882072
win_set_focused(ps, w, false);
20892073

@@ -2545,16 +2529,6 @@ ev_name(session_t *ps, xcb_generic_event_t *ev) {
25452529
if (ps->shape_exists && ev->response_type == ps->shape_event)
25462530
return "ShapeNotify";
25472531

2548-
#ifdef CONFIG_XSYNC
2549-
if (ps->xsync_exists) {
2550-
int o = ev->response_type - ps->xsync_event;
2551-
switch (o) {
2552-
CASESTRRET(XSyncCounterNotify);
2553-
CASESTRRET(XSyncAlarmNotify);
2554-
}
2555-
}
2556-
#endif
2557-
25582532
sprintf(buf, "Event %d", ev->response_type);
25592533

25602534
return buf;
@@ -3402,6 +3376,7 @@ usage(int ret) {
34023376
"--backend backend\n"
34033377
" Choose backend. Possible choices are xrender, glx, and\n"
34043378
" xr_glx_hybrid" WARNING ".\n"
3379+
#undef WARNING
34053380
"\n"
34063381
"--glx-no-stencil\n"
34073382
" GLX backend: Avoid using stencil buffer. Might cause issues\n"
@@ -3426,20 +3401,6 @@ usage(int ret) {
34263401
" GLX backend: Use GL_EXT_gpu_shader4 for some optimization on blur\n"
34273402
" GLSL code. My tests on GTX 670 show no noticeable effect.\n"
34283403
"\n"
3429-
"--xrender-sync\n"
3430-
" Attempt to synchronize client applications' draw calls with XSync(),\n"
3431-
" used on GLX backend to ensure up-to-date window content is painted.\n"
3432-
#undef WARNING
3433-
#ifndef CONFIG_XSYNC
3434-
#define WARNING WARNING_DISABLED
3435-
#else
3436-
#define WARNING
3437-
#endif
3438-
"\n"
3439-
"--xrender-sync-fence\n"
3440-
" Additionally use X Sync fence to sync clients' draw calls. Needed\n"
3441-
" on nvidia-drivers with GLX backend for some users." WARNING "\n"
3442-
"\n"
34433404
"--glx-fshader-win shader\n"
34443405
" GLX backend: Use specified GLSL fragment shader for rendering window\n"
34453406
" contents.\n"
@@ -3457,6 +3418,7 @@ usage(int ret) {
34573418
"--dbus\n"
34583419
" Enable remote control via D-Bus. See the D-BUS API section in the\n"
34593420
" man page for more details." WARNING "\n"
3421+
#undef WARNING
34603422
"\n"
34613423
"--benchmark cycles\n"
34623424
" Benchmark mode. Repeatedly paint until reaching the specified cycles.\n"
@@ -3470,7 +3432,6 @@ usage(int ret) {
34703432
;
34713433
FILE *f = (ret ? stderr: stdout);
34723434
fputs(usage_text, f);
3473-
#undef WARNING
34743435
#undef WARNING_DISABLED
34753436

34763437
exit(ret);
@@ -3996,8 +3957,12 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) {
39963957
ps->o.write_pid_path = mstrcpy(optarg);
39973958
break;
39983959
P_CASEBOOL(311, vsync_use_glfinish);
3999-
P_CASEBOOL(312, xrender_sync);
4000-
P_CASEBOOL(313, xrender_sync_fence);
3960+
case 312:
3961+
printf_errf("(): --xrender-sync %s", deprecation_message);
3962+
break;
3963+
case 313:
3964+
printf_errf("(): --xrender-sync-fence %s", deprecation_message);
3965+
break;
40013966
P_CASEBOOL(315, no_fading_destroyed_argb);
40023967
P_CASEBOOL(316, force_win_blend);
40033968
case 317:
@@ -4051,9 +4016,6 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) {
40514016
if (ps->o.blur_background_frame)
40524017
ps->o.blur_background = true;
40534018

4054-
if (ps->o.xrender_sync_fence)
4055-
ps->o.xrender_sync = true;
4056-
40574019
// Other variables determined by options
40584020

40594021
// Determine whether we need to track focus changes
@@ -5164,27 +5126,6 @@ session_init(session_t *ps_old, int argc, char **argv) {
51645126
ps->shape_exists = true;
51655127
}
51665128

5167-
if (ps->o.xrender_sync_fence) {
5168-
#ifdef CONFIG_XSYNC
5169-
// Query X Sync
5170-
if (XSyncQueryExtension(ps->dpy, &ps->xsync_event, &ps->xsync_error)) {
5171-
// TODO: Fencing may require version >= 3.0?
5172-
int major_version_return = 0, minor_version_return = 0;
5173-
if (XSyncInitialize(ps->dpy, &major_version_return, &minor_version_return))
5174-
ps->xsync_exists = true;
5175-
}
5176-
if (!ps->xsync_exists) {
5177-
printf_errf("(): X Sync extension not found. No X Sync fence sync is "
5178-
"possible.");
5179-
exit(1);
5180-
}
5181-
#else
5182-
printf_errf("(): X Sync support not compiled in. --xrender-sync-fence "
5183-
"can't work.");
5184-
exit(1);
5185-
#endif
5186-
}
5187-
51885129
// Query X RandR
51895130
if ((ps->o.sw_opti && !ps->o.refresh_rate) || ps->o.xinerama_shadow_crop) {
51905131
ext_info = xcb_get_extension_data(ps->c, &xcb_randr_id);
@@ -5498,7 +5439,6 @@ session_destroy(session_t *ps) {
54985439
ps->tgt_picture = None;
54995440
else
55005441
free_picture(ps, &ps->tgt_picture);
5501-
free_fence(ps, &ps->tgt_buffer_fence);
55025442

55035443
free_picture(ps, &ps->root_picture);
55045444
free_paint(ps, &ps->tgt_buffer);

src/compton.h

-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ free_paint(session_t *ps, paint_t *ppaint) {
209209
static inline void
210210
free_wpaint(session_t *ps, win *w) {
211211
free_paint(ps, &w->paint);
212-
free_fence(ps, &w->fence);
213212
}
214213

215214
/**

src/config_libconfig.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -355,10 +355,6 @@ parse_config(session_t *ps, struct options_tmp *pcfgtmp) {
355355
exit(1);
356356
// --glx-use-gpushader4
357357
lcfg_lookup_bool(&cfg, "glx-use-gpushader4", &ps->o.glx_use_gpushader4);
358-
// --xrender-sync
359-
lcfg_lookup_bool(&cfg, "xrender-sync", &ps->o.xrender_sync);
360-
// --xrender-sync-fence
361-
lcfg_lookup_bool(&cfg, "xrender-sync-fence", &ps->o.xrender_sync_fence);
362358

363359
if (lcfg_lookup_bool(&cfg, "clear-shadow", &bval))
364360
printf_errf("(): \"clear-shadow\" is removed as an option, and is always"
@@ -370,6 +366,10 @@ parse_config(session_t *ps, struct options_tmp *pcfgtmp) {
370366
printf_errf("(): \"glx-use-copysubbuffermesa\" %s", deprecation_message);
371367
if (lcfg_lookup_bool(&cfg, "glx-copy-from-front", &bval) && bval)
372368
printf_errf("(): \"glx-copy-from-front\" %s", deprecation_message);
369+
if (lcfg_lookup_bool(&cfg, "xrender-sync", &bval) && bval)
370+
printf_errf("(): \"xrender-sync\" %s", deprecation_message);
371+
if (lcfg_lookup_bool(&cfg, "xrender-sync-fence", &bval) && bval)
372+
printf_errf("(): \"xrender-sync-fence\" %s", deprecation_message);
373373

374374
// Wintype settings
375375

0 commit comments

Comments
 (0)