dxgi_fmt: use a generic way to get the vendor string
authorSteve Lhomme <robUx4@videolabs.io>
Fri, 1 Dec 2017 08:55:13 +0000 (09:55 +0100)
committerJean-Baptiste Kempf <jb@videolan.org>
Sun, 3 Dec 2017 23:06:22 +0000 (00:06 +0100)
Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
modules/codec/Makefile.am
modules/codec/avcodec/d3d11va.c
modules/codec/avcodec/dxva2.c
modules/video_chroma/dxgi_fmt.c
modules/video_chroma/dxgi_fmt.h

index 267888a..10132a9 100644 (file)
@@ -422,7 +422,7 @@ codec_LTLIBRARIES += libvaapi_plugin.la
 endif
 
 libd3d9_common_la_SOURCES = video_chroma/d3d9_fmt.c video_chroma/d3d9_fmt.h \
-       video_chroma/dxgi_fmt.h
+       video_chroma/dxgi_fmt.c video_chroma/dxgi_fmt.h
 libd3d9_common_la_LDFLAGS = -static
 if HAVE_WIN32_DESKTOP
 noinst_LTLIBRARIES += libd3d9_common.la
index 99305e0..333cd64 100644 (file)
@@ -447,18 +447,6 @@ static void D3dDestroyDevice(vlc_va_t *va)
  */
 static char *DxDescribe(vlc_va_sys_t *sys)
 {
-    static const struct {
-        unsigned id;
-        char     name[32];
-    } vendors [] = {
-        { GPU_MANUFACTURER_AMD,      "ATI"         },
-        { GPU_MANUFACTURER_NVIDIA,   "NVIDIA"      },
-        { GPU_MANUFACTURER_VIA,      "VIA"         },
-        { GPU_MANUFACTURER_INTEL,    "Intel"       },
-        { GPU_MANUFACTURER_S3,       "S3 Graphics" },
-        { GPU_MANUFACTURER_QUALCOMM, "Qualcomm"    },
-        { 0, "" }
-    };
 
     IDXGIAdapter *p_adapter = D3D11DeviceAdapter(sys->d3d_dev.d3ddevice);
     if (!p_adapter) {
@@ -468,20 +456,12 @@ static char *DxDescribe(vlc_va_sys_t *sys)
     char *description = NULL;
     DXGI_ADAPTER_DESC adapterDesc;
     if (SUCCEEDED(IDXGIAdapter_GetDesc(p_adapter, &adapterDesc))) {
-        const char *vendor = "Unknown";
-        for (int i = 0; vendors[i].id != 0; i++) {
-            if (vendors[i].id == adapterDesc.VendorId) {
-                vendor = vendors[i].name;
-                break;
-            }
-        }
-
         char *utfdesc = FromWide(adapterDesc.Description);
         if (likely(utfdesc!=NULL))
         {
             if (asprintf(&description, "D3D11VA (%s, vendor %u(%s), device %u, revision %u)",
                          utfdesc,
-                         adapterDesc.VendorId, vendor, adapterDesc.DeviceId, adapterDesc.Revision) < 0)
+                         adapterDesc.VendorId, DxgiVendorStr(adapterDesc.VendorId), adapterDesc.DeviceId, adapterDesc.Revision) < 0)
                 description = NULL;
             free(utfdesc);
         }
index ef6b8a2..b39c47e 100644 (file)
@@ -368,36 +368,16 @@ static void D3dDestroyDevice(vlc_va_t *va)
  */
 static char *DxDescribe(vlc_va_sys_t *sys)
 {
-    static const struct {
-        unsigned id;
-        char     name[32];
-    } vendors [] = {
-        { 0x1002, "ATI" },
-        { 0x10DE, "NVIDIA" },
-        { 0x1106, "VIA" },
-        { 0x8086, "Intel" },
-        { 0x5333, "S3 Graphics" },
-        { 0, "" }
-    };
-
     D3DADAPTER_IDENTIFIER9 d3dai;
     if (FAILED(IDirect3D9_GetAdapterIdentifier(sys->hd3d.obj,
                                                sys->d3d_dev.adapterId, 0, &d3dai))) {
         return NULL;
     }
 
-    const char *vendor = "Unknown";
-    for (int i = 0; vendors[i].id != 0; i++) {
-        if (vendors[i].id == d3dai.VendorId) {
-            vendor = vendors[i].name;
-            break;
-        }
-    }
-
     char *description;
-    if (asprintf(&description, "DXVA2 (%.*s, vendor %lu(%s), device %lu, revision %lu)",
+    if (asprintf(&description, "DXVA2 (%.*s, vendor %s(%lu), device %lu, revision %lu)",
                  (int)sizeof(d3dai.Description), d3dai.Description,
-                 d3dai.VendorId, vendor, d3dai.DeviceId, d3dai.Revision) < 0)
+                 DxgiVendorStr(d3dai.VendorId), d3dai.VendorId, d3dai.DeviceId, d3dai.Revision) < 0)
         return NULL;
     return description;
 }
index 9209b1d..1a0ba9e 100644 (file)
@@ -124,3 +124,26 @@ void DxgiFormatMask(DXGI_FORMAT format, video_format_t *fmt)
         fmt->i_bmask = 0xff000000;
     }
 }
+
+const char *DxgiVendorStr(int gpu_vendor)
+{
+    static const struct {
+        unsigned   id;
+        const char name[32];
+    } vendors [] = {
+        { GPU_MANUFACTURER_AMD,      "ATI"         },
+        { GPU_MANUFACTURER_NVIDIA,   "NVIDIA"      },
+        { GPU_MANUFACTURER_VIA,      "VIA"         },
+        { GPU_MANUFACTURER_INTEL,    "Intel"       },
+        { GPU_MANUFACTURER_S3,       "S3 Graphics" },
+        { GPU_MANUFACTURER_QUALCOMM, "Qualcomm"    },
+        { 0,                         "Unknown" }
+    };
+
+    int i = 0;
+    for (i = 0; vendors[i].id != 0; i++) {
+        if (vendors[i].id == gpu_vendor)
+            break;
+    }
+    return vendors[i].name;
+}
index 71dd65c..7128265 100644 (file)
@@ -53,5 +53,6 @@ const char *DxgiFormatToStr(DXGI_FORMAT format);
 vlc_fourcc_t DxgiFormatFourcc(DXGI_FORMAT format);
 const d3d_format_t *GetRenderFormatList(void);
 void DxgiFormatMask(DXGI_FORMAT format, video_format_t *);
+const char *DxgiVendorStr(int gpu_vendor);
 
 #endif /* include-guard */