mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-14 22:50:45 +00:00
Merge branch '635-nvrhi3-cleanexit' into 635-nvrhi3
This commit is contained in:
commit
7fb6948777
15 changed files with 153 additions and 12 deletions
|
@ -784,6 +784,9 @@ void idImageManager::Shutdown()
|
|||
imageHash.Clear();
|
||||
deferredImages.DeleteContents( true );
|
||||
deferredImageHash.Clear();
|
||||
#if defined( USE_NVRHI )
|
||||
commandList.Reset();
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -67,6 +67,12 @@ void fhImmediateMode::Init( nvrhi::ICommandList* commandList )
|
|||
InitBuffers( commandList );
|
||||
}
|
||||
|
||||
void fhImmediateMode::Shutdown()
|
||||
{
|
||||
vertexBuffer.FreeBufferObject();
|
||||
indexBuffer.FreeBufferObject();
|
||||
}
|
||||
|
||||
void fhImmediateMode::ResetStats()
|
||||
{
|
||||
drawCallCount = 0;
|
||||
|
|
|
@ -73,6 +73,7 @@ public:
|
|||
static void AddTrianglesFromPolygon( fhImmediateMode& im, const idVec3* xyz, int num );
|
||||
|
||||
static void Init( nvrhi::ICommandList* commandList );
|
||||
static void Shutdown();
|
||||
static void ResetStats();
|
||||
static int DrawCallCount();
|
||||
static int DrawCallVertexSize();
|
||||
|
|
|
@ -286,6 +286,9 @@ void idRenderModelManagerLocal::Shutdown()
|
|||
{
|
||||
models.DeleteContents( true );
|
||||
hash.Free();
|
||||
#if defined( USE_NVRHI )
|
||||
commandList.Reset();
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -199,7 +199,32 @@ void idRenderBackend::Init()
|
|||
|
||||
void idRenderBackend::Shutdown()
|
||||
{
|
||||
delete ssaoPass;
|
||||
// SRS - Clean up NVRHI resources before Sys_Quit(), otherwise non-zero exit code (destructors too late)
|
||||
|
||||
// Clear all cached pipeline data
|
||||
tr.backend.ClearCaches();
|
||||
pipelineCache.Shutdown();
|
||||
|
||||
// Delete all renderpass resources
|
||||
commonPasses.Shutdown();
|
||||
|
||||
// Delete current binding sets
|
||||
for( int i = 0; i < currentBindingSets.Num(); i++ )
|
||||
{
|
||||
currentBindingSets[i].Reset();
|
||||
}
|
||||
|
||||
// Unload shaders, delete binding layouts, and unmap memory
|
||||
renderProgManager.Shutdown();
|
||||
|
||||
// Delete renderlog command buffer and timer query resources
|
||||
renderLog.Shutdown();
|
||||
|
||||
// Delete command list
|
||||
commandList.Reset();
|
||||
|
||||
// Delete immediate mode buffer objects
|
||||
fhImmediateMode::Shutdown();
|
||||
|
||||
#if defined( VULKAN_USE_PLATFORM_SDL )
|
||||
VKimp_Shutdown();
|
||||
|
|
|
@ -177,6 +177,43 @@ void CommonRenderPasses::Init( nvrhi::IDevice* device )
|
|||
}
|
||||
}
|
||||
|
||||
void CommonRenderPasses::Shutdown()
|
||||
{
|
||||
// SRS - Delete the pipelines referenced by the blit cache
|
||||
for( auto& [key, pipeline] : m_BlitPsoCache )
|
||||
{
|
||||
pipeline.Reset();
|
||||
}
|
||||
|
||||
// SRS - These assets have automatic resource management with overloaded = operator
|
||||
m_RectVS = nullptr;
|
||||
m_BlitPS = nullptr;
|
||||
m_BlitArrayPS = nullptr;
|
||||
m_SharpenPS = nullptr;
|
||||
m_SharpenArrayPS = nullptr;
|
||||
|
||||
m_BlackTexture = nullptr;
|
||||
m_GrayTexture = nullptr;
|
||||
m_WhiteTexture = nullptr;
|
||||
m_BlackTexture2DArray = nullptr;
|
||||
m_WhiteTexture2DArray = nullptr;
|
||||
m_BlackCubeMapArray = nullptr;
|
||||
|
||||
m_PointClampSampler = nullptr;
|
||||
m_PointWrapSampler = nullptr;
|
||||
m_LinearClampSampler = nullptr;
|
||||
m_LinearBorderSampler = nullptr;
|
||||
m_LinearClampCompareSampler = nullptr;
|
||||
m_LinearWrapSampler = nullptr;
|
||||
m_AnisotropicWrapSampler = nullptr;
|
||||
m_AnisotropicClampEdgeSampler = nullptr;
|
||||
|
||||
m_BlitBindingLayout = nullptr;
|
||||
|
||||
// SRS - Remove reference to nvrhi::IDevice, otherwise won't clean up properly on shutdown
|
||||
m_Device = nullptr;
|
||||
}
|
||||
|
||||
void CommonRenderPasses::BlitTexture( nvrhi::ICommandList* commandList, const BlitParameters& params, BindingCache* bindingCache )
|
||||
{
|
||||
assert( commandList );
|
||||
|
|
|
@ -134,6 +134,7 @@ public:
|
|||
CommonRenderPasses();
|
||||
|
||||
void Init( nvrhi::IDevice* device );
|
||||
void Shutdown();
|
||||
|
||||
void BlitTexture( nvrhi::ICommandList* commandList, const BlitParameters& params, BindingCache* bindingCache = nullptr );
|
||||
|
||||
|
@ -141,4 +142,4 @@ public:
|
|||
void BlitTexture( nvrhi::ICommandList* commandList, nvrhi::IFramebuffer* targetFramebuffer, nvrhi::ITexture* sourceTexture, BindingCache* bindingCache = nullptr );
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -43,6 +43,12 @@ void PipelineCache::Init( nvrhi::DeviceHandle deviceHandle )
|
|||
device = deviceHandle;
|
||||
}
|
||||
|
||||
void PipelineCache::Shutdown()
|
||||
{
|
||||
// SRS - Remove reference to nvrhi::IDevice, otherwise won't clean up properly on shutdown
|
||||
device = nullptr;
|
||||
}
|
||||
|
||||
void PipelineCache::Clear()
|
||||
{
|
||||
pipelines.Clear();
|
||||
|
@ -515,4 +521,4 @@ nvrhi::DepthStencilState::StencilOpDesc PipelineCache::GetStencilOpState( uint64
|
|||
}
|
||||
|
||||
return stencilOp;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@ public:
|
|||
PipelineCache();
|
||||
|
||||
void Init( nvrhi::DeviceHandle deviceHandle );
|
||||
void Shutdown();
|
||||
|
||||
void Clear();
|
||||
|
||||
|
@ -85,4 +86,4 @@ private:
|
|||
};
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -332,6 +332,21 @@ void idRenderLog::Init()
|
|||
#endif
|
||||
}
|
||||
|
||||
void idRenderLog::Shutdown()
|
||||
{
|
||||
#if defined( USE_NVRHI )
|
||||
if( commandList )
|
||||
{
|
||||
commandList.Reset();
|
||||
}
|
||||
|
||||
for( int i = 0; i < MRB_TOTAL_QUERIES; i++ )
|
||||
{
|
||||
timerQueries[i].Reset();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void idRenderLog::StartFrame( nvrhi::ICommandList* _commandList )
|
||||
{
|
||||
#if defined( USE_NVRHI )
|
||||
|
@ -537,4 +552,4 @@ void idRenderLog::CloseBlock()
|
|||
{
|
||||
PC_EndNamedEvent( commandList );
|
||||
}
|
||||
// RB end
|
||||
// RB end
|
||||
|
|
|
@ -90,6 +90,7 @@ public:
|
|||
idRenderLog();
|
||||
|
||||
void Init();
|
||||
void Shutdown();
|
||||
|
||||
void StartFrame( nvrhi::ICommandList* _commandList );
|
||||
void EndFrame();
|
||||
|
|
|
@ -769,6 +769,29 @@ idRenderProgManager::Shutdown()
|
|||
void idRenderProgManager::Shutdown()
|
||||
{
|
||||
KillAllShaders();
|
||||
|
||||
#if defined( USE_NVRHI )
|
||||
// SRS - Delete renderprogs builtin binding layouts
|
||||
for( int i = 0; i < renderProgs.Num(); i++ )
|
||||
{
|
||||
for( int j = 0; j < renderProgs[i].bindingLayouts.Num(); j++ )
|
||||
{
|
||||
renderProgs[i].bindingLayouts[j].Reset();
|
||||
}
|
||||
}
|
||||
|
||||
// SRS - Delete binding layouts
|
||||
for( int i = 0; i < bindingLayouts.Num(); i++ )
|
||||
{
|
||||
for( int j = 0; j < bindingLayouts[i].Num(); j++ )
|
||||
{
|
||||
bindingLayouts[i][j].Reset();
|
||||
}
|
||||
}
|
||||
|
||||
// SRS - Unmap buffer memory using overloaded = operator
|
||||
constantBuffer = nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1228,4 +1251,4 @@ void RpPrintState( uint64 stateBits )
|
|||
{
|
||||
printStencil( STENCIL_FACE_NUM, stateBits, mask, ref );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2284,6 +2284,10 @@ void idRenderSystemLocal::Shutdown()
|
|||
|
||||
Clear();
|
||||
|
||||
#if defined( USE_NVRHI )
|
||||
commandList.Reset();
|
||||
#endif
|
||||
|
||||
ShutdownOpenGL();
|
||||
|
||||
bInitialized = false;
|
||||
|
|
|
@ -1083,6 +1083,20 @@ void DeviceManager_VK::DestroyDeviceAndSwapChain()
|
|||
|
||||
m_BarrierCommandList = nullptr;
|
||||
|
||||
while( m_FramesInFlight.size() > 0 )
|
||||
{
|
||||
auto query = m_FramesInFlight.front();
|
||||
m_FramesInFlight.pop();
|
||||
query = nullptr;
|
||||
}
|
||||
|
||||
if( !m_QueryPool.empty() )
|
||||
{
|
||||
auto query = m_QueryPool.back();
|
||||
m_QueryPool.pop_back();
|
||||
query = nullptr;
|
||||
}
|
||||
|
||||
m_NvrhiDevice = nullptr;
|
||||
m_ValidationLayer = nullptr;
|
||||
m_RendererString.clear();
|
||||
|
|
|
@ -534,12 +534,6 @@ bool VKimp_SetScreenParms( glimpParms_t parms )
|
|||
void DeviceManager::Shutdown()
|
||||
{
|
||||
DestroyDeviceAndSwapChain();
|
||||
|
||||
// destroy window
|
||||
VKimp_Shutdown();
|
||||
|
||||
// restore gamma
|
||||
//VKimp_RestoreGamma();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -552,6 +546,13 @@ void VKimp_Shutdown()
|
|||
{
|
||||
common->Printf( "Shutting down Vulkan subsystem\n" );
|
||||
|
||||
#if defined( USE_NVRHI )
|
||||
if( deviceManager )
|
||||
{
|
||||
deviceManager->Shutdown();
|
||||
}
|
||||
#endif
|
||||
|
||||
if( window )
|
||||
{
|
||||
SDL_DestroyWindow( window );
|
||||
|
|
Loading…
Reference in a new issue