From c2a68aa0b8d35107cba76ad7d55777b6317d920c Mon Sep 17 00:00:00 2001 From: refractionpcsx2 Date: Fri, 12 Aug 2022 19:20:19 +0100 Subject: [PATCH] GS: Fix bug where incorrect verticles were saved on flush Probably didn't matter in most cases, but for autoflush draws, it certainly does. --- pcsx2/GS/GSState.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pcsx2/GS/GSState.cpp b/pcsx2/GS/GSState.cpp index c033ee67c3..0b55efc6d4 100644 --- a/pcsx2/GS/GSState.cpp +++ b/pcsx2/GS/GSState.cpp @@ -1879,6 +1879,20 @@ void GSState::FlushPrim() m_vertex.tail = unused; m_vertex.next = next > head ? next - head : 0; + + // If it's a Triangle fan the XY buffer needs to be updated to point to the correct head vert + // Jak 3 shadows get spikey (with autoflush) if you don't. + if (PRIM->PRIM == GS_TRIANGLEFAN) + { + for (int i = 0; i < unused; i++) + { + GSVector4i* RESTRICT vert_ptr = (GSVector4i*)&m_vertex.buff[i]; + GSVector4i v = vert_ptr[1]; + v = v.xxxx().u16to32().sub32(m_ofxy); + GSVector4i::storel(&m_vertex.xy[i & 3], v.blend16<0xf0>(v.sra32(4)).ps32()); + m_vertex.xy_tail = unused; + } + } } else {