[vlc-commits] direct3d11: handle the pixel shader specific string in CompilePixelShader( )

Steve Lhomme git at videolan.org
Fri Mar 3 16:02:53 CET 2017


vlc | branch: master | Steve Lhomme <robUx4 at videolabs.io> | Thu Mar  2 17:28:35 2017 +0100| [0c0179a69156d7e05a08ace7b9dd4f4287d63a53] | committer: Jean-Baptiste Kempf

direct3d11: handle the pixel shader specific string in CompilePixelShader()

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/video_output/win32/direct3d11.c | 28 +++++++++++-----------------
 1 file changed, 11 insertions(+), 17 deletions(-)

diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 224b1a8..24188b8 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -1624,28 +1624,13 @@ static ID3DBlob* CompileShader(vout_display_t *vd, const char *psz_shader, bool
 {
     vout_display_sys_t *sys = vd->sys;
     ID3DBlob* pShaderBlob = NULL, *pErrBlob;
-    char *shader;
-    if (!pixel)
-        shader = (char*)psz_shader;
-    else
-    {
-        shader = malloc(strlen(psz_shader) + 32);
-        if (!shader)
-        {
-            msg_Err(vd, "no room for the Pixel Shader");
-            return NULL;
-        }
-        sprintf(shader, psz_shader, sys->legacy_shader ? "" : "Array", sys->legacy_shader ? "" : "Array");
-    }
 
     /* TODO : Match the version to the D3D_FEATURE_LEVEL */
-    HRESULT hr = D3DCompile(shader, strlen(shader),
+    HRESULT hr = D3DCompile(psz_shader, strlen(psz_shader),
                             NULL, NULL, NULL, "main",
                             pixel ? (sys->legacy_shader ? "ps_4_0_level_9_1" : "ps_4_0") :
                                     (sys->legacy_shader ? "vs_4_0_level_9_1" : "vs_4_0"),
                             0, 0, &pShaderBlob, &pErrBlob);
-    if (pixel)
-        free(shader);
 
     if (FAILED(hr)) {
         char *err = pErrBlob ? ID3D10Blob_GetBufferPointer(pErrBlob) : NULL;
@@ -1660,7 +1645,16 @@ static ID3DBlob* CompileShader(vout_display_t *vd, const char *psz_shader, bool
 static HRESULT CompilePixelShader(vout_display_t *vd, const char *psz_shader, ID3D11PixelShader **output)
 {
     vout_display_sys_t *sys = vd->sys;
-    ID3DBlob *pPSBlob = CompileShader(vd, psz_shader, true);
+    char *shader = malloc(strlen(psz_shader) + 32);
+    if (!shader)
+    {
+        msg_Err(vd, "no room for the Pixel Shader");
+        return E_OUTOFMEMORY;
+    }
+    sprintf(shader, psz_shader, sys->legacy_shader ? "" : "Array", sys->legacy_shader ? "" : "Array");
+
+    ID3DBlob *pPSBlob = CompileShader(vd, shader, true);
+    free(shader);
     if (!pPSBlob)
         return E_INVALIDARG;
 



More information about the vlc-commits mailing list