Misc: Fix wrong description & DEBUG_GLX_ERR

- Fix description of "opengl" VSync.

- Add DEBUG_GLX_ERR to check for OpenGL errors.

- Update man page.
This commit is contained in:
Richard Grenville 2013-04-25 09:27:14 +08:00
parent 85e7d18803
commit 4a4f857cc2
4 changed files with 93 additions and 3 deletions

View File

@ -125,7 +125,7 @@ OPTIONS
-- --
* 'none': No VSync * 'none': No VSync
* 'drm': VSync with 'DRM_IOCTL_WAIT_VBLANK'. May only work on some drivers. Experimental. * 'drm': VSync with 'DRM_IOCTL_WAIT_VBLANK'. May only work on some drivers. Experimental.
* 'opengl': Try to VSync with 'SGI_swap_control' OpenGL extension. Only work on some drivers. Experimental. * 'opengl': Try to VSync with 'SGI_video_sync' OpenGL extension. Only work on some drivers. Experimental.
* 'opengl-oml': Try to VSync with 'OML_sync_control' OpenGL extension. Only work on some drivers. Experimental. * 'opengl-oml': Try to VSync with 'OML_sync_control' OpenGL extension. Only work on some drivers. Experimental.
* 'opengl-swc': Try to VSync with 'SGI_swap_control' OpenGL extension. Only work on some drivers. Works only with GLX backend. Known to be most effective on many drivers. Does not actually control paint timing, only buffer swap is affected, so it doesn't have the effect of *--sw-opti* unlike other methods. Experimental. * 'opengl-swc': Try to VSync with 'SGI_swap_control' OpenGL extension. Only work on some drivers. Works only with GLX backend. Known to be most effective on many drivers. Does not actually control paint timing, only buffer swap is affected, so it doesn't have the effect of *--sw-opti* unlike other methods. Experimental.
* 'opengl-mswc': Try to VSync with 'MESA_swap_control' OpenGL extension. Basically the same as 'opengl-swc' above, except the extension we use. * 'opengl-mswc': Try to VSync with 'MESA_swap_control' OpenGL extension. Basically the same as 'opengl-swc' above, except the extension we use.
@ -185,7 +185,7 @@ OPTIONS
Specify the backend to use: 'xrender` or 'glx'. GLX (OpenGL) backend generally has much superior performance as far as you have a graphic card/chip and driver. Specify the backend to use: 'xrender` or 'glx'. GLX (OpenGL) backend generally has much superior performance as far as you have a graphic card/chip and driver.
*--glx-no-stencil*:: *--glx-no-stencil*::
GLX backend: Avoid using stencil buffer, useful if you don't have a stencil buffer. Might cause incorrect opacity when rendering transparent content and cannot work with *--blur-background*. May have a positive or negative effect on performance. (My test shows a 10% slowdown.) GLX backend: Avoid using stencil buffer, useful if you don't have a stencil buffer. Might cause incorrect opacity when rendering transparent content and cannot work with *--blur-background*. My tests show a 15% performance boost.
*--glx-copy-from-front*:: *--glx-copy-from-front*::
GLX backend: Copy unmodified regions from front buffer instead of redrawing them all. My tests with nvidia-drivers show a 10% decrease in performance when the whole screen is modified, but a 20% increase when only 1/4 is. My tests on nouveau show terrible slowdown. GLX backend: Copy unmodified regions from front buffer instead of redrawing them all. My tests with nvidia-drivers show a 10% decrease in performance when the whole screen is modified, but a 20% increase when only 1/4 is. My tests on nouveau show terrible slowdown.
@ -193,6 +193,12 @@ OPTIONS
*--glx-use-copysubbuffermesa*:: *--glx-use-copysubbuffermesa*::
GLX backend: Use MESA_copy_sub_buffer to do partial screen update. My tests on nouveau shows a 200% performance boost when only 1/4 of the screen is updated. May break VSync and is not available on some drivers. Overrides *--glx-copy-from-front*. GLX backend: Use MESA_copy_sub_buffer to do partial screen update. My tests on nouveau shows a 200% performance boost when only 1/4 of the screen is updated. May break VSync and is not available on some drivers. Overrides *--glx-copy-from-front*.
*--glx-no-rebind-pixmap*::
GLX backend: Avoid rebinding pixmap on window damage. Probably could improve performance on rapid window content changes, but is known to break things on some drivers (LLVMpipe).
*--glx-swap-method* undefined/exchange/copy::
GLX backend: GLX buffer swap method we assume. Could be "undefined", "exchange", or "copy". "undefined" is the slowest and the safest; "exchange" and "copy" are faster but may fail on some drivers. Useless with *--glx-use-copysubbuffermesa*. Defaults to "undefined".
*--dbus*:: *--dbus*::
Enable remote control via D-Bus. See the *D-BUS API* section below for more details. Enable remote control via D-Bus. See the *D-BUS API* section below for more details.

View File

@ -4175,7 +4175,7 @@ usage(void) {
#else #else
#define WARNING #define WARNING
#endif #endif
" opengl = Try to VSync with SGI_swap_control OpenGL extension. Only\n" " opengl = Try to VSync with SGI_video_sync OpenGL extension. Only\n"
" work on some drivers." WARNING"\n" " work on some drivers." WARNING"\n"
" opengl-oml = Try to VSync with OML_sync_control OpenGL extension.\n" " opengl-oml = Try to VSync with OML_sync_control OpenGL extension.\n"
" Only work on some drivers. Experimental." WARNING"\n" " Only work on some drivers. Experimental." WARNING"\n"

View File

@ -238,6 +238,10 @@ glx_init_blur(session_t *ps) {
#undef P_GET_UNIFM_LOC #undef P_GET_UNIFM_LOC
#ifdef DEBUG_GLX_ERR
glx_check_err(ps);
#endif
return true; return true;
#else #else
printf_errf("(): GLSL support not compiled in. Cannot do blur with GLX backend."); printf_errf("(): GLSL support not compiled in. Cannot do blur with GLX backend.");
@ -515,6 +519,10 @@ glx_bind_pixmap(session_t *ps, glx_texture_t **pptex, Pixmap pixmap,
glBindTexture(ptex->target, 0); glBindTexture(ptex->target, 0);
glDisable(ptex->target); glDisable(ptex->target);
#ifdef DEBUG_GLX_ERR
glx_check_err(ps);
#endif
return true; return true;
} }
@ -535,6 +543,10 @@ glx_release_pixmap(session_t *ps, glx_texture_t *ptex) {
glXDestroyPixmap(ps->dpy, ptex->glpixmap); glXDestroyPixmap(ps->dpy, ptex->glpixmap);
ptex->glpixmap = 0; ptex->glpixmap = 0;
} }
#ifdef DEBUG_GLX_ERR
glx_check_err(ps);
#endif
} }
/** /**
@ -585,6 +597,10 @@ glx_paint_pre(session_t *ps, XserverRegion *preg) {
free_region(ps, &all_damage_last); free_region(ps, &all_damage_last);
glx_set_clip(ps, *preg, NULL); glx_set_clip(ps, *preg, NULL);
#ifdef DEBUG_GLX_ERR
glx_check_err(ps);
#endif
} }
/** /**
@ -664,6 +680,10 @@ glx_set_clip(session_t *ps, XserverRegion reg, const reg_data_t *pcache_reg) {
} }
cxfree(rects_free); cxfree(rects_free);
#ifdef DEBUG_GLX_ERR
glx_check_err(ps);
#endif
} }
#define P_PAINTREG_START() \ #define P_PAINTREG_START() \
@ -783,6 +803,10 @@ glx_blur_dst(session_t *ps, int dx, int dy, int width, int height, float z,
glDeleteTextures(1, &tex_scr); glDeleteTextures(1, &tex_scr);
glDisable(tex_tgt); glDisable(tex_tgt);
#ifdef DEBUG_GLX_ERR
glx_check_err(ps);
#endif
return true; return true;
} }
@ -816,6 +840,10 @@ glx_dim_dst(session_t *ps, int dx, int dy, int width, int height, float z,
glColor4f(0.0f, 0.0f, 0.0f, 0.0f); glColor4f(0.0f, 0.0f, 0.0f, 0.0f);
glDisable(GL_BLEND); glDisable(GL_BLEND);
#ifdef DEBUG_GLX_ERR
glx_check_err(ps);
#endif
return true; return true;
} }
@ -999,6 +1027,10 @@ glx_render(session_t *ps, const glx_texture_t *ptex,
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
} }
#ifdef DEBUG_GLX_ERR
glx_check_err(ps);
#endif
return true; return true;
} }
@ -1029,6 +1061,10 @@ glx_swap_copysubbuffermesa(session_t *ps, XserverRegion reg) {
} }
} }
#ifdef DEBUG_GLX_ERR
glx_check_err(ps);
#endif
cxfree(rects); cxfree(rects);
} }

View File

@ -12,6 +12,54 @@
#include <ctype.h> #include <ctype.h>
#ifdef DEBUG_GLX_ERR
/**
* Get a textual representation of an OpenGL error.
*/
static inline const char *
glx_dump_err_str(GLenum err) {
switch (err) {
CASESTRRET(GL_NO_ERROR);
CASESTRRET(GL_INVALID_ENUM);
CASESTRRET(GL_INVALID_VALUE);
CASESTRRET(GL_INVALID_OPERATION);
CASESTRRET(GL_INVALID_FRAMEBUFFER_OPERATION);
CASESTRRET(GL_OUT_OF_MEMORY);
CASESTRRET(GL_STACK_UNDERFLOW);
CASESTRRET(GL_STACK_OVERFLOW);
}
return NULL;
}
/**
* Check for GLX error.
*
* http://blog.nobel-joergensen.com/2013/01/29/debugging-opengl-using-glgeterror/
*/
static inline void
glx_check_err_(session_t *ps, const char *func, int line) {
if (!ps->glx_context) return;
GLenum err = GL_NO_ERROR;
while (GL_NO_ERROR != (err = glGetError())) {
print_timestamp(ps);
printf("%s():%d: GLX error ", func, line);
const char *errtext = glx_dump_err_str(err);
if (errtext) {
printf_dbg("%s\n", errtext);
}
else {
printf_dbg("%d\n", err);
}
}
}
#define glx_check_err(ps) glx_check_err_(ps, __func__, __LINE__)
#endif
/** /**
* Check if a word is in string. * Check if a word is in string.
*/ */