diff options
| author | 2017-07-22 10:15:52 +0300 | |
|---|---|---|
| committer | 2017-07-22 10:15:52 +0300 | |
| commit | 045d0b5bbdf790952ddfedcfc8816c0afc7a2300 (patch) | |
| tree | fba1a440adf7d7ecd59edaf48e215e70b7c6cf9e /src/core/memory.h | |
| parent | Merge pull request #2833 from j-selby/single-header-json (diff) | |
| parent | Memory: Add function to flush a virtual range from the rasterizer cache (diff) | |
| download | yuzu-045d0b5bbdf790952ddfedcfc8816c0afc7a2300.tar.gz yuzu-045d0b5bbdf790952ddfedcfc8816c0afc7a2300.tar.xz yuzu-045d0b5bbdf790952ddfedcfc8816c0afc7a2300.zip | |
Merge pull request #2799 from yuriks/virtual-cached-range-flush
Add address conversion functions returning optional, Add function to flush virtual region from rasterizer cache
Diffstat (limited to 'src/core/memory.h')
| -rw-r--r-- | src/core/memory.h | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/src/core/memory.h b/src/core/memory.h index 71fb278ad..c8c56babd 100644 --- a/src/core/memory.h +++ b/src/core/memory.h | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | #include <array> | 7 | #include <array> |
| 8 | #include <cstddef> | 8 | #include <cstddef> |
| 9 | #include <string> | 9 | #include <string> |
| 10 | #include <boost/optional.hpp> | ||
| 10 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 11 | 12 | ||
| 12 | namespace Memory { | 13 | namespace Memory { |
| @@ -148,15 +149,23 @@ u8* GetPointer(VAddr virtual_address); | |||
| 148 | std::string ReadCString(VAddr virtual_address, std::size_t max_length); | 149 | std::string ReadCString(VAddr virtual_address, std::size_t max_length); |
| 149 | 150 | ||
| 150 | /** | 151 | /** |
| 151 | * Converts a virtual address inside a region with 1:1 mapping to physical memory to a physical | 152 | * Converts a virtual address inside a region with 1:1 mapping to physical memory to a physical |
| 152 | * address. This should be used by services to translate addresses for use by the hardware. | 153 | * address. This should be used by services to translate addresses for use by the hardware. |
| 153 | */ | 154 | */ |
| 155 | boost::optional<PAddr> TryVirtualToPhysicalAddress(VAddr addr); | ||
| 156 | |||
| 157 | /** | ||
| 158 | * Converts a virtual address inside a region with 1:1 mapping to physical memory to a physical | ||
| 159 | * address. This should be used by services to translate addresses for use by the hardware. | ||
| 160 | * | ||
| 161 | * @deprecated Use TryVirtualToPhysicalAddress(), which reports failure. | ||
| 162 | */ | ||
| 154 | PAddr VirtualToPhysicalAddress(VAddr addr); | 163 | PAddr VirtualToPhysicalAddress(VAddr addr); |
| 155 | 164 | ||
| 156 | /** | 165 | /** |
| 157 | * Undoes a mapping performed by VirtualToPhysicalAddress(). | 166 | * Undoes a mapping performed by VirtualToPhysicalAddress(). |
| 158 | */ | 167 | */ |
| 159 | VAddr PhysicalToVirtualAddress(PAddr addr); | 168 | boost::optional<VAddr> PhysicalToVirtualAddress(PAddr addr); |
| 160 | 169 | ||
| 161 | /** | 170 | /** |
| 162 | * Gets a pointer to the memory region beginning at the specified physical address. | 171 | * Gets a pointer to the memory region beginning at the specified physical address. |
| @@ -181,6 +190,19 @@ void RasterizerFlushRegion(PAddr start, u32 size); | |||
| 181 | */ | 190 | */ |
| 182 | void RasterizerFlushAndInvalidateRegion(PAddr start, u32 size); | 191 | void RasterizerFlushAndInvalidateRegion(PAddr start, u32 size); |
| 183 | 192 | ||
| 193 | enum class FlushMode { | ||
| 194 | /// Write back modified surfaces to RAM | ||
| 195 | Flush, | ||
| 196 | /// Write back modified surfaces to RAM, and also remove them from the cache | ||
| 197 | FlushAndInvalidate, | ||
| 198 | }; | ||
| 199 | |||
| 200 | /** | ||
| 201 | * Flushes and invalidates any externally cached rasterizer resources touching the given virtual | ||
| 202 | * address region. | ||
| 203 | */ | ||
| 204 | void RasterizerFlushVirtualRegion(VAddr start, u32 size, FlushMode mode); | ||
| 205 | |||
| 184 | /** | 206 | /** |
| 185 | * Dynarmic has an optimization to memory accesses when the pointer to the page exists that | 207 | * Dynarmic has an optimization to memory accesses when the pointer to the page exists that |
| 186 | * can be used by setting up the current page table as a callback. This function is used to | 208 | * can be used by setting up the current page table as a callback. This function is used to |