summaryrefslogtreecommitdiff
path: root/src/core/hw/gpu.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hw/gpu.cpp')
-rw-r--r--src/core/hw/gpu.cpp29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/core/hw/gpu.cpp b/src/core/hw/gpu.cpp
index 0ee6b7c3b..49fc574bc 100644
--- a/src/core/hw/gpu.cpp
+++ b/src/core/hw/gpu.cpp
@@ -53,10 +53,10 @@ void SetFramebufferLocation(const FramebufferLocation mode) {
53 * Gets the location of the framebuffers 53 * Gets the location of the framebuffers
54 * @return Location of framebuffers as FramebufferLocation enum 54 * @return Location of framebuffers as FramebufferLocation enum
55 */ 55 */
56const FramebufferLocation GetFramebufferLocation() { 56FramebufferLocation GetFramebufferLocation(u32 address) {
57 if ((g_regs.framebuffer_top_right_1 & ~Memory::VRAM_MASK) == Memory::VRAM_PADDR) { 57 if ((address & ~Memory::VRAM_MASK) == Memory::VRAM_PADDR) {
58 return FRAMEBUFFER_LOCATION_VRAM; 58 return FRAMEBUFFER_LOCATION_VRAM;
59 } else if ((g_regs.framebuffer_top_right_1 & ~Memory::FCRAM_MASK) == Memory::FCRAM_PADDR) { 59 } else if ((address & ~Memory::FCRAM_MASK) == Memory::FCRAM_PADDR) {
60 return FRAMEBUFFER_LOCATION_FCRAM; 60 return FRAMEBUFFER_LOCATION_FCRAM;
61 } else { 61 } else {
62 ERROR_LOG(GPU, "unknown framebuffer location!"); 62 ERROR_LOG(GPU, "unknown framebuffer location!");
@@ -64,21 +64,26 @@ const FramebufferLocation GetFramebufferLocation() {
64 return FRAMEBUFFER_LOCATION_UNKNOWN; 64 return FRAMEBUFFER_LOCATION_UNKNOWN;
65} 65}
66 66
67u32 GetFramebufferAddr(const u32 address) {
68 switch (GetFramebufferLocation(address)) {
69 case FRAMEBUFFER_LOCATION_FCRAM:
70 return Memory::VirtualAddressFromPhysical_FCRAM(address);
71 case FRAMEBUFFER_LOCATION_VRAM:
72 return Memory::VirtualAddressFromPhysical_VRAM(address);
73 default:
74 ERROR_LOG(GPU, "unknown framebuffer location");
75 }
76 return 0;
77}
78
67/** 79/**
68 * Gets a read-only pointer to a framebuffer in memory 80 * Gets a read-only pointer to a framebuffer in memory
69 * @param address Physical address of framebuffer 81 * @param address Physical address of framebuffer
70 * @return Returns const pointer to raw framebuffer 82 * @return Returns const pointer to raw framebuffer
71 */ 83 */
72const u8* GetFramebufferPointer(const u32 address) { 84const u8* GetFramebufferPointer(const u32 address) {
73 switch (GetFramebufferLocation()) { 85 u32 addr = GetFramebufferAddr(address);
74 case FRAMEBUFFER_LOCATION_FCRAM: 86 return (addr != 0) ? Memory::GetPointer(addr) : nullptr;
75 return (const u8*)Memory::GetPointer(Memory::VirtualAddressFromPhysical_FCRAM(address));
76 case FRAMEBUFFER_LOCATION_VRAM:
77 return (const u8*)Memory::GetPointer(Memory::VirtualAddressFromPhysical_VRAM(address));
78 default:
79 ERROR_LOG(GPU, "unknown framebuffer location");
80 }
81 return NULL;
82} 87}
83 88
84template <typename T> 89template <typename T>