From 2a9c379a1cbf760ad033613a2956a1c0a2f1670a Mon Sep 17 00:00:00 2001 From: lightningterror <18107717+lightningterror@users.noreply.github.com> Date: Fri, 8 Sep 2023 18:13:42 +0200 Subject: [PATCH] GS: Fix Using memset() on struct which contains a floating point number warning. Codacy. --- pcsx2/GS/Renderers/DX11/GSDevice11.cpp | 6 +++--- pcsx2/GS/Renderers/DX11/GSDevice11.h | 4 ++-- pcsx2/GS/Renderers/DX11/GSTextureFX11.cpp | 2 +- pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pcsx2/GS/Renderers/DX11/GSDevice11.cpp b/pcsx2/GS/Renderers/DX11/GSDevice11.cpp index 13277bb31f..63a2bf6db9 100644 --- a/pcsx2/GS/Renderers/DX11/GSDevice11.cpp +++ b/pcsx2/GS/Renderers/DX11/GSDevice11.cpp @@ -2019,16 +2019,16 @@ void GSDevice11::OMSetDepthStencilState(ID3D11DepthStencilState* dss, u8 sref) } } -void GSDevice11::OMSetBlendState(ID3D11BlendState* bs, float bf) +void GSDevice11::OMSetBlendState(ID3D11BlendState* bs, u8 bf) { if (m_state.bs != bs || m_state.bf != bf) { m_state.bs = bs; m_state.bf = bf; - const float BlendFactor[] = {bf, bf, bf, 0}; + const GSVector4 col(static_cast(bf) / 128.0f); - m_ctx->OMSetBlendState(bs, BlendFactor, 0xffffffff); + m_ctx->OMSetBlendState(bs, col.v, 0xffffffff); } } diff --git a/pcsx2/GS/Renderers/DX11/GSDevice11.h b/pcsx2/GS/Renderers/DX11/GSDevice11.h index f1f6741935..097c3c8eef 100644 --- a/pcsx2/GS/Renderers/DX11/GSDevice11.h +++ b/pcsx2/GS/Renderers/DX11/GSDevice11.h @@ -178,7 +178,7 @@ private: ID3D11DepthStencilState* dss; u8 sref; ID3D11BlendState* bs; - float bf; + u8 bf; ID3D11RenderTargetView* rt_view; ID3D11DepthStencilView* dsv; } m_state; @@ -352,7 +352,7 @@ public: void PSSetSamplerState(ID3D11SamplerState* ss0); void OMSetDepthStencilState(ID3D11DepthStencilState* dss, u8 sref); - void OMSetBlendState(ID3D11BlendState* bs, float bf); + void OMSetBlendState(ID3D11BlendState* bs, u8 bf); void OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVector4i* scissor = nullptr); void SetViewport(const GSVector2i& viewport); void SetScissor(const GSVector4i& scissor); diff --git a/pcsx2/GS/Renderers/DX11/GSTextureFX11.cpp b/pcsx2/GS/Renderers/DX11/GSTextureFX11.cpp index 9591d92fc4..972b902f8b 100644 --- a/pcsx2/GS/Renderers/DX11/GSTextureFX11.cpp +++ b/pcsx2/GS/Renderers/DX11/GSTextureFX11.cpp @@ -334,5 +334,5 @@ void GSDevice11::SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, u8 j = m_om_bs.try_emplace(bsel, std::move(bs)).first; } - OMSetBlendState(j->second.get(), (float)(int)afix / 0x80); + OMSetBlendState(j->second.get(), afix); } diff --git a/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp b/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp index dc2d9e7877..ae18591cd9 100644 --- a/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp +++ b/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp @@ -2230,7 +2230,7 @@ void GSDeviceOGL::OMSetBlendState(bool enable, GLenum src_factor, GLenum dst_fac if (is_constant && GLState::bf != constant) { GLState::bf = constant; - const float bf = (float)constant / 128.0f; + const float bf = static_cast(constant) / 128.0f; glBlendColor(bf, bf, bf, bf); }