History

vo_gpu/vo_gpu_next: fix transparency in glx

It seems that GLX requires us to explicitly set opts.want alpha before ra_ctx_create is called. b7fd232524bc213df91fa77ca0261ff514fad1e4 rearranged the function calls in a way made this not work. Fix this by rearranging it again so the value is set before ra_ctx is created.

Dudemanguy committed 2 years ago

Commit 38b5dcb1 parent fbf3ae54 files · +22 −21Browse files

Unified · Split

4 files
  1. video/out/gpu_next/context.c +1 −3
  2. video/out/gpu_next/context.h +2 −2
  3. video/out/vo_gpu.c +9 −8
  4. video/out/vo_gpu_next.c +10 −8
video/out/gpu_next/context.c+1−3
@@ -107,12 +107,10 @@ err_out: · 106 unmodified lines
107107 }
108108 #endif // HAVE_D3D11
109109
110−struct gpu_ctx *gpu_ctx_create(struct vo *vo, struct gl_video_opts *gl_opts)
110+struct gpu_ctx *gpu_ctx_create(struct vo *vo, struct ra_ctx_opts *ctx_opts)
111111 {
112112 struct gpu_ctx *ctx = talloc_zero(NULL, struct gpu_ctx);
113113 ctx->log = vo->log;
114−
115− struct ra_ctx_opts *ctx_opts = mp_get_config_group(ctx, vo->global, &ra_ctx_conf);
116114 ctx->ra_ctx = ra_ctx_create(vo, *ctx_opts);
117115 if (!ctx->ra_ctx)
118116 goto err_out;
video/out/gpu_next/context.h+2−2
@@ -21,8 +21,8 @@ · 20 unmodified lines
2121
2222 struct mp_log;
2323 struct ra_ctx;
24+struct ra_ctx_opts;
2425 struct vo;
25−struct gl_video_opts;
2626
2727 struct gpu_ctx {
2828 struct mp_log *log;
@@ -35,6 +35,6 @@ struct gpu_ctx { · 6 unmodified lines
3535 void *priv;
3636 };
3737
38−struct gpu_ctx *gpu_ctx_create(struct vo *vo, struct gl_video_opts *gl_opts);
38+struct gpu_ctx *gpu_ctx_create(struct vo *vo, struct ra_ctx_opts *ctx_opts);
3939 bool gpu_ctx_resize(struct gpu_ctx *ctx, int w, int h);
4040 void gpu_ctx_destroy(struct gpu_ctx **ctxp);
video/out/vo_gpu.c+9−8
@@ -169,13 +169,13 @@ static void get_and_update_ambient_lighting(struct gpu_priv *p) · 168 unmodified lines
169169 }
170170 }
171171
172−static void update_ra_ctx_options(struct vo *vo)
172+static void update_ra_ctx_options(struct vo *vo, struct ra_ctx_opts *ctx_opts)
173173 {
174174 struct gpu_priv *p = vo->priv;
175175 struct gl_video_opts *gl_opts = mp_get_config_group(p->ctx, vo->global, &gl_video_conf);
176− p->ctx->opts.want_alpha = (gl_opts->background == BACKGROUND_COLOR &&
177− gl_opts->background_color.a != 255) ||
178− gl_opts->background == BACKGROUND_NONE;
176+ ctx_opts->want_alpha = (gl_opts->background == BACKGROUND_COLOR &&
177+ gl_opts->background_color.a != 255) ||
178+ gl_opts->background == BACKGROUND_NONE;
179179 talloc_free(gl_opts);
180180 }
181181
@@ -198,12 +198,14 @@ static int control(struct vo *vo, uint32_t request, void *data) · 16 unmodified lines
198198 request_hwdec_api(vo, data);
199199 return true;
200200 case VOCTRL_UPDATE_RENDER_OPTS: {
201− update_ra_ctx_options(vo);
201+ struct ra_ctx_opts *ctx_opts = mp_get_config_group(vo, vo->global, &ra_ctx_conf);
202+ update_ra_ctx_options(vo, ctx_opts);
202203 gl_video_configure_queue(p->renderer, vo);
203204 get_and_update_icc_profile(p);
204205 if (p->ctx->fns->update_render_opts)
205206 p->ctx->fns->update_render_opts(p->ctx);
206207 vo->want_redraw = true;
208+ talloc_free(ctx_opts);
207209 return true;
208210 }
209211 case VOCTRL_RESET:
@@ -286,14 +288,13 @@ static int preinit(struct vo *vo) · 76 unmodified lines
286288 p->log = vo->log;
287289
288290 struct ra_ctx_opts *ctx_opts = mp_get_config_group(vo, vo->global, &ra_ctx_conf);
289− struct ra_ctx_opts opts = *ctx_opts;
290− p->ctx = ra_ctx_create(vo, opts);
291+ update_ra_ctx_options(vo, ctx_opts);
292+ p->ctx = ra_ctx_create(vo, *ctx_opts);
291293 talloc_free(ctx_opts);
292294 if (!p->ctx)
293295 goto err_out;
294296 assert(p->ctx->ra);
295297 assert(p->ctx->swapchain);
296− update_ra_ctx_options(vo);
297298
298299 p->renderer = gl_video_init(p->ctx->ra, vo->log, vo->global);
299300 gl_video_set_osd_source(p->renderer, vo->osd);
video/out/vo_gpu_next.c+10−8
@@ -1477,17 +1477,17 @@ static inline void copy_frame_info_to_mp(struct frame_info *pl, · 1476 unmodified lines
14771477 }
14781478 }
14791479
1480−static void update_ra_ctx_options(struct vo *vo)
1480+static void update_ra_ctx_options(struct vo *vo, struct ra_ctx_opts *ctx_opts)
14811481 {
14821482 struct priv *p = vo->priv;
14831483 struct gl_video_opts *gl_opts = p->opts_cache->opts;
14841484 bool border_alpha = (p->next_opts->border_background == BACKGROUND_COLOR &&
14851485 gl_opts->background_color.a != 255) ||
14861486 p->next_opts->border_background == BACKGROUND_NONE;
1487− p->ra_ctx->opts.want_alpha = (gl_opts->background == BACKGROUND_COLOR &&
1488− gl_opts->background_color.a != 255) ||
1489− gl_opts->background == BACKGROUND_NONE ||
1490− border_alpha;
1487+ ctx_opts->want_alpha = (gl_opts->background == BACKGROUND_COLOR &&
1488+ gl_opts->background_color.a != 255) ||
1489+ gl_opts->background == BACKGROUND_NONE ||
1490+ border_alpha;
14911491 }
14921492
14931493 static int control(struct vo *vo, uint32_t request, void *data)
@@ -1505,7 +1505,7 @@ static int control(struct vo *vo, uint32_t request, void *data) · 11 unmodified lines
15051505
15061506 case VOCTRL_UPDATE_RENDER_OPTS: {
15071507 m_config_cache_update(p->opts_cache);
1508− update_ra_ctx_options(vo);
1508+ update_ra_ctx_options(vo, &p->ra_ctx->opts);
15091509 if (p->ra_ctx->fns->update_render_opts)
15101510 p->ra_ctx->fns->update_render_opts(p->ra_ctx);
15111511 update_render_options(vo);
@@ -1825,7 +1825,10 @@ static int preinit(struct vo *vo) · 313 unmodified lines
18251825 p->log = vo->log;
18261826
18271827 struct gl_video_opts *gl_opts = p->opts_cache->opts;
1828− p->context = gpu_ctx_create(vo, gl_opts);
1828+ struct ra_ctx_opts *ctx_opts = mp_get_config_group(vo, vo->global, &ra_ctx_conf);
1829+ update_ra_ctx_options(vo, ctx_opts);
1830+ p->context = gpu_ctx_create(vo, ctx_opts);
1831+ talloc_free(ctx_opts);
18291832 if (!p->context)
18301833 goto err_out;
18311834 // For the time being
@@ -1838,7 +1841,6 @@ static int preinit(struct vo *vo) · 6 unmodified lines
18381841 .global = p->global,
18391842 .ra_ctx = p->ra_ctx,
18401843 };
1841− update_ra_ctx_options(vo);
18421844
18431845 vo->hwdec_devs = hwdec_devices_create();
18441846 hwdec_devices_set_loader(vo->hwdec_devs, load_hwdec_api, vo);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t