Flush pending dead on D3D11 before checking for wrappers. Closes #2145

* Otherwise we could AddRef() a dead object and then it gets released again for
  a double delete.
This commit is contained in:
baldurk
2021-01-11 11:08:13 +00:00
parent c63d222c69
commit b487aa85af
5 changed files with 31 additions and 0 deletions
@@ -2116,6 +2116,9 @@ void WrappedID3D11DeviceContext::SwapDeviceContextState(ID3DDeviceContextState *
{
WrappedID3DDeviceContextState *wrapped = NULL;
// need to flush pending dead now so we don't find a 'dead' wrapper below
m_pDevice->FlushPendingDead();
if(m_pDevice->GetResourceManager()->HasWrapper(prev))
{
wrapped = (WrappedID3DDeviceContextState *)m_pDevice->GetResourceManager()->GetWrapper(prev);
+7
View File
@@ -1639,6 +1639,9 @@ bool WrappedID3D11Device::Serialise_WrapSwapchainBuffer(SerialiserType &ser, IDX
IUnknown *WrappedID3D11Device::WrapSwapchainBuffer(IDXGISwapper *swapper, DXGI_FORMAT bufferFormat,
UINT buffer, IUnknown *realSurface)
{
// need to flush pending dead now so we don't find a 'dead' wrapper below
FlushPendingDead();
if(GetResourceManager()->HasWrapper((ID3D11DeviceChild *)realSurface))
{
ID3D11Texture2D *tex =
@@ -1705,6 +1708,10 @@ IDXGIResource *WrappedID3D11Device::WrapExternalDXGIResource(IDXGIResource *res)
{
ID3D11Resource *d3d11res;
res->QueryInterface(__uuidof(ID3D11Resource), (void **)&d3d11res);
// need to flush pending dead now so we don't find a 'dead' wrapper below
FlushPendingDead();
if(GetResourceManager()->HasWrapper(d3d11res))
{
ID3D11DeviceChild *wrapper = GetResourceManager()->GetWrapper(d3d11res);
@@ -132,6 +132,9 @@ HRESULT WrappedID3D11Device::CreateBlendState1(const D3D11_BLEND_DESC1 *pBlendSt
{
SCOPED_LOCK(m_D3DLock);
// need to flush pending dead now so we don't find a 'dead' wrapper below
FlushPendingDead();
// duplicate states can be returned, if Create is called with a previous descriptor
if(GetResourceManager()->HasWrapper(real))
{
@@ -239,6 +242,9 @@ HRESULT WrappedID3D11Device::CreateRasterizerState1(const D3D11_RASTERIZER_DESC1
{
SCOPED_LOCK(m_D3DLock);
// need to flush pending dead now so we don't find a 'dead' wrapper below
FlushPendingDead();
// duplicate states can be returned, if Create is called with a previous descriptor
if(GetResourceManager()->HasWrapper(real))
{
@@ -773,6 +773,9 @@ HRESULT WrappedID3D11Device::CreateRasterizerState2(const D3D11_RASTERIZER_DESC2
{
SCOPED_LOCK(m_D3DLock);
// need to flush pending dead now so we don't find a 'dead' wrapper below
FlushPendingDead();
// duplicate states can be returned, if Create is called with a previous descriptor
if(GetResourceManager()->HasWrapper(real))
{
@@ -2572,6 +2572,9 @@ HRESULT WrappedID3D11Device::CreateBlendState(const D3D11_BLEND_DESC *pBlendStat
{
SCOPED_LOCK(m_D3DLock);
// need to flush pending dead now so we don't find a 'dead' wrapper below
FlushPendingDead();
// duplicate states can be returned, if Create is called with a previous descriptor
if(GetResourceManager()->HasWrapper(real))
{
@@ -2678,6 +2681,9 @@ HRESULT WrappedID3D11Device::CreateDepthStencilState(const D3D11_DEPTH_STENCIL_D
{
SCOPED_LOCK(m_D3DLock);
// need to flush pending dead now so we don't find a 'dead' wrapper below
FlushPendingDead();
// duplicate states can be returned, if Create is called with a previous descriptor
if(GetResourceManager()->HasWrapper(real))
{
@@ -2782,6 +2788,9 @@ HRESULT WrappedID3D11Device::CreateRasterizerState(const D3D11_RASTERIZER_DESC *
{
SCOPED_LOCK(m_D3DLock);
// need to flush pending dead now so we don't find a 'dead' wrapper below
FlushPendingDead();
// duplicate states can be returned, if Create is called with a previous descriptor
if(GetResourceManager()->HasWrapper(real))
{
@@ -2886,6 +2895,9 @@ HRESULT WrappedID3D11Device::CreateSamplerState(const D3D11_SAMPLER_DESC *pSampl
{
SCOPED_LOCK(m_D3DLock);
// need to flush pending dead now so we don't find a 'dead' wrapper below
FlushPendingDead();
// duplicate states can be returned, if Create is called with a previous descriptor
if(GetResourceManager()->HasWrapper(real))
{