d3d9_fmt: keep the adapter info while it's loaded
authorSteve Lhomme <robux4@ycbcr.xyz>
Mon, 2 Mar 2020 14:41:45 +0000 (15:41 +0100)
committerSteve Lhomme <robux4@ycbcr.xyz>
Wed, 4 Mar 2020 15:06:24 +0000 (16:06 +0100)
No need to reload the same thing many times.

modules/codec/avcodec/dxva2.c
modules/video_chroma/d3d9_fmt.c
modules/video_chroma/d3d9_fmt.h

index 59b8d88..75fb22b 100644 (file)
@@ -328,13 +328,11 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat hwfmt, const
     if (err != VLC_SUCCESS)
         goto error;
 
-    D3DADAPTER_IDENTIFIER9 d3dai;
-    if (SUCCEEDED(IDirect3D9_GetAdapterIdentifier(d3d9_decoder->hd3d.obj,
-                                               d3d9_decoder->d3ddev.adapterId, 0, &d3dai))) {
-        msg_Info(va, "Using DXVA2 (%.*s, vendor %s(%lx), device %lx, revision %lx)",
-                    (int)sizeof(d3dai.Description), d3dai.Description,
-                    DxgiVendorStr(d3dai.VendorId), d3dai.VendorId, d3dai.DeviceId, d3dai.Revision);
-    }
+    const D3DADAPTER_IDENTIFIER9 *identifier = &d3d9_decoder->d3ddev.identifier;
+    msg_Info(va, "Using DXVA2 (%.*s, vendor %s(%lx), device %lx, revision %lx)",
+                (int)sizeof(identifier->Description), identifier->Description,
+                DxgiVendorStr(identifier->VendorId), identifier->VendorId,
+                identifier->DeviceId, identifier->Revision);
 
     d3d9_video_context_t *octx = GetD3D9ContextPrivate(sys->vctx);
     octx->format = sys->render;
@@ -436,18 +434,14 @@ static int DxSetupOutput(vlc_va_t *va, const directx_va_mode_t *mode, const vide
 
     d3d9_decoder_device_t *d3d9_decoder = GetD3D9OpaqueContext(sys->vctx);
 
-    D3DADAPTER_IDENTIFIER9 identifier;
-    HRESULT hr = IDirect3D9_GetAdapterIdentifier(d3d9_decoder->hd3d.obj, d3d9_decoder->d3ddev.adapterId, 0, &identifier);
-    if (FAILED(hr))
-        return VLC_EGENERIC;
-
-    UINT driverBuild = identifier.DriverVersion.LowPart & 0xFFFF;
-    if (identifier.VendorId == GPU_MANUFACTURER_INTEL && (identifier.DriverVersion.LowPart >> 16) >= 100)
+    const D3DADAPTER_IDENTIFIER9 *identifier = &d3d9_decoder->d3ddev.identifier;
+    UINT driverBuild = identifier->DriverVersion.LowPart & 0xFFFF;
+    if (identifier->VendorId == GPU_MANUFACTURER_INTEL && (identifier->DriverVersion.LowPart >> 16) >= 100)
     {
         /* new Intel driver format */
-        driverBuild += ((identifier.DriverVersion.LowPart >> 16) - 100) * 1000;
+        driverBuild += ((identifier->DriverVersion.LowPart >> 16) - 100) * 1000;
     }
-    if (!directx_va_canUseDecoder(va, identifier.VendorId, identifier.DeviceId,
+    if (!directx_va_canUseDecoder(va, identifier->VendorId, identifier->DeviceId,
                                   mode->guid, driverBuild))
     {
         msg_Warn(va, "GPU blacklisted for %s codec", mode->name);
index 0b34723..730a5b7 100644 (file)
@@ -214,12 +214,11 @@ d3d9_handle_t *hd3d = &sys->dec_device.hd3d;
     }
 
     /* */
-    D3DADAPTER_IDENTIFIER9 d3dai;
-    if (FAILED(IDirect3D9_GetAdapterIdentifier(hd3d->obj, AdapterToUse,0, &d3dai))) {
+    if (FAILED(IDirect3D9_GetAdapterIdentifier(hd3d->obj, AdapterToUse,0, &out->identifier))) {
         msg_Warn(o, "IDirect3D9_GetAdapterIdentifier failed");
     } else {
-        msg_Dbg(o, "Direct3d9 Device: %s %lx %lx %lx", d3dai.Description,
-                d3dai.VendorId, d3dai.DeviceId, d3dai.Revision );
+        msg_Dbg(o, "Direct3d9 Device: %s %lx %lx %lx", out->identifier.Description,
+                out->identifier.VendorId, out->identifier.DeviceId, out->identifier.Revision );
     }
 
     DWORD thread_modes[] = { D3DCREATE_MULTITHREADED, 0 };
index ddff8e0..3968723 100644 (file)
@@ -67,6 +67,7 @@ typedef struct
     UINT                    adapterId;
 
     D3DCAPS9                caps;
+    D3DADAPTER_IDENTIFIER9  identifier;
 } d3d9_device_t;
 
 typedef struct