mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-25 07:09:48 -06:00
D3D: Resize the swapchain when the fullscreen state is changed
This commit is contained in:
@ -52,8 +52,6 @@ unsigned int xres, yres;
|
|||||||
|
|
||||||
bool bFrameInProgress = false;
|
bool bFrameInProgress = false;
|
||||||
|
|
||||||
#define NUM_SWAPCHAIN_BUFFERS 2
|
|
||||||
|
|
||||||
HRESULT LoadDXGI()
|
HRESULT LoadDXGI()
|
||||||
{
|
{
|
||||||
if (dxgi_dll_ref++ > 0)
|
if (dxgi_dll_ref++ > 0)
|
||||||
@ -294,7 +292,7 @@ HRESULT Create(HWND wnd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
DXGI_SWAP_CHAIN_DESC1 swap_chain_desc = {};
|
DXGI_SWAP_CHAIN_DESC1 swap_chain_desc = {};
|
||||||
swap_chain_desc.BufferCount = NUM_SWAPCHAIN_BUFFERS;
|
swap_chain_desc.BufferCount = 2;
|
||||||
swap_chain_desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
swap_chain_desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
||||||
swap_chain_desc.SampleDesc.Count = 1;
|
swap_chain_desc.SampleDesc.Count = 1;
|
||||||
swap_chain_desc.SampleDesc.Quality = 0;
|
swap_chain_desc.SampleDesc.Quality = 0;
|
||||||
@ -548,7 +546,7 @@ void Reset()
|
|||||||
GetClientRect(hWnd, &client);
|
GetClientRect(hWnd, &client);
|
||||||
xres = client.right - client.left;
|
xres = client.right - client.left;
|
||||||
yres = client.bottom - client.top;
|
yres = client.bottom - client.top;
|
||||||
D3D::swapchain->ResizeBuffers(NUM_SWAPCHAIN_BUFFERS, xres, yres, DXGI_FORMAT_R8G8B8A8_UNORM, 0);
|
D3D::swapchain->ResizeBuffers(0, xres, yres, DXGI_FORMAT_R8G8B8A8_UNORM, 0);
|
||||||
|
|
||||||
// recreate back buffer texture
|
// recreate back buffer texture
|
||||||
ID3D11Texture2D* buf;
|
ID3D11Texture2D* buf;
|
||||||
|
@ -66,6 +66,7 @@ struct GXPipelineState
|
|||||||
static u32 s_last_multisamples = 1;
|
static u32 s_last_multisamples = 1;
|
||||||
static bool s_last_stereo_mode = false;
|
static bool s_last_stereo_mode = false;
|
||||||
static bool s_last_xfb_mode = false;
|
static bool s_last_xfb_mode = false;
|
||||||
|
static bool s_last_fullscreen_mode = false;
|
||||||
|
|
||||||
static Television s_television;
|
static Television s_television;
|
||||||
|
|
||||||
@ -240,6 +241,7 @@ Renderer::Renderer() : ::Renderer(D3D::GetBackBufferWidth(), D3D::GetBackBufferH
|
|||||||
s_last_multisamples = g_ActiveConfig.iMultisamples;
|
s_last_multisamples = g_ActiveConfig.iMultisamples;
|
||||||
s_last_stereo_mode = g_ActiveConfig.iStereoMode > 0;
|
s_last_stereo_mode = g_ActiveConfig.iStereoMode > 0;
|
||||||
s_last_xfb_mode = g_ActiveConfig.bUseRealXFB;
|
s_last_xfb_mode = g_ActiveConfig.bUseRealXFB;
|
||||||
|
s_last_fullscreen_mode = D3D::GetFullscreenState();
|
||||||
|
|
||||||
g_framebuffer_manager = std::make_unique<FramebufferManager>(m_target_width, m_target_height);
|
g_framebuffer_manager = std::make_unique<FramebufferManager>(m_target_width, m_target_height);
|
||||||
SetupDeviceObjects();
|
SetupDeviceObjects();
|
||||||
@ -838,7 +840,9 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
|
|||||||
|
|
||||||
SetWindowSize(fbStride, fbHeight);
|
SetWindowSize(fbStride, fbHeight);
|
||||||
|
|
||||||
const bool windowResized = CheckForResize();
|
const bool window_resized = CheckForResize();
|
||||||
|
const bool fullscreen = D3D::GetFullscreenState();
|
||||||
|
const bool fs_changed = s_last_fullscreen_mode != fullscreen;
|
||||||
|
|
||||||
bool xfbchanged = s_last_xfb_mode != g_ActiveConfig.bUseRealXFB;
|
bool xfbchanged = s_last_xfb_mode != g_ActiveConfig.bUseRealXFB;
|
||||||
|
|
||||||
@ -856,15 +860,16 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
|
|||||||
D3D::Present();
|
D3D::Present();
|
||||||
|
|
||||||
// Resize the back buffers NOW to avoid flickering
|
// Resize the back buffers NOW to avoid flickering
|
||||||
if (CalculateTargetSize() || xfbchanged || windowResized ||
|
if (CalculateTargetSize() || xfbchanged || window_resized || fs_changed ||
|
||||||
s_last_multisamples != g_ActiveConfig.iMultisamples ||
|
s_last_multisamples != g_ActiveConfig.iMultisamples ||
|
||||||
s_last_stereo_mode != (g_ActiveConfig.iStereoMode > 0))
|
s_last_stereo_mode != (g_ActiveConfig.iStereoMode > 0))
|
||||||
{
|
{
|
||||||
s_last_xfb_mode = g_ActiveConfig.bUseRealXFB;
|
s_last_xfb_mode = g_ActiveConfig.bUseRealXFB;
|
||||||
s_last_multisamples = g_ActiveConfig.iMultisamples;
|
s_last_multisamples = g_ActiveConfig.iMultisamples;
|
||||||
|
s_last_fullscreen_mode = fullscreen;
|
||||||
PixelShaderCache::InvalidateMSAAShaders();
|
PixelShaderCache::InvalidateMSAAShaders();
|
||||||
|
|
||||||
if (windowResized)
|
if (window_resized || fs_changed)
|
||||||
{
|
{
|
||||||
// TODO: Aren't we still holding a reference to the back buffer right now?
|
// TODO: Aren't we still holding a reference to the back buffer right now?
|
||||||
D3D::Reset();
|
D3D::Reset();
|
||||||
|
Reference in New Issue
Block a user