[vlc-commits] [Git][videolan/vlc][master] 7 commits: d3d11va: remove unused Qualcomm check

Steve Lhomme (@robUx4) gitlab at videolan.org
Sat Aug 17 14:23:43 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
fb17454e by Steve Lhomme at 2024-08-17T14:09:40+00:00
d3d11va: remove unused Qualcomm check

This limitation was found in old Windows Phone that we don't support anymore.

Recent Qualcomm GPUs+drivers are working fine with padding in decoding textures.

- - - - -
b5c16648 by Steve Lhomme at 2024-08-17T14:09:40+00:00
direct3d11: don't restrict the shader for texture arrays

We don't use texture array in the shader since ddf67a901b19ed06e3a278e6708f8ec7c859a0be.

- - - - -
60489378 by Steve Lhomme at 2024-08-17T14:09:40+00:00
d3d11: log errors when failing to create/get a ID3D11Device

- - - - -
ed1e0d29 by Steve Lhomme at 2024-08-17T14:09:40+00:00
d3d11: log errors when failing to use the input hardware format for rendering

- - - - -
030067d2 by Steve Lhomme at 2024-08-17T14:09:40+00:00
d3d11va: create the picture context with the resource from the decoder output

If the decoded format can't be used in shaders, we still want to be able to forward it.

- - - - -
5d043704 by Steve Lhomme at 2024-08-17T14:09:40+00:00
d3d11: fix potential double free of internal swapchain

- - - - -
dba07a41 by Steve Lhomme at 2024-08-17T14:09:40+00:00
d3d11: log the steps to find the shader output format

- - - - -


3 changed files:

- modules/codec/avcodec/d3d11va.c
- modules/video_chroma/d3d11_fmt.cpp
- modules/video_output/win32/direct3d11.cpp


Changes:

=====================================
modules/codec/avcodec/d3d11va.c
=====================================
@@ -142,7 +142,7 @@ static picture_context_t *d3d11va_pic_context_copy(picture_context_t *ctx)
     return &pic_ctx->ctx.s;
 }
 
-static struct d3d11va_pic_context *CreatePicContext(
+static struct d3d11va_pic_context *CreatePicContext(ID3D11Resource *p_resource,
                                                   UINT slice,
                                                   ID3D11ShaderResourceView *renderSrc[DXGI_MAX_SHADER_VIEW],
                                                   vlc_video_context *vctx)
@@ -155,9 +155,6 @@ static struct d3d11va_pic_context *CreatePicContext(
         vlc_video_context_Hold(vctx),
     };
 
-    ID3D11Resource *p_resource;
-    ID3D11ShaderResourceView_GetResource(renderSrc[0], &p_resource);
-
     pic_ctx->ctx.picsys.slice_index = slice;
     pic_ctx->ctx.picsys.sharedHandle = INVALID_HANDLE_VALUE;
     for (int i=0;i<DXGI_MAX_SHADER_VIEW; i++)
@@ -166,7 +163,6 @@ static struct d3d11va_pic_context *CreatePicContext(
         pic_ctx->ctx.picsys.renderSrc[i] = renderSrc[i];
     }
     AcquireD3D11PictureSys(&pic_ctx->ctx.picsys);
-    ID3D11Resource_Release(p_resource);
     return pic_ctx;
 }
 
