diff options
| author | Silent <zdanio95@gmail.com> | 2019-07-21 15:57:15 +0200 |
|---|---|---|
| committer | Silent <zdanio95@gmail.com> | 2019-07-29 16:39:21 +0200 |
| commit | 77425ef83b70f51a113b4dceee729e875fd7e418 (patch) | |
| tree | d85457b0b263c37157256103eb6d1bf0904f7cbb /Source/Core | |
| parent | 88db577c1740186257f1a2303e619be886ea2763 (diff) | |
D3D11: Ownership fixes for objects in D3DState
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/VideoBackends/D3D/D3DState.cpp | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/Source/Core/VideoBackends/D3D/D3DState.cpp b/Source/Core/VideoBackends/D3D/D3DState.cpp index 15e84f2018..a7b56145da 100644 --- a/Source/Core/VideoBackends/D3D/D3DState.cpp +++ b/Source/Core/VideoBackends/D3D/D3DState.cpp @@ -347,10 +347,9 @@ ID3D11SamplerState* StateCache::Get(SamplerState state) } 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"); - m_sampler.emplace(state.hex, res); - return res.Get(); + return m_sampler.emplace(state.hex, std::move(res)).first->second.Get(); } ID3D11BlendState* StateCache::Get(BlendingState state) @@ -381,12 +380,11 @@ ID3D11BlendState* StateCache::Get(BlendingState state) tdesc.LogicOpEnable = TRUE; tdesc.LogicOp = logic_ops[state.logicmode]; - ID3D11BlendState1* res; - HRESULT hr = D3D::device1->CreateBlendState1(&desc, &res); + ComPtr<ID3D11BlendState1> res; + HRESULT hr = D3D::device1->CreateBlendState1(&desc, res.GetAddressOf()); if (SUCCEEDED(hr)) { - m_blend.emplace(state.hex, res); - return res; + return m_blend.emplace(state.hex, std::move(res)).first->second.Get(); } } @@ -425,10 +423,9 @@ ID3D11BlendState* StateCache::Get(BlendingState state) tdesc.BlendOpAlpha = state.subtractAlpha ? D3D11_BLEND_OP_REV_SUBTRACT : D3D11_BLEND_OP_ADD; 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"); - m_blend.emplace(state.hex, res); - return res.Get(); + return m_blend.emplace(state.hex, std::move(res)).first->second.Get(); } ID3D11RasterizerState* StateCache::Get(RasterizationState state) @@ -447,10 +444,9 @@ ID3D11RasterizerState* StateCache::Get(RasterizationState state) desc.ScissorEnable = TRUE; 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"); - m_raster.emplace(state.hex, res); - return res.Get(); + return m_raster.emplace(state.hex, std::move(res)).first->second.Get(); } ID3D11DepthStencilState* StateCache::Get(DepthState state) @@ -490,10 +486,9 @@ ID3D11DepthStencilState* StateCache::Get(DepthState state) } 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"); - m_depth.emplace(state.hex, res); - return res.Get(); + return m_depth.emplace(state.hex, std::move(res)).first->second.Get(); } D3D11_PRIMITIVE_TOPOLOGY StateCache::GetPrimitiveTopology(PrimitiveType primitive) |
