This commit is contained in:
Robert Beckebans 2022-11-18 16:47:29 +01:00
parent fca592ca73
commit 8a821c3a7a
6 changed files with 70 additions and 70 deletions

View file

@ -220,7 +220,7 @@ extern bool R_UseTemporalAA();
#define FPS_FRAMES_HISTORY 90
float idConsoleLocal::DrawFPS( float y )
{
extern idCVar r_swapInterval;
extern idCVar r_swapInterval;
static float previousTimes[FPS_FRAMES];
static float previousTimesNormalized[FPS_FRAMES_HISTORY];
@ -299,9 +299,9 @@ float idConsoleLocal::DrawFPS( float y )
const uint64 rendererGPU_TAATime = commonLocal.GetRendererGpuTAAMicroseconds();
const uint64 rendererGPUPostProcessingTime = commonLocal.GetRendererGpuPostProcessingMicroseconds();
// SRS - Calculate max fps and max frame time based on glConfig.displayFrequency if vsync enabled and lower than engine Hz, otherwise use com_engineHz_latched
const int max_FPS = ( r_swapInterval.GetInteger() > 0 && glConfig.displayFrequency > 0 ? std::min( glConfig.displayFrequency, int( com_engineHz_latched ) ) : com_engineHz_latched );
const int maxTime = 1000.0 / max_FPS * 1000;
// SRS - Calculate max fps and max frame time based on glConfig.displayFrequency if vsync enabled and lower than engine Hz, otherwise use com_engineHz_latched
const int max_FPS = ( r_swapInterval.GetInteger() > 0 && glConfig.displayFrequency > 0 ? std::min( glConfig.displayFrequency, int( com_engineHz_latched ) ) : com_engineHz_latched );
const int maxTime = 1000.0 / max_FPS * 1000;
// SRS - Frame idle and busy time calculations are based on direct frame-over-frame measurement relative to finishSyncTime
const uint64 frameIdleTime = commonLocal.mainFrameTiming.startGameTime - commonLocal.mainFrameTiming.finishSyncTime;

View file

@ -82,8 +82,8 @@ private:
uint64 frameCounter;
uint32 frameParity;
idStaticList<nvrhi::TimerQueryHandle, MRB_TOTAL * NUM_FRAME_DATA> timerQueries;
idStaticList<bool, MRB_TOTAL * NUM_FRAME_DATA> timerUsed;
idStaticList<nvrhi::TimerQueryHandle, MRB_TOTAL* NUM_FRAME_DATA> timerQueries;
idStaticList<bool, MRB_TOTAL* NUM_FRAME_DATA> timerUsed;
#endif
public:

View file

@ -239,25 +239,25 @@ bool DeviceManager_DX12::CreateDeviceAndSwapChain()
isNvidia = IsNvDeviceID( aDesc.VendorId );
}
/*
// SRS - Don't center window here for DX12 only, instead use portable initialization in CreateWindowDeviceAndSwapChain() within win_glimp.cpp
// - Also, calling SetWindowPos() triggers a window mgr event that overwrites r_windowX / r_windowY, which may be undesirable to the user
/*
// SRS - Don't center window here for DX12 only, instead use portable initialization in CreateWindowDeviceAndSwapChain() within win_glimp.cpp
// - Also, calling SetWindowPos() triggers a window mgr event that overwrites r_windowX / r_windowY, which may be undesirable to the user
UINT windowStyle = deviceParms.startFullscreen
? ( WS_POPUP | WS_SYSMENU | WS_VISIBLE )
: deviceParms.startMaximized
? ( WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_MAXIMIZE )
: ( WS_OVERLAPPEDWINDOW | WS_VISIBLE );
UINT windowStyle = deviceParms.startFullscreen
? ( WS_POPUP | WS_SYSMENU | WS_VISIBLE )
: deviceParms.startMaximized
? ( WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_MAXIMIZE )
: ( WS_OVERLAPPEDWINDOW | WS_VISIBLE );
RECT rect = { 0, 0, LONG( deviceParms.backBufferWidth ), LONG( deviceParms.backBufferHeight ) };
AdjustWindowRect( &rect, windowStyle, FALSE );
RECT rect = { 0, 0, LONG( deviceParms.backBufferWidth ), LONG( deviceParms.backBufferHeight ) };
AdjustWindowRect( &rect, windowStyle, FALSE );
if( MoveWindowOntoAdapter( targetAdapter, rect ) )
{
SetWindowPos( ( HWND )windowHandle, deviceParms.startFullscreen ? HWND_TOPMOST : HWND_NOTOPMOST,
rect.left, rect.top, 0, 0, SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE );
}
*/
if( MoveWindowOntoAdapter( targetAdapter, rect ) )
{
SetWindowPos( ( HWND )windowHandle, deviceParms.startFullscreen ? HWND_TOPMOST : HWND_NOTOPMOST,
rect.left, rect.top, 0, 0, SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE );
}
*/
HRESULT hr = E_FAIL;
RECT clientRect;
@ -543,31 +543,31 @@ 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()
/* 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 ) ) )
{
if( fullScreenDesc.Windowed != newFullScreenDesc.Windowed )
DXGI_SWAP_CHAIN_DESC1 newSwapChainDesc;
DXGI_SWAP_CHAIN_FULLSCREEN_DESC newFullScreenDesc;
if( SUCCEEDED( m_SwapChain->GetDesc1( &newSwapChainDesc ) ) && SUCCEEDED( m_SwapChain->GetFullscreenDesc( &newFullScreenDesc ) ) )
{
BackBufferResizing();
fullScreenDesc = newFullScreenDesc;
m_SwapChainDesc = newSwapChainDesc;
deviceParms.backBufferWidth = newSwapChainDesc.Width;
deviceParms.backBufferHeight = newSwapChainDesc.Height;
if( newFullScreenDesc.Windowed )
if( fullScreenDesc.Windowed != newFullScreenDesc.Windowed )
{
//glfwSetWindowMonitor( m_Window, nullptr, 50, 50, newSwapChainDesc.Width, newSwapChainDesc.Height, 0 );
}
BackBufferResizing();
ResizeSwapChain();
BackBufferResized();
fullScreenDesc = newFullScreenDesc;
m_SwapChainDesc = newSwapChainDesc;
deviceParms.backBufferWidth = newSwapChainDesc.Width;
deviceParms.backBufferHeight = newSwapChainDesc.Height;
if( newFullScreenDesc.Windowed )
{
//glfwSetWindowMonitor( m_Window, nullptr, 50, 50, newSwapChainDesc.Width, newSwapChainDesc.Height, 0 );
}
ResizeSwapChain();
BackBufferResized();
}
}
}
*/
*/
auto bufferIndex = m_SwapChain->GetCurrentBackBufferIndex();
WaitForSingleObject( m_FrameFenceEvents[bufferIndex], INFINITE );

