GS/HW: Fix crash when looping memory during clear

This commit is contained in:
refractionpcsx2 2023-09-16 16:09:06 +01:00
parent 3dcc6dc299
commit 43f658a82b
1 changed files with 3 additions and 0 deletions

View File

@ -5952,6 +5952,7 @@ void GSRendererHW::ClearGSLocalMemory(const GSOffset& off, const GSVector4i& r,
pxAssert((off.bp() & (BLOCKS_PER_PAGE - 1)) == 0); pxAssert((off.bp() & (BLOCKS_PER_PAGE - 1)) == 0);
for (u32 current_page = off.bp() >> 5; top < page_aligned_bottom; top += pgs.y, current_page += fbw) for (u32 current_page = off.bp() >> 5; top < page_aligned_bottom; top += pgs.y, current_page += fbw)
{ {
current_page &= 0x7ff;
GSVector4i* ptr = reinterpret_cast<GSVector4i*>(m_mem.vm8() + current_page * PAGE_SIZE); GSVector4i* ptr = reinterpret_cast<GSVector4i*>(m_mem.vm8() + current_page * PAGE_SIZE);
GSVector4i* const ptr_end = ptr + iterations_per_page; GSVector4i* const ptr_end = ptr + iterations_per_page;
while (ptr != ptr_end) while (ptr != ptr_end)
@ -5966,6 +5967,7 @@ void GSRendererHW::ClearGSLocalMemory(const GSOffset& off, const GSVector4i& r,
pxAssert((off.bp() & (BLOCKS_PER_PAGE - 1)) == 0); pxAssert((off.bp() & (BLOCKS_PER_PAGE - 1)) == 0);
for (u32 current_page = off.bp() >> 5; top < page_aligned_bottom; top += pgs.y, current_page += fbw) for (u32 current_page = off.bp() >> 5; top < page_aligned_bottom; top += pgs.y, current_page += fbw)
{ {
current_page &= 0x7ff;
GSVector4i* ptr = reinterpret_cast<GSVector4i*>(m_mem.vm8() + current_page * PAGE_SIZE); GSVector4i* ptr = reinterpret_cast<GSVector4i*>(m_mem.vm8() + current_page * PAGE_SIZE);
GSVector4i* const ptr_end = ptr + iterations_per_page; GSVector4i* const ptr_end = ptr + iterations_per_page;
while (ptr != ptr_end) while (ptr != ptr_end)
@ -5984,6 +5986,7 @@ void GSRendererHW::ClearGSLocalMemory(const GSOffset& off, const GSVector4i& r,
pxAssert((off.bp() & (BLOCKS_PER_PAGE - 1)) == 0); pxAssert((off.bp() & (BLOCKS_PER_PAGE - 1)) == 0);
for (u32 current_page = off.bp() >> 5; top < page_aligned_bottom; top += pgs.y, current_page += fbw) for (u32 current_page = off.bp() >> 5; top < page_aligned_bottom; top += pgs.y, current_page += fbw)
{ {
current_page &= 0x7ff;
GSVector4i* ptr = reinterpret_cast<GSVector4i*>(m_mem.vm8() + current_page * PAGE_SIZE); GSVector4i* ptr = reinterpret_cast<GSVector4i*>(m_mem.vm8() + current_page * PAGE_SIZE);
GSVector4i* const ptr_end = ptr + iterations_per_page; GSVector4i* const ptr_end = ptr + iterations_per_page;
while (ptr != ptr_end) while (ptr != ptr_end)