d3d12; Add a texture cache

This commit is contained in:
vlj 2015-05-30 01:22:31 +02:00 committed by Vincent Lejeune
parent d8f76f5aee
commit 90fb4396fe
3 changed files with 12 additions and 3 deletions

View File

@ -1248,6 +1248,7 @@ void D3D12GSRender::Flip()
CloseHandle(handle); CloseHandle(handle);
m_perFrameStorage.Reset(); m_perFrameStorage.Reset();
m_texturesRTTs.clear(); m_texturesRTTs.clear();
m_texturesCache.clear();
m_frame->Flip(nullptr); m_frame->Flip(nullptr);
} }

View File

@ -49,6 +49,8 @@ class D3D12GSRender : public GSRender
private: private:
// Copy of RTT to be used as texture // Copy of RTT to be used as texture
std::unordered_map<u32, Microsoft::WRL::ComPtr<ID3D12Resource> > m_texturesRTTs; std::unordered_map<u32, Microsoft::WRL::ComPtr<ID3D12Resource> > m_texturesRTTs;
std::unordered_map<u32, ID3D12Resource*> m_texturesCache;
// std::vector<PostDrawObj> m_post_draw_objs; // std::vector<PostDrawObj> m_post_draw_objs;
PipelineStateObjectCache m_cachePSO; PipelineStateObjectCache m_cachePSO;

View File

@ -146,10 +146,15 @@ size_t D3D12GSRender::UploadTextures()
} }
ID3D12Resource *vramTexture; ID3D12Resource *vramTexture;
std::unordered_map<u32, Microsoft::WRL::ComPtr<ID3D12Resource> >::const_iterator It = m_texturesRTTs.find(texaddr); std::unordered_map<u32, Microsoft::WRL::ComPtr<ID3D12Resource> >::const_iterator ItRTT = m_texturesRTTs.find(texaddr);
if (It != m_texturesRTTs.end()) std::unordered_map<u32, ID3D12Resource* >::const_iterator ItCache = m_texturesCache.find(texaddr);
if (ItRTT != m_texturesRTTs.end())
{ {
vramTexture = It->second.Get(); vramTexture = ItRTT->second.Get();
}
else if (ItCache != m_texturesCache.end())
{
vramTexture = ItCache->second;
} }
else else
{ {
@ -242,6 +247,7 @@ size_t D3D12GSRender::UploadTextures()
commandList->Close(); commandList->Close();
m_commandQueueGraphic->ExecuteCommandLists(1, (ID3D12CommandList**)&commandList); m_commandQueueGraphic->ExecuteCommandLists(1, (ID3D12CommandList**)&commandList);
m_perFrameStorage.m_inflightCommandList.push_back(commandList); m_perFrameStorage.m_inflightCommandList.push_back(commandList);
m_texturesCache[texaddr] = vramTexture;
} }
D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = {}; D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = {};