[vlc-commits] d3d9_fmt: add a function to check the driver vendor/version is OK

Steve Lhomme git at videolan.org
Mon Dec 4 01:17:08 CET 2017


vlc/vlc-3.0 | branch: master | Steve Lhomme <robUx4 at videolabs.io> | Fri Dec  1 09:55:14 2017 +0100| [5c7b3032701e43545481f524bc69598bfe22a153] | committer: Jean-Baptiste Kempf

d3d9_fmt: add a function to check the driver vendor/version is OK

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
(cherry picked from commit 99b260eb557b85cc45b7f922cf97fc4665f37d17)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=5c7b3032701e43545481f524bc69598bfe22a153
---

 modules/video_chroma/d3d9_fmt.c | 28 ++++++++++++++++++++++++++++
 modules/video_chroma/d3d9_fmt.h |  8 ++++++++
 2 files changed, 36 insertions(+)

diff --git a/modules/video_chroma/d3d9_fmt.c b/modules/video_chroma/d3d9_fmt.c
index 6d82b9ba17..8ade6e6564 100644
--- a/modules/video_chroma/d3d9_fmt.c
+++ b/modules/video_chroma/d3d9_fmt.c
@@ -248,3 +248,31 @@ error:
     D3D9_Destroy( hd3d );
     return VLC_EGENERIC;
 }
+
+int D3D9CheckDriverVersion(d3d9_handle_t *hd3d, d3d9_device_t *d3d_dev,
+                           UINT vendorId, const struct wddm_version *min_ver)
+{
+    D3DADAPTER_IDENTIFIER9 identifier;
+    HRESULT hr = IDirect3D9_GetAdapterIdentifier(hd3d->obj, d3d_dev->adapterId, 0, &identifier);
+    if (FAILED(hr))
+        return VLC_EGENERIC;
+
+    if (vendorId && identifier.VendorId != vendorId)
+        return VLC_SUCCESS;
+
+    int wddm, d3d_features, revision, build;
+    wddm         = (int) (identifier.DriverVersion.HighPart >> 16 & 0xFFFF);
+    d3d_features = (int) (identifier.DriverVersion.HighPart >>  0 & 0xFFFF);
+    revision     = (int) (identifier.DriverVersion.LowPart  >> 16 & 0xFFFF);
+    build        = (int) (identifier.DriverVersion.LowPart  >>  0 & 0xFFFF);
+
+    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)))));
+
+    return newer ? VLC_SUCCESS : VLC_EGENERIC;
+}
diff --git a/modules/video_chroma/d3d9_fmt.h b/modules/video_chroma/d3d9_fmt.h
index 63959bbcb2..dcb37676e0 100644
--- a/modules/video_chroma/d3d9_fmt.h
+++ b/modules/video_chroma/d3d9_fmt.h
@@ -88,4 +88,12 @@ void D3D9_Destroy(d3d9_handle_t *);
 
 int D3D9_FillPresentationParameters(d3d9_handle_t *, const video_format_t *, d3d9_device_t *);
 
+struct wddm_version
+{
+    int wddm, d3d_features, revision, build;
+};
+int D3D9CheckDriverVersion(d3d9_handle_t *hd3d, d3d9_device_t *d3d_dev, UINT vendorId,
+                           const struct wddm_version *min_ver);
+
+
 #endif /* VLC_VIDEOCHROMA_D3D9_FMT_H_ */



More information about the vlc-commits mailing list