[d3d11] Use private temporary references for state objects

We really shouldn't be altering the application-visible ref
count when sending these objects to the CS thread.
This commit is contained in:
Philip Rebohle 2019-07-17 20:01:57 +02:00
parent 21a2ce045f
commit 7225674088
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
1 changed files with 24 additions and 11 deletions

View File

@ -2957,8 +2957,12 @@ namespace dxvk {
void D3D11DeviceContext::ApplyInputLayout() { void D3D11DeviceContext::ApplyInputLayout() {
if (m_state.ia.inputLayout != nullptr) { auto inputLayout = m_state.ia.inputLayout.prvRef();
EmitCs([cInputLayout = m_state.ia.inputLayout] (DxvkContext* ctx) {
if (likely(inputLayout != nullptr)) {
EmitCs([
cInputLayout = std::move(inputLayout)
] (DxvkContext* ctx) {
cInputLayout->BindToContext(ctx); cInputLayout->BindToContext(ctx);
}); });
} else { } else {
@ -3003,10 +3007,13 @@ namespace dxvk {
void D3D11DeviceContext::ApplyBlendState() { void D3D11DeviceContext::ApplyBlendState() {
auto cbState = m_state.om.cbState.prvRef();
if (unlikely(cbState == nullptr))
cbState = m_defaultBlendState.prvRef();
EmitCs([ EmitCs([
cBlendState = m_state.om.cbState != nullptr cBlendState = std::move(cbState),
? m_state.om.cbState
: m_defaultBlendState,
cSampleMask = m_state.om.sampleMask cSampleMask = m_state.om.sampleMask
] (DxvkContext* ctx) { ] (DxvkContext* ctx) {
cBlendState->BindToContext(ctx, cSampleMask); cBlendState->BindToContext(ctx, cSampleMask);
@ -3026,10 +3033,13 @@ namespace dxvk {
void D3D11DeviceContext::ApplyDepthStencilState() { void D3D11DeviceContext::ApplyDepthStencilState() {
auto dsState = m_state.om.dsState.prvRef();
if (unlikely(dsState == nullptr))
dsState = m_defaultDepthStencilState.prvRef();
EmitCs([ EmitCs([
cDepthStencilState = m_state.om.dsState != nullptr cDepthStencilState = std::move(dsState)
? m_state.om.dsState
: m_defaultDepthStencilState
] (DxvkContext* ctx) { ] (DxvkContext* ctx) {
cDepthStencilState->BindToContext(ctx); cDepthStencilState->BindToContext(ctx);
}); });
@ -3046,10 +3056,13 @@ namespace dxvk {
void D3D11DeviceContext::ApplyRasterizerState() { void D3D11DeviceContext::ApplyRasterizerState() {
auto rsState = m_state.rs.state.prvRef();
if (unlikely(rsState == nullptr))
rsState = m_defaultRasterizerState.prvRef();
EmitCs([ EmitCs([
cRasterizerState = m_state.rs.state != nullptr cRasterizerState = std::move(rsState)
? m_state.rs.state
: m_defaultRasterizerState
] (DxvkContext* ctx) { ] (DxvkContext* ctx) {
cRasterizerState->BindToContext(ctx); cRasterizerState->BindToContext(ctx);
}); });