View file

@ -575,7 +575,7 @@ bool DeviceManager_VK::pickPhysicalDevice()
}
if( ( find( surfacePModes.begin(), surfacePModes.end(), vk::PresentModeKHR::eImmediate ) == surfacePModes.end() ) ||
( find( surfacePModes.begin(), surfacePModes.end(), vk::PresentModeKHR::eFifo ) == surfacePModes.end() ) )
( find( surfacePModes.begin(), surfacePModes.end(), vk::PresentModeKHR::eFifo ) == surfacePModes.end() ) )
{
// can't find the required surface present modes
errorStream << std::endl << " - does not support the requested surface present modes";
@ -873,21 +873,21 @@ bool DeviceManager_VK::createDevice()
m_VulkanDevice.getQueue( m_PresentQueueFamily, 0, &m_PresentQueue );
VULKAN_HPP_DEFAULT_DISPATCHER.init( m_VulkanDevice );
// SRS - Determine if preferred image depth/stencil format D24S8 is supported (issue with Vulkan on AMD GPUs)
vk::ImageFormatProperties imageFormatProperties;
const vk::Result ret = m_VulkanPhysicalDevice.getImageFormatProperties( vk::Format::eD24UnormS8Uint,
vk::ImageType::e2D,
vk::ImageTiling::eOptimal,
vk::ImageUsageFlags( vk::ImageUsageFlagBits::eDepthStencilAttachment ),
vk::ImageCreateFlags( 0 ),
&imageFormatProperties );
vk::ImageType::e2D,
vk::ImageTiling::eOptimal,
vk::ImageUsageFlags( vk::ImageUsageFlagBits::eDepthStencilAttachment ),
vk::ImageCreateFlags( 0 ),
&imageFormatProperties );
deviceParms.enableImageFormatD24S8 = ( ret == vk::Result::eSuccess );
// SRS - Determine if "smart" (r_swapInterval = 1) vsync mode eFifoRelaxed is supported by device and surface
auto surfacePModes = m_VulkanPhysicalDevice.getSurfacePresentModesKHR( m_WindowSurface );
enablePModeFifoRelaxed = find( surfacePModes.begin(), surfacePModes.end(), vk::PresentModeKHR::eFifoRelaxed ) != surfacePModes.end();
// stash the renderer string
auto prop = m_VulkanPhysicalDevice.getProperties();
m_RendererString = std::string( prop.deviceName.data() );

