Skip to content
Permalink
Browse files

D3D11: Ownership fixes for objects in D3DState

  • Loading branch information...
CookiePLMonster committed Jul 21, 2019
1 parent 88db577 commit 77425ef83b70f51a113b4dceee729e875fd7e418
Showing with 11 additions and 16 deletions.
  1. +11 −16 Source/Core/VideoBackends/D3D/D3DState.cpp
@@ -347,10 +347,9 @@ ID3D11SamplerState* StateCache::Get(SamplerState state)
} }


ComPtr<ID3D11SamplerState> res; ComPtr<ID3D11SamplerState> res;
HRESULT hr = D3D::device->CreateSamplerState(&sampdc, &res); HRESULT hr = D3D::device->CreateSamplerState(&sampdc, res.GetAddressOf());
CHECK(SUCCEEDED(hr), "Creating D3D sampler state failed"); CHECK(SUCCEEDED(hr), "Creating D3D sampler state failed");
m_sampler.emplace(state.hex, res); return m_sampler.emplace(state.hex, std::move(res)).first->second.Get();
return res.Get();
} }


ID3D11BlendState* StateCache::Get(BlendingState state) ID3D11BlendState* StateCache::Get(BlendingState state)
@@ -381,12 +380,11 @@ ID3D11BlendState* StateCache::Get(BlendingState state)
tdesc.LogicOpEnable = TRUE; tdesc.LogicOpEnable = TRUE;
tdesc.LogicOp = logic_ops[state.logicmode]; tdesc.LogicOp = logic_ops[state.logicmode];


ID3D11BlendState1* res; ComPtr<ID3D11BlendState1> res;
HRESULT hr = D3D::device1->CreateBlendState1(&desc, &res); HRESULT hr = D3D::device1->CreateBlendState1(&desc, res.GetAddressOf());
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
m_blend.emplace(state.hex, res); return m_blend.emplace(state.hex, std::move(res)).first->second.Get();
return res;
} }
} }


@@ -425,10 +423,9 @@ ID3D11BlendState* StateCache::Get(BlendingState state)
tdesc.BlendOpAlpha = state.subtractAlpha ? D3D11_BLEND_OP_REV_SUBTRACT : D3D11_BLEND_OP_ADD; tdesc.BlendOpAlpha = state.subtractAlpha ? D3D11_BLEND_OP_REV_SUBTRACT : D3D11_BLEND_OP_ADD;


ComPtr<ID3D11BlendState> res; ComPtr<ID3D11BlendState> res;
HRESULT hr = D3D::device->CreateBlendState(&desc, &res); HRESULT hr = D3D::device->CreateBlendState(&desc, res.GetAddressOf());
CHECK(SUCCEEDED(hr), "Creating D3D blend state failed"); CHECK(SUCCEEDED(hr), "Creating D3D blend state failed");
m_blend.emplace(state.hex, res); return m_blend.emplace(state.hex, std::move(res)).first->second.Get();
return res.Get();
} }


ID3D11RasterizerState* StateCache::Get(RasterizationState state) ID3D11RasterizerState* StateCache::Get(RasterizationState state)
@@ -447,10 +444,9 @@ ID3D11RasterizerState* StateCache::Get(RasterizationState state)
desc.ScissorEnable = TRUE; desc.ScissorEnable = TRUE;


ComPtr<ID3D11RasterizerState> res; ComPtr<ID3D11RasterizerState> res;
HRESULT hr = D3D::device->CreateRasterizerState(&desc, &res); HRESULT hr = D3D::device->CreateRasterizerState(&desc, res.GetAddressOf());
CHECK(SUCCEEDED(hr), "Creating D3D rasterizer state failed"); CHECK(SUCCEEDED(hr), "Creating D3D rasterizer state failed");
m_raster.emplace(state.hex, res); return m_raster.emplace(state.hex, std::move(res)).first->second.Get();
return res.Get();
} }


ID3D11DepthStencilState* StateCache::Get(DepthState state) ID3D11DepthStencilState* StateCache::Get(DepthState state)
@@ -490,10 +486,9 @@ ID3D11DepthStencilState* StateCache::Get(DepthState state)
} }


ComPtr<ID3D11DepthStencilState> res; ComPtr<ID3D11DepthStencilState> res;
HRESULT hr = D3D::device->CreateDepthStencilState(&depthdc, &res); HRESULT hr = D3D::device->CreateDepthStencilState(&depthdc, res.GetAddressOf());
CHECK(SUCCEEDED(hr), "Creating D3D depth stencil state failed"); CHECK(SUCCEEDED(hr), "Creating D3D depth stencil state failed");
m_depth.emplace(state.hex, res); return m_depth.emplace(state.hex, std::move(res)).first->second.Get();
return res.Get();
} }


D3D11_PRIMITIVE_TOPOLOGY StateCache::GetPrimitiveTopology(PrimitiveType primitive) D3D11_PRIMITIVE_TOPOLOGY StateCache::GetPrimitiveTopology(PrimitiveType primitive)

0 comments on commit 77425ef

Please sign in to comment.
You can’t perform that action at this time.