GTE: Pack local config in struct
This commit is contained in:
parent
b6a264b8b4
commit
23962fd07e
|
@ -30,10 +30,17 @@ static constexpr s32 IR0_MAX_VALUE = 0x1000;
|
|||
static constexpr s32 IR123_MIN_VALUE = -(INT64_C(1) << 15);
|
||||
static constexpr s32 IR123_MAX_VALUE = (INT64_C(1) << 15) - 1;
|
||||
|
||||
static DisplayAspectRatio s_aspect_ratio = DisplayAspectRatio::R4_3;
|
||||
static u32 s_custom_aspect_ratio_numerator;
|
||||
static u32 s_custom_aspect_ratio_denominator;
|
||||
static float s_custom_aspect_ratio_f;
|
||||
namespace {
|
||||
struct Config
|
||||
{
|
||||
DisplayAspectRatio aspect_ratio = DisplayAspectRatio::R4_3;
|
||||
u32 custom_aspect_ratio_numerator;
|
||||
u32 custom_aspect_ratio_denominator;
|
||||
float custom_aspect_ratio_f;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
ALIGN_TO_CACHE_LINE static Config s_config;
|
||||
|
||||
#define REGS CPU::g_state.gte_regs
|
||||
|
||||
|
@ -207,7 +214,7 @@ static void Execute_GPF(Instruction inst);
|
|||
|
||||
void GTE::Initialize()
|
||||
{
|
||||
s_aspect_ratio = DisplayAspectRatio::R4_3;
|
||||
s_config.aspect_ratio = DisplayAspectRatio::R4_3;
|
||||
Reset();
|
||||
}
|
||||
|
||||
|
@ -226,20 +233,20 @@ void GTE::UpdateAspectRatio()
|
|||
{
|
||||
if (!g_settings.gpu_widescreen_hack)
|
||||
{
|
||||
s_aspect_ratio = DisplayAspectRatio::R4_3;
|
||||
s_config.aspect_ratio = DisplayAspectRatio::R4_3;
|
||||
return;
|
||||
}
|
||||
|
||||
s_aspect_ratio = g_settings.display_aspect_ratio;
|
||||
s_config.aspect_ratio = g_settings.display_aspect_ratio;
|
||||
|
||||
u32 num, denom;
|
||||
switch (s_aspect_ratio)
|
||||
switch (s_config.aspect_ratio)
|
||||
{
|
||||
case DisplayAspectRatio::MatchWindow:
|
||||
{
|
||||
if (!g_gpu_device)
|
||||
{
|
||||
s_aspect_ratio = DisplayAspectRatio::R4_3;
|
||||
s_config.aspect_ratio = DisplayAspectRatio::R4_3;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -264,10 +271,11 @@ void GTE::UpdateAspectRatio()
|
|||
const u32 y = 3u * num;
|
||||
const u32 gcd = std::gcd(x, y);
|
||||
|
||||
s_custom_aspect_ratio_numerator = x / gcd;
|
||||
s_custom_aspect_ratio_denominator = y / gcd;
|
||||
s_config.custom_aspect_ratio_numerator = x / gcd;
|
||||
s_config.custom_aspect_ratio_denominator = y / gcd;
|
||||
|
||||
s_custom_aspect_ratio_f = static_cast<float>((4.0 / 3.0) / (static_cast<double>(num) / static_cast<double>(denom)));
|
||||
s_config.custom_aspect_ratio_f =
|
||||
static_cast<float>((4.0 / 3.0) / (static_cast<double>(num) / static_cast<double>(denom)));
|
||||
}
|
||||
|
||||
u32 GTE::ReadRegister(u32 index)
|
||||
|
@ -520,7 +528,7 @@ ALWAYS_INLINE u32 GTE::UNRDivide(u32 lhs, u32 rhs)
|
|||
|
||||
void GTE::MulMatVec(const s16* M_, const s16 Vx, const s16 Vy, const s16 Vz, u8 shift, bool lm)
|
||||
{
|
||||
#define M(i, j) M_[((i)*3) + (j)]
|
||||
#define M(i, j) M_[((i) * 3) + (j)]
|
||||
#define dot3(i) \
|
||||
TruncateAndSetMACAndIR<i + 1>(SignExtendMACResult<i + 1>((s64(M(i, 0)) * s64(Vx)) + (s64(M(i, 1)) * s64(Vy))) + \
|
||||
(s64(M(i, 2)) * s64(Vz)), \
|
||||
|
@ -536,7 +544,7 @@ void GTE::MulMatVec(const s16* M_, const s16 Vx, const s16 Vy, const s16 Vz, u8
|
|||
|
||||
void GTE::MulMatVec(const s16* M_, const s32 T[3], const s16 Vx, const s16 Vy, const s16 Vz, u8 shift, bool lm)
|
||||
{
|
||||
#define M(i, j) M_[((i)*3) + (j)]
|
||||
#define M(i, j) M_[((i) * 3) + (j)]
|
||||
#define dot3(i) \
|
||||
TruncateAndSetMACAndIR<i + 1>( \
|
||||
SignExtendMACResult<i + 1>(SignExtendMACResult<i + 1>((s64(T[i]) << 12) + (s64(M(i, 0)) * s64(Vx))) + \
|
||||
|
@ -554,7 +562,7 @@ void GTE::MulMatVec(const s16* M_, const s32 T[3], const s16 Vx, const s16 Vy, c
|
|||
|
||||
void GTE::MulMatVecBuggy(const s16* M_, const s32 T[3], const s16 Vx, const s16 Vy, const s16 Vz, u8 shift, bool lm)
|
||||
{
|
||||
#define M(i, j) M_[((i)*3) + (j)]
|
||||
#define M(i, j) M_[((i) * 3) + (j)]
|
||||
#define dot3(i) \
|
||||
do \
|
||||
{ \
|
||||
|
@ -694,7 +702,7 @@ void GTE::RTPS(const s16 V[3], u8 shift, bool lm, bool last)
|
|||
const s64 result = static_cast<s64>(ZeroExtend64(UNRDivide(REGS.H, REGS.SZ3)));
|
||||
|
||||
s64 Sx;
|
||||
switch (s_aspect_ratio)
|
||||
switch (s_config.aspect_ratio)
|
||||
{
|
||||
case DisplayAspectRatio::R16_9:
|
||||
Sx = ((((s64(result) * s64(REGS.IR1)) * s64(3)) / s64(4)) + s64(REGS.OFX));
|
||||
|
@ -710,8 +718,8 @@ void GTE::RTPS(const s16 V[3], u8 shift, bool lm, bool last)
|
|||
|
||||
case DisplayAspectRatio::Custom:
|
||||
case DisplayAspectRatio::MatchWindow:
|
||||
Sx = ((((s64(result) * s64(REGS.IR1)) * s64(s_custom_aspect_ratio_numerator)) /
|
||||
s64(s_custom_aspect_ratio_denominator)) +
|
||||
Sx = ((((s64(result) * s64(REGS.IR1)) * s64(s_config.custom_aspect_ratio_numerator)) /
|
||||
s64(s_config.custom_aspect_ratio_denominator)) +
|
||||
s64(REGS.OFX));
|
||||
break;
|
||||
|
||||
|
@ -762,11 +770,11 @@ void GTE::RTPS(const s16 V[3], u8 shift, bool lm, bool last)
|
|||
const float fofy = float(REGS.OFY) / float(1 << 16);
|
||||
float precise_x = precise_ir1 * precise_h_div_sz;
|
||||
|
||||
switch (s_aspect_ratio)
|
||||
switch (s_config.aspect_ratio)
|
||||
{
|
||||
case DisplayAspectRatio::MatchWindow:
|
||||
case DisplayAspectRatio::Custom:
|
||||
precise_x = precise_x * s_custom_aspect_ratio_f;
|
||||
precise_x = precise_x * s_config.custom_aspect_ratio_f;
|
||||
break;
|
||||
|
||||
case DisplayAspectRatio::R16_9:
|
||||
|
|
Loading…
Reference in New Issue