render: move argb_fbconfig to struct session

Because it needs to be cleared when we reset, so we don't use a freed
fbconfig across reset.

Related: #381

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2020-04-20 19:10:53 +01:00
parent 754531ea2e
commit d1f4969fc1
No known key found for this signature in database
GPG Key ID: 37C999F617EA1A47
3 changed files with 6 additions and 5 deletions

View File

@ -214,6 +214,7 @@ typedef struct session {
/// Custom GLX program used for painting window.
// XXX should be in struct glx_session
glx_prog_main_t glx_prog_win;
struct glx_fbconfig_info *argb_fbconfig;
#endif
/// Sync fence to sync draw operations
xcb_sync_fence_t sync_fence;

View File

@ -252,6 +252,7 @@ void glx_destroy(session_t *ps) {
free(ps->psglx);
ps->psglx = NULL;
ps->argb_fbconfig = NULL;
}
/**

View File

@ -48,15 +48,14 @@ static inline bool paint_bind_tex(session_t *ps, paint_t *ppaint, int wid, int h
bool repeat, int depth, xcb_visualid_t visual, bool force) {
#ifdef CONFIG_OPENGL
// XXX This is a mess. But this will go away after the backend refactor.
static thread_local struct glx_fbconfig_info *argb_fbconfig = NULL;
if (!ppaint->pixmap)
return false;
struct glx_fbconfig_info *fbcfg;
if (!visual) {
assert(depth == 32);
if (!argb_fbconfig) {
argb_fbconfig =
if (!ps->argb_fbconfig) {
ps->argb_fbconfig =
glx_find_fbconfig(ps->dpy, ps->scr,
(struct xvisual_info){.red_size = 8,
.green_size = 8,
@ -64,11 +63,11 @@ static inline bool paint_bind_tex(session_t *ps, paint_t *ppaint, int wid, int h
.alpha_size = 8,
.visual_depth = 32});
}
if (!argb_fbconfig) {
if (!ps->argb_fbconfig) {
log_error("Failed to find appropriate FBConfig for 32 bit depth");
return false;
}
fbcfg = argb_fbconfig;
fbcfg = ps->argb_fbconfig;
} else {
auto m = x_get_visual_info(ps->c, visual);
if (m.visual_depth < 0) {