I am adding multithread rendering to my d3d11 engine. I am encountering an issue where it is getting an out of memory error after a minute or so. Basically I have a class called renderer which is an encapsulation of a context. I create a context in the constructor and do commands on it then call finish on it to get the list then pass it to a class which encapsulates the immediate context and call execute on the list. Is there a cleanup step I am missing? I have tried using new contexts each time and that doesn't help either. For now I have one thread which builds the contexts and another which renders the contexts.
D3D11Renderer::D3D11Renderer(void)
{
if (FAILED(g_Device->CreateDeferredContext(0, m_Context)))
{
_ASSERT(false);
}
}
void D3D11Renderer::End(bool bPresent)
{
m_List = nullptr;
if(FAILED(m_Context->FinishCommandList(false, &m_List)))
{
_ASSERT(false);
}
}
void D3D11RenderQueue::Execute(std::list<IRendererPointer>& List)
{
for each(IRendererPointer Render in List)
{
if (Render.Cast<D3D11Renderer>()->m_List)
{
g_Immediate->ExecuteCommandList(Render.Cast<D3D11Renderer>()->m_List, false);
}
}
}