| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#pragma once |
| 5 |
|
| 6 |
#include <dxgi1_5.h> |
| 7 |
#include <wrl/client.h> |
| 8 |
|
| 9 |
#include "Common/CommonTypes.h" |
| 10 |
#include "Common/WindowSystemInfo.h" |
| 11 |
#include "VideoBackends/D3DCommon/D3DCommon.h" |
| 12 |
#include "VideoCommon/TextureConfig.h" |
| 13 |
|
| 14 |
namespace D3DCommon |
| 15 |
{ |
| 16 |
class SwapChain |
| 17 |
{ |
| 18 |
public: |
| 19 |
SwapChain(const WindowSystemInfo& wsi, IDXGIFactory* dxgi_factory, IUnknown* d3d_device); |
| 20 |
virtual ~SwapChain(); |
| 21 |
|
| 22 |
|
| 23 |
static const u32 SWAP_CHAIN_BUFFER_COUNT = 3; |
| 24 |
|
| 25 |
|
| 26 |
static bool WantsStereo(); |
| 27 |
|
| 28 |
static bool WantsHDR(); |
| 29 |
|
| 30 |
IDXGISwapChain* GetDXGISwapChain() const { return m_swap_chain.Get(); } |
| 31 |
AbstractTextureFormat GetFormat() const |
| 32 |
{ |
| 33 |
return m_hdr ? m_texture_format_hdr : m_texture_format; |
| 34 |
} |
| 35 |
u32 GetWidth() const { return m_width; } |
| 36 |
u32 GetHeight() const { return m_height; } |
| 37 |
|
| 38 |
|
| 39 |
bool GetFullscreen() const; |
| 40 |
void SetFullscreen(bool request); |
| 41 |
|
| 42 |
|
| 43 |
bool CheckForFullscreenChange(); |
| 44 |
|
| 45 |
|
| 46 |
virtual bool Present(); |
| 47 |
|
| 48 |
bool ChangeSurface(void* native_handle); |
| 49 |
bool ResizeSwapChain(); |
| 50 |
void SetStereo(bool stereo); |
| 51 |
void SetHDR(bool hdr); |
| 52 |
|
| 53 |
protected: |
| 54 |
u32 GetSwapChainFlags() const; |
| 55 |
bool CreateSwapChain(bool stereo = false, bool hdr = false); |
| 56 |
void DestroySwapChain(); |
| 57 |
|
| 58 |
virtual bool CreateSwapChainBuffers() = 0; |
| 59 |
virtual void DestroySwapChainBuffers() = 0; |
| 60 |
|
| 61 |
WindowSystemInfo m_wsi; |
| 62 |
Microsoft::WRL::ComPtr<IDXGIFactory> m_dxgi_factory; |
| 63 |
Microsoft::WRL::ComPtr<IDXGISwapChain> m_swap_chain; |
| 64 |
Microsoft::WRL::ComPtr<IUnknown> m_d3d_device; |
| 65 |
const AbstractTextureFormat m_texture_format = AbstractTextureFormat::RGB10_A2; |
| 66 |
const AbstractTextureFormat m_texture_format_hdr = AbstractTextureFormat::RGBA16F; |
| 67 |
|
| 68 |
u32 m_width = 1; |
| 69 |
u32 m_height = 1; |
| 70 |
|
| 71 |
bool m_stereo = false; |
| 72 |
bool m_hdr = false; |
| 73 |
bool m_allow_tearing_supported = false; |
| 74 |
bool m_has_fullscreen = false; |
| 75 |
bool m_fullscreen_request = false; |
| 76 |
}; |
| 77 |
|
| 78 |
} |