[vlc-devel] [PATCH 09/29] dxgi_fmt: add a helper function to detect the Xbox One
Steve Lhomme
robux4 at videolabs.io
Thu Jan 19 11:10:44 CET 2017
--
replaces https://patches.videolan.org/patch/15378/
- add a generic D3D11DeviceAdapter() function
---
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..a6a9bc7 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;
+extern bool isXboxHardware(ID3D11Device *d3ddev);
+extern IDXGIAdapter *D3D11DeviceAdapter(ID3D11Device *d3ddev);
+
#endif /* include-guard */
--
2.10.2
More information about the vlc-devel
mailing list