mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-22 19:00:14 -05:00
GPU: Interface cleanup.
This commit is contained in:
parent
46950ee4de
commit
9d618d0b70
2 changed files with 20 additions and 13 deletions
|
@ -53,10 +53,10 @@ void SetFramebufferLocation(const FramebufferLocation mode) {
|
||||||
* Gets the location of the framebuffers
|
* Gets the location of the framebuffers
|
||||||
* @return Location of framebuffers as FramebufferLocation enum
|
* @return Location of framebuffers as FramebufferLocation enum
|
||||||
*/
|
*/
|
||||||
const FramebufferLocation GetFramebufferLocation() {
|
FramebufferLocation GetFramebufferLocation(u32 address) {
|
||||||
if ((g_regs.framebuffer_top_right_1 & ~Memory::VRAM_MASK) == Memory::VRAM_PADDR) {
|
if ((address & ~Memory::VRAM_MASK) == Memory::VRAM_PADDR) {
|
||||||
return FRAMEBUFFER_LOCATION_VRAM;
|
return FRAMEBUFFER_LOCATION_VRAM;
|
||||||
} else if ((g_regs.framebuffer_top_right_1 & ~Memory::FCRAM_MASK) == Memory::FCRAM_PADDR) {
|
} else if ((address & ~Memory::FCRAM_MASK) == Memory::FCRAM_PADDR) {
|
||||||
return FRAMEBUFFER_LOCATION_FCRAM;
|
return FRAMEBUFFER_LOCATION_FCRAM;
|
||||||
} else {
|
} else {
|
||||||
ERROR_LOG(GPU, "unknown framebuffer location!");
|
ERROR_LOG(GPU, "unknown framebuffer location!");
|
||||||
|
@ -64,21 +64,26 @@ const FramebufferLocation GetFramebufferLocation() {
|
||||||
return FRAMEBUFFER_LOCATION_UNKNOWN;
|
return FRAMEBUFFER_LOCATION_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u32 GetFramebufferAddr(const u32 address) {
|
||||||
|
switch (GetFramebufferLocation(address)) {
|
||||||
|
case FRAMEBUFFER_LOCATION_FCRAM:
|
||||||
|
return Memory::VirtualAddressFromPhysical_FCRAM(address);
|
||||||
|
case FRAMEBUFFER_LOCATION_VRAM:
|
||||||
|
return Memory::VirtualAddressFromPhysical_VRAM(address);
|
||||||
|
default:
|
||||||
|
ERROR_LOG(GPU, "unknown framebuffer location");
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a read-only pointer to a framebuffer in memory
|
* Gets a read-only pointer to a framebuffer in memory
|
||||||
* @param address Physical address of framebuffer
|
* @param address Physical address of framebuffer
|
||||||
* @return Returns const pointer to raw framebuffer
|
* @return Returns const pointer to raw framebuffer
|
||||||
*/
|
*/
|
||||||
const u8* GetFramebufferPointer(const u32 address) {
|
const u8* GetFramebufferPointer(const u32 address) {
|
||||||
switch (GetFramebufferLocation()) {
|
u32 addr = GetFramebufferAddr(address);
|
||||||
case FRAMEBUFFER_LOCATION_FCRAM:
|
return (addr != 0) ? Memory::GetPointer(addr) : nullptr;
|
||||||
return (const u8*)Memory::GetPointer(Memory::VirtualAddressFromPhysical_FCRAM(address));
|
|
||||||
case FRAMEBUFFER_LOCATION_VRAM:
|
|
||||||
return (const u8*)Memory::GetPointer(Memory::VirtualAddressFromPhysical_VRAM(address));
|
|
||||||
default:
|
|
||||||
ERROR_LOG(GPU, "unknown framebuffer location");
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|
|
@ -219,10 +219,12 @@ void SetFramebufferLocation(const FramebufferLocation mode);
|
||||||
*/
|
*/
|
||||||
const u8* GetFramebufferPointer(const u32 address);
|
const u8* GetFramebufferPointer(const u32 address);
|
||||||
|
|
||||||
|
u32 GetFramebufferAddr(const u32 address);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the location of the framebuffers
|
* Gets the location of the framebuffers
|
||||||
*/
|
*/
|
||||||
const FramebufferLocation GetFramebufferLocation();
|
FramebufferLocation GetFramebufferLocation(u32 address);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline void Read(T &var, const u32 addr);
|
inline void Read(T &var, const u32 addr);
|
||||||
|
|
Loading…
Reference in a new issue