From affbcfe135bda3b64c6ceaaefe5c4ce56bcbdbaa Mon Sep 17 00:00:00 2001 From: Stenzek Date: Thu, 13 Jun 2024 23:28:39 +1000 Subject: [PATCH] GS/SW: Zero out texture cache buffers This _shouldn't_ be necessary, but apparently our texture min/max is wrong somewhere, and we end up sampling from "random" malloc memory, which breaks GS dump runs. --- pcsx2/GS/Renderers/SW/GSTextureCacheSW.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pcsx2/GS/Renderers/SW/GSTextureCacheSW.cpp b/pcsx2/GS/Renderers/SW/GSTextureCacheSW.cpp index 3c32648ebf..b69c95fbe9 100644 --- a/pcsx2/GS/Renderers/SW/GSTextureCacheSW.cpp +++ b/pcsx2/GS/Renderers/SW/GSTextureCacheSW.cpp @@ -225,10 +225,15 @@ bool GSTextureCacheSW::Texture::Update(const GSVector4i& rect) if (!m_buff) { const u32 pitch = (1 << m_tw) << shift; + const size_t size = pitch * th * 4; - m_buff = _aligned_malloc(pitch * th * 4, VECTOR_ALIGNMENT); + m_buff = _aligned_malloc(size, VECTOR_ALIGNMENT); if (!m_buff) return false; + + // This _shouldn't_ be necessary, but apparently our texture min/max is wrong somewhere, + // and we end up sampling from "random" malloc memory, which breaks GS dump runs. + std::memset(m_buff, 0, size); } GSLocalMemory& mem = g_gs_renderer->m_mem;