[vlc-commits] [Git][videolan/vlc][master] libplacebo/display: defer submission until PictureDisplay

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Fri Aug 11 12:54:37 UTC 2023



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
0f108f59 by Niklas Haas at 2023-08-11T12:37:19+00:00
libplacebo/display: defer submission until PictureDisplay

Calling pl_swapchain_submit_frame() in PictureRender() is the wrong
place, and may cause frames to become visible sooner than intended.

The correct thing to do is to defer submission until the actual
PictureDisplay() call, and merely flush the GPU work in PictureRender().

To handle the edge case of `pl_swapchain_start_frame` failing (e.g. when
the window gets lost), we keep track of whether or not there's an active
FBO being rendered, and no-op in the case that there isn't. It might
seem like overkill to store a `pl_tex` here when a bool will suffice,
but this is future-proofing for an upcoming redesign of the libplacebo
swapchain API.

- - - - -


1 changed file:

- modules/video_output/libplacebo/display.c


Changes:

=====================================
modules/video_output/libplacebo/display.c
=====================================
@@ -45,6 +45,7 @@ typedef struct vout_display_sys_t
     vlc_placebo_t *pl;
     pl_renderer renderer;
     pl_tex plane_tex[4];
+    pl_tex fbo;
 
     // Pool of textures for the subpictures
     struct pl_overlay *overlays;
@@ -225,6 +226,7 @@ static void PictureRender(vout_display_t *vd, picture_t *pic,
         vlc_placebo_ReleaseCurrent(sys->pl);
         return; // Probably benign error, ignore it
     }
+    sys->fbo = frame.fbo;
 
 #if PL_API_VER >= 199
     bool need_vflip = false;
@@ -454,8 +456,7 @@ done:
     if (failed)
         pl_tex_clear(gpu, frame.fbo, (float[4]){ 1.0, 0.0, 0.0, 1.0 });
 
-    if (!pl_swapchain_submit_frame(sys->pl->swapchain))
-        msg_Err(vd, "Failed rendering frame!");
+    pl_gpu_flush(gpu);
 
     vlc_placebo_ReleaseCurrent(sys->pl);
 }
@@ -464,7 +465,13 @@ static void PictureDisplay(vout_display_t *vd, picture_t *pic)
 {
     VLC_UNUSED(pic);
     vout_display_sys_t *sys = vd->sys;
+    if (!sys->fbo)
+        return;
+
+    sys->fbo = NULL;
     if (vlc_placebo_MakeCurrent(sys->pl) == VLC_SUCCESS) {
+        if (!pl_swapchain_submit_frame(sys->pl->swapchain))
+            msg_Err(vd, "Failed rendering frame!");
         pl_swapchain_swap_buffers(sys->pl->swapchain);
         vlc_placebo_ReleaseCurrent(sys->pl);
     }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/0f108f598c0567e2bee3706044c6c8c782be2961

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/0f108f598c0567e2bee3706044c6c8c782be2961
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list