summaryrefslogtreecommitdiff
path: root/src/core/device_memory.h
diff options
context:
space:
mode:
authorGravatar liamwhite2023-03-23 10:00:19 -0400
committerGravatar GitHub2023-03-23 10:00:19 -0400
commitc41a4baf06efe935f08331bc6f8ff6d80dc088f5 (patch)
treea6580d41bd440b240b2f60db38fdeec60fca2eff /src/core/device_memory.h
parentMerge pull request #9962 from Kelebek1/disable_srgb (diff)
parentkernel: use KTypedAddress for addresses (diff)
downloadyuzu-c41a4baf06efe935f08331bc6f8ff6d80dc088f5.tar.gz
yuzu-c41a4baf06efe935f08331bc6f8ff6d80dc088f5.tar.xz
yuzu-c41a4baf06efe935f08331bc6f8ff6d80dc088f5.zip
Merge pull request #9964 from liamwhite/typed-address
kernel: use KTypedAddress for addresses
Diffstat (limited to 'src/core/device_memory.h')
-rw-r--r--src/core/device_memory.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/core/device_memory.h b/src/core/device_memory.h
index 90510733c..13388b73e 100644
--- a/src/core/device_memory.h
+++ b/src/core/device_memory.h
@@ -3,8 +3,8 @@
3 3
4#pragma once 4#pragma once
5 5
6#include "common/common_types.h"
7#include "common/host_memory.h" 6#include "common/host_memory.h"
7#include "common/typed_address.h"
8 8
9namespace Core { 9namespace Core {
10 10
@@ -25,20 +25,22 @@ public:
25 DeviceMemory(const DeviceMemory&) = delete; 25 DeviceMemory(const DeviceMemory&) = delete;
26 26
27 template <typename T> 27 template <typename T>
28 PAddr GetPhysicalAddr(const T* ptr) const { 28 Common::PhysicalAddress GetPhysicalAddr(const T* ptr) const {
29 return (reinterpret_cast<uintptr_t>(ptr) - 29 return (reinterpret_cast<uintptr_t>(ptr) -
30 reinterpret_cast<uintptr_t>(buffer.BackingBasePointer())) + 30 reinterpret_cast<uintptr_t>(buffer.BackingBasePointer())) +
31 DramMemoryMap::Base; 31 DramMemoryMap::Base;
32 } 32 }
33 33
34 template <typename T> 34 template <typename T>
35 T* GetPointer(PAddr addr) { 35 T* GetPointer(Common::PhysicalAddress addr) {
36 return reinterpret_cast<T*>(buffer.BackingBasePointer() + (addr - DramMemoryMap::Base)); 36 return reinterpret_cast<T*>(buffer.BackingBasePointer() +
37 (GetInteger(addr) - DramMemoryMap::Base));
37 } 38 }
38 39
39 template <typename T> 40 template <typename T>
40 const T* GetPointer(PAddr addr) const { 41 const T* GetPointer(Common::PhysicalAddress addr) const {
41 return reinterpret_cast<T*>(buffer.BackingBasePointer() + (addr - DramMemoryMap::Base)); 42 return reinterpret_cast<T*>(buffer.BackingBasePointer() +
43 (GetInteger(addr) - DramMemoryMap::Base));
42 } 44 }
43 45
44 Common::HostMemory buffer; 46 Common::HostMemory buffer;