From fb5b465a4e8c9364d1320dfb49e12cd301254978 Mon Sep 17 00:00:00 2001 From: refractionpcsx2 Date: Wed, 15 Jun 2022 05:54:54 +0100 Subject: [PATCH] GS: Fix overflow calculation from errantly going off. --- pcsx2/GS/GSState.cpp | 12 ++++-------- pcsx2/GS/GSState.h | 1 - 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/pcsx2/GS/GSState.cpp b/pcsx2/GS/GSState.cpp index 5556b693c0..83a739189b 100644 --- a/pcsx2/GS/GSState.cpp +++ b/pcsx2/GS/GSState.cpp @@ -3792,7 +3792,6 @@ GIFRegTEX0 GSState::GetTex0Layer(u32 lod) GSState::GSTransferBuffer::GSTransferBuffer() { x = y = 0; - overflow = false; start = end = total = 0; constexpr size_t alloc_size = 1024 * 1024 * 4; @@ -3814,24 +3813,21 @@ void GSState::GSTransferBuffer::Init(int tx, int ty, const GIFRegBITBLTBUF& blit bool GSState::GSTransferBuffer::Update(int tw, int th, int bpp, int& len) { - u32 packet_size = 0; - u32 tex_size = 0; + int tex_size = (((tw * th * bpp) + 7) >> 3); // Round to nearest byte + int packet_size = (tex_size + 15) & ~0xF; // Round up to the nearest quadword + if (total == 0) { start = end = 0; - tex_size = (((tw * th * bpp) + 7) >> 3); - packet_size = (tex_size + 15) & ~0xF; // Round up to the nearest quadword total = std::min(tex_size, 1024 * 1024 * 4); - overflow = false; } const int remaining = total - end; if (len > remaining) { - if (!overflow && len > packet_size) + if (len > packet_size) { - overflow = true; #if defined(PCSX2_DEVBUILD) || defined(_DEBUG) Console.Warning("GS transfer buffer overflow len %d remaining %d, tex_size %d tw %d th %d bpp %d", len, remaining, tex_size, tw, th, bpp); #endif diff --git a/pcsx2/GS/GSState.h b/pcsx2/GS/GSState.h index c2ff670401..ccd34d66ac 100644 --- a/pcsx2/GS/GSState.h +++ b/pcsx2/GS/GSState.h @@ -132,7 +132,6 @@ class GSState : public GSAlignedClass<32> { int x, y; int start, end, total; - bool overflow; u8* buff; GIFRegBITBLTBUF m_blit;