Enable everything OpenGL when using OpenGL
Remove finer grained macro definitions, just enable everything OpenGL when we are using OpenGL.
This commit is contained in:
parent
3ce59930a4
commit
571a6cf15f
19
Makefile
19
Makefile
|
@ -65,23 +65,14 @@ endif
|
|||
|
||||
# ==== OpenGL ====
|
||||
# Enables support for GLX backend, OpenGL VSync methods, etc.
|
||||
ifeq "$(NO_VSYNC_OPENGL)" ""
|
||||
CFG += -DCONFIG_VSYNC_OPENGL
|
||||
ifneq "$(NO_VSYNC_OPENGL)" ""
|
||||
NO_OPENGL=$(NO_VSYNC_OPENGL)
|
||||
endif
|
||||
ifeq "$(NO_OPENGL)" ""
|
||||
CFG += -DCONFIG_OPENGL
|
||||
# -lGL must precede some other libraries, or it segfaults on FreeBSD (#74)
|
||||
LIBS := -lGL $(LIBS)
|
||||
OBJS += opengl.o
|
||||
# Enables support for GLSL (GLX background blur, etc.)
|
||||
ifeq "$(NO_VSYNC_OPENGL_GLSL)" ""
|
||||
CFG += -DCONFIG_VSYNC_OPENGL_GLSL
|
||||
endif
|
||||
# Enables support for GL FBO (GLX multi-pass blur, etc.)
|
||||
ifeq "$(NO_VSYNC_OPENGL_FBO)" ""
|
||||
CFG += -DCONFIG_VSYNC_OPENGL_FBO
|
||||
endif
|
||||
# Enables support for GL VBO (does nothing right now)
|
||||
ifeq "$(NO_VSYNC_OPENGL_VBO)" ""
|
||||
CFG += -DCONFIG_VSYNC_OPENGL_VBO
|
||||
endif
|
||||
endif
|
||||
|
||||
# ==== D-Bus ====
|
||||
|
|
53
src/common.h
53
src/common.h
|
@ -43,12 +43,8 @@
|
|||
// #define CONFIG_LIBCONFIG 1
|
||||
// Whether to enable DRM VSync support
|
||||
// #define CONFIG_VSYNC_DRM 1
|
||||
// Whether to enable OpenGL support
|
||||
// #define CONFIG_VSYNC_OPENGL 1
|
||||
// Whether to enable GLX GLSL support
|
||||
// #define CONFIG_VSYNC_OPENGL_GLSL 1
|
||||
// Whether to enable GLX FBO support
|
||||
// #define CONFIG_VSYNC_OPENGL_FBO 1
|
||||
// Whether to enable OpenGL support (include GLSL, FBO)
|
||||
// #define CONFIG_OPENGL 1
|
||||
// Whether to enable DBus support with libdbus.
|
||||
// #define CONFIG_DBUS 1
|
||||
// Whether to enable X Sync support.
|
||||
|
@ -56,7 +52,7 @@
|
|||
// Whether to enable GLX Sync support.
|
||||
// #define CONFIG_GLX_XSYNC 1
|
||||
|
||||
#if (!defined(CONFIG_XSYNC) || !defined(CONFIG_VSYNC_OPENGL)) && defined(CONFIG_GLX_SYNC)
|
||||
#if (!defined(CONFIG_XSYNC) || !defined(CONFIG_OPENGL)) && defined(CONFIG_GLX_SYNC)
|
||||
#error Cannot enable GL sync without X Sync / OpenGL support.
|
||||
#endif
|
||||
|
||||
|
@ -110,12 +106,9 @@
|
|||
#include <dbus/dbus.h>
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_VSYNC_OPENGL
|
||||
|
||||
#ifdef CONFIG_OPENGL
|
||||
// libGL
|
||||
#if defined(CONFIG_VSYNC_OPENGL_GLSL) || defined(CONFIG_VSYNC_OPENGL_FBO)
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#endif
|
||||
|
||||
#include <GL/glx.h>
|
||||
|
||||
|
@ -354,7 +347,7 @@ enum {
|
|||
|
||||
typedef struct _glx_texture glx_texture_t;
|
||||
|
||||
#ifdef CONFIG_VSYNC_OPENGL
|
||||
#ifdef CONFIG_OPENGL
|
||||
#ifdef DEBUG_GLX_DEBUG_CONTEXT
|
||||
typedef GLXContext (*f_glXCreateContextAttribsARB) (Display *dpy,
|
||||
GLXFBConfig config, GLXContext share_context, Bool direct,
|
||||
|
@ -445,7 +438,7 @@ struct _glx_texture {
|
|||
bool y_inverted;
|
||||
};
|
||||
|
||||
#ifdef CONFIG_VSYNC_OPENGL_GLSL
|
||||
#ifdef CONFIG_OPENGL
|
||||
typedef struct {
|
||||
/// Fragment shader for blur.
|
||||
GLuint frag_shader;
|
||||
|
@ -556,7 +549,7 @@ typedef struct _options_t {
|
|||
bool glx_use_gpushader4;
|
||||
/// Custom fragment shader for painting windows, as a string.
|
||||
char *glx_fshader_win_str;
|
||||
#ifdef CONFIG_VSYNC_OPENGL_GLSL
|
||||
#ifdef CONFIG_OPENGL
|
||||
/// Custom GLX program used for painting window.
|
||||
glx_prog_main_t glx_prog_win;
|
||||
#endif
|
||||
|
@ -726,7 +719,7 @@ typedef struct _options_t {
|
|||
bool track_leader;
|
||||
} options_t;
|
||||
|
||||
#ifdef CONFIG_VSYNC_OPENGL
|
||||
#ifdef CONFIG_OPENGL
|
||||
/// Structure containing GLX-dependent data for a compton session.
|
||||
typedef struct {
|
||||
// === OpenGL related ===
|
||||
|
@ -776,7 +769,7 @@ typedef struct {
|
|||
int z;
|
||||
/// FBConfig-s for GLX pixmap of different depths.
|
||||
glx_fbconfig_t *fbconfigs[OPENGL_MAX_DEPTH + 1];
|
||||
#ifdef CONFIG_VSYNC_OPENGL_GLSL
|
||||
#ifdef CONFIG_OPENGL
|
||||
glx_blur_pass_t blur_passes[MAX_BLUR_PASS];
|
||||
#endif
|
||||
} glx_session_t;
|
||||
|
@ -826,7 +819,7 @@ typedef struct session {
|
|||
XdbeBackBuffer root_dbe;
|
||||
/// Window ID of the window we register as a symbol.
|
||||
Window reg_win;
|
||||
#ifdef CONFIG_VSYNC_OPENGL
|
||||
#ifdef CONFIG_OPENGL
|
||||
/// Pointer to GLX data.
|
||||
glx_session_t *psglx;
|
||||
#endif
|
||||
|
@ -965,7 +958,7 @@ typedef struct session {
|
|||
int randr_event;
|
||||
/// Error base number for X RandR extension.
|
||||
int randr_error;
|
||||
#ifdef CONFIG_VSYNC_OPENGL
|
||||
#ifdef CONFIG_OPENGL
|
||||
/// Whether X GLX extension exists.
|
||||
bool glx_exists;
|
||||
/// Event base number for X GLX extension.
|
||||
|
@ -1211,7 +1204,7 @@ struct win {
|
|||
/// Background state on last paint.
|
||||
bool blur_background_last;
|
||||
|
||||
#ifdef CONFIG_VSYNC_OPENGL_GLSL
|
||||
#ifdef CONFIG_OPENGL
|
||||
/// Textures and FBO background blur use.
|
||||
glx_blur_cache_t glx_blur_cache;
|
||||
#endif
|
||||
|
@ -1917,7 +1910,7 @@ bkend_use_glx(session_t *ps) {
|
|||
*/
|
||||
static inline bool
|
||||
glx_has_context(session_t *ps) {
|
||||
#ifdef CONFIG_VSYNC_OPENGL
|
||||
#ifdef CONFIG_OPENGL
|
||||
return ps->psglx && ps->psglx->context;
|
||||
#else
|
||||
return false;
|
||||
|
@ -2124,7 +2117,7 @@ vsync_init(session_t *ps);
|
|||
void
|
||||
vsync_deinit(session_t *ps);
|
||||
|
||||
#ifdef CONFIG_VSYNC_OPENGL
|
||||
#ifdef CONFIG_OPENGL
|
||||
/** @name GLX
|
||||
*/
|
||||
///@{
|
||||
|
@ -2149,7 +2142,7 @@ glx_on_root_change(session_t *ps);
|
|||
bool
|
||||
glx_init_blur(session_t *ps);
|
||||
|
||||
#ifdef CONFIG_VSYNC_OPENGL_GLSL
|
||||
#ifdef CONFIG_OPENGL
|
||||
bool
|
||||
glx_load_prog_main(session_t *ps,
|
||||
const char *vshader_str, const char *fshader_str,
|
||||
|
@ -2178,7 +2171,7 @@ glx_tex_binded(const glx_texture_t *ptex, Pixmap pixmap) {
|
|||
void
|
||||
glx_set_clip(session_t *ps, XserverRegion reg, const reg_data_t *pcache_reg);
|
||||
|
||||
#ifdef CONFIG_VSYNC_OPENGL_GLSL
|
||||
#ifdef CONFIG_OPENGL
|
||||
bool
|
||||
glx_blur_dst(session_t *ps, int dx, int dy, int width, int height, float z,
|
||||
GLfloat factor_center,
|
||||
|
@ -2195,12 +2188,12 @@ 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
|
||||
#ifdef CONFIG_OPENGL
|
||||
, const glx_prog_main_t *pprogram
|
||||
#endif
|
||||
);
|
||||
|
||||
#ifdef CONFIG_VSYNC_OPENGL_GLSL
|
||||
#ifdef CONFIG_OPENGL
|
||||
#define \
|
||||
glx_render(ps, ptex, x, y, dx, dy, width, height, z, opacity, argb, neg, reg_tgt, pcache_reg, pprogram) \
|
||||
glx_render_(ps, ptex, x, y, dx, dy, width, height, z, opacity, argb, neg, reg_tgt, pcache_reg, pprogram)
|
||||
|
@ -2216,7 +2209,7 @@ glx_swap_copysubbuffermesa(session_t *ps, XserverRegion reg);
|
|||
unsigned char *
|
||||
glx_take_screenshot(session_t *ps, int *out_length);
|
||||
|
||||
#ifdef CONFIG_VSYNC_OPENGL_GLSL
|
||||
#ifdef CONFIG_OPENGL
|
||||
GLuint
|
||||
glx_create_shader(GLenum shader_type, const char *shader_str);
|
||||
|
||||
|
@ -2245,7 +2238,7 @@ free_texture_r(session_t *ps, GLuint *ptexture) {
|
|||
*/
|
||||
static inline void
|
||||
free_glx_fbo(session_t *ps, GLuint *pfbo) {
|
||||
#ifdef CONFIG_VSYNC_OPENGL_FBO
|
||||
#ifdef CONFIG_OPENGL
|
||||
if (*pfbo) {
|
||||
glDeleteFramebuffers(1, pfbo);
|
||||
*pfbo = 0;
|
||||
|
@ -2254,7 +2247,7 @@ free_glx_fbo(session_t *ps, GLuint *pfbo) {
|
|||
assert(!*pfbo);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_VSYNC_OPENGL_GLSL
|
||||
#ifdef CONFIG_OPENGL
|
||||
/**
|
||||
* Free data in glx_blur_cache_t on resize.
|
||||
*/
|
||||
|
@ -2288,7 +2281,7 @@ free_texture(session_t *ps, glx_texture_t **pptex) {
|
|||
if (!ptex)
|
||||
return;
|
||||
|
||||
#ifdef CONFIG_VSYNC_OPENGL
|
||||
#ifdef CONFIG_OPENGL
|
||||
glx_release_pixmap(ps, ptex);
|
||||
|
||||
free_texture_r(ps, &ptex->texture);
|
||||
|
@ -2315,7 +2308,7 @@ static inline void
|
|||
free_win_res_glx(session_t *ps, win *w) {
|
||||
free_paint_glx(ps, &w->paint);
|
||||
free_paint_glx(ps, &w->shadow_paint);
|
||||
#ifdef CONFIG_VSYNC_OPENGL_GLSL
|
||||
#ifdef CONFIG_OPENGL
|
||||
free_glx_bc(ps, &w->glx_blur_cache);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ static int (* const (VSYNC_FUNCS_WAIT[NUM_VSYNC]))(session_t *ps) = {
|
|||
#ifdef CONFIG_VSYNC_DRM
|
||||
[VSYNC_DRM ] = vsync_drm_wait,
|
||||
#endif
|
||||
#ifdef CONFIG_VSYNC_OPENGL
|
||||
#ifdef CONFIG_OPENGL
|
||||
[VSYNC_OPENGL ] = vsync_opengl_wait,
|
||||
[VSYNC_OPENGL_OML ] = vsync_opengl_oml_wait,
|
||||
#endif
|
||||
|
@ -74,7 +74,7 @@ static int (* const (VSYNC_FUNCS_WAIT[NUM_VSYNC]))(session_t *ps) = {
|
|||
|
||||
/// Function pointers to deinitialize VSync.
|
||||
static void (* const (VSYNC_FUNCS_DEINIT[NUM_VSYNC]))(session_t *ps) = {
|
||||
#ifdef CONFIG_VSYNC_OPENGL
|
||||
#ifdef CONFIG_OPENGL
|
||||
[VSYNC_OPENGL_SWC ] = vsync_opengl_swc_deinit,
|
||||
[VSYNC_OPENGL_MSWC ] = vsync_opengl_mswc_deinit,
|
||||
#endif
|
||||
|
@ -844,7 +844,7 @@ get_root_tile(session_t *ps) {
|
|||
|
||||
ps->root_tile_fill = fill;
|
||||
ps->root_tile_paint.pixmap = pixmap;
|
||||
#ifdef CONFIG_VSYNC_OPENGL
|
||||
#ifdef CONFIG_OPENGL
|
||||
if (BKEND_GLX == ps->o.backend)
|
||||
return glx_bind_pixmap(ps, &ps->root_tile_paint.ptex, ps->root_tile_paint.pixmap, 0, 0, 0);
|
||||
#endif
|
||||
|
@ -1482,7 +1482,7 @@ win_blur_background(session_t *ps, win *w, Picture tgt_buffer,
|
|||
free_region(ps, ®_noframe);
|
||||
}
|
||||
break;
|
||||
#ifdef CONFIG_VSYNC_OPENGL_GLSL
|
||||
#ifdef CONFIG_OPENGL
|
||||
case BKEND_GLX:
|
||||
// TODO: Handle frame opacity
|
||||
glx_blur_dst(ps, x, y, wid, hei, ps->psglx->z - 0.5, factor_center,
|
||||
|
@ -1499,7 +1499,7 @@ 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
|
||||
#ifdef CONFIG_OPENGL
|
||||
, const glx_prog_main_t *pprogram
|
||||
#endif
|
||||
) {
|
||||
|
@ -1515,7 +1515,7 @@ render_(session_t *ps, int x, int y, int dx, int dy, int wid, int hei,
|
|||
}
|
||||
break;
|
||||
}
|
||||
#ifdef CONFIG_VSYNC_OPENGL
|
||||
#ifdef CONFIG_OPENGL
|
||||
case BKEND_GLX:
|
||||
glx_render(ps, ptex, x, y, dx, dy, wid, hei,
|
||||
ps->psglx->z, opacity, argb, neg, reg_paint, pcache_reg, pprogram);
|
||||
|
@ -1699,7 +1699,7 @@ win_paint_win(session_t *ps, win *w, XserverRegion reg_paint,
|
|||
&color, &rect, 1);
|
||||
}
|
||||
break;
|
||||
#ifdef CONFIG_VSYNC_OPENGL
|
||||
#ifdef CONFIG_OPENGL
|
||||
case BKEND_GLX:
|
||||
glx_dim_dst(ps, x, y, wid, hei, ps->psglx->z - 0.7, dim_opacity,
|
||||
reg_paint, pcache_reg);
|
||||
|
@ -1743,7 +1743,7 @@ paint_all(session_t *ps, XserverRegion region, XserverRegion region_real, win *t
|
|||
#endif
|
||||
XserverRegion reg_paint = None, reg_tmp = None, reg_tmp2 = None;
|
||||
|
||||
#ifdef CONFIG_VSYNC_OPENGL
|
||||
#ifdef CONFIG_OPENGL
|
||||
if (bkend_use_glx(ps)) {
|
||||
glx_paint_pre(ps, ®ion);
|
||||
}
|
||||
|
@ -1941,7 +1941,7 @@ paint_all(session_t *ps, XserverRegion region, XserverRegion region_real, win *t
|
|||
// Make sure all previous requests are processed to achieve best
|
||||
// effect
|
||||
XSync(ps->dpy, False);
|
||||
#ifdef CONFIG_VSYNC_OPENGL
|
||||
#ifdef CONFIG_OPENGL
|
||||
if (glx_has_context(ps)) {
|
||||
if (ps->o.vsync_use_glfinish)
|
||||
glFinish();
|
||||
|
@ -1977,7 +1977,7 @@ paint_all(session_t *ps, XserverRegion region, XserverRegion region_real, win *t
|
|||
0, 0, ps->root_width, ps->root_height);
|
||||
}
|
||||
break;
|
||||
#ifdef CONFIG_VSYNC_OPENGL
|
||||
#ifdef CONFIG_OPENGL
|
||||
case BKEND_XR_GLX_HYBRID:
|
||||
XSync(ps->dpy, False);
|
||||
if (ps->o.vsync_use_glfinish)
|
||||
|
@ -2018,7 +2018,7 @@ paint_all(session_t *ps, XserverRegion region, XserverRegion region_real, win *t
|
|||
|
||||
XFlush(ps->dpy);
|
||||
|
||||
#ifdef CONFIG_VSYNC_OPENGL
|
||||
#ifdef CONFIG_OPENGL
|
||||
if (glx_has_context(ps)) {
|
||||
glFlush();
|
||||
glXWaitX();
|
||||
|
@ -3061,7 +3061,7 @@ configure_win(session_t *ps, XConfigureEvent *ce) {
|
|||
redir_start(ps);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_VSYNC_OPENGL
|
||||
#ifdef CONFIG_OPENGL
|
||||
// Reinitialize GLX on root change
|
||||
if (ps->o.glx_reinit_on_root_change && ps->psglx) {
|
||||
if (!glx_reinit(ps, bkend_use_glx(ps)))
|
||||
|
@ -3317,7 +3317,7 @@ xerror(Display __attribute__((unused)) *dpy, XErrorEvent *ev) {
|
|||
CASESTRRET2(BadGlyph);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_VSYNC_OPENGL
|
||||
#ifdef CONFIG_OPENGL
|
||||
if (ps->glx_exists) {
|
||||
o = ev->error_code - ps->glx_error;
|
||||
switch (o) {
|
||||
|
@ -4595,7 +4595,7 @@ usage(int ret) {
|
|||
" drm = VSync with DRM_IOCTL_WAIT_VBLANK. May only work on some\n"
|
||||
" (DRI-based) drivers." WARNING "\n"
|
||||
#undef WARNING
|
||||
#ifndef CONFIG_VSYNC_OPENGL
|
||||
#ifndef CONFIG_OPENGL
|
||||
#define WARNING WARNING_DISABLED
|
||||
#else
|
||||
#define WARNING
|
||||
|
@ -4730,7 +4730,7 @@ usage(int ret) {
|
|||
" screen." WARNING "\n"
|
||||
"\n"
|
||||
#undef WARNING
|
||||
#ifndef CONFIG_VSYNC_OPENGL
|
||||
#ifndef CONFIG_OPENGL
|
||||
#define WARNING "(GLX BACKENDS DISABLED AT COMPILE TIME)"
|
||||
#else
|
||||
#define WARNING
|
||||
|
@ -4921,7 +4921,7 @@ fork_after(session_t *ps) {
|
|||
if (getppid() == 1)
|
||||
return true;
|
||||
|
||||
#ifdef CONFIG_VSYNC_OPENGL
|
||||
#ifdef CONFIG_OPENGL
|
||||
// GLX context must be released and reattached on fork
|
||||
if (glx_has_context(ps) && !glXMakeCurrent(ps->dpy, None, NULL)) {
|
||||
printf_errf("(): Failed to detach GLx context.");
|
||||
|
@ -4940,7 +4940,7 @@ fork_after(session_t *ps) {
|
|||
|
||||
setsid();
|
||||
|
||||
#ifdef CONFIG_VSYNC_OPENGL
|
||||
#ifdef CONFIG_OPENGL
|
||||
if (glx_has_context(ps)
|
||||
&& !glXMakeCurrent(ps->dpy, get_tgt_window(ps), ps->psglx->context)) {
|
||||
printf_errf("(): Failed to make GLX context current.");
|
||||
|
@ -5126,9 +5126,7 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) {
|
|||
// instead of commas in atof().
|
||||
setlocale(LC_NUMERIC, "C");
|
||||
|
||||
#ifdef CONFIG_LIBCONFIG
|
||||
parse_config(ps, &cfgtmp);
|
||||
#endif
|
||||
|
||||
// Parse commandline arguments. Range checking will be done later.
|
||||
|
||||
|
@ -5613,7 +5611,7 @@ vsync_drm_wait(session_t *ps) {
|
|||
*/
|
||||
static bool
|
||||
vsync_opengl_init(session_t *ps) {
|
||||
#ifdef CONFIG_VSYNC_OPENGL
|
||||
#ifdef CONFIG_OPENGL
|
||||
if (!ensure_glx_context(ps))
|
||||
return false;
|
||||
|
||||
|
@ -5638,7 +5636,7 @@ vsync_opengl_init(session_t *ps) {
|
|||
|
||||
static bool
|
||||
vsync_opengl_oml_init(session_t *ps) {
|
||||
#ifdef CONFIG_VSYNC_OPENGL
|
||||
#ifdef CONFIG_OPENGL
|
||||
if (!ensure_glx_context(ps))
|
||||
return false;
|
||||
|
||||
|
@ -5663,7 +5661,7 @@ vsync_opengl_oml_init(session_t *ps) {
|
|||
|
||||
static bool
|
||||
vsync_opengl_swc_init(session_t *ps) {
|
||||
#ifdef CONFIG_VSYNC_OPENGL
|
||||
#ifdef CONFIG_OPENGL
|
||||
if (!ensure_glx_context(ps))
|
||||
return false;
|
||||
|
||||
|
@ -5691,7 +5689,7 @@ vsync_opengl_swc_init(session_t *ps) {
|
|||
|
||||
static bool
|
||||
vsync_opengl_mswc_init(session_t *ps) {
|
||||
#ifdef CONFIG_VSYNC_OPENGL
|
||||
#ifdef CONFIG_OPENGL
|
||||
if (!ensure_glx_context(ps))
|
||||
return false;
|
||||
|
||||
|
@ -5717,7 +5715,7 @@ vsync_opengl_mswc_init(session_t *ps) {
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef CONFIG_VSYNC_OPENGL
|
||||
#ifdef CONFIG_OPENGL
|
||||
/**
|
||||
* Wait for next VSync, OpenGL method.
|
||||
*/
|
||||
|
@ -5898,7 +5896,7 @@ init_filters(session_t *ps) {
|
|||
}
|
||||
break;
|
||||
}
|
||||
#ifdef CONFIG_VSYNC_OPENGL
|
||||
#ifdef CONFIG_OPENGL
|
||||
case BKEND_GLX:
|
||||
return glx_init_blur(ps);
|
||||
#endif
|
||||
|
@ -6276,7 +6274,7 @@ session_init(session_t *ps_old, int argc, char **argv) {
|
|||
.backend = BKEND_XRENDER,
|
||||
.glx_no_stencil = false,
|
||||
.glx_copy_from_front = false,
|
||||
#ifdef CONFIG_VSYNC_OPENGL_GLSL
|
||||
#ifdef CONFIG_OPENGL
|
||||
.glx_prog_win = GLX_PROG_MAIN_INIT,
|
||||
#endif
|
||||
.mark_wmwin_focused = false,
|
||||
|
@ -6411,7 +6409,7 @@ session_init(session_t *ps_old, int argc, char **argv) {
|
|||
.randr_exists = 0,
|
||||
.randr_event = 0,
|
||||
.randr_error = 0,
|
||||
#ifdef CONFIG_VSYNC_OPENGL
|
||||
#ifdef CONFIG_OPENGL
|
||||
.glx_exists = false,
|
||||
.glx_event = 0,
|
||||
.glx_error = 0,
|
||||
|
@ -6626,7 +6624,7 @@ session_init(session_t *ps_old, int argc, char **argv) {
|
|||
|
||||
// Initialize OpenGL as early as possible
|
||||
if (bkend_use_glx(ps)) {
|
||||
#ifdef CONFIG_VSYNC_OPENGL
|
||||
#ifdef CONFIG_OPENGL
|
||||
if (!glx_init(ps, true))
|
||||
exit(1);
|
||||
#else
|
||||
|
@ -6636,7 +6634,7 @@ session_init(session_t *ps_old, int argc, char **argv) {
|
|||
|
||||
// Initialize window GL shader
|
||||
if (BKEND_GLX == ps->o.backend && ps->o.glx_fshader_win_str) {
|
||||
#ifdef CONFIG_VSYNC_OPENGL_GLSL
|
||||
#ifdef CONFIG_OPENGL
|
||||
if (!glx_load_prog_main(ps, NULL, ps->o.glx_fshader_win_str, &ps->o.glx_prog_win))
|
||||
exit(1);
|
||||
#else
|
||||
|
@ -6900,7 +6898,7 @@ session_destroy(session_t *ps) {
|
|||
free(ps->o.glx_fshader_win_str);
|
||||
free_xinerama_info(ps);
|
||||
|
||||
#ifdef CONFIG_VSYNC_OPENGL
|
||||
#ifdef CONFIG_OPENGL
|
||||
glx_destroy(ps);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -209,7 +209,7 @@ paint_isvalid(session_t *ps, const paint_t *ppaint) {
|
|||
if (bkend_use_xrender(ps) && !ppaint->pict)
|
||||
return false;
|
||||
|
||||
#ifdef CONFIG_VSYNC_OPENGL
|
||||
#ifdef CONFIG_OPENGL
|
||||
if (BKEND_GLX == ps->o.backend && !glx_tex_binded(ppaint->ptex, None))
|
||||
return false;
|
||||
#endif
|
||||
|
@ -223,7 +223,7 @@ 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
|
||||
#ifdef CONFIG_OPENGL
|
||||
if (!ppaint->pixmap)
|
||||
return false;
|
||||
|
||||
|
@ -672,12 +672,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
|
||||
#ifdef CONFIG_OPENGL
|
||||
, const glx_prog_main_t *pprogram
|
||||
#endif
|
||||
);
|
||||
|
||||
#ifdef CONFIG_VSYNC_OPENGL_GLSL
|
||||
#ifdef CONFIG_OPENGL
|
||||
#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)
|
||||
|
@ -708,7 +708,7 @@ set_tgt_clip(session_t *ps, XserverRegion reg, const reg_data_t *pcache_reg) {
|
|||
case BKEND_XR_GLX_HYBRID:
|
||||
XFixesSetPictureClipRegion(ps->dpy, ps->tgt_buffer.pict, 0, 0, reg);
|
||||
break;
|
||||
#ifdef CONFIG_VSYNC_OPENGL
|
||||
#ifdef CONFIG_OPENGL
|
||||
case BKEND_GLX:
|
||||
glx_set_clip(ps, reg, pcache_reg);
|
||||
break;
|
||||
|
@ -1169,7 +1169,7 @@ swopti_init(session_t *ps);
|
|||
static void
|
||||
swopti_handle_timeout(session_t *ps, struct timeval *ptv);
|
||||
|
||||
#ifdef CONFIG_VSYNC_OPENGL
|
||||
#ifdef CONFIG_OPENGL
|
||||
/**
|
||||
* Ensure we have a GLX context.
|
||||
*/
|
||||
|
@ -1203,7 +1203,7 @@ vsync_opengl_swc_init(session_t *ps);
|
|||
static bool
|
||||
vsync_opengl_mswc_init(session_t *ps);
|
||||
|
||||
#ifdef CONFIG_VSYNC_OPENGL
|
||||
#ifdef CONFIG_OPENGL
|
||||
static int
|
||||
vsync_opengl_wait(session_t *ps);
|
||||
|
||||
|
|
|
@ -29,4 +29,9 @@ parse_cfg_condlst(session_t *ps, const config_t *pcfg, c2_lptr_t **pcondlst,
|
|||
|
||||
void
|
||||
parse_config(session_t *ps, struct options_tmp *pcfgtmp);
|
||||
#else
|
||||
static inline void parse_config(session_t *a, struct options_tmp *b) {
|
||||
(void)a;
|
||||
(void)b;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -967,7 +967,7 @@ 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
|
||||
#ifdef CONFIG_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);
|
||||
|
|
46
src/opengl.c
46
src/opengl.c
|
@ -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_end:
|
|||
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
|
||||
|
@ -529,14 +514,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.
|
||||
*/
|
||||
|
@ -570,8 +549,6 @@ glx_load_prog_main(session_t *ps,
|
|||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Update the FBConfig of given depth.
|
||||
*/
|
||||
|
@ -1172,7 +1149,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.
|
||||
*/
|
||||
|
@ -1235,22 +1211,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);
|
||||
|
@ -1290,7 +1262,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);
|
||||
|
@ -1312,7 +1283,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);
|
||||
|
@ -1379,9 +1349,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)
|
||||
|
@ -1397,7 +1365,6 @@ glx_blur_dst_end:
|
|||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool
|
||||
glx_dim_dst(session_t *ps, int dx, int dy, int width, int height, float z,
|
||||
|
@ -1442,9 +1409,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.");
|
||||
|
@ -1458,9 +1423,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
|
||||
|
@ -1481,9 +1444,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
|
||||
|
@ -1558,7 +1519,6 @@ glx_render_(session_t *ps, const glx_texture_t *ptex,
|
|||
}
|
||||
}
|
||||
}
|
||||
#ifdef CONFIG_VSYNC_OPENGL_GLSL
|
||||
else {
|
||||
// Programmable path
|
||||
assert(pprogram->prog);
|
||||
|
@ -1570,7 +1530,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);
|
||||
|
@ -1653,10 +1612,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);
|
||||
|
||||
|
@ -1799,7 +1756,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
|
||||
|
@ -1921,5 +1877,3 @@ glx_create_program_from_str(const char *vert_shader_str,
|
|||
|
||||
return prog;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue