mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-14 22:50:45 +00:00
Support window resize and fullscreen changes on Windows and Linux without validation errors
This commit is contained in:
parent
f6e5571d39
commit
f5745b4ab6
5 changed files with 29 additions and 22 deletions
|
@ -539,6 +539,8 @@ void DeviceManager_DX12::ResizeSwapChain()
|
|||
|
||||
void DeviceManager_DX12::BeginFrame()
|
||||
{
|
||||
/* SRS - This code not needed: framebuffer/swapchain resizing & fullscreen are handled by idRenderBackend::ResizeImages() and DeviceManager::UpdateWindowSize()
|
||||
|
||||
DXGI_SWAP_CHAIN_DESC1 newSwapChainDesc;
|
||||
DXGI_SWAP_CHAIN_FULLSCREEN_DESC newFullScreenDesc;
|
||||
if( SUCCEEDED( m_SwapChain->GetDesc1( &newSwapChainDesc ) ) && SUCCEEDED( m_SwapChain->GetFullscreenDesc( &newFullScreenDesc ) ) )
|
||||
|
@ -561,7 +563,7 @@ void DeviceManager_DX12::BeginFrame()
|
|||
BackBufferResized();
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
auto bufferIndex = m_SwapChain->GetCurrentBackBufferIndex();
|
||||
|
||||
WaitForSingleObject( m_FrameFenceEvents[bufferIndex], INFINITE );
|
||||
|
|
|
@ -1165,7 +1165,7 @@ void DeviceManager_VK::BeginFrame()
|
|||
vk::Fence(),
|
||||
&m_SwapChainIndex );
|
||||
|
||||
assert( res == vk::Result::eSuccess );
|
||||
assert( res == vk::Result::eSuccess || res == vk::Result::eSuboptimalKHR );
|
||||
|
||||
m_NvrhiDevice->queueWaitForSemaphore( nvrhi::CommandQueue::Graphics, m_PresentSemaphore, 0 );
|
||||
}
|
||||
|
@ -1189,7 +1189,7 @@ void DeviceManager_VK::Present()
|
|||
.setPImageIndices( &m_SwapChainIndex );
|
||||
|
||||
const vk::Result res = m_PresentQueue.presentKHR( &info );
|
||||
assert( res == vk::Result::eSuccess || res == vk::Result::eErrorOutOfDateKHR );
|
||||
assert( res == vk::Result::eSuccess || res == vk::Result::eErrorOutOfDateKHR || res == vk::Result::eSuboptimalKHR );
|
||||
|
||||
if( deviceParms.enableDebugRuntime )
|
||||
{
|
||||
|
|
|
@ -163,6 +163,10 @@ void DeviceManager::UpdateWindowSize( const glimpParms_t& parms )
|
|||
ResizeSwapChain();
|
||||
BackBufferResized();
|
||||
}
|
||||
else
|
||||
{
|
||||
deviceParms.vsyncEnabled = requestedVSync;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1138,19 +1138,17 @@ bool DeviceManager::CreateWindowDeviceAndSwapChain( const glimpParms_t& parms, c
|
|||
|
||||
glConfig.isFullscreen = parms.fullScreen;
|
||||
|
||||
UpdateWindowSize( parms );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void DeviceManager::UpdateWindowSize( const glimpParms_t& params )
|
||||
void DeviceManager::UpdateWindowSize( const glimpParms_t& parms )
|
||||
{
|
||||
windowVisible = true;
|
||||
|
||||
if( int( deviceParms.backBufferWidth ) != params.width ||
|
||||
int( deviceParms.backBufferHeight ) != params.height ||
|
||||
if( int( deviceParms.backBufferWidth ) != parms.width ||
|
||||
int( deviceParms.backBufferHeight ) != parms.height ||
|
||||
#if ID_MSAA
|
||||
int( deviceParms.backBufferSampleCount ) != params.multiSamples ||
|
||||
int( deviceParms.backBufferSampleCount ) != parms.multiSamples ||
|
||||
#endif
|
||||
( deviceParms.vsyncEnabled != requestedVSync && GetGraphicsAPI() == nvrhi::GraphicsAPI::VULKAN ) )
|
||||
{
|
||||
|
@ -1158,16 +1156,18 @@ void DeviceManager::UpdateWindowSize( const glimpParms_t& params )
|
|||
|
||||
BackBufferResizing();
|
||||
|
||||
deviceParms.backBufferWidth = params.width;
|
||||
deviceParms.backBufferHeight = params.height;
|
||||
deviceParms.backBufferSampleCount = params.multiSamples;
|
||||
deviceParms.backBufferWidth = parms.width;
|
||||
deviceParms.backBufferHeight = parms.height;
|
||||
deviceParms.backBufferSampleCount = parms.multiSamples;
|
||||
deviceParms.vsyncEnabled = requestedVSync;
|
||||
|
||||
ResizeSwapChain();
|
||||
BackBufferResized();
|
||||
}
|
||||
|
||||
deviceParms.vsyncEnabled = requestedVSync;
|
||||
else
|
||||
{
|
||||
deviceParms.vsyncEnabled = requestedVSync;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1538,11 +1538,11 @@ bool GLimp_SetScreenParms( glimpParms_t parms )
|
|||
glConfig.isFullscreen = parms.fullScreen;
|
||||
glConfig.pixelAspect = 1.0f; // FIXME: some monitor modes may be distorted
|
||||
|
||||
glConfig.isFullscreen = parms.fullScreen;
|
||||
glConfig.isStereoPixelFormat = parms.stereo;
|
||||
glConfig.nativeScreenWidth = parms.width;
|
||||
glConfig.nativeScreenHeight = parms.height;
|
||||
|
||||
deviceManager->UpdateWindowSize( parms );
|
||||
glConfig.displayFrequency = parms.displayHz;
|
||||
glConfig.multisamples = parms.multiSamples;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -180,14 +180,13 @@ LONG WINAPI MainWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
|||
{
|
||||
case WM_WINDOWPOSCHANGED:
|
||||
// RB: FIXME this messes with with the window size in a really bad way
|
||||
#if 0
|
||||
if( renderSystem->IsInitialized() )//&& win32.hDC != NULL )
|
||||
// SRS - Needed by ResizeImages() to resize before the start of a frame
|
||||
// SRS - Aspect ratio constraints are controlled by WIN_Sizing() above
|
||||
if( renderSystem->IsInitialized() && win32.hDC != NULL )
|
||||
{
|
||||
RECT rect;
|
||||
if( ::GetClientRect( win32.hWnd, &rect ) )
|
||||
{
|
||||
auto originalWidth = glConfig.nativeScreenWidth;
|
||||
auto originalHeight = glConfig.nativeScreenHeight;
|
||||
if( rect.right > rect.left && rect.bottom > rect.top )
|
||||
{
|
||||
glConfig.nativeScreenWidth = rect.right - rect.left;
|
||||
|
@ -200,10 +199,12 @@ LONG WINAPI MainWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
|||
r_windowWidth.SetInteger( glConfig.nativeScreenWidth );
|
||||
r_windowHeight.SetInteger( glConfig.nativeScreenHeight );
|
||||
}
|
||||
|
||||
// SRS - Inform ImGui that the window size has changed
|
||||
ImGuiHook::NotifyDisplaySizeChanged( glConfig.nativeScreenWidth, glConfig.nativeScreenHeight );
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case WM_MOVE:
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue