Skip to content

Commit 8f552cf

Browse files
committed
temp-commit
1 parent b429b4e commit 8f552cf

File tree

3 files changed

+60
-49
lines changed

3 files changed

+60
-49
lines changed

pcsx2-gsrunner/Main.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -514,12 +514,6 @@ bool GSRunner::ParseCommandLineArgs(int argc, char* argv[], VMBootParameters& pa
514514
std::string str(argv[++i]);
515515

516516
s_settings_interface.SetBoolValue("EmuCore/GS", "dump", true);
517-
s_settings_interface.SetIntValue("EmuCore/GS", "saven", 0);
518-
s_settings_interface.SetIntValue("EmuCore/GS", "savel", -1);
519-
s_settings_interface.SetIntValue("EmuCore/GS", "saveb", 1);
520-
s_settings_interface.SetIntValue("EmuCore/GS", "savenf", 0);
521-
s_settings_interface.SetIntValue("EmuCore/GS", "savelf", -1);
522-
s_settings_interface.SetIntValue("EmuCore/GS", "savelf", 1);
523517

524518
if (str.find("rt") != std::string::npos)
525519
s_settings_interface.SetBoolValue("EmuCore/GS", "save", true);

pcsx2/GS/GSState.cpp

Lines changed: 59 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,49 +1677,7 @@ void GSState::FlushPrim()
16771677

16781678
m_vt.Update(m_vertex.buff, m_index.buff, m_vertex.tail, m_index.tail, GSUtil::GetPrimClass(PRIM->PRIM));
16791679

1680-
// Texel coordinate rounding
1681-
// Helps Manhunt (lights shining through objects).
1682-
// Can help with some alignment issues when upscaling too, and is for both Software and Hardware renderers.
1683-
// Sometimes hardware doesn't get affected, likely due to the difference in how GPU's handle textures (Persona minimap).
1684-
if (PRIM->TME && (GSUtil::GetPrimClass(PRIM->PRIM) == GS_PRIM_CLASS::GS_SPRITE_CLASS || m_vt.m_eq.z))
1685-
{
1686-
if (!PRIM->FST) // STQ's
1687-
{
1688-
const bool is_sprite = GSUtil::GetPrimClass(PRIM->PRIM) == GS_PRIM_CLASS::GS_SPRITE_CLASS;
1689-
// ST's have the lowest 9 bits (or greater depending on exponent difference) rounding down (from hardware tests).
1690-
for (int i = m_index.tail - 1; i >= 0; i--)
1691-
{
1692-
GSVertex* v = &m_vertex.buff[m_index.buff[i]];
1693-
1694-
// Only Q on the second vertex is valid
1695-
if (!(i & 1) && is_sprite)
1696-
v->RGBAQ.Q = m_vertex.buff[m_index.buff[i + 1]].RGBAQ.Q;
1697-
1698-
int T = std::bit_cast<int>(v->ST.T);
1699-
int Q = std::bit_cast<int>(v->RGBAQ.Q);
1700-
int S = std::bit_cast<int>(v->ST.S);
1701-
const int expS = (S >> 23) & 0xff;
1702-
const int expT = (T >> 23) & 0xff;
1703-
const int expQ = (Q >> 23) & 0xff;
1704-
int max_exp = std::max(expS, expQ);
1705-
1706-
u32 mask = CalcMask(expS, max_exp);
1707-
S &= ~mask;
1708-
v->ST.S = std::bit_cast<float>(S);
1709-
max_exp = std::max(expT, expQ);
1710-
mask = CalcMask(expT, max_exp);
1711-
T &= ~mask;
1712-
v->ST.T = std::bit_cast<float>(T);
1713-
Q &= ~0xff;
1714-
1715-
if (!is_sprite || (i & 1))
1716-
v->RGBAQ.Q = std::bit_cast<float>(Q);
1717-
1718-
m_vt.m_min.t.x = std::min(m_vt.m_min.t.x, (v->ST.S / v->RGBAQ.Q) * (1 << m_context->TEX0.TW));
1719-
m_vt.m_min.t.y = std::min(m_vt.m_min.t.y, (v->ST.T / v->RGBAQ.Q) * (1 << m_context->TEX0.TH));
1720-
}
1721-
}
1722-
}
1680+
TexelCoordinateRounding();
17231681

17241682
// Skip draw if Z test is enabled, but set to fail all pixels.
17251683
const bool skip_draw = (m_context->TEST.ZTE && m_context->TEST.ZTST == ZTST_NEVER);
@@ -4009,6 +3967,64 @@ GSState::TextureMinMaxResult GSState::GetTextureMinMax(GIFRegTEX0 TEX0, GIFRegCL
40093967
return { vr, uses_border };
40103968
}
40113969

3970+
// Texel coordinate rounding
3971+
// Helps Manhunt (lights shining through objects).
3972+
// Can help with some alignment issues when upscaling too, and is for both Software and Hardware renderers.
3973+
// Sometimes hardware doesn't get affected, likely due to the difference in how GPU's handle textures (Persona minimap).
3974+
void GSState::TexelCoordinateRounding()
3975+
{
3976+
if (PRIM->TME && (GSUtil::GetPrimClass(PRIM->PRIM) == GS_PRIM_CLASS::GS_SPRITE_CLASS || m_vt.m_eq.z))
3977+
{
3978+
if (!PRIM->FST) // STQ's
3979+
{
3980+
const bool is_sprite = GSUtil::GetPrimClass(PRIM->PRIM) == GS_PRIM_CLASS::GS_SPRITE_CLASS;
3981+
// ST's have the lowest 9 bits (or greater depending on exponent difference) rounding down (from hardware tests).
3982+
for (int i = m_index.tail - 1; i >= 0; i--)
3983+
{
3984+
GSVertex* v = &m_vertex.buff[m_index.buff[i]];
3985+
3986+
// Only Q on the second vertex is valid
3987+
if (!(i & 1) && is_sprite)
3988+
v->RGBAQ.Q = m_vertex.buff[m_index.buff[i + 1]].RGBAQ.Q;
3989+
3990+
int T = std::bit_cast<int>(v->ST.T);
3991+
int Q = std::bit_cast<int>(v->RGBAQ.Q);
3992+
int S = std::bit_cast<int>(v->ST.S);
3993+
const int expS = (S >> 23) & 0xff;
3994+
const int expT = (T >> 23) & 0xff;
3995+
const int expQ = (Q >> 23) & 0xff;
3996+
int max_exp = std::max(expS, expQ);
3997+
3998+
u32 mask = CalcMask(expS, max_exp);
3999+
S &= ~mask;
4000+
v->ST.S = std::bit_cast<float>(S);
4001+
max_exp = std::max(expT, expQ);
4002+
mask = CalcMask(expT, max_exp);
4003+
T &= ~mask;
4004+
v->ST.T = std::bit_cast<float>(T);
4005+
Q &= ~0xff;
4006+
4007+
if (!is_sprite || (i & 1))
4008+
v->RGBAQ.Q = std::bit_cast<float>(Q);
4009+
4010+
float U = (v->ST.S / v->RGBAQ.Q) * (1 << m_context->TEX0.TW);
4011+
float V = (v->ST.T / v->RGBAQ.Q) * (1 << m_context->TEX0.TH);
4012+
4013+
m_vt.m_min.t.x = std::isnan(U) ? m_vt.m_min.t.x : std::min(m_vt.m_min.t.x, U);
4014+
m_vt.m_min.t.y = std::isnan(V) ? m_vt.m_min.t.y : std::min(m_vt.m_min.t.y, V);
4015+
m_vt.m_max.t.x = std::isnan(U) ? m_vt.m_max.t.x : std::min(m_vt.m_max.t.x, U);
4016+
m_vt.m_max.t.y = std::isnan(V) ? m_vt.m_max.t.y : std::min(m_vt.m_max.t.y, V);
4017+
}
4018+
}
4019+
}
4020+
4021+
// Clamp the min/max UV values to the min/max valid UV values.
4022+
// This is needed in certain cases where buggy GS input results
4023+
// in huge floating points values for ST.
4024+
m_vt.m_min.t = m_vt.m_min.t.min(GSVector4(2047.0f)).max(GSVector4(-2047.0f)).xyzw(m_vt.m_min.t);
4025+
m_vt.m_max.t = m_vt.m_max.t.min(GSVector4(2047.0f)).max(GSVector4(-2047.0f)).xyzw(m_vt.m_max.t);
4026+
}
4027+
40124028
void GSState::CalcAlphaMinMax(const int tex_alpha_min, const int tex_alpha_max)
40134029
{
40144030
if (m_vt.m_alpha.valid && tex_alpha_min == 0 && tex_alpha_max == 255)

pcsx2/GS/GSState.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ class GSState : public GSAlignedClass<32>
190190
bool IsCoverageAlpha();
191191
void CalcAlphaMinMax(const int tex_min, const int tex_max);
192192
void CorrectATEAlphaMinMax(const u32 atst, const int aref);
193+
void TexelCoordinateRounding();
193194

194195
public:
195196
struct GSUploadQueue

0 commit comments

Comments
 (0)