mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-21 03:55:32 +00:00
d3d12: Factorize cleaning function for heaps
This commit is contained in:
parent
aa66ddcd86
commit
dca9ae6ab5
2 changed files with 28 additions and 17 deletions
|
@ -1031,29 +1031,22 @@ void D3D12GSRender::Flip()
|
|||
m_texturesCache.clear();
|
||||
m_texturesRTTs.clear();
|
||||
|
||||
storage.m_inUseConstantsBuffers = m_constantsData.m_resourceStoredSinceLastSync;
|
||||
m_constantsData.m_resourceStoredSinceLastSync.clear();
|
||||
storage.m_inUseVertexIndexBuffers = m_vertexIndexData.m_resourceStoredSinceLastSync;
|
||||
m_vertexIndexData.m_resourceStoredSinceLastSync.clear();
|
||||
storage.m_inUseTextureUploadBuffers = m_textureUploadData.m_resourceStoredSinceLastSync;
|
||||
m_textureUploadData.m_resourceStoredSinceLastSync.clear();
|
||||
storage.m_inUseTexture2D = m_textureData.m_resourceStoredSinceLastSync;
|
||||
m_textureData.m_resourceStoredSinceLastSync.clear();
|
||||
std::vector<std::function<void()> > cleaningFunction =
|
||||
{
|
||||
m_constantsData.getCleaningFunction(),
|
||||
m_vertexIndexData.getCleaningFunction(),
|
||||
m_textureUploadData.getCleaningFunction(),
|
||||
m_textureData.getCleaningFunction()
|
||||
};
|
||||
|
||||
m_GC.pushWork([&]()
|
||||
m_GC.pushWork([&, cleaningFunction]()
|
||||
{
|
||||
WaitForSingleObject(storage.m_frameFinishedHandle, INFINITE);
|
||||
CloseHandle(storage.m_frameFinishedHandle);
|
||||
storage.m_frameFinishedFence->Release();
|
||||
|
||||
for (auto tmp : storage.m_inUseConstantsBuffers)
|
||||
m_constantsData.m_getPos = std::get<0>(tmp);
|
||||
for (auto tmp : storage.m_inUseVertexIndexBuffers)
|
||||
m_vertexIndexData.m_getPos = std::get<0>(tmp);
|
||||
for (auto tmp : storage.m_inUseTextureUploadBuffers)
|
||||
m_textureUploadData.m_getPos = std::get<0>(tmp);
|
||||
for (auto tmp : storage.m_inUseTexture2D)
|
||||
m_textureData.m_getPos = std::get<0>(tmp);
|
||||
for (unsigned i = 0; i < 4; i++)
|
||||
cleaningFunction[i]();
|
||||
storage.Reset();
|
||||
});
|
||||
|
||||
|
|
|
@ -160,6 +160,24 @@ struct DataHeap
|
|||
SAFE_RELEASE(std::get<2>(tmp));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a function that cleans heaps.
|
||||
* It's caller responsability to ensure data are not used when executed.
|
||||
*/
|
||||
std::function<void()> getCleaningFunction()
|
||||
{
|
||||
size_t& getPointer = m_getPos;
|
||||
auto duplicatem_resourceStoredSinceLastSync = m_resourceStoredSinceLastSync;
|
||||
m_resourceStoredSinceLastSync.clear();
|
||||
return [=, &getPointer]() {
|
||||
for (auto tmp : duplicatem_resourceStoredSinceLastSync)
|
||||
{
|
||||
SAFE_RELEASE(std::get<2>(tmp));
|
||||
getPointer = std::get<0>(tmp);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue