D3D11: Ownership fixes for objects in D3DState
This commit is contained in:
parent
88db577c17
commit
77425ef83b
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue