summaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2021-11-11 21:24:40 +0100
committerFernando Sahmkow <fsahmkow27@gmail.com>2022-10-06 21:00:51 +0200
commitcbaf3fb433a351f7d9509f17f88d4896ba66afd1 (patch)
tree08790ccd701bc894e49d4f13f64703caeb8129db /src/common
parentCommon: implement MultiLevelPageTable. (diff)
downloadyuzu-cbaf3fb433a351f7d9509f17f88d4896ba66afd1.tar
yuzu-cbaf3fb433a351f7d9509f17f88d4896ba66afd1.tar.gz
yuzu-cbaf3fb433a351f7d9509f17f88d4896ba66afd1.tar.bz2
yuzu-cbaf3fb433a351f7d9509f17f88d4896ba66afd1.tar.lz
yuzu-cbaf3fb433a351f7d9509f17f88d4896ba66afd1.tar.xz
yuzu-cbaf3fb433a351f7d9509f17f88d4896ba66afd1.tar.zst
yuzu-cbaf3fb433a351f7d9509f17f88d4896ba66afd1.zip
Diffstat (limited to 'src/common')
-rw-r--r--src/common/multi_level_page_table.cpp1
-rw-r--r--src/common/multi_level_page_table.inc7
2 files changed, 4 insertions, 4 deletions
diff --git a/src/common/multi_level_page_table.cpp b/src/common/multi_level_page_table.cpp
index 561785ca7..aed04d0b5 100644
--- a/src/common/multi_level_page_table.cpp
+++ b/src/common/multi_level_page_table.cpp
@@ -4,4 +4,5 @@ namespace Common {
template class Common::MultiLevelPageTable<GPUVAddr>;
template class Common::MultiLevelPageTable<VAddr>;
template class Common::MultiLevelPageTable<PAddr>;
+template class Common::MultiLevelPageTable<u32>;
} // namespace Common
diff --git a/src/common/multi_level_page_table.inc b/src/common/multi_level_page_table.inc
index a75e61f9d..7fbcb908a 100644
--- a/src/common/multi_level_page_table.inc
+++ b/src/common/multi_level_page_table.inc
@@ -20,7 +20,7 @@ MultiLevelPageTable<BaseAddr>::MultiLevelPageTable(std::size_t address_space_bit
: address_space_bits{address_space_bits_},
first_level_bits{first_level_bits_}, page_bits{page_bits_} {
first_level_shift = address_space_bits - first_level_bits;
- first_level_chunk_size = 1ULL << (first_level_shift - page_bits);
+ first_level_chunk_size = (1ULL << (first_level_shift - page_bits)) * sizeof(BaseAddr);
alloc_size = (1ULL << (address_space_bits - page_bits)) * sizeof(BaseAddr);
std::size_t first_level_size = 1ULL << first_level_bits;
first_level_map.resize(first_level_size, nullptr);
@@ -53,8 +53,7 @@ MultiLevelPageTable<BaseAddr>::~MultiLevelPageTable() noexcept {
template <typename BaseAddr>
void MultiLevelPageTable<BaseAddr>::ReserveRange(u64 start, std::size_t size) {
const u64 new_start = start >> first_level_shift;
- const u64 new_end =
- (start + size + (first_level_chunk_size << page_bits) - 1) >> first_level_shift;
+ const u64 new_end = (start + size) >> first_level_shift;
for (u64 i = new_start; i <= new_end; i++) {
if (!first_level_map[i]) {
AllocateLevel(i);
@@ -64,7 +63,7 @@ void MultiLevelPageTable<BaseAddr>::ReserveRange(u64 start, std::size_t size) {
template <typename BaseAddr>
void MultiLevelPageTable<BaseAddr>::AllocateLevel(u64 level) {
- void* ptr = reinterpret_cast<char*>(base_ptr) + level * first_level_chunk_size;
+ void* ptr = reinterpret_cast<char *>(base_ptr) + level * first_level_chunk_size;
#ifdef _WIN32
void* base{VirtualAlloc(ptr, first_level_chunk_size, MEM_COMMIT, PAGE_READWRITE)};
#else