[vlc-commits] d3d11_fmt: keep the WDDM version of the device when it's created
Steve Lhomme
git at videolan.org
Wed Jan 17 11:24:10 CET 2018
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Jan 17 11:22:33 2018 +0100| [b628306fa15ce52c27cffae17097451fd212ee2c] | committer: Steve Lhomme
d3d11_fmt: keep the WDDM version of the device when it's created
And log it.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b628306fa15ce52c27cffae17097451fd212ee2c
---
modules/codec/avcodec/d3d11va.c | 2 +-
modules/video_chroma/d3d11_fmt.c | 139 +++++++++++++++++++-------------
modules/video_chroma/d3d11_fmt.h | 5 +-
modules/video_output/win32/direct3d11.c | 2 +-
4 files changed, 88 insertions(+), 60 deletions(-)
diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c
index dc8e5c2766..83a3e577ba 100644
--- a/modules/codec/avcodec/d3d11va.c
+++ b/modules/codec/avcodec/d3d11va.c
@@ -537,7 +537,7 @@ static bool CanUseIntelHEVC(vlc_va_t *va)
.revision = 15,
.build = 4836,
};
- if (D3D11CheckDriverVersion(sys->d3d_dev.d3ddevice, GPU_MANUFACTURER_INTEL, &WDMM) == VLC_SUCCESS)
+ if (D3D11CheckDriverVersion(&sys->d3d_dev, GPU_MANUFACTURER_INTEL, &WDMM) == VLC_SUCCESS)
return true;
msg_Dbg(va, "HEVC not supported with these drivers");
diff --git a/modules/video_chroma/d3d11_fmt.c b/modules/video_chroma/d3d11_fmt.c
index c39e6c8a61..9ebd7ff5b3 100644
--- a/modules/video_chroma/d3d11_fmt.c
+++ b/modules/video_chroma/d3d11_fmt.c
@@ -134,6 +134,75 @@ int AllocateShaderView(vlc_object_t *obj, ID3D11Device *d3ddevice,
return VLC_SUCCESS;
}
+
+#if !VLC_WINSTORE_APP
+static HKEY GetAdapterRegistry(DXGI_ADAPTER_DESC *adapterDesc)
+{
+ HKEY hKey;
+ TCHAR key[128];
+ TCHAR szData[256], lookup[256];
+ DWORD len = 256;
+
+ _sntprintf(lookup, 256, TEXT("pci\\ven_%04x&dev_%04x"), adapterDesc->VendorId, adapterDesc->DeviceId);
+ for (int i=0;;i++)
+ {
+ _sntprintf(key, 128, TEXT("SYSTEM\\CurrentControlSet\\Control\\Class\\{4d36e968-e325-11ce-bfc1-08002be10318}\\%04d"), i);
+ if( RegOpenKeyEx(HKEY_LOCAL_MACHINE, key, 0, KEY_READ, &hKey) != ERROR_SUCCESS )
+ return NULL;
+
+ len = sizeof(szData);
+ if( RegQueryValueEx( hKey, TEXT("MatchingDeviceId"), NULL, NULL, (LPBYTE) &szData, &len ) == ERROR_SUCCESS ) {
+ if (_tcsncmp(lookup, szData, _tcslen(lookup)) == 0)
+ return hKey;
+ }
+
+ RegCloseKey(hKey);
+ }
+ return NULL;
+}
+#endif
+
+static void GetDriverVersion(vlc_object_t *obj, d3d11_device_t *d3d_dev)
+{
+ memset(&d3d_dev->WDDM, 0, sizeof(d3d_dev->WDDM));
+#if VLC_WINSTORE_APP
+ return;
+#else
+ IDXGIAdapter *pAdapter = D3D11DeviceAdapter(d3d_dev->d3ddevice);
+ if (!pAdapter)
+ return;
+
+ DXGI_ADAPTER_DESC adapterDesc;
+ HRESULT hr = IDXGIAdapter_GetDesc(pAdapter, &adapterDesc);
+ IDXGIAdapter_Release(pAdapter);
+ if (FAILED(hr))
+ return;
+
+ LONG err = ERROR_ACCESS_DENIED;
+ TCHAR szData[256];
+ DWORD len = 256;
+ HKEY hKey = GetAdapterRegistry(&adapterDesc);
+ if (hKey == NULL)
+ return;
+
+ err = RegQueryValueEx( hKey, TEXT("DriverVersion"), NULL, NULL, (LPBYTE) &szData, &len );
+ RegCloseKey(hKey);
+
+ if (err != ERROR_SUCCESS )
+ return;
+
+ int wddm, d3d_features, revision, build;
+ /* see https://msdn.microsoft.com/windows/hardware/commercialize/design/compatibility/device-graphics */
+ if (_stscanf(szData, TEXT("%d.%d.%d.%d"), &wddm, &d3d_features, &revision, &build) != 4)
+ return;
+ d3d_dev->WDDM.wddm = wddm;
+ d3d_dev->WDDM.d3d_features = d3d_features;
+ d3d_dev->WDDM.revision = revision;
+ d3d_dev->WDDM.build = build;
+ msg_Dbg(obj, "%s WDDM driver %d.%d.%d.%d", DxgiVendorStr(adapterDesc.VendorId), wddm, d3d_features, revision, build);
+#endif
+}
+
void D3D11_ReleaseDevice(d3d11_device_t *d3d_dev)
{
if (d3d_dev->d3dcontext)
@@ -162,7 +231,7 @@ HRESULT D3D11_CreateDevice(vlc_object_t *obj, d3d11_handle_t *hd3d,
msg_Err(obj, "Cannot locate reference to D3D11CreateDevice ABI in DLL");
return E_NOINTERFACE;
}
-#endif
+#endif /* VLC_WINSTORE_APP */
HRESULT hr = E_NOTIMPL;
UINT creationFlags = 0;
@@ -173,7 +242,7 @@ HRESULT D3D11_CreateDevice(vlc_object_t *obj, d3d11_handle_t *hd3d,
#if !defined(NDEBUG)
# if !VLC_WINSTORE_APP
if (IsDebuggerPresent())
-# endif
+# endif /* VLC_WINSTORE_APP */
{
HINSTANCE sdklayer_dll = LoadLibrary(TEXT("d3d11_1sdklayers.dll"));
if (sdklayer_dll) {
@@ -222,6 +291,7 @@ HRESULT D3D11_CreateDevice(vlc_object_t *obj, d3d11_handle_t *hd3d,
if (SUCCEEDED(hr))
{
out->owner = true;
+ GetDriverVersion(obj, out);
}
return hr;
@@ -278,36 +348,9 @@ bool isNvidiaHardware(ID3D11Device *d3ddev)
return result;
}
-#if !VLC_WINSTORE_APP
-static HKEY GetAdapterRegistry(DXGI_ADAPTER_DESC *adapterDesc)
+int D3D11CheckDriverVersion(d3d11_device_t *d3d_dev, UINT vendorId, const struct wddm_version *min_ver)
{
- HKEY hKey;
- TCHAR key[128];
- TCHAR szData[256], lookup[256];
- DWORD len = 256;
-
- _sntprintf(lookup, 256, TEXT("pci\\ven_%04x&dev_%04x"), adapterDesc->VendorId, adapterDesc->DeviceId);
- for (int i=0;;i++)
- {
- _sntprintf(key, 128, TEXT("SYSTEM\\CurrentControlSet\\Control\\Class\\{4d36e968-e325-11ce-bfc1-08002be10318}\\%04d"), i);
- if( RegOpenKeyEx(HKEY_LOCAL_MACHINE, key, 0, KEY_READ, &hKey) != ERROR_SUCCESS )
- return NULL;
-
- len = sizeof(szData);
- if( RegQueryValueEx( hKey, TEXT("MatchingDeviceId"), NULL, NULL, (LPBYTE) &szData, &len ) == ERROR_SUCCESS ) {
- if (_tcsncmp(lookup, szData, _tcslen(lookup)) == 0)
- return hKey;
- }
-
- RegCloseKey(hKey);
- }
- return NULL;
-}
-#endif
-
-int D3D11CheckDriverVersion(ID3D11Device *d3ddev, UINT vendorId, const struct wddm_version *min_ver)
-{
- IDXGIAdapter *pAdapter = D3D11DeviceAdapter(d3ddev);
+ IDXGIAdapter *pAdapter = D3D11DeviceAdapter(d3d_dev->d3ddevice);
if (!pAdapter)
return VLC_EGENERIC;
@@ -317,37 +360,19 @@ int D3D11CheckDriverVersion(ID3D11Device *d3ddev, UINT vendorId, const struct wd
if (FAILED(hr))
return VLC_EGENERIC;
- if (vendorId && adapterDesc.VendorId != vendorId)
- return VLC_SUCCESS;
-
- LONG err = ERROR_ACCESS_DENIED;
#if VLC_WINSTORE_APP
return VLC_SUCCESS;
#else
- TCHAR szData[256];
- DWORD len = 256;
- HKEY hKey = GetAdapterRegistry(&adapterDesc);
- if (hKey == NULL)
- return VLC_EGENERIC;
-
- err = RegQueryValueEx( hKey, TEXT("DriverVersion"), NULL, NULL, (LPBYTE) &szData, &len );
- RegCloseKey(hKey);
-
- if (err != ERROR_SUCCESS )
- return VLC_EGENERIC;
-
- int wddm, d3d_features, revision, build;
- /* see https://msdn.microsoft.com/windows/hardware/commercialize/design/compatibility/device-graphics */
- if (_stscanf(szData, TEXT("%d.%d.%d.%d"), &wddm, &d3d_features, &revision, &build) != 4)
- return VLC_EGENERIC;
+ if (vendorId && adapterDesc.VendorId != vendorId)
+ return VLC_SUCCESS;
bool newer =
- wddm > min_ver->wddm ||
- (wddm == min_ver->wddm && (d3d_features > min_ver->d3d_features ||
- (d3d_features == min_ver->d3d_features &&
- (revision > min_ver->revision ||
- (revision == min_ver->revision &&
- build > min_ver->build)))));
+ d3d_dev->WDDM.wddm > min_ver->wddm ||
+ (d3d_dev->WDDM.wddm == min_ver->wddm && (d3d_dev->WDDM.d3d_features > min_ver->d3d_features ||
+ (d3d_dev->WDDM.d3d_features == min_ver->d3d_features &&
+ (d3d_dev->WDDM.revision > min_ver->revision ||
+ (d3d_dev->WDDM.revision == min_ver->revision &&
+ d3d_dev->WDDM.build > min_ver->build)))));
return newer ? VLC_SUCCESS : VLC_EGENERIC;
#endif
diff --git a/modules/video_chroma/d3d11_fmt.h b/modules/video_chroma/d3d11_fmt.h
index d9cbad85f3..94e0a08cf1 100644
--- a/modules/video_chroma/d3d11_fmt.h
+++ b/modules/video_chroma/d3d11_fmt.h
@@ -40,6 +40,9 @@ typedef struct
ID3D11Device *d3ddevice; /* D3D device */
ID3D11DeviceContext *d3dcontext; /* D3D context */
bool owner;
+#if !VLC_WINSTORE_APP
+ struct wddm_version WDDM;
+#endif
} d3d11_device_t;
typedef struct
@@ -106,7 +109,7 @@ void D3D11_Destroy(d3d11_handle_t *);
bool isXboxHardware(ID3D11Device *d3ddev);
bool isNvidiaHardware(ID3D11Device *d3ddev);
IDXGIAdapter *D3D11DeviceAdapter(ID3D11Device *d3ddev);
-int D3D11CheckDriverVersion(ID3D11Device *d3ddev, UINT vendorId,
+int D3D11CheckDriverVersion(d3d11_device_t *, UINT vendorId,
const struct wddm_version *min_ver);
static inline bool DeviceSupportsFormat(ID3D11Device *d3ddevice,
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 0305392e45..168e112a28 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -1979,7 +1979,7 @@ static bool CanUseTextureArray(vout_display_t *vd)
.revision = 162,
.build = 0,
};
- if (D3D11CheckDriverVersion(vd->sys->d3d_dev.d3ddevice, GPU_MANUFACTURER_AMD, &WDDM) == VLC_SUCCESS)
+ if (D3D11CheckDriverVersion(&vd->sys->d3d_dev, GPU_MANUFACTURER_AMD, &WDDM) == VLC_SUCCESS)
return true;
msg_Dbg(vd, "fallback to legacy shader mode for old AMD drivers");
More information about the vlc-commits
mailing list