1 /*############################################################################
2 # Copyright (C) 2012-2020 Intel Corporation
4 # SPDX-License-Identifier: MIT
5 ############################################################################*/
7 #ifndef DISPATCHER_WINDOWS_MFX_DXVA2_DEVICE_H_
8 #define DISPATCHER_WINDOWS_MFX_DXVA2_DEVICE_H_
14 #include "vpl/mfx_dispatcher_vpl.h"
16 #define TOSTRING(L) #L
17 #define STRINGIFY(L) TOSTRING(L)
19 #if defined(MEDIASDK_UWP_DISPATCHER)
20 #if defined(MFX_D3D9_ENABLED) && !defined(MFX_FORCE_D3D9_ENABLED)
21 #undef MFX_D3D9_ENABLED
23 #if defined(MFX_FORCE_D3D9_ENABLED)
24 #define MFX_D3D9_ENABLED
27 #define MFX_D3D9_ENABLED
30 #include "vpl/mfxdefs.h"
32 #ifdef DXVA2DEVICE_LOG
34 #define DXVA2DEVICE_TRACE(expr) printf expr;
35 #define DXVA2DEVICE_TRACE_OPERATION(expr) expr;
37 #define DXVA2DEVICE_TRACE(expr)
38 #define DXVA2DEVICE_TRACE_OPERATION(expr)
44 inline bool operator==(const LUID &lhs, const LUID &rhs) {
45 return (lhs.LowPart == rhs.LowPart && lhs.HighPart == rhs.HighPart);
50 // Default constructor
53 virtual ~DXDevice(void) = 0;
55 // Initialize device using DXGI 1.1 or VAAPI interface
56 virtual bool Init(const mfxU32 adapterNum) = 0;
58 // Obtain graphic card's parameter
59 mfxU32 GetVendorID(void) const;
60 mfxU32 GetDeviceID(void) const;
61 mfxU64 GetDriverVersion(void) const;
62 mfxU64 GetLUID(void) const;
64 // Provide the number of available adapters
65 mfxU32 GetAdapterCount(void) const;
68 virtual void Close(void);
70 // Load the required DLL module
71 void LoadDLLModule(const wchar_t *pModuleName);
75 void UnloadDLLModule(void);
77 // Handle to the DLL library
80 // Number of adapters available
87 // x.x.x.x each x of two bytes
88 mfxU64 m_driverVersion;
93 // unimplemented by intent to make this class and its descendants non-copyable
94 DXDevice(const DXDevice &);
95 void operator=(const DXDevice &);
98 #ifdef MFX_D3D9_ENABLED
99 class D3D9Device : public DXDevice {
101 // Default constructor
104 virtual ~D3D9Device(void);
106 // Initialize device using D3D v9 interface
107 virtual bool Init(const mfxU32 adapterNum);
110 virtual void Close(void);
113 // Pointer to the D3D v9 interface
115 // Pointer to the D3D v9 extended interface
118 #endif // MFX_D3D9_ENABLED
120 class DXGI1Device : public DXDevice {
122 // Default constructor
125 virtual ~DXGI1Device(void);
128 virtual bool Init(const mfxU32 adapterNum);
131 virtual void Close(void);
133 // lightweight method to get list of adapters
134 static bool GetAdapterList(std::vector<DXGI1DeviceInfo> &adapterInfo);
137 // Pointer to the DXGI1 factory
138 void *m_pDXGIFactory1;
139 // Pointer to the current DXGI1 adapter
140 void *m_pDXGIAdapter1;
145 // Default constructor
150 // Initialize device using D3D v9 interface
151 bool InitD3D9(const mfxU32 adapterNum);
153 // Initialize device using DXGI 1.1 interface
154 bool InitDXGI1(const mfxU32 adapterNum);
156 // Obtain graphic card's parameter
157 mfxU32 GetVendorID(void) const;
158 mfxU32 GetDeviceID(void) const;
159 mfxU64 GetDriverVersion(void) const;
160 mfxU64 GetLUID(void) const;
162 // Provide the number of available adapters
163 mfxU32 GetAdapterCount(void) const;
168 #ifdef MFX_D3D9_ENABLED
169 // Get vendor & device IDs by alternative way (D3D9 in Remote Desktop sessions)
170 void UseAlternativeWay(const D3D9Device *pD3D9Device);
171 #endif // MFX_D3D9_ENABLED
172 // Number of adapters available
173 mfxU32 m_numAdapters;
180 mfxU64 m_driverVersion;
185 // unimplemented by intent to make this class non-copyable
186 DXVA2Device(const DXVA2Device &);
187 void operator=(const DXVA2Device &);
192 #endif // DISPATCHER_WINDOWS_MFX_DXVA2_DEVICE_H_