dxgi.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * Copyright 2011-2023 Branimir Karadzic. All rights reserved.
  3. * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
  4. */
  5. #ifndef BGFX_DXGI_H_HEADER_GUARD
  6. #define BGFX_DXGI_H_HEADER_GUARD
  7. #include <sal.h>
  8. #include <unknwn.h>
  9. #if BX_PLATFORM_LINUX || BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT
  10. # include <d3dcommon.h>
  11. # include <dxgi1_6.h>
  12. #else
  13. # include <d3d11_x.h>
  14. #endif // BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT
  15. namespace bgfx
  16. {
  17. #if BX_PLATFORM_LINUX || BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT
  18. typedef ::IUnknown IUnknown;
  19. #else
  20. typedef ::IGraphicsUnknown IUnknown;
  21. #endif // BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT
  22. typedef HRESULT (WINAPI* PFN_CREATE_DXGI_FACTORY)(REFIID _riid, void** _factory);
  23. typedef HRESULT (WINAPI* PFN_GET_DEBUG_INTERFACE)(REFIID _riid, void** _debug);
  24. typedef HRESULT (WINAPI* PFN_GET_DEBUG_INTERFACE1)(UINT _flags, REFIID _riid, void** _debug);
  25. struct SwapChainDesc
  26. {
  27. uint32_t width;
  28. uint32_t height;
  29. DXGI_FORMAT format;
  30. bool stereo;
  31. DXGI_SAMPLE_DESC sampleDesc;
  32. DXGI_USAGE bufferUsage;
  33. uint32_t bufferCount;
  34. DXGI_SCALING scaling;
  35. DXGI_SWAP_EFFECT swapEffect;
  36. DXGI_ALPHA_MODE alphaMode;
  37. uint32_t flags;
  38. uint8_t maxFrameLatency;
  39. void* nwh;
  40. void* ndt;
  41. bool windowed;
  42. };
  43. struct DxgiSwapChain
  44. {
  45. ///
  46. DxgiSwapChain();
  47. };
  48. ///
  49. struct Dxgi
  50. {
  51. #if BX_PLATFORM_LINUX || BX_PLATFORM_WINDOWS
  52. typedef ::IDXGIAdapter3 AdapterI;
  53. typedef ::IDXGIFactory5 FactoryI;
  54. typedef ::IDXGISwapChain3 SwapChainI;
  55. typedef ::IDXGIOutput OutputI;
  56. #elif BX_PLATFORM_WINRT
  57. typedef ::IDXGIAdapter AdapterI;
  58. typedef ::IDXGIFactory4 FactoryI;
  59. typedef ::IDXGISwapChain1 SwapChainI;
  60. typedef ::IDXGIOutput OutputI;
  61. #else
  62. typedef ::IDXGIAdapter AdapterI;
  63. typedef ::IDXGIFactory2 FactoryI;
  64. typedef ::IDXGISwapChain1 SwapChainI;
  65. typedef ::IDXGIOutput OutputI;
  66. #endif // BX_PLATFORM_WINDOWS
  67. ///
  68. Dxgi();
  69. ///
  70. bool init(Caps& _caps);
  71. ///
  72. void shutdown();
  73. ///
  74. void update(IUnknown* _device);
  75. ///
  76. HRESULT createSwapChain(IUnknown* _device, const SwapChainDesc& _scd, SwapChainI** _swapChain);
  77. #if BX_PLATFORM_WINRT
  78. ///
  79. HRESULT removeSwapChain(const SwapChainDesc& _scd, SwapChainI** _swapChain);
  80. #endif
  81. ///
  82. void updateHdr10(SwapChainI* _swapChain, const SwapChainDesc& _scd);
  83. ///
  84. HRESULT resizeBuffers(SwapChainI* _swapChain, const SwapChainDesc& _scd, const uint32_t* _nodeMask = NULL, IUnknown* const* _presentQueue = NULL);
  85. ///
  86. void trim();
  87. ///
  88. bool tearingSupported() const;
  89. ///
  90. void* m_dxgiDll;
  91. void* m_dxgiDebugDll;
  92. D3D_DRIVER_TYPE m_driverType;
  93. DXGI_ADAPTER_DESC m_adapterDesc;
  94. FactoryI* m_factory;
  95. AdapterI* m_adapter;
  96. OutputI* m_output;
  97. bool m_tearingSupported;
  98. };
  99. } // namespace bgfx
  100. #endif // BGFX_DXGI_H_HEADER_GUARD