Misc: Add DEBUG_GLX_MARK & Misc

- GLX backend: Add DEBUG_GLX_MARK, to add GL marks around functions with
  glStringMarkerGREMEDY(), and mark frame termination with
  glFrameTerminatorGREMEDY().

- Print output of `compton -h` to stdout. (#110)

- GLX backend: Strip out elements with factor 0 in GLSL blur code.
  Thanks to jrfonseca for guides. (#107)
pull/2/head
Richard Grenville 11 years ago
parent 060b5ab23c
commit 2b0dfa9b96

@ -317,6 +317,11 @@ typedef void (*f_ReleaseTexImageEXT) (Display *display, GLXDrawable drawable, in
typedef void (*f_CopySubBuffer) (Display *dpy, GLXDrawable drawable, int x, int y, int width, int height);
#ifdef DEBUG_GLX_MARK
typedef void (*f_StringMarkerGREMEDY) (GLsizei len, const void *string);
typedef void (*f_FrameTerminatorGREMEDY) (void);
#endif
/// @brief Wrapper of a GLX FBConfig.
typedef struct {
GLXFBConfig cfg;
@ -688,6 +693,12 @@ typedef struct {
f_ReleaseTexImageEXT glXReleaseTexImageProc;
/// Pointer to glXCopySubBufferMESA function.
f_CopySubBuffer glXCopySubBufferProc;
#ifdef DEBUG_GLX_MARK
/// Pointer to StringMarkerGREMEDY function.
f_StringMarkerGREMEDY glStringMarkerGREMEDY;
/// Pointer to FrameTerminatorGREMEDY function.
f_FrameTerminatorGREMEDY glFrameTerminatorGREMEDY;
#endif
/// FBConfig-s for GLX pixmap of different depths.
glx_fbconfig_t *glx_fbconfigs[OPENGL_MAX_DEPTH + 1];
#ifdef CONFIG_VSYNC_OPENGL_GLSL
@ -1803,6 +1814,38 @@ glx_create_program(const GLuint * const shaders, int nshaders);
#endif
#endif
/**
* Add a OpenGL debugging marker.
*/
static inline void
glx_mark_(session_t *ps, const char *func, XID xid, bool start) {
#ifdef DEBUG_GLX_MARK
if (BKEND_GLX == ps->o.backend && ps->glStringMarkerGREMEDY) {
if (!func) func = "(unknown)";
const char *postfix = (start ? " (start)": " (end)");
char *str = malloc((strlen(func) + 12 + 2
+ strlen(postfix) + 5) * sizeof(char));
strcpy(str, func);
sprintf(str + strlen(str), "(%#010lx)%s", xid, postfix);
ps->glStringMarkerGREMEDY(strlen(str), str);
free(str);
}
#endif
}
#define glx_mark(ps, xid, start) glx_mark_(ps, __func__, xid, start)
/**
* Add a OpenGL debugging marker.
*/
static inline void
glx_mark_frame(session_t *ps) {
#ifdef DEBUG_GLX_MARK
if (BKEND_GLX == ps->o.backend && ps->glFrameTerminatorGREMEDY)
ps->glFrameTerminatorGREMEDY();
#endif
}
static inline void
free_texture(session_t *ps, glx_texture_t **pptex) {
#ifdef CONFIG_VSYNC_OPENGL

@ -1402,6 +1402,8 @@ render(session_t *ps, int x, int y, int dx, int dy, int wid, int hei,
static inline void
win_paint_win(session_t *ps, win *w, XserverRegion reg_paint,
const reg_data_t *pcache_reg) {
glx_mark(ps, w->id, true);
// Fetch Pixmap
if (!w->paint.pixmap && ps->has_name_pixmap) {
set_ignore_next(ps);
@ -1564,6 +1566,8 @@ win_paint_win(session_t *ps, win *w, XserverRegion reg_paint,
#endif
}
}
glx_mark(ps, w->id, false);
}
/**
@ -1812,6 +1816,7 @@ paint_all(session_t *ps, XserverRegion region, XserverRegion region_real, win *t
default:
assert(0);
}
glx_mark_frame(ps);
if (ps->o.vsync_aggressive)
vsync_wait(ps);
@ -4050,7 +4055,7 @@ ev_handle(session_t *ps, XEvent *ev) {
* Print usage text and exit.
*/
static void
usage(void) {
usage(int ret) {
#define WARNING_DISABLED " (DISABLED AT COMPILE TIME)"
#define WARNING
const static char *usage_text =
@ -4277,11 +4282,12 @@ usage(void) {
" Specify window ID to repaint in benchmark mode. If omitted or is 0,\n"
" the whole screen is repainted.\n"
;
fputs(usage_text , stderr);
FILE *f = (ret ? stderr: stdout);
fputs(usage_text, f);
#undef WARNING
#undef WARNING_DISABLED
exit(1);
exit(ret);
}
/**
@ -4903,7 +4909,7 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) {
else if ('d' == o)
ps->o.display = mstrcpy(optarg);
else if ('?' == o || ':' == o)
usage();
usage(1);
}
// Check for abundant positional arguments
@ -4944,7 +4950,7 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) {
#define P_CASEBOOL(idx, option) case idx: ps->o.option = true; break
// Short options
case 'h':
usage();
usage(0);
break;
case 'd':
break;
@ -5118,7 +5124,7 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) {
break;
P_CASEBOOL(303, glx_use_gpushader4);
default:
usage();
usage(1);
break;
#undef P_CASEBOOL
}

@ -813,7 +813,7 @@ ev_window(session_t *ps, XEvent *ev);
#endif
static void __attribute__ ((noreturn))
usage(void);
usage(int ret);
static bool
register_cm(session_t *ps);

@ -605,6 +605,20 @@ cdbus_process(session_t *ps, DBusMessage *msg) {
"org.freedesktop.DBus.Introspectable", "Introspect")) {
success = cdbus_process_introspect(ps, msg);
}
else if (dbus_message_is_method_call(msg,
"org.freedesktop.DBus.Peer", "Ping")) {
cdbus_reply(ps, msg, NULL, NULL);
success = true;
}
else if (dbus_message_is_method_call(msg,
"org.freedesktop.DBus.Peer", "GetMachineId")) {
char *uuid = dbus_get_local_machine_id();
if (uuid) {
cdbus_reply_string(ps, msg, uuid);
dbus_free(uuid);
success = true;
}
}
else if (dbus_message_is_signal(msg, "org.freedesktop.DBus", "NameAcquired")
|| dbus_message_is_signal(msg, "org.freedesktop.DBus", "NameLost")) {
success = true;
@ -1028,6 +1042,12 @@ cdbus_process_introspect(session_t *ps, DBusMessage *msg) {
" <arg name='data' direction='out' type='s' />\n"
" </method>\n"
" </interface>\n"
" <interface name='org.freedesktop.DBus.Peer'>\n"
" <method name='Ping' />\n"
" <method name='GetMachineId'>\n"
" <arg name='machine_uuid' direction='out' type='s' />\n"
" </method>\n"
" </interface>\n"
" <interface name='" CDBUS_INTERFACE_NAME "'>\n"
" <signal name='win_added'>\n"
" <arg name='wid' type='" CDBUS_TYPE_WINDOW_STR "'/>\n"

@ -90,6 +90,13 @@ glx_init(session_t *ps, bool need_render) {
// Acquire function addresses
if (need_render) {
#ifdef DEBUG_GLX_MARK
ps->glStringMarkerGREMEDY = (f_StringMarkerGREMEDY)
glXGetProcAddress((const GLubyte *) "glStringMarkerGREMEDY");
ps->glFrameTerminatorGREMEDY = (f_FrameTerminatorGREMEDY)
glXGetProcAddress((const GLubyte *) "glFrameTerminatorGREMEDY");
#endif
ps->glXBindTexImageProc = (f_BindTexImageEXT)
glXGetProcAddress((const GLubyte *) "glXBindTexImageEXT");
ps->glXReleaseTexImageProc = (f_ReleaseTexImageEXT)
@ -249,6 +256,8 @@ glx_init_blur(session_t *ps) {
if (hei / 2 == i && wid / 2 == j)
continue;
double val = XFixedToDouble(ps->o.blur_kern[2 + i * wid + j]);
if (0.0 == val)
continue;
sum += val;
sprintf(pc, shader_add, val, texture_func, j - wid / 2, i - hei / 2);
pc += strlen(pc);

Loading…
Cancel
Save