mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-14 22:50:45 +00:00
Fix Vsync mode switching to support all modes: 0 (off), 1 (smart), 2 (on)
This commit is contained in:
parent
fd86362724
commit
2faa15bab5
4 changed files with 8 additions and 8 deletions
|
@ -1836,7 +1836,7 @@ void idRenderBackend::CheckCVars()
|
|||
if( r_swapInterval.IsModified() )
|
||||
{
|
||||
r_swapInterval.ClearModified();
|
||||
deviceManager->SetVsyncEnabled( r_swapInterval.GetBool() );
|
||||
deviceManager->SetVsyncEnabled( r_swapInterval.GetInteger() );
|
||||
}
|
||||
|
||||
// filtering
|
||||
|
|
|
@ -59,7 +59,7 @@ struct DeviceCreationParameters
|
|||
uint32_t swapChainSampleQuality = 0;
|
||||
bool enableDebugRuntime = false;
|
||||
bool enableNvrhiValidationLayer = false;
|
||||
bool vsyncEnabled = false;
|
||||
int vsyncEnabled = 0;
|
||||
bool enableRayTracingExtensions = false; // for vulkan
|
||||
bool enableComputeQueue = false;
|
||||
bool enableCopyQueue = false;
|
||||
|
@ -158,7 +158,7 @@ protected:
|
|||
|
||||
float m_DPIScaleFactorX = 1.f;
|
||||
float m_DPIScaleFactorY = 1.f;
|
||||
bool m_RequestedVSync = false;
|
||||
int m_RequestedVSync = 0;
|
||||
|
||||
uint32_t m_FrameIndex = 0;
|
||||
|
||||
|
@ -181,9 +181,9 @@ public:
|
|||
[[nodiscard]] virtual nvrhi::GraphicsAPI GetGraphicsAPI() const = 0;
|
||||
|
||||
const DeviceCreationParameters& GetDeviceParams();
|
||||
virtual void SetVsyncEnabled( bool enabled )
|
||||
virtual void SetVsyncEnabled( int vsyncMode )
|
||||
{
|
||||
m_RequestedVSync = enabled; /* will be processed later */
|
||||
m_RequestedVSync = vsyncMode; /* will be processed later */
|
||||
}
|
||||
virtual void ReportLiveObjects() {}
|
||||
|
||||
|
|
|
@ -662,7 +662,7 @@ void DeviceManager_DX12::Present()
|
|||
UINT presentFlags = 0;
|
||||
|
||||
// SRS - DXGI docs say fullscreen must be disabled for unlocked fps/tear, but this does not seem to be true
|
||||
if( !m_DeviceParams.vsyncEnabled && m_TearingSupported ) //&& !glConfig.isFullscreen )
|
||||
if( m_DeviceParams.vsyncEnabled == 0 && m_TearingSupported ) //&& !glConfig.isFullscreen )
|
||||
{
|
||||
presentFlags |= DXGI_PRESENT_ALLOW_TEARING;
|
||||
}
|
||||
|
@ -671,7 +671,7 @@ void DeviceManager_DX12::Present()
|
|||
OPTICK_CATEGORY( "Present", Optick::Category::Wait );
|
||||
|
||||
// SRS - Don't change m_DeviceParams.vsyncEnabled here, simply test for vsync mode 2 to set DXGI SyncInterval
|
||||
m_SwapChain->Present( m_DeviceParams.vsyncEnabled && r_swapInterval.GetInteger() == 2 ? 1 : 0, presentFlags );
|
||||
m_SwapChain->Present( m_DeviceParams.vsyncEnabled == 2 ? 1 : 0, presentFlags );
|
||||
|
||||
m_FrameFence->SetEventOnCompletion( m_FrameCount, m_FrameFenceEvents[bufferIndex] );
|
||||
m_GraphicsQueue->Signal( m_FrameFence, m_FrameCount );
|
||||
|
|
|
@ -1020,7 +1020,7 @@ bool DeviceManager_VK::createSwapChain()
|
|||
.setPQueueFamilyIndices( enableSwapChainSharing ? queues.data() : nullptr )
|
||||
.setPreTransform( vk::SurfaceTransformFlagBitsKHR::eIdentity )
|
||||
.setCompositeAlpha( vk::CompositeAlphaFlagBitsKHR::eOpaque )
|
||||
.setPresentMode( m_DeviceParams.vsyncEnabled ? ( r_swapInterval.GetInteger() == 2 || !enablePModeFifoRelaxed ? vk::PresentModeKHR::eFifo : vk::PresentModeKHR::eFifoRelaxed ) : vk::PresentModeKHR::eImmediate )
|
||||
.setPresentMode( m_DeviceParams.vsyncEnabled > 0 ? ( m_DeviceParams.vsyncEnabled == 2 || !enablePModeFifoRelaxed ? vk::PresentModeKHR::eFifo : vk::PresentModeKHR::eFifoRelaxed ) : vk::PresentModeKHR::eImmediate )
|
||||
.setClipped( true )
|
||||
.setOldSwapchain( nullptr );
|
||||
|
||||
|
|
Loading…
Reference in a new issue