History

drm: use VOCTRL_REDRAW when flipping buffers

Basically whenever the VO does a redraw, we always have to flip buffers for vo_drm and drm_egl. The old way of doing this was checking if the video was paused and if the frame was still. This does work, but what really needs to be known is simply if the VO is redrawing. Since the added VOCTRL_REDRAW tells us this, we can shuffle around some logic and simplify greatly. drm_egl no longer needs its custom override for the submit_frame step so that can be eliminated along with the vo_gpu_next hack. Fixes 0959cdeb038de6484f75eada21f674bcc2407b89.

Dudemanguy committed 1 year ago

Commit 1bcc76d1 parent fc9d1ca8 files · +7 −34Browse files

Unified · Split

8 files
  1. video/out/drm_common.c +2 −3
  2. video/out/drm_common.h +1 −2
  3. video/out/opengl/context.c +0 −4
  4. video/out/opengl/context_drm_egl.c +2 −13
  5. video/out/vo.c +0 −6
  6. video/out/vo.h +0 −1
  7. video/out/vo_drm.c +2 −4
  8. video/out/vo_gpu_next.c +0 −1
video/out/drm_common.c+2−3
@@ -1046,10 +1046,9 @@ int vo_drm_control(struct vo *vo, int *events, int request, void *arg) · 1045 unmodified lines
10461046 }
10471047 case VOCTRL_PAUSE:
10481048 vo->want_redraw = true;
1049− drm->paused = true;
10501049 return VO_TRUE;
1051− case VOCTRL_RESUME:
1052− drm->paused = false;
1050+ case VOCTRL_REDRAW:
1051+ drm->redraw = true;
10531052 return VO_TRUE;
10541053 }
10551054 return VO_NOTIMPL;
video/out/drm_common.h+1−2
@@ -141,8 +141,7 @@ struct vo_drm_state { · 140 unmodified lines
141141 bool supported_colorspace;
142142
143143 bool active;
144− bool paused;
145− bool still;
144+ bool redraw;
146145 bool vt_switcher_active;
147146 bool waiting_for_flip;
148147
video/out/opengl/context.c+0−4
@@ -241,10 +241,6 @@ bool ra_gl_ctx_submit_frame(struct ra_swapchain *sw, const struct vo_frame *fram · 240 unmodified lines
241241 struct priv *p = sw->priv;
242242 GL *gl = p->gl;
243243
244− // Dumb hack for drm_egl and vo_gpu_next.
245− if (vo_is_gpu_next(sw->ctx->vo))
246− return true;
247−
248244 if (p->opts->use_glfinish)
249245 gl->Finish();
250246
video/out/opengl/context_drm_egl.c+2−13
@@ -388,22 +388,11 @@ static void wait_fence(struct ra_ctx *ctx) · 387 unmodified lines
388388 }
389389 }
390390
391−static bool drm_egl_submit_frame(struct ra_swapchain *sw, const struct vo_frame *frame)
392−{
393− struct ra_ctx *ctx = sw->ctx;
394− struct vo_drm_state *drm = ctx->vo->drm;
395−
396− drm->still = frame->still;
397−
398− return ra_gl_ctx_submit_frame(sw, frame);
399−}
400−
401391 static void drm_egl_swap_buffers(struct ra_swapchain *sw)
402392 {
403393 struct ra_ctx *ctx = sw->ctx;
404394 struct priv *p = ctx->priv;
405395 struct vo_drm_state *drm = ctx->vo->drm;
406− const bool drain = drm->paused || drm->still; // True when we need to drain the swapchain
407396
408397 if (!drm->atomic_context->request) {
409398 drm->atomic_context->request = drmModeAtomicAlloc();
@@ -425,7 +414,7 @@ static void drm_egl_swap_buffers(struct ra_swapchain *sw) · 15 unmodified lines
425414 enqueue_bo(ctx, new_bo);
426415 new_fence(ctx);
427416
428− while (drain || p->gbm.num_bos > ctx->vo->opts->swapchain_depth ||
417+ while (drm->redraw || p->gbm.num_bos > ctx->vo->opts->swapchain_depth ||
429418 !gbm_surface_has_free_buffers(p->gbm.surface)) {
430419 if (drm->waiting_for_flip) {
431420 vo_drm_wait_on_flip(drm);
@@ -440,10 +429,10 @@ static void drm_egl_swap_buffers(struct ra_swapchain *sw) · 8 unmodified lines
440429 }
441430 queue_flip(ctx, p->gbm.bo_queue[1]);
442431 }
432+ drm->redraw = false;
443433 }
444434
445435 static const struct ra_swapchain_fns drm_egl_swapchain = {
446− .submit_frame = drm_egl_submit_frame,
447436 .swap_buffers = drm_egl_swap_buffers,
448437 };
449438
video/out/vo.c+0−6
@@ -860,12 +860,6 @@ bool vo_is_ready_for_frame(struct vo *vo, int64_t next_pts) · 859 unmodified lines
860860 return r;
861861 }
862862
863−// Needed by egl_drm
864−bool vo_is_gpu_next(struct vo *vo)
865−{
866− return vo && vo->driver && vo->driver == &video_out_gpu_next;
867−}
868−
869863 // Check if the VO reports that the mpv window is visible.
870864 bool vo_is_visible(struct vo *vo)
871865 {
video/out/vo.h+0−1
@@ -534,7 +534,6 @@ int vo_reconfig2(struct vo *vo, struct mp_image *img); · 533 unmodified lines
534534
535535 int vo_control(struct vo *vo, int request, void *data);
536536 void vo_control_async(struct vo *vo, int request, void *data);
537−bool vo_is_gpu_next(struct vo *vo);
538537 bool vo_is_ready_for_frame(struct vo *vo, int64_t next_pts);
539538 bool vo_is_visible(struct vo *vo);
540539 void vo_queue_frame(struct vo *vo, struct vo_frame *frame);
video/out/vo_drm.c+2−4
@@ -308,8 +308,6 @@ static bool draw_frame(struct vo *vo, struct vo_frame *frame) · 307 unmodified lines
308308 if (!drm->active)
309309 goto done;
310310
311− drm->still = frame->still;
312−
313311 // we redraw the entire image when OSD needs to be redrawn
314312 struct framebuffer *fb = p->bufs[p->front_buf];
315313 const bool repeat = frame->repeat && !frame->redraw;
@@ -341,12 +339,11 @@ static void flip_page(struct vo *vo) · 25 unmodified lines
341339 {
342340 struct priv *p = vo->priv;
343341 struct vo_drm_state *drm = vo->drm;
344− const bool drain = drm->paused || drm->still;
345342
346343 if (!drm->active)
347344 return;
348345
349− while (drain || p->fb_queue_len > vo->opts->swapchain_depth) {
346+ while (drm->redraw || p->fb_queue_len > vo->opts->swapchain_depth) {
350347 if (drm->waiting_for_flip) {
351348 vo_drm_wait_on_flip(vo->drm);
352349 swapchain_step(vo);
@@ -360,6 +357,7 @@ static void flip_page(struct vo *vo) · 7 unmodified lines
360357 }
361358 queue_flip(vo, p->fb_queue[1]);
362359 }
360+ drm->redraw = false;
363361 }
364362
365363 static void get_vsync(struct vo *vo, struct vo_vsync_info *info)
video/out/vo_gpu_next.c+0−1
@@ -1170,7 +1170,6 @@ done: · 1169 unmodified lines
11701170 if (!valid) // clear with purple to indicate error
11711171 pl_tex_clear(gpu, swframe.fbo, (float[4]){ 0.5, 0.0, 1.0, 1.0 });
11721172
1173− sw->fns->submit_frame(sw, frame); // for drm_egl
11741173 pl_gpu_flush(gpu);
11751174 p->frame_pending = true;
11761175 return VO_TRUE;

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