View file

@ -519,9 +519,9 @@ static bool SetScreenParmsWindowed( glimpParms_t parms )
// SRS - this logic prevents window position drift on linux when coming in and out of fullscreen
#if !defined(__APPLE__)
SDL_bool borderState = SDL_GetWindowFlags( window ) & SDL_WINDOW_BORDERLESS ? SDL_FALSE : SDL_TRUE;
SDL_SetWindowBordered( window, SDL_FALSE );
SDL_SetWindowBordered( window, SDL_FALSE );
SDL_SetWindowPosition( window, parms.x, parms.y );
SDL_SetWindowBordered( window, borderState );
SDL_SetWindowBordered( window, borderState );
#endif
return true;

View file

@ -733,24 +733,24 @@ static bool GetDisplayCoordinates( const int deviceNum, int& x, int& y, int& wid
if( verbose )
{
common->Printf("display device: %i\n", deviceNum);
common->Printf(" DeviceName : %s\n", device.DeviceName);
common->Printf(" DeviceString: %s\n", device.DeviceString);
common->Printf(" StateFlags : 0x%x\n", device.StateFlags);
common->Printf(" DeviceID : %s\n", device.DeviceID);
common->Printf(" DeviceKey : %s\n", device.DeviceKey);
common->Printf(" DeviceName : %s\n", monitor.DeviceName);
common->Printf(" DeviceString: %s\n", monitor.DeviceString);
common->Printf(" StateFlags : 0x%x\n", monitor.StateFlags);
common->Printf(" DeviceID : %s\n", monitor.DeviceID);
common->Printf(" DeviceKey : %s\n", monitor.DeviceKey);
common->Printf(" dmPosition.x : %i\n", devmode.dmPosition.x);
common->Printf(" dmPosition.y : %i\n", devmode.dmPosition.y);
common->Printf(" dmBitsPerPel : %i\n", devmode.dmBitsPerPel);
common->Printf(" dmPelsWidth : %i\n", devmode.dmPelsWidth);
common->Printf(" dmPelsHeight : %i\n", devmode.dmPelsHeight);
common->Printf(" dmDisplayFlags : 0x%x\n", devmode.dmDisplayFlags);
common->Printf(" dmDisplayFrequency: %i\n", devmode.dmDisplayFrequency);
common->Printf( "display device: %i\n", deviceNum );
common->Printf( " DeviceName : %s\n", device.DeviceName );
common->Printf( " DeviceString: %s\n", device.DeviceString );
common->Printf( " StateFlags : 0x%x\n", device.StateFlags );
common->Printf( " DeviceID : %s\n", device.DeviceID );
common->Printf( " DeviceKey : %s\n", device.DeviceKey );
common->Printf( " DeviceName : %s\n", monitor.DeviceName );
common->Printf( " DeviceString: %s\n", monitor.DeviceString );
common->Printf( " StateFlags : 0x%x\n", monitor.StateFlags );
common->Printf( " DeviceID : %s\n", monitor.DeviceID );
common->Printf( " DeviceKey : %s\n", monitor.DeviceKey );
common->Printf( " dmPosition.x : %i\n", devmode.dmPosition.x );
common->Printf( " dmPosition.y : %i\n", devmode.dmPosition.y );
common->Printf( " dmBitsPerPel : %i\n", devmode.dmBitsPerPel );
common->Printf( " dmPelsWidth : %i\n", devmode.dmPelsWidth );
common->Printf( " dmPelsHeight : %i\n", devmode.dmPelsHeight );
common->Printf( " dmDisplayFlags : 0x%x\n", devmode.dmDisplayFlags );
common->Printf( " dmDisplayFrequency: %i\n", devmode.dmDisplayFrequency );
}
x = devmode.dmPosition.x;