Probably fixed Vulkan swapchain problem

This commit is contained in:
Robert Beckebans 2022-09-22 18:34:07 +02:00
parent 9307983475
commit 1d456a9026
8 changed files with 46 additions and 20 deletions

View file

@ -1434,9 +1434,10 @@ idRenderBackend::GL_EndFrame
*/
void idRenderBackend::GL_EndFrame()
{
#if defined( USE_VK )
tr.SetReadyToPresent();
#endif
if( deviceManager->GetGraphicsAPI() == nvrhi::GraphicsAPI::VULKAN )
{
tr.SetReadyToPresent();
}
renderLog.CloseMainBlock( MRB_GPU_TIME );
@ -1444,12 +1445,11 @@ void idRenderBackend::GL_EndFrame()
deviceManager->GetDevice()->executeCommandList( commandList );
// required for Vulkan: transition our swap image to present
deviceManager->EndFrame();
// update jitter for perspective matrix
taaPass->AdvanceFrame();
#if defined( USE_VK )
//GL_BlockingSwapBuffers();
#endif
}
/*
@ -1471,6 +1471,11 @@ void idRenderBackend::GL_BlockingSwapBuffers()
deviceManager->Present();
renderLog.EndFrame();
if( deviceManager->GetGraphicsAPI() == nvrhi::GraphicsAPI::VULKAN )
{
tr.InvalidateSwapBuffers();
}
}
/*

View file

@ -6600,12 +6600,14 @@ void idRenderBackend::ExecuteBackEndCommands( const emptyCommand_t* cmds )
delete hiZGenPass;
}
#if defined( USE_VK )
// FIXME
hiZGenPass = NULL;
#else
hiZGenPass = new MipMapGenPass( deviceManager->GetDevice(), globalImages->hierarchicalZbufferImage->GetTextureHandle() );
#endif
if( deviceManager->GetGraphicsAPI() == nvrhi::GraphicsAPI::VULKAN )
{
hiZGenPass = NULL;
}
else
{
hiZGenPass = new MipMapGenPass( deviceManager->GetDevice(), globalImages->hierarchicalZbufferImage->GetTextureHandle() );
}
}

View file

@ -994,6 +994,11 @@ public:
bInitialized = true;
}
void InvalidateSwapBuffers()
{
omitSwapBuffers = true;
}
void SetReadyToPresent()
{
omitSwapBuffers = false;

View file

@ -98,7 +98,10 @@ enum graphicsDriverType_t
GLDRV_OPENGL_MESA, // fear this, it is probably the best to disable GPU skinning and run shaders in GLSL ES 1.0
GLDRV_OPENGL_MESA_CORE_PROFILE,
GLDRV_VULKAN
GLDRV_VULKAN,
GLDRV_NVRHI_DX12,
GLDRV_NVRHI_VULKAN,
};
#define ID_MSAA 0

View file

@ -2225,10 +2225,11 @@ void idRenderSystemLocal::Init()
frontEndJobList = parallelJobManager->AllocJobList( JOBLIST_RENDERER_FRONTEND, JOBLIST_PRIORITY_MEDIUM, 2048, 0, NULL );
envprobeJobList = parallelJobManager->AllocJobList( JOBLIST_UTILITY, JOBLIST_PRIORITY_MEDIUM, 2048, 0, NULL ); // RB
#if defined( USE_VK )
// avoid GL_BlockingSwapBuffers
omitSwapBuffers = true;
#endif
if( deviceManager->GetGraphicsAPI() == nvrhi::GraphicsAPI::VULKAN )
{
// avoid GL_BlockingSwapBuffers
omitSwapBuffers = true;
}
// make sure the command buffers are ready to accept the first screen update
SwapCommandBuffers( NULL, NULL, NULL, NULL, NULL, NULL );

View file

@ -157,6 +157,7 @@ protected:
virtual void DestroyDeviceAndSwapChain() = 0;
virtual void ResizeSwapChain() = 0;
virtual void BeginFrame() = 0;
virtual void EndFrame() = 0; // RB: added for BFG edition
virtual void Present() = 0;
public:

View file

@ -93,6 +93,7 @@ protected:
uint32_t GetCurrentBackBufferIndex() override;
uint32_t GetBackBufferCount() override;
void BeginFrame() override;
void EndFrame() override;
void Present() override;
private:
@ -590,6 +591,11 @@ uint32_t DeviceManager_DX12::GetBackBufferCount()
return m_SwapChainDesc.BufferCount;
}
void DeviceManager_DX12::EndFrame()
{
}
void DeviceManager_DX12::Present()
{
if( !windowVisible )

View file

@ -88,6 +88,7 @@ protected:
}
void BeginFrame() override;
void EndFrame() override;
void Present() override;
const char* GetRendererString() const override
@ -281,7 +282,6 @@ private:
idLib::Printf( "[Vulkan] DEBUG location=0x%zx code=%d, layerPrefix='%s'] %s", location, code, layerPrefix, msg );
}
return VK_FALSE;
}
};
@ -1156,14 +1156,17 @@ void DeviceManager_VK::BeginFrame()
m_NvrhiDevice->queueWaitForSemaphore( nvrhi::CommandQueue::Graphics, m_PresentSemaphore, 0 );
}
void DeviceManager_VK::Present()
void DeviceManager_VK::EndFrame()
{
m_NvrhiDevice->queueSignalSemaphore( nvrhi::CommandQueue::Graphics, m_PresentSemaphore, 0 );
m_BarrierCommandList->open(); // umm...
m_BarrierCommandList->close();
m_NvrhiDevice->executeCommandList( m_BarrierCommandList );
}
void DeviceManager_VK::Present()
{
vk::PresentInfoKHR info = vk::PresentInfoKHR()
.setWaitSemaphoreCount( 1 )
.setPWaitSemaphores( &m_PresentSemaphore )