video_core: rasterizer_accelerated: Improve error handling & fix implicit conversion.

This commit is contained in:
bunnei 2021-03-02 17:44:02 -08:00
parent 94da1e8a7e
commit 6ab839462c
1 changed files with 8 additions and 4 deletions

View File

@ -20,9 +20,15 @@ void RasterizerAccelerated::UpdatePagesCachedCount(VAddr addr, u64 size, int del
for (auto page = addr >> Core::Memory::PAGE_BITS; page != page_end; ++page) { for (auto page = addr >> Core::Memory::PAGE_BITS; page != page_end; ++page) {
auto& count = cached_pages.at(page >> 3).Count(page); auto& count = cached_pages.at(page >> 3).Count(page);
ASSERT_MSG(count < UINT8_MAX, "Count may exceed UINT8_MAX!"); if (delta < 0) {
ASSERT_MSG(count > 0, "Count may underflow!");
} else if (delta > 0) {
ASSERT_MSG(count < UINT8_MAX, "Count may overflow!");
} else {
ASSERT_MSG(true, "Delta must be non-zero!");
}
count += delta; count += static_cast<s8>(delta);
// Assume delta is either -1 or 1 // Assume delta is either -1 or 1
if (count == 0) { if (count == 0) {
@ -31,8 +37,6 @@ void RasterizerAccelerated::UpdatePagesCachedCount(VAddr addr, u64 size, int del
} else if (count == 1 && delta > 0) { } else if (count == 1 && delta > 0) {
cpu_memory.RasterizerMarkRegionCached(page << Core::Memory::PAGE_BITS, cpu_memory.RasterizerMarkRegionCached(page << Core::Memory::PAGE_BITS,
Core::Memory::PAGE_SIZE, true); Core::Memory::PAGE_SIZE, true);
} else {
ASSERT(count >= 0);
} }
} }
} }