qsv: Remove unnecessary pargma message
[platform/upstream/gstreamer.git] / subprojects / gst-plugins-bad / sys / qsv / libmfx / dispatcher / windows / mfx_dxva2_device.h
1 /*############################################################################
2   # Copyright (C) 2012-2020 Intel Corporation
3   #
4   # SPDX-License-Identifier: MIT
5   ############################################################################*/
6
7 #ifndef DISPATCHER_WINDOWS_MFX_DXVA2_DEVICE_H_
8 #define DISPATCHER_WINDOWS_MFX_DXVA2_DEVICE_H_
9
10 #include <windows.h>
11
12 #include <vector>
13
14 #include "vpl/mfx_dispatcher_vpl.h"
15
16 #define TOSTRING(L)  #L
17 #define STRINGIFY(L) TOSTRING(L)
18
19 #if defined(MEDIASDK_UWP_DISPATCHER)
20     #if defined(MFX_D3D9_ENABLED) && !defined(MFX_FORCE_D3D9_ENABLED)
21         #undef MFX_D3D9_ENABLED
22     #endif
23     #if defined(MFX_FORCE_D3D9_ENABLED)
24         #define MFX_D3D9_ENABLED
25     #endif
26 #else
27     #define MFX_D3D9_ENABLED
28 #endif
29
30 #include "vpl/mfxdefs.h"
31
32 #ifdef DXVA2DEVICE_LOG
33     #include <stdio.h>
34     #define DXVA2DEVICE_TRACE(expr)           printf expr;
35     #define DXVA2DEVICE_TRACE_OPERATION(expr) expr;
36 #else
37     #define DXVA2DEVICE_TRACE(expr)
38     #define DXVA2DEVICE_TRACE_OPERATION(expr)
39 #endif
40
41 namespace MFX {
42
43 // compare LUIDs
44 inline bool operator==(const LUID &lhs, const LUID &rhs) {
45     return (lhs.LowPart == rhs.LowPart && lhs.HighPart == rhs.HighPart);
46 }
47
48 class DXDevice {
49 public:
50     // Default constructor
51     DXDevice(void);
52     // Destructor
53     virtual ~DXDevice(void) = 0;
54
55     // Initialize device using DXGI 1.1 or VAAPI interface
56     virtual bool Init(const mfxU32 adapterNum) = 0;
57
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;
63
64     // Provide the number of available adapters
65     mfxU32 GetAdapterCount(void) const;
66
67     // Close the object
68     virtual void Close(void);
69
70     // Load the required DLL module
71     void LoadDLLModule(const wchar_t *pModuleName);
72
73 protected:
74     // Free DLL module
75     void UnloadDLLModule(void);
76
77     // Handle to the DLL library
78     HMODULE m_hModule;
79
80     // Number of adapters available
81     mfxU32 m_numAdapters;
82
83     // Vendor ID
84     mfxU32 m_vendorID;
85     // Device ID
86     mfxU32 m_deviceID;
87     // x.x.x.x each x of two bytes
88     mfxU64 m_driverVersion;
89     // LUID
90     mfxU64 m_luid;
91
92 private:
93     // unimplemented by intent to make this class and its descendants non-copyable
94     DXDevice(const DXDevice &);
95     void operator=(const DXDevice &);
96 };
97
98 #ifdef MFX_D3D9_ENABLED
99 class D3D9Device : public DXDevice {
100 public:
101     // Default constructor
102     D3D9Device(void);
103     // Destructor
104     virtual ~D3D9Device(void);
105
106     // Initialize device using D3D v9 interface
107     virtual bool Init(const mfxU32 adapterNum);
108
109     // Close the object
110     virtual void Close(void);
111
112 protected:
113     // Pointer to the D3D v9 interface
114     void *m_pD3D9;
115     // Pointer to the D3D v9 extended interface
116     void *m_pD3D9Ex;
117 };
118 #endif // MFX_D3D9_ENABLED
119
120 class DXGI1Device : public DXDevice {
121 public:
122     // Default constructor
123     DXGI1Device(void);
124     // Destructor
125     virtual ~DXGI1Device(void);
126
127     // Initialize device
128     virtual bool Init(const mfxU32 adapterNum);
129
130     // Close the object
131     virtual void Close(void);
132
133     // lightweight method to get list of adapters
134     static bool GetAdapterList(std::vector<DXGI1DeviceInfo> &adapterInfo);
135
136 protected:
137     // Pointer to the DXGI1 factory
138     void *m_pDXGIFactory1;
139     // Pointer to the current DXGI1 adapter
140     void *m_pDXGIAdapter1;
141 };
142
143 class DXVA2Device {
144 public:
145     // Default constructor
146     DXVA2Device(void);
147     // Destructor
148     ~DXVA2Device(void);
149
150     // Initialize device using D3D v9 interface
151     bool InitD3D9(const mfxU32 adapterNum);
152
153     // Initialize device using DXGI 1.1 interface
154     bool InitDXGI1(const mfxU32 adapterNum);
155
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;
161
162     // Provide the number of available adapters
163     mfxU32 GetAdapterCount(void) const;
164
165     void Close(void);
166
167 protected:
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;
174
175     // Vendor ID
176     mfxU32 m_vendorID;
177     // Device ID
178     mfxU32 m_deviceID;
179     //x.x.x.x
180     mfxU64 m_driverVersion;
181     // LUID
182     mfxU64 m_luid;
183
184 private:
185     // unimplemented by intent to make this class non-copyable
186     DXVA2Device(const DXVA2Device &);
187     void operator=(const DXVA2Device &);
188 };
189
190 } // namespace MFX
191
192 #endif // DISPATCHER_WINDOWS_MFX_DXVA2_DEVICE_H_