Skip to content

Commit

Permalink
buffer_cache: Remove redundant page calculations.
Browse files Browse the repository at this point in the history
Called functions will convert to page numbers/addresses themselves.
  • Loading branch information
squidbus committed Dec 11, 2024
1 parent 0782008 commit 1178c14
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/video_core/buffer_cache/buffer_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,15 @@ BufferCache::~BufferCache() = default;

void BufferCache::InvalidateMemory(VAddr device_addr, u64 size) {
std::scoped_lock lk{mutex};
const auto pages_start = PageManager::GetPageAddr(device_addr);
const auto pages_end = PageManager::GetNextPageAddr(device_addr + size - 1);
const auto pages_size = pages_end - pages_start;
const bool is_tracked = IsRegionRegistered(pages_start, pages_size);
const bool is_tracked = IsRegionRegistered(device_addr, size);
if (!is_tracked) {
return;
}
// Mark the page as CPU modified to stop tracking writes.
SCOPE_EXIT {
memory_tracker.MarkRegionAsCpuModified(pages_start, pages_size);
memory_tracker.MarkRegionAsCpuModified(device_addr, size);
};
if (!memory_tracker.IsRegionGpuModified(pages_start, pages_size)) {
if (!memory_tracker.IsRegionGpuModified(device_addr, size)) {
// Page has not been modified by the GPU, nothing to do.
return;
}
Expand Down

0 comments on commit 1178c14

Please sign in to comment.