mirror of
https://gitlab.com/Mr_Goldberg/goldberg_emulator.git
synced 2024-11-14 00:18:58 +01:00
Fixed ressource leaks.
This commit is contained in:
parent
c99628a88a
commit
8757f4a548
3 changed files with 12 additions and 5 deletions
|
@ -89,7 +89,7 @@ void DX10_Hook::prepareForOverlay(IDXGISwapChain* pSwapChain)
|
||||||
|
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
{
|
{
|
||||||
if (FAILED(pSwapChain->GetDevice(__uuidof(ID3D10Device), (PVOID*)& pDevice)))
|
if (FAILED(pSwapChain->GetDevice(IID_PPV_ARGS(&pDevice))))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
|
@ -98,12 +98,14 @@ void DX10_Hook::prepareForOverlay(IDXGISwapChain* pSwapChain)
|
||||||
|
|
||||||
ID3D10Texture2D* pBackBuffer;
|
ID3D10Texture2D* pBackBuffer;
|
||||||
|
|
||||||
pSwapChain->GetBuffer(0, __uuidof(ID3D10Texture2D), (LPVOID*)& pBackBuffer);
|
pSwapChain->GetBuffer(0, IID_PPV_ARGS(&pBackBuffer));
|
||||||
pDevice->CreateRenderTargetView(pBackBuffer, NULL, &mainRenderTargetView);
|
pDevice->CreateRenderTargetView(pBackBuffer, NULL, &mainRenderTargetView);
|
||||||
pBackBuffer->Release();
|
pBackBuffer->Release();
|
||||||
|
|
||||||
ImGui_ImplDX10_Init(pDevice);
|
ImGui_ImplDX10_Init(pDevice);
|
||||||
|
|
||||||
|
pDevice->Release();
|
||||||
|
|
||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ DX11_Hook* DX11_Hook::_inst = nullptr;
|
||||||
|
|
||||||
HRESULT GetDeviceAndCtxFromSwapchain(IDXGISwapChain* pSwapChain, ID3D11Device** ppDevice, ID3D11DeviceContext** ppContext)
|
HRESULT GetDeviceAndCtxFromSwapchain(IDXGISwapChain* pSwapChain, ID3D11Device** ppDevice, ID3D11DeviceContext** ppContext)
|
||||||
{
|
{
|
||||||
HRESULT ret = pSwapChain->GetDevice(__uuidof(ID3D11Device), (PVOID*)ppDevice);
|
HRESULT ret = pSwapChain->GetDevice(IID_PPV_ARGS(ppDevice));
|
||||||
|
|
||||||
if (SUCCEEDED(ret))
|
if (SUCCEEDED(ret))
|
||||||
(*ppDevice)->GetImmediateContext(ppContext);
|
(*ppDevice)->GetImmediateContext(ppContext);
|
||||||
|
@ -111,12 +111,14 @@ void DX11_Hook::prepareForOverlay(IDXGISwapChain* pSwapChain)
|
||||||
|
|
||||||
ID3D11Texture2D* pBackBuffer;
|
ID3D11Texture2D* pBackBuffer;
|
||||||
|
|
||||||
pSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)& pBackBuffer);
|
pSwapChain->GetBuffer(0, IID_PPV_ARGS(&pBackBuffer));
|
||||||
pDevice->CreateRenderTargetView(pBackBuffer, NULL, &mainRenderTargetView);
|
pDevice->CreateRenderTargetView(pBackBuffer, NULL, &mainRenderTargetView);
|
||||||
pBackBuffer->Release();
|
pBackBuffer->Release();
|
||||||
|
|
||||||
ImGui_ImplDX11_Init(pDevice, pContext);
|
ImGui_ImplDX11_Init(pDevice, pContext);
|
||||||
|
|
||||||
|
pDevice->Release();
|
||||||
|
|
||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -138,7 +138,9 @@ void DX12_Hook::prepareForOverlay(IDXGISwapChain* pSwapChain)
|
||||||
}
|
}
|
||||||
if (!SUCCEEDED(pDevice->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, pCmdAlloc, NULL, IID_PPV_ARGS(&pCmdList))))
|
if (!SUCCEEDED(pDevice->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, pCmdAlloc, NULL, IID_PPV_ARGS(&pCmdList))))
|
||||||
{
|
{
|
||||||
|
pCmdAlloc->Release();
|
||||||
|
pDescriptorHeap->Release();
|
||||||
|
pDevice->Release();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,6 +152,7 @@ void DX12_Hook::prepareForOverlay(IDXGISwapChain* pSwapChain)
|
||||||
pDescriptorHeap->GetCPUDescriptorHandleForHeapStart(),
|
pDescriptorHeap->GetCPUDescriptorHandleForHeapStart(),
|
||||||
pDescriptorHeap->GetGPUDescriptorHandleForHeapStart());
|
pDescriptorHeap->GetGPUDescriptorHandleForHeapStart());
|
||||||
|
|
||||||
|
pCmdList->Release();
|
||||||
pCmdAlloc->Release();
|
pCmdAlloc->Release();
|
||||||
pDescriptorHeap->Release();
|
pDescriptorHeap->Release();
|
||||||
pDevice->Release();
|
pDevice->Release();
|
||||||
|
|
Loading…
Reference in a new issue