@@ -182,9 +178,13 @@ static picture_context_t* NewSurfacePicContext(vlc_va_t *va, vlc_va_surface_t *v
     for (size_t i=0; i<DXGI_MAX_SHADER_VIEW; i++)
         resourceView[i] = sys->renderSrc[viewDesc.Texture2D.ArraySlice*DXGI_MAX_SHADER_VIEW + i];
 
-    struct d3d11va_pic_context *pic_ctx = CreatePicContext(
+    ID3D11Resource *p_resource;
+    ID3D11VideoDecoderOutputView_GetResource(surface, &p_resource);
+
+    struct d3d11va_pic_context *pic_ctx = CreatePicContext(p_resource,
                                                   viewDesc.Texture2D.ArraySlice,
                                                   resourceView, sys->vctx);
+    ID3D11Resource_Release(p_resource);
     if (unlikely(pic_ctx==NULL))
         return NULL;
     pic_ctx->va_surface = va_surface;
@@ -485,13 +485,6 @@ static int DxSetupOutput(vlc_va_t *va, const directx_va_mode_t *mode, const vide
     return VLC_EGENERIC;
 }
 
-static bool CanUseDecoderPadding(const vlc_va_sys_t *sys)
-{
-    /* Qualcomm hardware has issues with textures and pixels that should not be
-    * part of the decoded area */
-    return sys->d3d_dev->adapterDesc.VendorId != GPU_MANUFACTURER_QUALCOMM;
-}
-
 /**
  * It creates a Direct3D11 decoder using the given video format
  */


=====================================
modules/video_chroma/d3d11_fmt.cpp
=====================================
@@ -538,6 +538,7 @@ d3d11_decoder_device_t *(D3D11_CreateDevice)(vlc_object_t *obj,
             {
                 if (sys->external.cleanupDeviceCb)
                     sys->external.cleanupDeviceCb( sys->external.opaque );
+                msg_Err(obj, "Failed to setup external D3D11 device");
                 goto error;
             }
             hr = D3D11_CreateDeviceExternal(obj, static_cast<ID3D11DeviceContext*>(out.d3d11.device_context), out.d3d11.context_mutex,
@@ -556,14 +557,20 @@ d3d11_decoder_device_t *(D3D11_CreateDevice)(vlc_object_t *obj,
                 if (likely(hKernel32 != NULL))
                     isWin81OrGreater = GetProcAddress(hKernel32, "IsProcessCritical") != NULL;
                 if (!isWin81OrGreater)
+                {
+                    msg_Dbg(obj, "D3D11 not forced on Win7/8");
                     goto error;
+                }
             }
 #endif
 
             hr = CreateDevice( obj, adapter, hw_decoding, &sys->dec_device.d3d_dev );
         }
         else
+        {
+            msg_Dbg(obj, "Unsupported engine type %d", engineType);
             goto error;
+        }
     }
 
 error:


=====================================
modules/video_output/win32/direct3d11.cpp
=====================================
@@ -910,9 +910,18 @@ static const d3d_format_t *GetDisplayFormatByDepth(vout_display_t *vd, uint8_t b
     UINT supportFlags = D3D11_FORMAT_SUPPORT_SHADER_LOAD;
     if (from_processor)
         supportFlags |= D3D11_FORMAT_SUPPORT_VIDEO_PROCESSOR_OUTPUT;
-    return FindD3D11Format( vd, sys->d3d_dev, 0, rgb_yuv,
+    const d3d_format_t *res;
+    res = FindD3D11Format( vd, sys->d3d_dev, 0, rgb_yuv,
                             bit_depth, widthDenominator+1, heightDenominator+1, alpha_bits,
                             DXGI_CHROMA_CPU, supportFlags );
+    if (res == nullptr)
+    {
+        msg_Dbg(vd, "No display format for %u-bit %u:%u%s%s%s", bit_depth, widthDenominator, heightDenominator,
+                                                          rgb_yuv & DXGI_YUV_FORMAT ? " YUV" : "",
+                                                          rgb_yuv & DXGI_RGB_FORMAT ? " RGB" : "",
+                                                          from_processor ? " supporting video processor" : "");
+    }
+    return res;
 }
 
 static const d3d_format_t *GetBlendableFormat(vout_display_t *vd, vlc_fourcc_t i_src_chroma)
@@ -969,8 +978,11 @@ static int Direct3D11Open(vout_display_t *vd, video_format_t *fmtp, vlc_video_co
         if (err != VLC_SUCCESS)
         {
 #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
-            if ( sys->swapCb == D3D11_LocalSwapchainSwap )
+            if ( sys->swapCb == D3D11_LocalSwapchainSwap && sys->outside_opaque )
+            {
                 D3D11_LocalSwapchainCleanupDevice( sys->outside_opaque );
+                sys->outside_opaque = nullptr;
+            }
 #endif // WINAPI_PARTITION_DESKTOP
             return err;
         }
@@ -1020,8 +1032,11 @@ static int Direct3D11Open(vout_display_t *vd, video_format_t *fmtp, vlc_video_co
     if (Direct3D11CreateGenericResources(vd)) {
         msg_Err(vd, "Failed to allocate resources");
 #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
-        if ( sys->swapCb == D3D11_LocalSwapchainSwap )
+        if ( sys->swapCb == D3D11_LocalSwapchainSwap && sys->outside_opaque )
+        {
             D3D11_LocalSwapchainCleanupDevice( sys->outside_opaque );
+            sys->outside_opaque = nullptr;
+        }
 #endif // WINAPI_PARTITION_DESKTOP
         return VLC_EGENERIC;
     }
@@ -1042,12 +1057,19 @@ static const d3d_format_t *SelectOutputFormat(vout_display_t *vd, const video_fo
     const d3d_format_t *res = nullptr;
 
     d3d11_video_context_t *vtcx_sys = GetD3D11ContextPrivate(vctx);
-    if (vtcx_sys != NULL &&
-        D3D11_DeviceSupportsFormat( sys->d3d_dev, vtcx_sys->format, D3D11_FORMAT_SUPPORT_SHADER_LOAD ))
+    if (vtcx_sys != NULL)
     {
-        res = D3D11_RenderFormat(vtcx_sys->format, vtcx_sys->secondary ,true);
-        if (res != nullptr)
-            return res;
+        if (D3D11_DeviceSupportsFormat( sys->d3d_dev, vtcx_sys->format, D3D11_FORMAT_SUPPORT_SHADER_LOAD ))
+        {
+            res = D3D11_RenderFormat(vtcx_sys->format, vtcx_sys->secondary ,true);
+            if (likely(res != nullptr))
+                return res;
+            msg_Dbg(vd, "Unsupported rendering texture format %s/%s", DxgiFormatToStr(vtcx_sys->format), DxgiFormatToStr(vtcx_sys->secondary));
+        }
+        else
+        {
+            msg_Dbg(vd, "Texture format %s not supported by shaders", DxgiFormatToStr(vtcx_sys->format));
+        }
     }
 
     // look for the requested pixel format first
@@ -1055,6 +1077,8 @@ static const d3d_format_t *SelectOutputFormat(vout_display_t *vd, const video_fo
     if (res != nullptr)
         return res;
 
+    msg_Dbg(vd, "Direct rendering not usable for %4.4s", (char*)&fmt->i_chroma);
+
     // look for any pixel format that we can handle with enough pixels per channel
     uint8_t bits_per_channel;
     uint8_t widthDenominator, heightDenominator;
@@ -1189,8 +1213,11 @@ static void Direct3D11Close(vout_display_t *vd)
     Direct3D11DestroyResources(vd);
 
 #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
-    if ( sys->swapCb == D3D11_LocalSwapchainSwap )
+    if ( sys->swapCb == D3D11_LocalSwapchainSwap && sys->outside_opaque )
+    {
         D3D11_LocalSwapchainCleanupDevice( sys->outside_opaque );
+        sys->outside_opaque = nullptr;
+    }
 #endif // WINAPI_PARTITION_DESKTOP
 
     if (sys->d3d_dev && sys->d3d_dev == &sys->local_d3d_dev->d3d_dev)
@@ -1199,39 +1226,6 @@ static void Direct3D11Close(vout_display_t *vd)
     msg_Dbg(vd, "Direct3D11 display adapter closed");
 }
 
-static bool CanUseTextureArray(vout_display_t *vd)
-{
-    vout_display_sys_t *sys = static_cast<vout_display_sys_t *>(vd->sys);
-
-    // 15.200.1062.1004 is wrong - 2015/08/03 - 15.7.1 WHQL
-    // 21.19.144.1281 is wrong   -
-    // 22.19.165.3 is good       - 2017/05/04 - ReLive Edition 17.5.1
-    const auto WDDM_os = []{
-        struct wddm_version wddm = {};
-        wddm.wddm         = 21;  // starting with drivers designed for W10 Anniversary Update
-        return wddm;
-    }();
-    if (D3D11CheckDriverVersion(sys->d3d_dev, GPU_MANUFACTURER_AMD, &WDDM_os) != VLC_SUCCESS)
-    {
-        msg_Dbg(vd, "AMD driver too old, fallback to legacy shader mode");
-        return false;
-    }
-
-    // xx.xx.1000.xxx drivers can't happen here for WDDM > 2.0
-    const auto WDDM_build = []{
-        struct wddm_version wddm = {};
-        wddm.revision      = 162;
-        return wddm;
-    }();
-    if (D3D11CheckDriverVersion(sys->d3d_dev, GPU_MANUFACTURER_AMD, &WDDM_build) != VLC_SUCCESS)
-    {
-        msg_Dbg(vd, "Bogus AMD driver detected, fallback to legacy shader mode");
-        return false;
-    }
-
-    return true;
-}
-
 static bool BogusZeroCopy(const vout_display_t *vd)
 {
     vout_display_sys_t *sys = static_cast<vout_display_sys_t *>(vd->sys);
@@ -1265,7 +1259,6 @@ static int Direct3D11CreateFormatResources(vout_display_t *vd, const video_forma
     HRESULT hr;
 
     sys->legacy_shader = sys->d3d_dev->feature_level < D3D_FEATURE_LEVEL_10_0 ||
-            (sys->scaleProc == nullptr && !CanUseTextureArray(vd)) ||
             BogusZeroCopy(vd) || (sys->tonemapProc == NULL && !is_d3d11_opaque(fmt->i_chroma));
 
     d3d_shader_blob pPSBlob[DXGI_MAX_RENDER_TARGET] = { };



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/58674ee975de3ea8aba3d0f028c59a055e4a5fa5...dba07a4112145ed10b27a4a28706317b6d14eec1

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/58674ee975de3ea8aba3d0f028c59a055e4a5fa5...dba07a4112145ed10b27a4a28706317b6d14eec1
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