mfx_dxva2_device.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. /* ****************************************************************************** *\
  2. Copyright (C) 2012-2017 Intel Corporation. All rights reserved.
  3. Redistribution and use in source and binary forms, with or without
  4. modification, are permitted provided that the following conditions are met:
  5. - Redistributions of source code must retain the above copyright notice,
  6. this list of conditions and the following disclaimer.
  7. - Redistributions in binary form must reproduce the above copyright notice,
  8. this list of conditions and the following disclaimer in the documentation
  9. and/or other materials provided with the distribution.
  10. - Neither the name of Intel Corporation nor the names of its contributors
  11. may be used to endorse or promote products derived from this software
  12. without specific prior written permission.
  13. THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR
  14. IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  15. OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  16. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,
  17. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  18. NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  19. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  20. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  21. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  22. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23. File Name: mfx_dxva2_device.h
  24. \* ****************************************************************************** */
  25. #if !defined(__MFX_DXVA2_DEVICE_H)
  26. #define __MFX_DXVA2_DEVICE_H
  27. #if defined(_WIN32) || defined(_WIN64)
  28. #include <windows.h>
  29. #define TOSTRING(L) #L
  30. #define STRINGIFY(L) TOSTRING(L)
  31. #if defined(MEDIASDK_UWP_LOADER) || defined(MEDIASDK_UWP_PROCTABLE)
  32. #if defined(MFX_D3D9_ENABLED) && !defined(MFX_FORCE_D3D9_ENABLED)
  33. #undef MFX_D3D9_ENABLED
  34. // if you really like to use D3D9 from intel_gfx_api-x64/x86.dll, use MFX_FORCE_D3D9_ENABLED
  35. #pragma message("\n\nATTENTION:\nin file\n\t" __FILE__ " (" STRINGIFY(__LINE__) "):\nUsing of D3D9 disabled for UWP!\n\n")
  36. #endif
  37. #if defined(MFX_FORCE_D3D9_ENABLED)
  38. #define MFX_D3D9_ENABLED
  39. #endif
  40. #else
  41. #define MFX_D3D9_ENABLED
  42. #pragma message("\n\nATTENTION:\nin file\n\t" __FILE__ " (" STRINGIFY(__LINE__) "):\nUsing of D3D9 enabled!\n\n")
  43. #endif
  44. #endif // #if defined(_WIN32) || defined(_WIN64)
  45. #include <mfxdefs.h>
  46. #ifdef DXVA2DEVICE_LOG
  47. #include <stdio.h>
  48. #define DXVA2DEVICE_TRACE(expr) printf expr;
  49. #define DXVA2DEVICE_TRACE_OPERATION(expr) expr;
  50. #else
  51. #define DXVA2DEVICE_TRACE(expr)
  52. #define DXVA2DEVICE_TRACE_OPERATION(expr)
  53. #endif
  54. namespace MFX
  55. {
  56. class DXDevice
  57. {
  58. public:
  59. // Default constructor
  60. DXDevice(void);
  61. // Destructor
  62. virtual
  63. ~DXDevice(void) = 0;
  64. // Initialize device using DXGI 1.1 or VAAPI interface
  65. virtual
  66. bool Init(const mfxU32 adapterNum) = 0;
  67. // Obtain graphic card's parameter
  68. mfxU32 GetVendorID(void) const;
  69. mfxU32 GetDeviceID(void) const;
  70. mfxU64 GetDriverVersion(void) const;
  71. mfxU64 GetLUID(void) const;
  72. // Provide the number of available adapters
  73. mfxU32 GetAdapterCount(void) const;
  74. // Close the object
  75. virtual
  76. void Close(void);
  77. // Load the required DLL module
  78. void LoadDLLModule(const wchar_t *pModuleName);
  79. protected:
  80. // Free DLL module
  81. void UnloadDLLModule(void);
  82. #if defined(_WIN32) || defined(_WIN64)
  83. // Handle to the DLL library
  84. HMODULE m_hModule;
  85. #endif // #if defined(_WIN32) || defined(_WIN64)
  86. // Number of adapters available
  87. mfxU32 m_numAdapters;
  88. // Vendor ID
  89. mfxU32 m_vendorID;
  90. // Device ID
  91. mfxU32 m_deviceID;
  92. // x.x.x.x each x of two bytes
  93. mfxU64 m_driverVersion;
  94. // LUID
  95. mfxU64 m_luid;
  96. private:
  97. // unimplemented by intent to make this class and its descendants non-copyable
  98. DXDevice(const DXDevice &);
  99. void operator=(const DXDevice &);
  100. };
  101. #if defined(_WIN32) || defined(_WIN64)
  102. #ifdef MFX_D3D9_ENABLED
  103. class D3D9Device : public DXDevice
  104. {
  105. public:
  106. // Default constructor
  107. D3D9Device(void);
  108. // Destructor
  109. virtual
  110. ~D3D9Device(void);
  111. // Initialize device using D3D v9 interface
  112. virtual
  113. bool Init(const mfxU32 adapterNum);
  114. // Close the object
  115. virtual
  116. void Close(void);
  117. protected:
  118. // Pointer to the D3D v9 interface
  119. void *m_pD3D9;
  120. // Pointer to the D3D v9 extended interface
  121. void *m_pD3D9Ex;
  122. };
  123. #endif // MFX_D3D9_ENABLED
  124. class DXGI1Device : public DXDevice
  125. {
  126. public:
  127. // Default constructor
  128. DXGI1Device(void);
  129. // Destructor
  130. virtual
  131. ~DXGI1Device(void);
  132. // Initialize device
  133. virtual
  134. bool Init(const mfxU32 adapterNum);
  135. // Close the object
  136. virtual
  137. void Close(void);
  138. protected:
  139. // Pointer to the DXGI1 factory
  140. void *m_pDXGIFactory1;
  141. // Pointer to the current DXGI1 adapter
  142. void *m_pDXGIAdapter1;
  143. };
  144. #endif // #if defined(_WIN32) || defined(_WIN64)
  145. class DXVA2Device
  146. {
  147. public:
  148. // Default constructor
  149. DXVA2Device(void);
  150. // Destructor
  151. ~DXVA2Device(void);
  152. // Initialize device using D3D v9 interface
  153. bool InitD3D9(const mfxU32 adapterNum);
  154. // Initialize device using DXGI 1.1 interface
  155. 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. // Provide the number of available adapters
  161. mfxU32 GetAdapterCount(void) const;
  162. void Close(void);
  163. protected:
  164. #ifdef MFX_D3D9_ENABLED
  165. // Get vendor & device IDs by alternative way (D3D9 in Remote Desktop sessions)
  166. void UseAlternativeWay(const D3D9Device *pD3D9Device);
  167. #endif // MFX_D3D9_ENABLED
  168. // Number of adapters available
  169. mfxU32 m_numAdapters;
  170. // Vendor ID
  171. mfxU32 m_vendorID;
  172. // Device ID
  173. mfxU32 m_deviceID;
  174. //x.x.x.x
  175. mfxU64 m_driverVersion;
  176. private:
  177. // unimplemented by intent to make this class non-copyable
  178. DXVA2Device(const DXVA2Device &);
  179. void operator=(const DXVA2Device &);
  180. };
  181. } // namespace MFX
  182. #endif // __MFX_DXVA2_DEVICE_H