[vlc-commits] d3d11_shaders: add a function to clear a render target

Steve Lhomme git at videolan.org
Mon May 28 13:25:38 CEST 2018


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Tue Jan  9 15:03:37 2018 +0100| [2758d6bd4e5c1d85f097e668ec157493c6c873ef] | committer: Steve Lhomme

d3d11_shaders: add a function to clear a render target

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2758d6bd4e5c1d85f097e668ec157493c6c873ef
---

 modules/video_output/win32/d3d11_shaders.c | 36 ++++++++++++++++++++++++++++++
 modules/video_output/win32/d3d11_shaders.h |  3 +++
 2 files changed, 39 insertions(+)

diff --git a/modules/video_output/win32/d3d11_shaders.c b/modules/video_output/win32/d3d11_shaders.c
index 747916f1bb..35405811e3 100644
--- a/modules/video_output/win32/d3d11_shaders.c
+++ b/modules/video_output/win32/d3d11_shaders.c
@@ -537,3 +537,39 @@ HRESULT D3D11_CreateRenderTargets( d3d11_device_t *d3d_dev, ID3D11Resource *text
     }
     return S_OK;
 }
+
+void D3D11_ClearRenderTargets(d3d11_device_t *d3d_dev, const d3d_format_t *cfg,
+                              ID3D11RenderTargetView *targets[D3D11_MAX_SHADER_VIEW])
+{
+    static const FLOAT blackY[1] = {0.0f};
+    static const FLOAT blackUV[2] = {0.5f, 0.5f};
+    static const FLOAT blackRGBA[4] = {0.0f, 0.0f, 0.0f, 1.0f};
+    static const FLOAT blackYUY2[4] = {0.0f, 0.5f, 0.0f, 0.5f};
+    static const FLOAT blackVUYA[4] = {0.5f, 0.5f, 0.0f, 1.0f};
+
+    switch (cfg->formatTexture)
+    {
+    case DXGI_FORMAT_NV12:
+    case DXGI_FORMAT_P010:
+        ID3D11DeviceContext_ClearRenderTargetView( d3d_dev->d3dcontext, targets[0], blackY);
+        ID3D11DeviceContext_ClearRenderTargetView( d3d_dev->d3dcontext, targets[1], blackUV);
+        break;
+    case DXGI_FORMAT_R8G8B8A8_UNORM:
+    case DXGI_FORMAT_B8G8R8A8_UNORM:
+    case DXGI_FORMAT_B8G8R8X8_UNORM:
+    case DXGI_FORMAT_R10G10B10A2_UNORM:
+        ID3D11DeviceContext_ClearRenderTargetView( d3d_dev->d3dcontext, targets[0], blackRGBA);
+        break;
+    case DXGI_FORMAT_YUY2:
+        ID3D11DeviceContext_ClearRenderTargetView( d3d_dev->d3dcontext, targets[0], blackYUY2);
+        break;
+    case DXGI_FORMAT_AYUV:
+        ID3D11DeviceContext_ClearRenderTargetView( d3d_dev->d3dcontext, targets[0], blackVUYA);
+        break;
+    case DXGI_FORMAT_B5G6R5_UNORM:
+        ID3D11DeviceContext_ClearRenderTargetView( d3d_dev->d3dcontext, targets[0], blackRGBA);
+        break;
+    default:
+        vlc_assert_unreachable();
+    }
+}
diff --git a/modules/video_output/win32/d3d11_shaders.h b/modules/video_output/win32/d3d11_shaders.h
index b668f79fb8..1bdfa10822 100644
--- a/modules/video_output/win32/d3d11_shaders.h
+++ b/modules/video_output/win32/d3d11_shaders.h
@@ -94,4 +94,7 @@ float GetFormatLuminance(vlc_object_t *, const video_format_t *);
 HRESULT D3D11_CreateRenderTargets(d3d11_device_t *, ID3D11Resource *, const d3d_format_t *,
                                   ID3D11RenderTargetView *output[D3D11_MAX_SHADER_VIEW]);
 
+void D3D11_ClearRenderTargets(d3d11_device_t *, const d3d_format_t *,
+                              ID3D11RenderTargetView *targets[D3D11_MAX_SHADER_VIEW]);
+
 #endif /* VLC_D3D11_SHADERS_H */



More information about the vlc-commits mailing list