direct3d11: split some functions to do the render target clean before displaying
authorSteve Lhomme <robux4@ycbcr.xyz>
Fri, 10 Aug 2018 11:44:17 +0000 (13:44 +0200)
committerSteve Lhomme <robux4@ycbcr.xyz>
Fri, 10 Aug 2018 14:07:50 +0000 (16:07 +0200)
modules/video_output/win32/direct3d11.c

index 7c26449..71bec97 100644 (file)
@@ -778,11 +778,14 @@ static void Manage(vout_display_t *vd)
     }
 }
 
-static void Prepare(vout_display_t *vd, picture_t *picture,
-                    subpicture_t *subpicture, vlc_tick_t date)
+static void DisplayPicture(vout_display_sys_t *sys, d3d_quad_t *quad, d3d_vshader_t *vs_shader,
+                           ID3D11ShaderResourceView *renderSrc[D3D11_MAX_SHADER_VIEW])
+{
+    D3D11_RenderQuad(&sys->d3d_dev, quad, vs_shader, renderSrc, sys->swapchainTargetView);
+}
+
+static void PreparePicture(vout_display_t *vd, picture_t *picture, subpicture_t *subpicture)
 {
-    Manage(vd);
-    VLC_UNUSED(date);
     vout_display_sys_t *sys = vd->sys;
 
     if (sys->picQuad.textureFormat->formatTexture == DXGI_FORMAT_UNKNOWN)
@@ -881,8 +884,6 @@ static void Prepare(vout_display_t *vd, picture_t *picture,
         sys->d3dregions      = subpicture_regions;
     }
 
-    D3D11_ClearRenderTargets( &sys->d3d_dev, sys->display.pixelFormat, sys->swapchainTargetView );
-
     if (picture->format.mastering.max_luminance)
     {
         D3D11_UpdateQuadLuminanceScale(vd, &sys->d3d_dev, &sys->picQuad, GetFormatLuminance(VLC_OBJECT(vd), &picture->format) / (float)sys->display.luminance_peak);
@@ -914,9 +915,9 @@ static void Prepare(vout_display_t *vd, picture_t *picture,
         picture_sys_t *p_sys = ActivePictureSys(picture);
         renderSrc = p_sys->renderSrc;
     }
-    D3D11_RenderQuad(&sys->d3d_dev, &sys->picQuad,
-                     vd->fmt.projection_mode == PROJECTION_MODE_RECTANGULAR ? &sys->flatVShader : &sys->projectionVShader,
-                     renderSrc, sys->swapchainTargetView);
+    DisplayPicture(sys, &sys->picQuad,
+                   vd->fmt.projection_mode == PROJECTION_MODE_RECTANGULAR ? &sys->flatVShader : &sys->projectionVShader,
+                   renderSrc);
 
     if (subpicture) {
         // draw the additional vertices
@@ -924,7 +925,7 @@ static void Prepare(vout_display_t *vd, picture_t *picture,
             if (sys->d3dregions[i])
             {
                 d3d_quad_t *quad = (d3d_quad_t *) sys->d3dregions[i]->p_sys;
-                D3D11_RenderQuad(&sys->d3d_dev, quad, &sys->flatVShader, quad->picSys.renderSrc, sys->swapchainTargetView);
+                DisplayPicture(sys, quad, &sys->flatVShader, quad->picSys.renderSrc);
             }
         }
     }
@@ -935,6 +936,19 @@ static void Prepare(vout_display_t *vd, picture_t *picture,
         d3d11_device_unlock( &sys->d3d_dev );
 }
 
+static void Prepare(vout_display_t *vd, picture_t *picture,
+                    subpicture_t *subpicture, vlc_tick_t date)
+{
+    vout_display_sys_t *sys = vd->sys;
+
+    Manage(vd);
+    VLC_UNUSED(date);
+
+    D3D11_ClearRenderTargets( &sys->d3d_dev, sys->display.pixelFormat, sys->swapchainTargetView );
+
+    PreparePicture(vd, picture, subpicture);
+}
+
 static void Display(vout_display_t *vd, picture_t *picture, subpicture_t *subpicture)
 {
     vout_display_sys_t *sys = vd->sys;