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
107}107}
108#endif // HAVE_D3D11108#endif // HAVE_D3D11
109 109
110struct gpu_ctx *gpu_ctx_create(struct vo *vo, struct gl_video_opts *gl_opts)110struct gpu_ctx *gpu_ctx_create(struct vo *vo, struct ra_ctx_opts *ctx_opts)
111{111{
112 struct gpu_ctx *ctx = talloc_zero(NULL, struct gpu_ctx);112 struct gpu_ctx *ctx = talloc_zero(NULL, struct gpu_ctx);
113 ctx->log = vo->log;113 ctx->log = vo->log;
114
115 struct ra_ctx_opts *ctx_opts = mp_get_config_group(ctx, vo->global, &ra_ctx_conf);
116 ctx->ra_ctx = ra_ctx_create(vo, *ctx_opts);114 ctx->ra_ctx = ra_ctx_create(vo, *ctx_opts);
117 if (!ctx->ra_ctx)115 if (!ctx->ra_ctx)
118 goto err_out;116 goto err_out;
video/out/gpu_next/context.h+2−2
@@ -21,8 +21,8 @@ · 20 unmodified lines
21 21
22struct mp_log;22struct mp_log;
23struct ra_ctx;23struct ra_ctx;
24struct ra_ctx_opts;
24struct vo;25struct vo;
25struct gl_video_opts;
26 26
27struct gpu_ctx {27struct gpu_ctx {
28 struct mp_log *log;28 struct mp_log *log;
@@ -35,6 +35,6 @@ struct gpu_ctx { · 6 unmodified lines
35 void *priv;35 void *priv;
36};36};
37 37
38struct gpu_ctx *gpu_ctx_create(struct vo *vo, struct gl_video_opts *gl_opts);38struct gpu_ctx *gpu_ctx_create(struct vo *vo, struct ra_ctx_opts *ctx_opts);
39bool gpu_ctx_resize(struct gpu_ctx *ctx, int w, int h);39bool gpu_ctx_resize(struct gpu_ctx *ctx, int w, int h);
40void gpu_ctx_destroy(struct gpu_ctx **ctxp);40void 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
169 }169 }
170}170}
171 171
172static void update_ra_ctx_options(struct vo *vo)172static void update_ra_ctx_options(struct vo *vo, struct ra_ctx_opts *ctx_opts)
173{173{
174 struct gpu_priv *p = vo->priv;174 struct gpu_priv *p = vo->priv;
175 struct gl_video_opts *gl_opts = mp_get_config_group(p->ctx, vo->global, &gl_video_conf);175 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 &&176 ctx_opts->want_alpha = (gl_opts->background == BACKGROUND_COLOR &&
177 gl_opts->background_color.a != 255) ||177 gl_opts->background_color.a != 255) ||
178 gl_opts->background == BACKGROUND_NONE;178 gl_opts->background == BACKGROUND_NONE;
179 talloc_free(gl_opts);179 talloc_free(gl_opts);
180}180}
181 181
@@ -198,12 +198,14 @@ static int control(struct vo *vo, uint32_t request, void *data) · 16 unmodified lines
198 request_hwdec_api(vo, data);198 request_hwdec_api(vo, data);
199 return true;199 return true;
200 case VOCTRL_UPDATE_RENDER_OPTS: {200 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);
202 gl_video_configure_queue(p->renderer, vo);203 gl_video_configure_queue(p->renderer, vo);
203 get_and_update_icc_profile(p);204 get_and_update_icc_profile(p);
204 if (p->ctx->fns->update_render_opts)205 if (p->ctx->fns->update_render_opts)
205 p->ctx->fns->update_render_opts(p->ctx);206 p->ctx->fns->update_render_opts(p->ctx);
206 vo->want_redraw = true;207 vo->want_redraw = true;
208 talloc_free(ctx_opts);
207 return true;209 return true;
208 }210 }
209 case VOCTRL_RESET:211 case VOCTRL_RESET:
@@ -286,14 +288,13 @@ static int preinit(struct vo *vo) · 76 unmodified lines
286 p->log = vo->log;288 p->log = vo->log;
287 289
288 struct ra_ctx_opts *ctx_opts = mp_get_config_group(vo, vo->global, &ra_ctx_conf);290 struct ra_ctx_opts *ctx_opts = mp_get_config_group(vo, vo->global, &ra_ctx_conf);
289 struct ra_ctx_opts opts = *ctx_opts;291 update_ra_ctx_options(vo, ctx_opts);
290 p->ctx = ra_ctx_create(vo, opts);292 p->ctx = ra_ctx_create(vo, *ctx_opts);
291 talloc_free(ctx_opts);293 talloc_free(ctx_opts);
292 if (!p->ctx)294 if (!p->ctx)
293 goto err_out;295 goto err_out;
294 assert(p->ctx->ra);296 assert(p->ctx->ra);
295 assert(p->ctx->swapchain);297 assert(p->ctx->swapchain);
296 update_ra_ctx_options(vo);
297 298
298 p->renderer = gl_video_init(p->ctx->ra, vo->log, vo->global);299 p->renderer = gl_video_init(p->ctx->ra, vo->log, vo->global);
299 gl_video_set_osd_source(p->renderer, vo->osd);300 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
1477 }1477 }
1478}1478}
1479 1479
1480static void update_ra_ctx_options(struct vo *vo)1480static void update_ra_ctx_options(struct vo *vo, struct ra_ctx_opts *ctx_opts)
1481{1481{
1482 struct priv *p = vo->priv;1482 struct priv *p = vo->priv;
1483 struct gl_video_opts *gl_opts = p->opts_cache->opts;1483 struct gl_video_opts *gl_opts = p->opts_cache->opts;
1484 bool border_alpha = (p->next_opts->border_background == BACKGROUND_COLOR &&1484 bool border_alpha = (p->next_opts->border_background == BACKGROUND_COLOR &&
1485 gl_opts->background_color.a != 255) ||1485 gl_opts->background_color.a != 255) ||
1486 p->next_opts->border_background == BACKGROUND_NONE;1486 p->next_opts->border_background == BACKGROUND_NONE;
1487 p->ra_ctx->opts.want_alpha = (gl_opts->background == BACKGROUND_COLOR &&1487 ctx_opts->want_alpha = (gl_opts->background == BACKGROUND_COLOR &&
1488 gl_opts->background_color.a != 255) ||1488 gl_opts->background_color.a != 255) ||
1489 gl_opts->background == BACKGROUND_NONE ||1489 gl_opts->background == BACKGROUND_NONE ||
1490 border_alpha;1490 border_alpha;
1491}1491}
1492 1492
1493static int control(struct vo *vo, uint32_t request, void *data)1493static 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
1505 1505
1506 case VOCTRL_UPDATE_RENDER_OPTS: {1506 case VOCTRL_UPDATE_RENDER_OPTS: {
1507 m_config_cache_update(p->opts_cache);1507 m_config_cache_update(p->opts_cache);
1508 update_ra_ctx_options(vo);1508 update_ra_ctx_options(vo, &p->ra_ctx->opts);
1509 if (p->ra_ctx->fns->update_render_opts)1509 if (p->ra_ctx->fns->update_render_opts)
1510 p->ra_ctx->fns->update_render_opts(p->ra_ctx);1510 p->ra_ctx->fns->update_render_opts(p->ra_ctx);
1511 update_render_options(vo);1511 update_render_options(vo);
@@ -1825,7 +1825,10 @@ static int preinit(struct vo *vo) · 313 unmodified lines
1825 p->log = vo->log;1825 p->log = vo->log;
1826 1826
1827 struct gl_video_opts *gl_opts = p->opts_cache->opts;1827 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);
1829 if (!p->context)1832 if (!p->context)
1830 goto err_out;1833 goto err_out;
1831 // For the time being1834 // For the time being
@@ -1838,7 +1841,6 @@ static int preinit(struct vo *vo) · 6 unmodified lines
1838 .global = p->global,1841 .global = p->global,
1839 .ra_ctx = p->ra_ctx,1842 .ra_ctx = p->ra_ctx,
1840 };1843 };
1841 update_ra_ctx_options(vo);
1842 1844
1843 vo->hwdec_devs = hwdec_devices_create();1845 vo->hwdec_devs = hwdec_devices_create();
1844 hwdec_devices_set_loader(vo->hwdec_devs, load_hwdec_api, vo);1846 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