Files
Ranieri d74a3ce139 Feature/gs refactor (#204)
* refactor: from guest  threads to EE scheduler

* feat: bad wip mpeg fix for code veronica

* feat: cheap copy from host
feat: small perf o vsync tick

* feat: added EE clock Hz
fix: fix MPEG out of sync with new EE refactor

* fix: fix lotr tests

* fix: fix cri dtx loading
fix: fix wrong mmi instruction translation
fix: fix thread info params
feat: added EE  timers decoder and consumer
feat: split SFI and IOP memory to prevent collision and overrides

* feat: revert wrong changes

* refactor: change GS architecture
2026-08-13 22:49:04 -03:00

63 lines
1.1 KiB
C++

#ifndef PS2_GS_COMMON_H
#define PS2_GS_COMMON_H
#include "runtime/gs/gs_types.h"
#include <cstdint>
namespace GSInternal
{
static inline uint32_t bitsPerPixel(uint8_t psm)
{
switch (psm)
{
case GS_PSM_CT32:
case GS_PSM_Z32:
return 32;
case GS_PSM_CT24:
case GS_PSM_Z24:
return 32;
case GS_PSM_CT16:
case GS_PSM_CT16S:
case GS_PSM_Z16:
case GS_PSM_Z16S:
return 16;
case GS_PSM_T8:
case GS_PSM_T8H:
return 8;
case GS_PSM_T4:
case GS_PSM_T4HL:
case GS_PSM_T4HH:
return 4;
default:
return 32;
}
}
static inline uint32_t fbStride(uint32_t fbw, uint8_t psm)
{
uint32_t pixelsPerRow = fbw * 64u;
return pixelsPerRow * (bitsPerPixel(psm) / 8u);
}
static inline uint32_t framePageBaseToBlock(uint32_t fbp)
{
return fbp << 5u;
}
static inline int clampInt(int v, int lo, int hi)
{
if (v < lo) return lo;
if (v > hi) return hi;
return v;
}
static inline uint8_t clampU8(int v)
{
if (v < 0) return 0;
if (v > 255) return 255;
return static_cast<uint8_t>(v);
}
}
#endif