summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar James Rowe2016-11-24 12:42:32 -0700
committerGravatar James Rowe2016-11-24 20:41:18 -0700
commitbbe57a66cad1b4159f351bf55f84c97040b04753 (patch)
treea2643734bf9af63e5a8f44ff7207e6f8848267f0
parentCache Vertices instead of Output registers (#2165) (diff)
downloadyuzu-bbe57a66cad1b4159f351bf55f84c97040b04753.tar.gz
yuzu-bbe57a66cad1b4159f351bf55f84c97040b04753.tar.xz
yuzu-bbe57a66cad1b4159f351bf55f84c97040b04753.zip
Expose page table to dynarmic for optimized reads and writes to the JIT
Diffstat (limited to '')
-rw-r--r--src/core/arm/dynarmic/arm_dynarmic.cpp1
-rw-r--r--src/core/memory.cpp14
-rw-r--r--src/core/memory.h9
3 files changed, 18 insertions, 6 deletions
diff --git a/src/core/arm/dynarmic/arm_dynarmic.cpp b/src/core/arm/dynarmic/arm_dynarmic.cpp
index b4444c869..2595defdf 100644
--- a/src/core/arm/dynarmic/arm_dynarmic.cpp
+++ b/src/core/arm/dynarmic/arm_dynarmic.cpp
@@ -52,6 +52,7 @@ static Dynarmic::UserCallbacks GetUserCallbacks(ARMul_State* interpeter_state) {
52 user_callbacks.MemoryWrite16 = &Memory::Write16; 52 user_callbacks.MemoryWrite16 = &Memory::Write16;
53 user_callbacks.MemoryWrite32 = &Memory::Write32; 53 user_callbacks.MemoryWrite32 = &Memory::Write32;
54 user_callbacks.MemoryWrite64 = &Memory::Write64; 54 user_callbacks.MemoryWrite64 = &Memory::Write64;
55 user_callbacks.page_table = Memory::GetCurrentPageTablePointers();
55 return user_callbacks; 56 return user_callbacks;
56} 57}
57 58
diff --git a/src/core/memory.cpp b/src/core/memory.cpp
index 64c388374..65e4bba85 100644
--- a/src/core/memory.cpp
+++ b/src/core/memory.cpp
@@ -45,13 +45,11 @@ struct SpecialRegion {
45 * requires an indexed fetch and a check for NULL. 45 * requires an indexed fetch and a check for NULL.
46 */ 46 */
47struct PageTable { 47struct PageTable {
48 static const size_t NUM_ENTRIES = 1 << (32 - PAGE_BITS);
49
50 /** 48 /**
51 * Array of memory pointers backing each page. An entry can only be non-null if the 49 * Array of memory pointers backing each page. An entry can only be non-null if the
52 * corresponding entry in the `attributes` array is of type `Memory`. 50 * corresponding entry in the `attributes` array is of type `Memory`.
53 */ 51 */
54 std::array<u8*, NUM_ENTRIES> pointers; 52 std::array<u8*, PAGE_TABLE_NUM_ENTRIES> pointers;
55 53
56 /** 54 /**
57 * Contains MMIO handlers that back memory regions whose entries in the `attribute` array is of 55 * Contains MMIO handlers that back memory regions whose entries in the `attribute` array is of
@@ -63,13 +61,13 @@ struct PageTable {
63 * Array of fine grained page attributes. If it is set to any value other than `Memory`, then 61 * Array of fine grained page attributes. If it is set to any value other than `Memory`, then
64 * the corresponding entry in `pointers` MUST be set to null. 62 * the corresponding entry in `pointers` MUST be set to null.
65 */ 63 */
66 std::array<PageType, NUM_ENTRIES> attributes; 64 std::array<PageType, PAGE_TABLE_NUM_ENTRIES> attributes;
67 65
68 /** 66 /**
69 * Indicates the number of externally cached resources touching a page that should be 67 * Indicates the number of externally cached resources touching a page that should be
70 * flushed before the memory is accessed 68 * flushed before the memory is accessed
71 */ 69 */
72 std::array<u8, NUM_ENTRIES> cached_res_count; 70 std::array<u8, PAGE_TABLE_NUM_ENTRIES> cached_res_count;
73}; 71};
74 72
75/// Singular page table used for the singleton process 73/// Singular page table used for the singleton process
@@ -77,6 +75,10 @@ static PageTable main_page_table;
77/// Currently active page table 75/// Currently active page table
78static PageTable* current_page_table = &main_page_table; 76static PageTable* current_page_table = &main_page_table;
79 77
78std::array<u8*, PAGE_TABLE_NUM_ENTRIES>* GetCurrentPageTablePointers() {
79 return &current_page_table->pointers;
80}
81
80static void MapPages(u32 base, u32 size, u8* memory, PageType type) { 82static void MapPages(u32 base, u32 size, u8* memory, PageType type) {
81 LOG_DEBUG(HW_Memory, "Mapping %p onto %08X-%08X", memory, base * PAGE_SIZE, 83 LOG_DEBUG(HW_Memory, "Mapping %p onto %08X-%08X", memory, base * PAGE_SIZE,
82 (base + size) * PAGE_SIZE); 84 (base + size) * PAGE_SIZE);
@@ -84,7 +86,7 @@ static void MapPages(u32 base, u32 size, u8* memory, PageType type) {
84 u32 end = base + size; 86 u32 end = base + size;
85 87
86 while (base != end) { 88 while (base != end) {
87 ASSERT_MSG(base < PageTable::NUM_ENTRIES, "out of range mapping at %08X", base); 89 ASSERT_MSG(base < PAGE_TABLE_NUM_ENTRIES, "out of range mapping at %08X", base);
88 90
89 // Since pages are unmapped on shutdown after video core is shutdown, the renderer may be 91 // Since pages are unmapped on shutdown after video core is shutdown, the renderer may be
90 // null here 92 // null here
diff --git a/src/core/memory.h b/src/core/memory.h
index 8fd3080ff..903b58a22 100644
--- a/src/core/memory.h
+++ b/src/core/memory.h
@@ -4,6 +4,7 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <array>
7#include <cstddef> 8#include <cstddef>
8#include <string> 9#include <string>
9#include "common/common_types.h" 10#include "common/common_types.h"
@@ -17,6 +18,7 @@ namespace Memory {
17const u32 PAGE_SIZE = 0x1000; 18const u32 PAGE_SIZE = 0x1000;
18const u32 PAGE_MASK = PAGE_SIZE - 1; 19const u32 PAGE_MASK = PAGE_SIZE - 1;
19const int PAGE_BITS = 12; 20const int PAGE_BITS = 12;
21const size_t PAGE_TABLE_NUM_ENTRIES = 1 << (32 - PAGE_BITS);
20 22
21/// Physical memory regions as seen from the ARM11 23/// Physical memory regions as seen from the ARM11
22enum : PAddr { 24enum : PAddr {
@@ -166,4 +168,11 @@ void RasterizerFlushRegion(PAddr start, u32 size);
166 * Flushes and invalidates any externally cached rasterizer resources touching the given region. 168 * Flushes and invalidates any externally cached rasterizer resources touching the given region.
167 */ 169 */
168void RasterizerFlushAndInvalidateRegion(PAddr start, u32 size); 170void RasterizerFlushAndInvalidateRegion(PAddr start, u32 size);
171
172/**
173 * Dynarmic has an optimization to memory accesses when the pointer to the page exists that
174 * can be used by setting up the current page table as a callback. This function is used to
175 * retrieve the current page table for that purpose.
176 */
177std::array<u8*, PAGE_TABLE_NUM_ENTRIES>* GetCurrentPageTablePointers();
169} 178}