Release references to duplicate states before re-using existing wrapper

* Fixes a dangling reference that ends up keeing the D3D11 device alive
  and so leaking a lot of memory each time the capture is opened.
This commit is contained in:
baldurk
2017-06-29 19:37:07 +01:00
parent beb570c286
commit 9b913de877
3 changed files with 7 additions and 0 deletions
@@ -91,6 +91,7 @@ bool WrappedID3D11Device::Serialise_CreateBlendState1(const D3D11_BLEND_DESC1 *p
{
if(GetResourceManager()->HasWrapper(ret))
{
ret->Release();
ret = (ID3D11BlendState1 *)GetResourceManager()->GetWrapper(ret);
ret->AddRef();
@@ -181,6 +182,7 @@ bool WrappedID3D11Device::Serialise_CreateRasterizerState1(
{
if(GetResourceManager()->HasWrapper(ret))
{
ret->Release();
ret = (ID3D11RasterizerState1 *)GetResourceManager()->GetWrapper(ret);
ret->AddRef();
@@ -663,6 +663,7 @@ bool WrappedID3D11Device::Serialise_CreateRasterizerState2(
{
if(GetResourceManager()->HasWrapper(ret))
{
ret->Release();
ret = (ID3D11RasterizerState2 *)GetResourceManager()->GetWrapper(ret);
ret->AddRef();
@@ -1995,6 +1995,7 @@ bool WrappedID3D11Device::Serialise_CreateBlendState(const D3D11_BLEND_DESC *pBl
{
if(GetResourceManager()->HasWrapper(ret))
{
ret->Release();
ret = (ID3D11BlendState *)GetResourceManager()->GetWrapper(ret);
ret->AddRef();
@@ -2079,6 +2080,7 @@ bool WrappedID3D11Device::Serialise_CreateDepthStencilState(
{
if(GetResourceManager()->HasWrapper(ret))
{
ret->Release();
ret = (ID3D11DepthStencilState *)GetResourceManager()->GetWrapper(ret);
ret->AddRef();
@@ -2163,6 +2165,7 @@ bool WrappedID3D11Device::Serialise_CreateRasterizerState(const D3D11_RASTERIZER
{
if(GetResourceManager()->HasWrapper(ret))
{
ret->Release();
ret = (ID3D11RasterizerState *)GetResourceManager()->GetWrapper(ret);
ret->AddRef();
@@ -2247,6 +2250,7 @@ bool WrappedID3D11Device::Serialise_CreateSamplerState(const D3D11_SAMPLER_DESC
{
if(GetResourceManager()->HasWrapper(ret))
{
ret->Release();
ret = (ID3D11SamplerState *)GetResourceManager()->GetWrapper(ret);
ret->AddRef();