[vlc-devel] [PATCH 21/39] direct3d11: move AllocateShaderView() in d3d11_fmt.h

Steve Lhomme robux4 at videolabs.io
Fri Jun 2 16:46:24 CEST 2017


---
 modules/video_chroma/d3d11_fmt.h        | 54 +++++++++++++++++++++++++++++++++
 modules/video_output/win32/direct3d11.c | 53 --------------------------------
 2 files changed, 54 insertions(+), 53 deletions(-)

diff --git a/modules/video_chroma/d3d11_fmt.h b/modules/video_chroma/d3d11_fmt.h
index 3c69cfff0b..1ab3977ccd 100644
--- a/modules/video_chroma/d3d11_fmt.h
+++ b/modules/video_chroma/d3d11_fmt.h
@@ -24,6 +24,7 @@
 #define VLC_VIDEOCHROMA_D3D11_FMT_H_
 
 #include <d3d11.h>
+#include <assert.h>
 
 #include "dxgi_fmt.h"
 
@@ -76,4 +77,57 @@ static inline void ReleasePictureSys(picture_sys_t *p_sys)
     }
 }
 
+/* map texture planes to resource views */
+static inline int AllocateShaderView(vlc_object_t *obj, ID3D11Device *d3ddevice,
+                              const d3d_format_t *format,
+                              ID3D11Texture2D *p_texture, UINT slice_index,
+                              ID3D11ShaderResourceView *resourceView[D3D11_MAX_SHADER_VIEW])
+{
+    HRESULT hr;
+    int i;
+    D3D11_SHADER_RESOURCE_VIEW_DESC resviewDesc = { 0 };
+    D3D11_TEXTURE2D_DESC texDesc;
+    ID3D11Texture2D_GetDesc(p_texture, &texDesc);
+    assert(texDesc.BindFlags & D3D11_BIND_SHADER_RESOURCE);
+
+    if (texDesc.ArraySize == 1)
+    {
+        resviewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
+        resviewDesc.Texture2D.MipLevels = 1;
+    }
+    else
+    {
+        resviewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY;
+        resviewDesc.Texture2DArray.MipLevels = -1;
+        resviewDesc.Texture2DArray.ArraySize = 1;
+        resviewDesc.Texture2DArray.FirstArraySlice = slice_index;
+    }
+    for (i=0; i<D3D11_MAX_SHADER_VIEW; i++)
+    {
+        resviewDesc.Format = format->resourceFormat[i];
+        if (resviewDesc.Format == DXGI_FORMAT_UNKNOWN)
+            resourceView[i] = NULL;
+        else
+        {
+            hr = ID3D11Device_CreateShaderResourceView(d3ddevice, (ID3D11Resource*)p_texture, &resviewDesc, &resourceView[i]);
+            if (FAILED(hr)) {
+                msg_Err(obj, "Could not Create the Texture ResourceView %d slice %d. (hr=0x%lX)", i, slice_index, hr);
+                break;
+            }
+        }
+    }
+
+    if (i != D3D11_MAX_SHADER_VIEW)
+    {
+        while (--i >= 0)
+        {
+            ID3D11ShaderResourceView_Release(resourceView[i]);
+            resourceView[i] = NULL;
+        }
+        return VLC_EGENERIC;
+    }
+
+    return VLC_SUCCESS;
+}
+
 #endif /* include-guard */
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index e56acabcfe..187cedbe82 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -574,59 +574,6 @@ static void Close(vlc_object_t *object)
     free(vd->sys);
 }
 
-/* map texture planes to resource views */
-static int AllocateShaderView(vlc_object_t *obj, ID3D11Device *d3ddevice,
-                              const d3d_format_t *format,
-                              ID3D11Texture2D *p_texture, UINT slice_index,
-                              ID3D11ShaderResourceView *resourceView[D3D11_MAX_SHADER_VIEW])
-{
-    HRESULT hr;
-    int i;
-    D3D11_SHADER_RESOURCE_VIEW_DESC resviewDesc = { 0 };
-    D3D11_TEXTURE2D_DESC texDesc;
-    ID3D11Texture2D_GetDesc(p_texture, &texDesc);
-    assert(texDesc.BindFlags & D3D11_BIND_SHADER_RESOURCE);
-
-    if (texDesc.ArraySize == 1)
-    {
-        resviewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
-        resviewDesc.Texture2D.MipLevels = 1;
-    }
-    else
-    {
-        resviewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY;
-        resviewDesc.Texture2DArray.MipLevels = -1;
-        resviewDesc.Texture2DArray.ArraySize = 1;
-        resviewDesc.Texture2DArray.FirstArraySlice = slice_index;
-    }
-    for (i=0; i<D3D11_MAX_SHADER_VIEW; i++)
-    {
-        resviewDesc.Format = format->resourceFormat[i];
-        if (resviewDesc.Format == DXGI_FORMAT_UNKNOWN)
-            resourceView[i] = NULL;
-        else
-        {
-            hr = ID3D11Device_CreateShaderResourceView(d3ddevice, (ID3D11Resource*)p_texture, &resviewDesc, &resourceView[i]);
-            if (FAILED(hr)) {
-                msg_Err(obj, "Could not Create the Texture ResourceView %d slice %d. (hr=0x%lX)", i, slice_index, hr);
-                break;
-            }
-        }
-    }
-
-    if (i != D3D11_MAX_SHADER_VIEW)
-    {
-        while (--i >= 0)
-        {
-            ID3D11ShaderResourceView_Release(resourceView[i]);
-            resourceView[i] = NULL;
-        }
-        return VLC_EGENERIC;
-    }
-
-    return VLC_SUCCESS;
-}
-
 static int AllocateTextures(vout_display_t *vd, const d3d_format_t *cfg,
                             video_format_t *fmt, unsigned pool_size,
                             ID3D11Texture2D *textures[],
-- 
2.12.1



More information about the vlc-devel mailing list