page_table.cpp 1.1 KB

1234567891011121314151617181920212223242526272829
  1. // Copyright 2019 yuzu Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include "common/page_table.h"
  5. namespace Common {
  6. PageTable::PageTable(std::size_t page_size_in_bits) : page_size_in_bits{page_size_in_bits} {}
  7. PageTable::~PageTable() = default;
  8. void PageTable::Resize(std::size_t address_space_width_in_bits) {
  9. const std::size_t num_page_table_entries = 1ULL
  10. << (address_space_width_in_bits - page_size_in_bits);
  11. pointers.resize(num_page_table_entries);
  12. attributes.resize(num_page_table_entries);
  13. // The default is a 39-bit address space, which causes an initial 1GB allocation size. If the
  14. // vector size is subsequently decreased (via resize), the vector might not automatically
  15. // actually reallocate/resize its underlying allocation, which wastes up to ~800 MB for
  16. // 36-bit titles. Call shrink_to_fit to reduce capacity to what's actually in use.
  17. pointers.shrink_to_fit();
  18. attributes.shrink_to_fit();
  19. }
  20. } // namespace Common