Prefer FBConfig with smaller depth + stencil buffer

Reduce GPU memory usage to what it was before fix-fbconfig.

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

View File

@ -10,6 +10,7 @@
*
*/
#include <limits.h>
#include <GL/glx.h>
#include <X11/Xlib-xcb.h>
#include <assert.h>
@ -96,8 +97,15 @@ glx_find_fbconfig(Display *dpy, int screen, xcb_render_pictforminfo_t *pictfmt,
} while (0)
int texture_tgts, y_inverted, texture_fmt;
bool found = false;
int min_cost = INT_MAX;
GLXFBConfig ret;
for (int i = 0; i < ncfg; i++) {
int depthbuf, stencil;
glXGetFBConfigAttribChecked(dpy, cfg[i], GLX_DEPTH_SIZE, &depthbuf);
glXGetFBConfigAttribChecked(dpy, cfg[i], GLX_STENCIL_SIZE, &stencil);
if (depthbuf + stencil >= min_cost) {
continue;
}
int red, green, blue;
glXGetFBConfigAttribChecked(dpy, cfg[i], GLX_RED_SIZE, &red);
glXGetFBConfigAttribChecked(dpy, cfg[i], GLX_BLUE_SIZE, &blue);
@ -139,7 +147,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;
}
break;
min_cost = depthbuf + stencil;
}
#undef glXGetFBConfigAttribChecked
free(cfg);