diff options
| author | 2021-05-27 14:47:24 -0700 | |
|---|---|---|
| committer | 2021-05-27 14:47:24 -0700 | |
| commit | 4b95b0df973027f4682549b0bd27bf9e05d8155f (patch) | |
| tree | 652552c8f0bc1e6d0b06d463ec2d73c8f3134615 /src/video_core/rasterizer_accelerated.cpp | |
| parent | Merge pull request #6346 from lat9nq/apply-config-pgc (diff) | |
| download | yuzu-4b95b0df973027f4682549b0bd27bf9e05d8155f.tar.gz yuzu-4b95b0df973027f4682549b0bd27bf9e05d8155f.tar.xz yuzu-4b95b0df973027f4682549b0bd27bf9e05d8155f.zip | |
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.
Diffstat (limited to 'src/video_core/rasterizer_accelerated.cpp')
| -rw-r--r-- | src/video_core/rasterizer_accelerated.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/video_core/rasterizer_accelerated.cpp b/src/video_core/rasterizer_accelerated.cpp index 62d84c0f8..6decd2546 100644 --- a/src/video_core/rasterizer_accelerated.cpp +++ b/src/video_core/rasterizer_accelerated.cpp | |||
| @@ -18,10 +18,10 @@ RasterizerAccelerated::~RasterizerAccelerated() = default; | |||
| 18 | void RasterizerAccelerated::UpdatePagesCachedCount(VAddr addr, u64 size, int delta) { | 18 | void RasterizerAccelerated::UpdatePagesCachedCount(VAddr addr, u64 size, int delta) { |
| 19 | const auto page_end = Common::DivCeil(addr + size, Core::Memory::PAGE_SIZE); | 19 | const auto page_end = Common::DivCeil(addr + size, Core::Memory::PAGE_SIZE); |
| 20 | for (auto page = addr >> Core::Memory::PAGE_BITS; page != page_end; ++page) { | 20 | for (auto page = addr >> Core::Memory::PAGE_BITS; page != page_end; ++page) { |
| 21 | auto& count = cached_pages.at(page >> 3).Count(page); | 21 | auto& count = cached_pages.at(page >> 2).Count(page); |
| 22 | 22 | ||
| 23 | if (delta > 0) { | 23 | if (delta > 0) { |
| 24 | ASSERT_MSG(count < UINT8_MAX, "Count may overflow!"); | 24 | ASSERT_MSG(count < UINT16_MAX, "Count may overflow!"); |
| 25 | } else if (delta < 0) { | 25 | } else if (delta < 0) { |
| 26 | ASSERT_MSG(count > 0, "Count may underflow!"); | 26 | ASSERT_MSG(count > 0, "Count may underflow!"); |
| 27 | } else { | 27 | } else { |
| @@ -29,7 +29,7 @@ void RasterizerAccelerated::UpdatePagesCachedCount(VAddr addr, u64 size, int del | |||
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | // Adds or subtracts 1, as count is a unsigned 8-bit value | 31 | // Adds or subtracts 1, as count is a unsigned 8-bit value |
| 32 | count += static_cast<u8>(delta); | 32 | count += static_cast<u16>(delta); |
| 33 | 33 | ||
| 34 | // Assume delta is either -1 or 1 | 34 | // Assume delta is either -1 or 1 |
| 35 | if (count == 0) { | 35 | if (count == 0) { |