mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-12 17:58:37 +12: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_texturesCache.clear();
|
||||||
m_texturesRTTs.clear();
|
m_texturesRTTs.clear();
|
||||||
|
|
||||||
storage.m_inUseConstantsBuffers = m_constantsData.m_resourceStoredSinceLastSync;
|
std::vector<std::function<void()> > cleaningFunction =
|
||||||
m_constantsData.m_resourceStoredSinceLastSync.clear();
|
{
|
||||||
storage.m_inUseVertexIndexBuffers = m_vertexIndexData.m_resourceStoredSinceLastSync;
|
m_constantsData.getCleaningFunction(),
|
||||||
m_vertexIndexData.m_resourceStoredSinceLastSync.clear();
|
m_vertexIndexData.getCleaningFunction(),
|
||||||
storage.m_inUseTextureUploadBuffers = m_textureUploadData.m_resourceStoredSinceLastSync;
|
m_textureUploadData.getCleaningFunction(),
|
||||||
m_textureUploadData.m_resourceStoredSinceLastSync.clear();
|
m_textureData.getCleaningFunction()
|
||||||
storage.m_inUseTexture2D = m_textureData.m_resourceStoredSinceLastSync;
|
};
|
||||||
m_textureData.m_resourceStoredSinceLastSync.clear();
|
|
||||||
|
|
||||||
m_GC.pushWork([&]()
|
m_GC.pushWork([&, cleaningFunction]()
|
||||||
{
|
{
|
||||||
WaitForSingleObject(storage.m_frameFinishedHandle, INFINITE);
|
WaitForSingleObject(storage.m_frameFinishedHandle, INFINITE);
|
||||||
CloseHandle(storage.m_frameFinishedHandle);
|
CloseHandle(storage.m_frameFinishedHandle);
|
||||||
storage.m_frameFinishedFence->Release();
|
storage.m_frameFinishedFence->Release();
|
||||||
|
|
||||||
for (auto tmp : storage.m_inUseConstantsBuffers)
|
for (unsigned i = 0; i < 4; i++)
|
||||||
m_constantsData.m_getPos = std::get<0>(tmp);
|
cleaningFunction[i]();
|
||||||
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);
|
|
||||||
storage.Reset();
|
storage.Reset();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -160,6 +160,24 @@ struct DataHeap
|
||||||
SAFE_RELEASE(std::get<2>(tmp));
|
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
Add a link
Reference in a new issue