[vlc-commits] dxgi_fmt: add a helper function to detect the Xbox One

Steve Lhomme git at videolan.org
Fri Jan 20 14:38:21 CET 2017


vlc | branch: master | Steve Lhomme <robUx4 at videolabs.io> | Thu Jan 19 11:10:44 2017 +0100| [8580081fde98e94cf2fc87719def6c192097748b] | committer: Jean-Baptiste Kempf

dxgi_fmt: add a helper function to detect the Xbox One

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8580081fde98e94cf2fc87719def6c192097748b
---

 modules/video_chroma/dxgi_fmt.c | 43 ++++++++++++++++++++++++++++++++++++++++-
 modules/video_chroma/dxgi_fmt.h |  5 +++++
 2 files changed, 47 insertions(+), 1 deletion(-)

diff --git a/modules/video_chroma/dxgi_fmt.c b/modules/video_chroma/dxgi_fmt.c
index d956085..0b84d6f 100644
--- a/modules/video_chroma/dxgi_fmt.c
+++ b/modules/video_chroma/dxgi_fmt.c
@@ -24,9 +24,14 @@
 # include "config.h"
 #endif
 
-#include "dxgi_fmt.h"
 #include <vlc_es.h>
 
+#define COBJMACROS
+#include <initguid.h>
+#include <d3d11.h>
+
+#include "dxgi_fmt.h"
+
 typedef struct
 {
     const char   *name;
@@ -119,3 +124,39 @@ void DxgiFormatMask(DXGI_FORMAT format, video_format_t *fmt)
         fmt->i_bmask = 0xff000000;
     }
 }
+
+IDXGIAdapter *D3D11DeviceAdapter(ID3D11Device *d3ddev)
+{
+    IDXGIDevice *pDXGIDevice = NULL;
+    HRESULT hr = ID3D11Device_QueryInterface(d3ddev, &IID_IDXGIDevice, (void **)&pDXGIDevice);
+    if (FAILED(hr)) {
+        return NULL;
+    }
+
+    IDXGIAdapter *p_adapter;
+    hr = IDXGIDevice_GetAdapter(pDXGIDevice, &p_adapter);
+    IDXGIDevice_Release(pDXGIDevice);
+    if (FAILED(hr)) {
+        return NULL;
+    }
+    return p_adapter;
+}
+
+bool isXboxHardware(ID3D11Device *d3ddev)
+{
+    IDXGIAdapter *p_adapter = D3D11DeviceAdapter(d3ddev);
+    if (!p_adapter)
+        return NULL;
+
+    bool result = false;
+    DXGI_ADAPTER_DESC adapterDesc;
+    if (SUCCEEDED(IDXGIAdapter_GetDesc(p_adapter, &adapterDesc))) {
+        if (adapterDesc.VendorId == 0 &&
+            adapterDesc.DeviceId == 0 &&
+            !wcscmp(L"ROOT\\SraKmd\\0000", adapterDesc.Description))
+            result = true;
+    }
+
+    IDXGIAdapter_Release(p_adapter);
+    return result;
+}
diff --git a/modules/video_chroma/dxgi_fmt.h b/modules/video_chroma/dxgi_fmt.h
index 8f2e3bb..190bd69 100644
--- a/modules/video_chroma/dxgi_fmt.h
+++ b/modules/video_chroma/dxgi_fmt.h
@@ -23,6 +23,7 @@
 #ifndef VLC_VIDEOCHROMA_DXGI_FMT_H_
 #define VLC_VIDEOCHROMA_DXGI_FMT_H_
 
+#include <dxgi.h>
 #include <dxgiformat.h>
 
 #include <vlc_common.h>
@@ -45,4 +46,8 @@ extern vlc_fourcc_t DxgiFormatFourcc(DXGI_FORMAT format);
 extern const d3d_format_t *GetRenderFormatList(void);
 extern void DxgiFormatMask(DXGI_FORMAT format, video_format_t *);
 
+typedef struct ID3D11Device ID3D11Device;
+bool isXboxHardware(ID3D11Device *d3ddev);
+IDXGIAdapter *D3D11DeviceAdapter(ID3D11Device *d3ddev);
+
 #endif /* include-guard */



More information about the vlc-commits mailing list