diff --git a/pcsx2/GS/Renderers/DX11/GSDevice11.cpp b/pcsx2/GS/Renderers/DX11/GSDevice11.cpp index bcce0a4ee4..1ba2219243 100644 --- a/pcsx2/GS/Renderers/DX11/GSDevice11.cpp +++ b/pcsx2/GS/Renderers/DX11/GSDevice11.cpp @@ -196,9 +196,11 @@ bool GSDevice11::Create() memset(&bsd, 0, sizeof(bsd)); - bsd.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; - - m_dev->CreateBlendState(&bsd, m_convert.bs.put()); + for (u32 i = 0; i < static_cast(m_convert.bs.size()); i++) + { + bsd.RenderTarget[0].RenderTargetWriteMask = static_cast(i); + m_dev->CreateBlendState(&bsd, m_convert.bs[i].put()); + } // merge @@ -608,26 +610,15 @@ void GSDevice11::StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* void GSDevice11::StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* dTex, const GSVector4& dRect, ID3D11PixelShader* ps, ID3D11Buffer* ps_cb, bool linear) { - StretchRect(sTex, sRect, dTex, dRect, ps, ps_cb, m_convert.bs.get(), linear); + StretchRect(sTex, sRect, dTex, dRect, ps, ps_cb, m_convert.bs[D3D11_COLOR_WRITE_ENABLE_ALL].get(), linear); } void GSDevice11::StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* dTex, const GSVector4& dRect, bool red, bool green, bool blue, bool alpha) { - D3D11_BLEND_DESC bd = {}; - - u8 write_mask = 0; - - if (red) write_mask |= D3D11_COLOR_WRITE_ENABLE_RED; - if (green) write_mask |= D3D11_COLOR_WRITE_ENABLE_GREEN; - if (blue) write_mask |= D3D11_COLOR_WRITE_ENABLE_BLUE; - if (alpha) write_mask |= D3D11_COLOR_WRITE_ENABLE_ALPHA; - - bd.RenderTarget[0].RenderTargetWriteMask = write_mask; - - wil::com_ptr_nothrow bs; - m_dev->CreateBlendState(&bd, bs.put()); - - StretchRect(sTex, sRect, dTex, dRect, m_convert.ps[static_cast(ShaderConvert::COPY)].get(), nullptr, bs.get(), false); + const u8 index = static_cast(red) | (static_cast(green) << 1) | (static_cast(blue) << 2) | + (static_cast(alpha) << 3); + StretchRect(sTex, sRect, dTex, dRect, m_convert.ps[static_cast(ShaderConvert::COPY)].get(), nullptr, + m_convert.bs[index].get(), false); } void GSDevice11::StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* dTex, const GSVector4& dRect, ID3D11PixelShader* ps, ID3D11Buffer* ps_cb, ID3D11BlendState* bs, bool linear) @@ -730,7 +721,7 @@ void GSDevice11::PresentRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* // om OMSetDepthStencilState(m_convert.dss.get(), 0); - OMSetBlendState(m_convert.bs.get(), 0); + OMSetBlendState(m_convert.bs[D3D11_COLOR_WRITE_ENABLE_ALL].get(), 0); @@ -806,7 +797,7 @@ void GSDevice11::DrawMultiStretchRects(const MultiStretchRect* rects, u32 num_re GSSetShader(nullptr, nullptr); PSSetShader(m_convert.ps[static_cast(shader)].get(), nullptr); OMSetDepthStencilState(m_convert.dss.get(), 0); - OMSetBlendState(nullptr, 0.0f); + OMSetBlendState(m_convert.bs[D3D11_COLOR_WRITE_ENABLE_ALL].get(), 0.0f); OMSetRenderTargets(dTex, nullptr); const GSVector2 ds(static_cast(dTex->GetWidth()), static_cast(dTex->GetHeight())); diff --git a/pcsx2/GS/Renderers/DX11/GSDevice11.h b/pcsx2/GS/Renderers/DX11/GSDevice11.h index 5bd9188d8d..7fde04dfcf 100644 --- a/pcsx2/GS/Renderers/DX11/GSDevice11.h +++ b/pcsx2/GS/Renderers/DX11/GSDevice11.h @@ -176,7 +176,7 @@ private: wil::com_ptr_nothrow pt; wil::com_ptr_nothrow dss; wil::com_ptr_nothrow dss_write; - wil::com_ptr_nothrow bs; + std::array, 16> bs; } m_convert; struct