Consider buffer size and double buffering as well

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2019-02-03 19:15:30 +00:00
parent 519bf8500b
commit 2263bab2ff
No known key found for this signature in database
GPG Key ID: 37C999F617EA1A47
1 changed files with 5 additions and 3 deletions

View File

@ -100,10 +100,12 @@ glx_find_fbconfig(Display *dpy, int screen, xcb_render_pictforminfo_t *pictfmt,
int min_cost = INT_MAX; int min_cost = INT_MAX;
GLXFBConfig ret; GLXFBConfig ret;
for (int i = 0; i < ncfg; i++) { 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_DEPTH_SIZE, &depthbuf);
glXGetFBConfigAttribChecked(dpy, cfg[i], GLX_STENCIL_SIZE, &stencil); 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; continue;
} }
int red, green, blue; int red, green, blue;
@ -147,7 +149,7 @@ glx_find_fbconfig(Display *dpy, int screen, xcb_render_pictforminfo_t *pictfmt,
} else { } else {
texture_fmt = rgb ? GLX_TEXTURE_FORMAT_RGB_EXT : GLX_TEXTURE_FORMAT_RGBA_EXT; 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 #undef glXGetFBConfigAttribChecked
free(cfg); free(cfg);