From 2263bab2ff07c93aeee25d4538e7cd919ebadb3d Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Sun, 3 Feb 2019 19:15:30 +0000 Subject: [PATCH] Consider buffer size and double buffering as well Signed-off-by: Yuxuan Shui --- src/backend/gl/glx.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/backend/gl/glx.c b/src/backend/gl/glx.c index 4de2d9b..4e39e92 100644 --- a/src/backend/gl/glx.c +++ b/src/backend/gl/glx.c @@ -100,10 +100,12 @@ glx_find_fbconfig(Display *dpy, int screen, xcb_render_pictforminfo_t *pictfmt, int min_cost = INT_MAX; GLXFBConfig ret; for (int i = 0; i < ncfg; i++) { - int depthbuf, stencil; + int depthbuf, stencil, doublebuf, bufsize; + glXGetFBConfigAttribChecked(dpy, cfg[i], GLX_BUFFER_SIZE, &bufsize); glXGetFBConfigAttribChecked(dpy, cfg[i], GLX_DEPTH_SIZE, &depthbuf); glXGetFBConfigAttribChecked(dpy, cfg[i], GLX_STENCIL_SIZE, &stencil); - if (depthbuf + stencil >= min_cost) { + glXGetFBConfigAttribChecked(dpy, cfg[i], GLX_DOUBLEBUFFER, &doublebuf); + if ((depthbuf + stencil + bufsize) * (doublebuf + 1) >= min_cost) { continue; } int red, green, blue; @@ -147,7 +149,7 @@ glx_find_fbconfig(Display *dpy, int screen, xcb_render_pictforminfo_t *pictfmt, } else { texture_fmt = rgb ? GLX_TEXTURE_FORMAT_RGB_EXT : GLX_TEXTURE_FORMAT_RGBA_EXT; } - min_cost = depthbuf + stencil; + min_cost = (depthbuf + stencil + bufsize) * (doublebuf + 1); } #undef glXGetFBConfigAttribChecked free(cfg);