Large diffs are not rendered by default.

@@ -222,10 +222,8 @@ paint_isvalid(session_t *ps, const paint_t *ppaint) {
if (bkend_use_xrender(ps) && !ppaint->pict)
return false;

#ifdef CONFIG_VSYNC_OPENGL
if (BKEND_GLX == ps->o.backend && !glx_tex_binded(ppaint->ptex, None))
return false;
#endif

return true;
}
@@ -236,13 +234,11 @@ paint_isvalid(session_t *ps, const paint_t *ppaint) {
static inline bool
paint_bind_tex_real(session_t *ps, paint_t *ppaint,
unsigned wid, unsigned hei, unsigned depth, bool force) {
#ifdef CONFIG_VSYNC_OPENGL
if (!ppaint->pixmap)
return false;

if (force || !glx_tex_binded(ppaint->ptex, ppaint->pixmap))
return glx_bind_pixmap(ps, &ppaint->ptex, ppaint->pixmap, wid, hei, depth);
#endif

return true;
}
@@ -692,20 +688,12 @@ render_(session_t *ps, int x, int y, int dx, int dy, int wid, int hei,
double opacity, bool argb, bool neg,
Picture pict, glx_texture_t *ptex,
XserverRegion reg_paint, const reg_data_t *pcache_reg
#ifdef CONFIG_VSYNC_OPENGL_GLSL
, const glx_prog_main_t *pprogram
#endif
);

#ifdef CONFIG_VSYNC_OPENGL_GLSL
#define \
render(ps, x, y, dx, dy, wid, hei, opacity, argb, neg, pict, ptex, reg_paint, pcache_reg, pprogram) \
render_(ps, x, y, dx, dy, wid, hei, opacity, argb, neg, pict, ptex, reg_paint, pcache_reg, pprogram)
#else
#define \
render(ps, x, y, dx, dy, wid, hei, opacity, argb, neg, pict, ptex, reg_paint, pcache_reg, pprogram) \
render_(ps, x, y, dx, dy, wid, hei, opacity, argb, neg, pict, ptex, reg_paint, pcache_reg)
#endif

static inline void
win_render(session_t *ps, win *w, int x, int y, int wid, int hei,
@@ -723,24 +711,9 @@ win_render(session_t *ps, win *w, int x, int y, int wid, int hei,

static inline void
set_tgt_clip(session_t *ps, XserverRegion reg, const reg_data_t *pcache_reg) {
switch (ps->o.backend) {
case BKEND_XRENDER:
case BKEND_XR_GLX_HYBRID:
XFixesSetPictureClipRegion(ps->dpy, ps->tgt_buffer.pict, 0, 0, reg);
break;
#ifdef CONFIG_VSYNC_OPENGL
case BKEND_GLX:
glx_set_clip(ps, reg, pcache_reg);
break;
#endif
}
glx_set_clip(ps, reg, pcache_reg);
}

static bool
xr_blur_dst(session_t *ps, Picture tgt_buffer,
int x, int y, int wid, int hei, XFixed **blur_kerns,
XserverRegion reg_clip);

/**
* Normalize a convolution kernel.
*/
@@ -885,9 +858,6 @@ win_on_wtype_change(session_t *ps, win *w);
static void
win_on_factor_change(session_t *ps, win *w);

static void
win_upd_run(session_t *ps, win *w, win_upd_t *pupd);

static void
calc_win_size(session_t *ps, win *w);

@@ -1230,7 +1200,6 @@ swopti_init(session_t *ps);
static void
swopti_handle_timeout(session_t *ps, struct timeval *ptv);

#ifdef CONFIG_VSYNC_OPENGL
/**
* Ensure we have a GLX context.
*/
@@ -1242,7 +1211,6 @@ ensure_glx_context(session_t *ps) {

return ps->psglx->context;
}
#endif

static bool
vsync_drm_init(session_t *ps);
@@ -1264,7 +1232,6 @@ vsync_opengl_swc_init(session_t *ps);
static bool
vsync_opengl_mswc_init(session_t *ps);

#ifdef CONFIG_VSYNC_OPENGL
static int
vsync_opengl_wait(session_t *ps);

@@ -1276,7 +1243,6 @@ vsync_opengl_swc_deinit(session_t *ps);

static void
vsync_opengl_mswc_deinit(session_t *ps);
#endif

static void
vsync_wait(session_t *ps);
@@ -966,13 +966,11 @@ cdbus_process_opts_get(session_t *ps, DBusMessage *msg) {
cdbus_m_opts_get_do(detect_transient, cdbus_reply_bool);
cdbus_m_opts_get_do(detect_client_leader, cdbus_reply_bool);

#ifdef CONFIG_VSYNC_OPENGL
cdbus_m_opts_get_do(glx_no_stencil, cdbus_reply_bool);
cdbus_m_opts_get_do(glx_copy_from_front, cdbus_reply_bool);
cdbus_m_opts_get_do(glx_use_copysubbuffermesa, cdbus_reply_bool);
cdbus_m_opts_get_do(glx_no_rebind_pixmap, cdbus_reply_bool);
cdbus_m_opts_get_do(glx_swap_method, cdbus_reply_int32);
#endif

cdbus_m_opts_get_do(track_focus, cdbus_reply_bool);
cdbus_m_opts_get_do(track_wdata, cdbus_reply_bool);
@@ -104,14 +104,12 @@ glx_init(session_t *ps, bool need_render) {
ps->psglx = cmalloc(1, glx_session_t);
memcpy(ps->psglx, &CGLX_SESSION_DEF, sizeof(glx_session_t));

#ifdef CONFIG_VSYNC_OPENGL_GLSL
for (int i = 0; i < MAX_BLUR_PASS; ++i) {
glx_blur_pass_t *ppass = &ps->psglx->blur_passes[i];
ppass->unifm_factor_center = -1;
ppass->unifm_offset_x = -1;
ppass->unifm_offset_y = -1;
}
#endif
}

glx_session_t *psglx = ps->psglx;
@@ -277,8 +275,6 @@ glx_init(session_t *ps, bool need_render) {
return success;
}

#ifdef CONFIG_VSYNC_OPENGL_GLSL

static void
glx_free_prog_main(session_t *ps, glx_prog_main_t *pprogram) {
if (!pprogram)
@@ -292,8 +288,6 @@ glx_free_prog_main(session_t *ps, glx_prog_main_t *pprogram) {
pprogram->unifm_tex = -1;
}

#endif

/**
* Destroy GLX related resources.
*/
@@ -306,7 +300,6 @@ glx_destroy(session_t *ps) {
for (win *w = ps->list; w; w = w->next)
free_win_res_glx(ps, w);

#ifdef CONFIG_VSYNC_OPENGL_GLSL
// Free GLSL shaders/programs
for (int i = 0; i < MAX_BLUR_PASS; ++i) {
glx_blur_pass_t *ppass = &ps->psglx->blur_passes[i];
@@ -319,7 +312,6 @@ glx_destroy(session_t *ps) {
glx_free_prog_main(ps, &ps->o.glx_prog_win);

glx_check_err(ps);
#endif

// Free FBConfigs
for (int i = 0; i <= OPENGL_MAX_DEPTH; ++i) {
@@ -383,7 +375,6 @@ glx_init_blur(session_t *ps) {

// Allocate PBO if more than one blur kernel is present
if (ps->o.blur_kerns[1]) {
#ifdef CONFIG_VSYNC_OPENGL_FBO
// Try to generate a framebuffer
GLuint fbo = 0;
glGenFramebuffers(1, &fbo);
@@ -393,14 +384,8 @@ glx_init_blur(session_t *ps) {
return false;
}
glDeleteFramebuffers(1, &fbo);
#else
printf_errf("(): FBO support not compiled in. Cannot do multi-pass blur "
"with GLX backend.");
return false;
#endif
}

#ifdef CONFIG_VSYNC_OPENGL_GLSL
{
char *lc_numeric_old = mstrcpy(setlocale(LC_NUMERIC, NULL));
// Enforce LC_NUMERIC locale "C" here to make sure decimal point is sane
@@ -482,6 +467,12 @@ glx_init_blur(session_t *ps) {
assert(strlen(shader_str) < len);
}
ppass->frag_shader = glx_create_shader(GL_FRAGMENT_SHADER, shader_str);

{
FILE* fd = fopen("shader.glsl", "w");
fprintf(fd, "%s\n", shader_str);
fflush(fd);
}
free(shader_str);
}

@@ -524,14 +515,8 @@ glx_init_blur(session_t *ps) {
glx_check_err(ps);

return true;
#else
printf_errf("(): GLSL support not compiled in. Cannot do blur with GLX backend.");
return false;
#endif
}

#ifdef CONFIG_VSYNC_OPENGL_GLSL

/**
* Load a GLSL main program from shader strings.
*/
@@ -565,8 +550,6 @@ glx_load_prog_main(session_t *ps,
return true;
}

#endif

/**
* @brief Update the FBConfig of given depth.
*/
@@ -1157,7 +1140,6 @@ glx_copy_region_to_tex(session_t *ps, GLenum tex_tgt, int basex, int basey,
dx, ps->root_height - dy - height, width, height);
}

#ifdef CONFIG_VSYNC_OPENGL_GLSL
/**
* Blur contents in a particular region.
*/
@@ -1220,22 +1202,18 @@ glx_blur_dst(session_t *ps, int dx, int dy, int width, int height, float z,
pbc->width = mwidth;
pbc->height = mheight;
GLuint tex_scr2 = pbc->textures[1];
#ifdef CONFIG_VSYNC_OPENGL_FBO
if (more_passes && !pbc->fbo)
glGenFramebuffers(1, &pbc->fbo);
const GLuint fbo = pbc->fbo;
#endif

if (!tex_scr || (more_passes && !tex_scr2)) {
printf_errf("(): Failed to allocate texture.");
goto glx_blur_dst_end;
}
#ifdef CONFIG_VSYNC_OPENGL_FBO
if (more_passes && !fbo) {
printf_errf("(): Failed to allocate framebuffer.");
goto glx_blur_dst_end;
}
#endif

// Read destination pixels into a texture
glEnable(tex_tgt);
@@ -1275,7 +1253,6 @@ glx_blur_dst(session_t *ps, int dx, int dy, int width, int height, float z,
assert(tex_scr);
glBindTexture(tex_tgt, tex_scr);

#ifdef CONFIG_VSYNC_OPENGL_FBO
if (!last_pass) {
static const GLenum DRAWBUFS[2] = { GL_COLOR_ATTACHMENT0 };
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
@@ -1297,7 +1274,6 @@ glx_blur_dst(session_t *ps, int dx, int dy, int width, int height, float z,
if (have_stencil)
glEnable(GL_STENCIL_TEST);
}
#endif

// Color negation for testing...
// glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
@@ -1364,9 +1340,7 @@ glx_blur_dst(session_t *ps, int dx, int dy, int width, int height, float z,
ret = true;

glx_blur_dst_end:
#ifdef CONFIG_VSYNC_OPENGL_FBO
glBindFramebuffer(GL_FRAMEBUFFER, 0);
#endif
glBindTexture(tex_tgt, 0);
glDisable(tex_tgt);
if (have_scissors)
@@ -1382,7 +1356,6 @@ glx_blur_dst(session_t *ps, int dx, int dy, int width, int height, float z,

return ret;
}
#endif

bool
glx_dim_dst(session_t *ps, int dx, int dy, int width, int height, float z,
@@ -1427,9 +1400,7 @@ glx_render_(session_t *ps, const glx_texture_t *ptex,
int x, int y, int dx, int dy, int width, int height, int z,
double opacity, bool argb, bool neg,
XserverRegion reg_tgt, const reg_data_t *pcache_reg
#ifdef CONFIG_VSYNC_OPENGL_GLSL
, const glx_prog_main_t *pprogram
#endif
) {
if (!ptex || !ptex->texture) {
printf_errf("(): Missing texture.");
@@ -1443,9 +1414,7 @@ glx_render_(session_t *ps, const glx_texture_t *ptex,

argb = argb || (GLX_TEXTURE_FORMAT_RGBA_EXT ==
ps->psglx->fbconfigs[ptex->depth]->texture_fmt);
#ifdef CONFIG_VSYNC_OPENGL_GLSL
const bool has_prog = pprogram && pprogram->prog;
#endif
bool dual_texture = false;

// It's required by legacy versions of OpenGL to enable texture target
@@ -1466,9 +1435,7 @@ glx_render_(session_t *ps, const glx_texture_t *ptex,
glColor4f(opacity, opacity, opacity, opacity);
}

#ifdef CONFIG_VSYNC_OPENGL_GLSL
if (!has_prog)
#endif
{
// The default, fixed-function path
// Color negation
@@ -1543,7 +1510,6 @@ glx_render_(session_t *ps, const glx_texture_t *ptex,
}
}
}
#ifdef CONFIG_VSYNC_OPENGL_GLSL
else {
// Programmable path
assert(pprogram->prog);
@@ -1555,7 +1521,6 @@ glx_render_(session_t *ps, const glx_texture_t *ptex,
if (pprogram->unifm_tex >= 0)
glUniform1i(pprogram->unifm_tex, 0);
}
#endif

#ifdef DEBUG_GLX
printf_dbgf("(): Draw: %d, %d, %d, %d -> %d, %d (%d, %d) z %d\n", x, y, width, height, dx, dy, ptex->width, ptex->height, z);
@@ -1638,10 +1603,8 @@ glx_render_(session_t *ps, const glx_texture_t *ptex,
glActiveTexture(GL_TEXTURE0);
}

#ifdef CONFIG_VSYNC_OPENGL_GLSL
if (has_prog)
glUseProgram(0);
#endif

glx_check_err(ps);

@@ -1780,7 +1743,6 @@ glx_take_screenshot(session_t *ps, int *out_length) {
return buf;
}

#ifdef CONFIG_VSYNC_OPENGL_GLSL
GLuint
glx_create_shader(GLenum shader_type, const char *shader_str) {
#ifdef DEBUG_GLX_GLSL
@@ -1902,5 +1864,4 @@ glx_create_program_from_str(const char *vert_shader_str,

return prog;
}
#endif

@@ -6,8 +6,7 @@ BASE_DIR=$(dirname "$0")/..
. "${BASE_DIR}/functions.sh"

OPTIONS=( NO_XINERAMA NO_LIBCONFIG NO_REGEX_PCRE NO_REGEX_PCRE_JIT
NO_VSYNC_DRM NO_VSYNC_OPENGL NO_VSYNC_OPENGL_GLSL NO_VSYNC_OPENGL_FBO
NO_VSYNC_OPENGL_VBO NO_DBUS NO_XSYNC NO_C2 )
NO_VSYNC_DRM NO_DBUS NO_XSYNC NO_C2 )

for o in "${OPTIONS[@]}"; do
einfo Building with $o