video_core: rasterizer_cache: Use u16 for cached page count.

- Greatly reduces the risk of overflow, at the cost of doubling the size of this array.
This commit is contained in:
bunnei 2021-05-27 14:47:24 -07:00
parent 9110cfdefb
commit 4b95b0df97
2 changed files with 9 additions and 9 deletions

View file

@ -29,20 +29,20 @@ private:
public:
CacheEntry() = default;
std::atomic_uint8_t& Count(std::size_t page) {
return values[page & 7];
std::atomic_uint16_t& Count(std::size_t page) {
return values[page & 3];
}
const std::atomic_uint8_t& Count(std::size_t page) const {
return values[page & 7];
const std::atomic_uint16_t& Count(std::size_t page) const {
return values[page & 3];
}
private:
std::array<std::atomic_uint8_t, 8> values{};
std::array<std::atomic_uint16_t, 4> values{};
};
static_assert(sizeof(CacheEntry) == 8, "CacheEntry should be 8 bytes!");
std::array<CacheEntry, 0x800000> cached_pages;
std::array<CacheEntry, 0x1000000> cached_pages;
Core::Memory::Memory& cpu_memory;
};