mirror of
https://github.com/ran-j/PS2Recomp.git
synced 2026-09-29 01:47:44 -04:00
Feature/agressive recompiler (#146)
* feat: added guestBranchKind enum to categorize branch types feat: added missingFunctionPolicy enum to define behaviors for missing function scenarios refactor: added handle guest branches and report missing functions feat lookupFunction to utilize new dispatch logic and improve error handling for unregistered functions * fix: fix test conflict * feat: added debug sound driver logs * feat: emmiter for return * feat: added recompiler reporter feat: added strict diagnostics flag for heavy debug calls * feat: staticc table insted of hashmap for runtime * feat: back file to ignore * feat: explode code across helpers and classes * feat: update codegen test feat: better guest nop check * feat: fix link problem on linux * feat: fix Segmentation fault * feat: added recompile replace for DMA and MMIO feat: added a clean memory helpers feat: use memory helpers across the project feat: fix ucrt on msvc * feat: undo messup merge
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
#ifndef PS2_ADDRESS_H
|
||||
#define PS2_ADDRESS_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "runtime/ps2_memory.h"
|
||||
|
||||
static inline constexpr uint32_t PS2_EE_UNCACHED_RAM_MIRROR_BASE = 0x20000000u;
|
||||
static inline constexpr uint32_t PS2_EE_UNCACHED_RAM_MIRROR_SIZE = 0x20000000u;
|
||||
static inline constexpr uint32_t PS2_KSEG0_BASE = 0x80000000u;
|
||||
static inline constexpr uint32_t PS2_KSEG0_KSEG1_SIZE = 0x40000000u;
|
||||
static inline constexpr uint32_t PS2_KSEG2_BASE = 0xC0000000u;
|
||||
|
||||
static inline constexpr bool Ps2AddressInRange(uint32_t value, uint32_t base, uint32_t size)
|
||||
{
|
||||
return (value - base) < size;
|
||||
}
|
||||
|
||||
static inline constexpr bool Ps2IsUncachedRamMirrorAddress(uint32_t addr)
|
||||
{
|
||||
return Ps2AddressInRange(addr, PS2_EE_UNCACHED_RAM_MIRROR_BASE, PS2_EE_UNCACHED_RAM_MIRROR_SIZE);
|
||||
}
|
||||
|
||||
static inline constexpr bool Ps2IsKseg01Address(uint32_t addr)
|
||||
{
|
||||
return Ps2AddressInRange(addr, PS2_KSEG0_BASE, PS2_KSEG0_KSEG1_SIZE);
|
||||
}
|
||||
|
||||
static inline constexpr bool Ps2IsKseg23Address(uint32_t addr)
|
||||
{
|
||||
return addr >= PS2_KSEG2_BASE;
|
||||
}
|
||||
|
||||
static inline constexpr uint32_t Ps2DirectMappedPhysicalAddress(uint32_t addr)
|
||||
{
|
||||
return addr & 0x1FFFFFFFu;
|
||||
}
|
||||
|
||||
static inline constexpr uint32_t Ps2PhysicalAddress(uint32_t addr)
|
||||
{
|
||||
return (addr >= PS2_KSEG0_BASE) ? Ps2DirectMappedPhysicalAddress(addr) : addr;
|
||||
}
|
||||
|
||||
static inline constexpr bool Ps2IsPhysicalSpecialAddress(uint32_t physAddr)
|
||||
{
|
||||
return Ps2AddressInRange(physAddr, PS2_BIOS_BASE, PS2_BIOS_SIZE) ||
|
||||
Ps2AddressInRange(physAddr, PS2_SCRATCHPAD_BASE, PS2_SCRATCHPAD_SIZE) ||
|
||||
Ps2AddressInRange(physAddr, PS2_IO_BASE, PS2_IO_SIZE) ||
|
||||
Ps2AddressInRange(physAddr, PS2_GS_PRIV_REG_BASE, PS2_GS_PRIV_REG_SIZE) ||
|
||||
(physAddr >= PS2_VU0_DATA_BASE && physAddr < (PS2_VU1_CODE_BASE + PS2_VU1_CODE_SIZE));
|
||||
}
|
||||
|
||||
static inline constexpr bool Ps2IsSpecialAddress(uint32_t addr)
|
||||
{
|
||||
if (Ps2IsKseg23Address(addr))
|
||||
return true;
|
||||
|
||||
return Ps2IsPhysicalSpecialAddress(Ps2PhysicalAddress(addr));
|
||||
}
|
||||
|
||||
#endif // PS2_ADDRESS_H
|
||||
@@ -33,6 +33,7 @@ public:
|
||||
void submit(GifPathId pathId, const uint8_t *data, uint32_t sizeBytes, bool path2DirectHl = false);
|
||||
|
||||
void drain();
|
||||
bool empty() const { return m_queue.empty(); }
|
||||
|
||||
private:
|
||||
ProcessPacketFn m_processFn;
|
||||
|
||||
@@ -321,6 +321,13 @@ public:
|
||||
void reset();
|
||||
|
||||
void processGIFPacket(const uint8_t *data, uint32_t sizeBytes);
|
||||
bool processNativePackedGIFPacket(const uint8_t *data, uint32_t sizeBytes);
|
||||
void uploadImageNative(uint64_t bitbltbuf,
|
||||
uint64_t trxpos,
|
||||
uint64_t trxreg,
|
||||
uint64_t trxdir,
|
||||
const uint8_t *data,
|
||||
uint32_t sizeBytes);
|
||||
void writeRegister(uint8_t regAddr, uint64_t value);
|
||||
|
||||
const uint8_t *lockDisplaySnapshot(uint32_t &outSize);
|
||||
@@ -346,6 +353,8 @@ public:
|
||||
bool *outUsedPreferred = nullptr) const;
|
||||
bool clearFramebufferContext(uint32_t contextIndex, uint32_t rgba);
|
||||
bool clearActiveFramebuffer(uint32_t rgba);
|
||||
uint64_t nativeImageUploadCount() const { return m_nativeImageUploadCount; }
|
||||
uint64_t nativePackedGIFPacketCount() const { return m_nativePackedGIFPacketCount; }
|
||||
|
||||
uint32_t consumeLocalToHostBytes(uint8_t *dst, uint32_t maxBytes);
|
||||
|
||||
@@ -369,6 +378,7 @@ private:
|
||||
void recordPresentDebugEventUnlocked(uint32_t displayFbp, uint32_t sourceFbp, uint32_t width, uint32_t height, bool usedPreferred);
|
||||
|
||||
void processImageData(const uint8_t *data, uint32_t sizeBytes);
|
||||
bool tryProcessNativeImageUploadPacket(const uint8_t *data, uint32_t sizeBytes);
|
||||
void performLocalToLocalTransfer();
|
||||
void performLocalToHostToBuffer();
|
||||
bool copyFrameToHostRgbaUnlocked(const GSFrameReg &frame,
|
||||
@@ -433,6 +443,8 @@ private:
|
||||
uint32_t m_hostPresentationSourceFbp = 0;
|
||||
bool m_hostPresentationUsedPreferred = false;
|
||||
bool m_hasHostPresentationFrame = false;
|
||||
uint64_t m_nativeImageUploadCount = 0;
|
||||
uint64_t m_nativePackedGIFPacketCount = 0;
|
||||
|
||||
std::vector<uint8_t> m_localToHostBuffer;
|
||||
size_t m_localToHostReadPos = 0;
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#include <smmintrin.h> // For SSE4.1 instructions
|
||||
#endif
|
||||
|
||||
class GS;
|
||||
|
||||
constexpr uint32_t PS2_RAM_SIZE = 32u * 1024u * 1024u; // 32MB
|
||||
constexpr uint32_t PS2_RAM_MASK = PS2_RAM_SIZE - 1u; // Mask for 32MB alignment
|
||||
constexpr uint32_t PS2_RAM_BASE = 0x00000000; // Physical base of RDRAM
|
||||
@@ -332,6 +334,8 @@ public:
|
||||
void submitGifPacket(GifPathId pathId, const uint8_t *data, uint32_t sizeBytes, bool drainImmediately = true, bool path2DirectHl = false);
|
||||
void processGIFPacket(uint32_t srcPhysAddr, uint32_t qwCount);
|
||||
void processGIFPacket(const uint8_t *data, uint32_t sizeBytes);
|
||||
bool tryProcessNativeGifImageUploadChain(GS &gs, uint32_t tadr, uint32_t chcr);
|
||||
bool tryProcessNativeGifPackedChain(GS &gs, uint32_t tadr, uint32_t chcr);
|
||||
void processVIF0Data(uint32_t srcPhysAddr, uint32_t sizeBytes);
|
||||
void processVIF0Data(const uint8_t *data, uint32_t sizeBytes);
|
||||
void processVIF1Data(uint32_t srcPhysAddr, uint32_t sizeBytes);
|
||||
|
||||
Reference in New Issue
Block a user