dxgi.h 2.5 KB

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