From 519bf8500be46ea3774b225ce8d322a1c769557c Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Sun, 3 Feb 2019 19:06:20 +0000 Subject: [PATCH] Prefer FBConfig with smaller depth + stencil buffer Reduce GPU memory usage to what it was before fix-fbconfig. Signed-off-by: Yuxuan Shui --- src/backend/gl/glx.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/backend/gl/glx.c b/src/backend/gl/glx.c index b89d983..4de2d9b 100644 --- a/src/backend/gl/glx.c +++ b/src/backend/gl/glx.c @@ -10,6 +10,7 @@ * */ +#include #include #include #include @@ -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);