mirror of
https://github.com/ran-j/PS2Recomp.git
synced 2026-10-01 02:17:14 -04:00
Feature/random fixes platform support (#179)
* feat: implement memory card IOP * feat: IOP trace * feat: move IOP logic to ps2xIOP refactor: small refactor on audio api on runtime * feat: android support feat: prevent race on GS feat: a bit cleanup and reimplement on memory card * feat: finish guest thread feat: android build support feat: vita build support with suspicious setup scripts * feat: remove idea from track
This commit is contained in:
@@ -348,6 +348,19 @@ public:
|
||||
uint32_t m_depth = 0u;
|
||||
};
|
||||
|
||||
class DeferredGuestYieldScope
|
||||
{
|
||||
public:
|
||||
explicit DeferredGuestYieldScope(bool &pendingOut) noexcept;
|
||||
~DeferredGuestYieldScope();
|
||||
|
||||
DeferredGuestYieldScope(const DeferredGuestYieldScope &) = delete;
|
||||
DeferredGuestYieldScope &operator=(const DeferredGuestYieldScope &) = delete;
|
||||
|
||||
private:
|
||||
bool &m_pendingOut;
|
||||
};
|
||||
|
||||
bool replaceFunction(uint32_t address, RecompiledFunction func);
|
||||
// TODO remove this later need to update all tests
|
||||
bool registerFunction(uint32_t address, RecompiledFunction func);
|
||||
@@ -399,17 +412,33 @@ public:
|
||||
uint32_t guestHeapEnd() const;
|
||||
uint32_t guestHeapLimit() const;
|
||||
uint32_t reserveAsyncCallbackStack(uint32_t size, uint32_t alignment = 16u);
|
||||
|
||||
void dispatchLoop(uint8_t *rdram, R5900Context *ctx);
|
||||
|
||||
void drainCompletedDmacHandlers(uint8_t *rdram);
|
||||
|
||||
bool shouldPreemptGuestExecution();
|
||||
void yieldGuestExecutionAfterWake();
|
||||
void waitForGuestExecutionHandoff();
|
||||
void waitForGuestExecutionHandoff(uint64_t baselineEpoch);
|
||||
uint64_t guestExecutionHandoffEpochSnapshot() const
|
||||
{
|
||||
return m_guestExecutionHandoffEpoch.load(std::memory_order_acquire);
|
||||
}
|
||||
|
||||
void requestStop();
|
||||
bool isStopRequested() const;
|
||||
|
||||
uint32_t guestExecutionWaiterCountForTesting() const
|
||||
{
|
||||
return m_guestExecutionWaiters.load(std::memory_order_acquire);
|
||||
}
|
||||
|
||||
uint64_t guestExecutionHandoffTimeouts() const
|
||||
{
|
||||
return m_guestExecutionHandoffTimeouts.load(std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
uint8_t Load8(uint8_t *rdram, R5900Context *ctx, uint32_t vaddr);
|
||||
uint16_t Load16(uint8_t *rdram, R5900Context *ctx, uint32_t vaddr);
|
||||
uint32_t Load32(uint8_t *rdram, R5900Context *ctx, uint32_t vaddr);
|
||||
@@ -506,6 +535,7 @@ private:
|
||||
mutable std::mutex m_guestExecutionHandoffMutex;
|
||||
mutable std::condition_variable m_guestExecutionHandoffCv;
|
||||
std::atomic<uint64_t> m_guestExecutionHandoffEpoch{0u};
|
||||
std::atomic<uint64_t> m_guestExecutionHandoffTimeouts{0u};
|
||||
mutable std::mutex m_guestHeapMutex;
|
||||
mutable std::mutex m_asyncCallbackStackMutex;
|
||||
std::vector<GuestHeapBlock> m_guestHeapBlocks;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
namespace GSMem
|
||||
{
|
||||
constexpr usz MEMORY_SIZE = 4_mb;
|
||||
constexpr usz PAGE_SIZE = 8_kb;
|
||||
constexpr usz GS_PAGE_SIZE = 8_kb;
|
||||
|
||||
// these are all the same regardless of storage mode
|
||||
constexpr usz BLOCKS_PER_PAGE = 32;
|
||||
@@ -38,19 +38,32 @@ namespace GSMem
|
||||
Max = 0x3F // 6 bits of values
|
||||
};
|
||||
|
||||
|
||||
inline constexpr PixelStorageMode C32 = PixelStorageMode::C32;
|
||||
inline constexpr PixelStorageMode C24 = PixelStorageMode::C24;
|
||||
inline constexpr PixelStorageMode C16 = PixelStorageMode::C16;
|
||||
inline constexpr PixelStorageMode C16S = PixelStorageMode::C16S;
|
||||
inline constexpr PixelStorageMode P8 = PixelStorageMode::P8;
|
||||
inline constexpr PixelStorageMode P4 = PixelStorageMode::P4;
|
||||
inline constexpr PixelStorageMode P8H = PixelStorageMode::P8H;
|
||||
inline constexpr PixelStorageMode P4HL = PixelStorageMode::P4HL;
|
||||
inline constexpr PixelStorageMode P4HH = PixelStorageMode::P4HH;
|
||||
inline constexpr PixelStorageMode Z32 = PixelStorageMode::Z32;
|
||||
inline constexpr PixelStorageMode Z24 = PixelStorageMode::Z24;
|
||||
inline constexpr PixelStorageMode Z16 = PixelStorageMode::Z16;
|
||||
inline constexpr PixelStorageMode Z16S = PixelStorageMode::Z16S;
|
||||
|
||||
struct Extent2D
|
||||
{
|
||||
u32 x{ 0 };
|
||||
u32 y{ 0 };
|
||||
};
|
||||
|
||||
template<typename T, Extent2D Extent>
|
||||
using LookupTable = std::array<std::array<T, Extent.x>, Extent.y>;
|
||||
template<typename T, usz Width, usz Height>
|
||||
using LookupTable = std::array<std::array<T, Width>, Height>;
|
||||
|
||||
constexpr bool IsValidPsm(PixelStorageMode psm)
|
||||
{
|
||||
using enum PixelStorageMode;
|
||||
|
||||
switch (psm)
|
||||
{
|
||||
case C32:
|
||||
@@ -75,8 +88,6 @@ namespace GSMem
|
||||
// Bits per pixel in unpacked format (GS memory)
|
||||
constexpr usz UnpackedBitWidth(PixelStorageMode psm)
|
||||
{
|
||||
using enum PixelStorageMode;
|
||||
|
||||
switch (psm)
|
||||
{
|
||||
case C32:
|
||||
@@ -104,8 +115,6 @@ namespace GSMem
|
||||
// bits per pixel (packed width)
|
||||
constexpr usz BitsPerPixel(PixelStorageMode psm)
|
||||
{
|
||||
using enum PixelStorageMode;
|
||||
|
||||
switch (psm)
|
||||
{
|
||||
case C32:
|
||||
@@ -135,8 +144,6 @@ namespace GSMem
|
||||
|
||||
constexpr bool IsDepth(PixelStorageMode psm)
|
||||
{
|
||||
using enum PixelStorageMode;
|
||||
|
||||
switch (psm)
|
||||
{
|
||||
case Z16:
|
||||
@@ -158,8 +165,6 @@ namespace GSMem
|
||||
|
||||
constexpr bool IsPaletted(PixelStorageMode psm)
|
||||
{
|
||||
using enum PixelStorageMode;
|
||||
|
||||
switch (psm)
|
||||
{
|
||||
case P8:
|
||||
@@ -209,8 +214,6 @@ namespace GSMem
|
||||
template<PixelStorageMode psm>
|
||||
struct PixelStorageTraits
|
||||
{
|
||||
using enum PixelStorageMode;
|
||||
|
||||
// page extent, in units of pixels
|
||||
static constexpr Extent2D PageExtent();
|
||||
|
||||
@@ -229,9 +232,9 @@ namespace GSMem
|
||||
// pixel count in a page
|
||||
static constexpr usz PixelsPerPage();
|
||||
|
||||
using BlockLookupTableT = LookupTable<u8, BlockExtent()>;
|
||||
using ColumnLookupTableT = LookupTable<u16, ColumnExtent()>;
|
||||
using PageLookupTableT = std::array<LookupTable<u16, PageExtent()>, BlocksPerPage()>;
|
||||
using BlockLookupTableT = LookupTable<u8, BlockExtent().x, BlockExtent().y>;
|
||||
using ColumnLookupTableT = LookupTable<u16, ColumnExtent().x, ColumnExtent().y>;
|
||||
using PageLookupTableT = std::array<LookupTable<u16, PageExtent().x, PageExtent().y>, BlocksPerPage()>;
|
||||
|
||||
// calculates the column offset
|
||||
static constexpr usz ColumnId(const ColumnLookupTableT& table, u32 x, u32 y);
|
||||
|
||||
Reference in New Issue
Block a user