VIF: Handle edge case of direct qword buffer transfer.

If buffer contained a SIGNAL command that isn't ready to be processed, VIF state would get bad. Fixes hang in Million Monkeys.
This commit is contained in:
Jean-Philip Desjardins 2025-04-04 08:49:37 -04:00
parent 225e37d0dc
commit 64c63f1b03

View file

@ -166,7 +166,7 @@ void CVif1::Cmd_DIRECT(StreamType& stream, CODE nCommand)
if(hasPartialQword)
{
//Read enough bytes to try to complete our qword
assert(m_directQwordBufferIndex < QWORD_SIZE);
assert(m_directQwordBufferIndex <= QWORD_SIZE);
uint32 readAmount = std::min(nSize, QWORD_SIZE - m_directQwordBufferIndex);
stream.Read(m_directQwordBuffer + m_directQwordBufferIndex, readAmount);
m_directQwordBufferIndex += readAmount;
@ -176,13 +176,16 @@ void CVif1::Cmd_DIRECT(StreamType& stream, CODE nCommand)
if(m_directQwordBufferIndex == QWORD_SIZE)
{
assert(m_CODE.nIMM != 0);
FRAMEWORK_MAYBE_UNUSED uint32 processed = m_gif.ProcessMultiplePackets(m_directQwordBuffer,
uint32 processed = m_gif.ProcessMultiplePackets(m_directQwordBuffer,
QWORD_SIZE, 0, QWORD_SIZE, CGsPacketMetadata(2));
if(processed != 0)
{
assert(processed == QWORD_SIZE);
m_CODE.nIMM--;
m_directQwordBufferIndex = 0;
}
}
}
//If no data pending in our partial qword buffer, go forward with multiple qword transfer
if(m_directQwordBufferIndex == 0)