mirror of https://github.com/PCSX2/pcsx2.git
GS-hw: Cleanup GSRendererHW.
Constants, initializations, casts, broken commented out logs and more. Remove unused/duplicate function EmulateAtst.
This commit is contained in:
parent
d6c1af1a0c
commit
3a2307a5c6
|
@ -242,16 +242,16 @@ GSTexture* GSRendererHW::GetOutput(int i, int& y_offset)
|
||||||
const int videomode = static_cast<int>(GetVideoMode()) - 1;
|
const int videomode = static_cast<int>(GetVideoMode()) - 1;
|
||||||
const GSVector4i offsets = VideoModeOffsets[videomode];
|
const GSVector4i offsets = VideoModeOffsets[videomode];
|
||||||
|
|
||||||
const int fb_width = std::min<int>(std::min<int>(GetFramebufferWidth(), DISPFB.FBW * 64) + (int)DISPFB.DBX, 2048);
|
const int fb_width = std::min<int>(std::min<int>(GetFramebufferWidth(), DISPFB.FBW * 64) + static_cast<int>(DISPFB.DBX), 2048);
|
||||||
const int display_height = offsets.y * ((isinterlaced() && !m_regs->SMODE2.FFMD) ? 2 : 1);
|
const int display_height = offsets.y * ((isinterlaced() && !m_regs->SMODE2.FFMD) ? 2 : 1);
|
||||||
const int display_offset = GetResolutionOffset(i).y;
|
const int display_offset = GetResolutionOffset(i).y;
|
||||||
int fb_height = (std::min<int>(GetFramebufferHeight(), display_height) + (int)DISPFB.DBY) % 2048;
|
int fb_height = (std::min<int>(GetFramebufferHeight(), display_height) + static_cast<int>(DISPFB.DBY)) % 2048;
|
||||||
// If there is a negative vertical offset on the picture, we need to read more.
|
// If there is a negative vertical offset on the picture, we need to read more.
|
||||||
if (display_offset < 0)
|
if (display_offset < 0)
|
||||||
{
|
{
|
||||||
fb_height += -display_offset;
|
fb_height += -display_offset;
|
||||||
}
|
}
|
||||||
// TRACE(_T("[%d] GetOutput %d %05x (%d)\n"), (int)m_perfmon.GetFrame(), i, (int)TEX0.TBP0, (int)TEX0.PSM);
|
// TRACE(_T("[%d] GetOutput %d %05x (%d)\n"), static_cast<int>(g_perfmon.GetFrame()), i, static_cast<int>(TEX0.TBP0), static_cast<int>(TEX0.PSM));
|
||||||
|
|
||||||
GSTexture* t = nullptr;
|
GSTexture* t = nullptr;
|
||||||
|
|
||||||
|
@ -273,7 +273,7 @@ GSTexture* GSRendererHW::GetOutput(int i, int& y_offset)
|
||||||
{
|
{
|
||||||
if (GSConfig.SaveFrame && s_n >= GSConfig.SaveN)
|
if (GSConfig.SaveFrame && s_n >= GSConfig.SaveN)
|
||||||
{
|
{
|
||||||
t->Save(GetDrawDumpPath("%05d_f%lld_fr%d_%05x_%s.bmp", s_n, g_perfmon.GetFrame(), i, (int)TEX0.TBP0, psm_str(TEX0.PSM)));
|
t->Save(GetDrawDumpPath("%05d_f%lld_fr%d_%05x_%s.bmp", s_n, g_perfmon.GetFrame(), i, static_cast<int>(TEX0.TBP0), psm_str(TEX0.PSM)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -302,7 +302,7 @@ GSTexture* GSRendererHW::GetFeedbackOutput()
|
||||||
|
|
||||||
#ifdef ENABLE_OGL_DEBUG
|
#ifdef ENABLE_OGL_DEBUG
|
||||||
if (GSConfig.DumpGSData && GSConfig.SaveFrame && s_n >= GSConfig.SaveN)
|
if (GSConfig.DumpGSData && GSConfig.SaveFrame && s_n >= GSConfig.SaveN)
|
||||||
t->Save(GetDrawDumpPath("%05d_f%lld_fr%d_%05x_%s.bmp", s_n, g_perfmon.GetFrame(), 3, (int)TEX0.TBP0, psm_str(TEX0.PSM)));
|
t->Save(GetDrawDumpPath("%05d_f%lld_fr%d_%05x_%s.bmp", s_n, g_perfmon.GetFrame(), 3, static_cast<int>(TEX0.TBP0), psm_str(TEX0.PSM)));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return t;
|
return t;
|
||||||
|
@ -325,7 +325,7 @@ void GSRendererHW::Lines2Sprites()
|
||||||
{
|
{
|
||||||
const size_t count = m_vertex.next;
|
const size_t count = m_vertex.next;
|
||||||
|
|
||||||
int i = (int)count * 2 - 4;
|
int i = static_cast<int>(count) * 2 - 4;
|
||||||
GSVertex* s = &m_vertex.buff[count - 2];
|
GSVertex* s = &m_vertex.buff[count - 2];
|
||||||
GSVertex* q = &m_vertex.buff[count * 2 - 4];
|
GSVertex* q = &m_vertex.buff[count * 2 - 4];
|
||||||
u32* RESTRICT index = &m_index.buff[count * 3 - 6];
|
u32* RESTRICT index = &m_index.buff[count * 3 - 6];
|
||||||
|
@ -419,7 +419,7 @@ void GSRendererHW::ExpandIndices()
|
||||||
constexpr GSVector4i low0 = GSVector4i::cxpr(0, 1, 2, 1);
|
constexpr GSVector4i low0 = GSVector4i::cxpr(0, 1, 2, 1);
|
||||||
constexpr GSVector4i low1 = GSVector4i::cxpr(2, 3, 0, 1);
|
constexpr GSVector4i low1 = GSVector4i::cxpr(2, 3, 0, 1);
|
||||||
constexpr GSVector4i low2 = GSVector4i::cxpr(2, 1, 2, 3);
|
constexpr GSVector4i low2 = GSVector4i::cxpr(2, 1, 2, 3);
|
||||||
GSVector4i in = read->sll32(2);
|
const GSVector4i in = read->sll32(2);
|
||||||
write[0] = in.xxxx() | low0;
|
write[0] = in.xxxx() | low0;
|
||||||
write[1] = in.xxyy() | low1;
|
write[1] = in.xxyy() | low1;
|
||||||
write[2] = in.yyyy() | low2;
|
write[2] = in.yyyy() | low2;
|
||||||
|
@ -433,7 +433,7 @@ void GSRendererHW::ExpandIndices()
|
||||||
constexpr GSVector4i low0 = GSVector4i::cxpr(0, 1, 2, 1);
|
constexpr GSVector4i low0 = GSVector4i::cxpr(0, 1, 2, 1);
|
||||||
constexpr GSVector4i low1 = GSVector4i::cxpr(2, 3, 0, 1);
|
constexpr GSVector4i low1 = GSVector4i::cxpr(2, 3, 0, 1);
|
||||||
constexpr GSVector4i low2 = GSVector4i::cxpr(2, 1, 2, 3);
|
constexpr GSVector4i low2 = GSVector4i::cxpr(2, 1, 2, 3);
|
||||||
GSVector4i in = read->sll32(2);
|
const GSVector4i in = read->sll32(2);
|
||||||
write[0] = in.xxyx() | low0;
|
write[0] = in.xxyx() | low0;
|
||||||
write[1] = in.yyzz() | low1;
|
write[1] = in.yyzz() | low1;
|
||||||
write[2] = in.wzww() | low2;
|
write[2] = in.wzww() | low2;
|
||||||
|
@ -442,7 +442,7 @@ void GSRendererHW::ExpandIndices()
|
||||||
case GSHWDrawConfig::VSExpand::Sprite:
|
case GSHWDrawConfig::VSExpand::Sprite:
|
||||||
{
|
{
|
||||||
constexpr GSVector4i low = GSVector4i::cxpr(0, 1, 0, 1);
|
constexpr GSVector4i low = GSVector4i::cxpr(0, 1, 0, 1);
|
||||||
GSVector4i in = read->sll32(1);
|
const GSVector4i in = read->sll32(1);
|
||||||
write[0] = in.xxyx() | low;
|
write[0] = in.xxyx() | low;
|
||||||
write[1] = in.yyzz() | low;
|
write[1] = in.yyzz() | low;
|
||||||
write[2] = in.wzww() | low;
|
write[2] = in.wzww() | low;
|
||||||
|
@ -452,52 +452,6 @@ void GSRendererHW::ExpandIndices()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GSRendererHW::EmulateAtst(GSVector4& FogColor_AREF, u8& ps_atst, const bool pass_2)
|
|
||||||
{
|
|
||||||
static const u32 inverted_atst[] = {ATST_ALWAYS, ATST_NEVER, ATST_GEQUAL, ATST_GREATER, ATST_NOTEQUAL, ATST_LESS, ATST_LEQUAL, ATST_EQUAL};
|
|
||||||
|
|
||||||
if (!m_context->TEST.ATE)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Check for pass 2, otherwise do pass 1.
|
|
||||||
const int atst = pass_2 ? inverted_atst[m_context->TEST.ATST] : m_context->TEST.ATST;
|
|
||||||
|
|
||||||
switch (atst)
|
|
||||||
{
|
|
||||||
case ATST_LESS:
|
|
||||||
FogColor_AREF.a = (float)m_context->TEST.AREF - 0.1f;
|
|
||||||
ps_atst = 1;
|
|
||||||
break;
|
|
||||||
case ATST_LEQUAL:
|
|
||||||
FogColor_AREF.a = (float)m_context->TEST.AREF - 0.1f + 1.0f;
|
|
||||||
ps_atst = 1;
|
|
||||||
break;
|
|
||||||
case ATST_GEQUAL:
|
|
||||||
// Maybe a -1 trick multiplication factor could be used to merge with ATST_LEQUAL case
|
|
||||||
FogColor_AREF.a = (float)m_context->TEST.AREF - 0.1f;
|
|
||||||
ps_atst = 2;
|
|
||||||
break;
|
|
||||||
case ATST_GREATER:
|
|
||||||
// Maybe a -1 trick multiplication factor could be used to merge with ATST_LESS case
|
|
||||||
FogColor_AREF.a = (float)m_context->TEST.AREF - 0.1f + 1.0f;
|
|
||||||
ps_atst = 2;
|
|
||||||
break;
|
|
||||||
case ATST_EQUAL:
|
|
||||||
FogColor_AREF.a = (float)m_context->TEST.AREF;
|
|
||||||
ps_atst = 3;
|
|
||||||
break;
|
|
||||||
case ATST_NOTEQUAL:
|
|
||||||
FogColor_AREF.a = (float)m_context->TEST.AREF;
|
|
||||||
ps_atst = 4;
|
|
||||||
break;
|
|
||||||
case ATST_NEVER: // Draw won't be done so no need to implement it in shader
|
|
||||||
case ATST_ALWAYS:
|
|
||||||
default:
|
|
||||||
ps_atst = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fix the vertex position/tex_coordinate from 16 bits color to 32 bits color
|
// Fix the vertex position/tex_coordinate from 16 bits color to 32 bits color
|
||||||
void GSRendererHW::ConvertSpriteTextureShuffle(bool& write_ba, bool& read_ba)
|
void GSRendererHW::ConvertSpriteTextureShuffle(bool& write_ba, bool& read_ba)
|
||||||
{
|
{
|
||||||
|
@ -510,8 +464,8 @@ void GSRendererHW::ConvertSpriteTextureShuffle(bool& write_ba, bool& read_ba)
|
||||||
write_ba = (pos > 112 && pos < 136);
|
write_ba = (pos > 112 && pos < 136);
|
||||||
|
|
||||||
// Read texture is 8 to 16 pixels (same as above)
|
// Read texture is 8 to 16 pixels (same as above)
|
||||||
const float tw = (float)(1u << m_context->TEX0.TW);
|
const float tw = static_cast<float>(1u << m_context->TEX0.TW);
|
||||||
int tex_pos = (PRIM->FST) ? v[0].U : (int)(tw * v[0].ST.S);
|
int tex_pos = (PRIM->FST) ? v[0].U : static_cast<int>(tw * v[0].ST.S);
|
||||||
tex_pos &= 0xFF;
|
tex_pos &= 0xFF;
|
||||||
read_ba = (tex_pos > 112 && tex_pos < 144);
|
read_ba = (tex_pos > 112 && tex_pos < 144);
|
||||||
|
|
||||||
|
@ -557,7 +511,7 @@ void GSRendererHW::ConvertSpriteTextureShuffle(bool& write_ba, bool& read_ba)
|
||||||
int YCord = 0;
|
int YCord = 0;
|
||||||
|
|
||||||
if (!PRIM->FST)
|
if (!PRIM->FST)
|
||||||
YCord = (int)((1 << m_context->TEX0.TH) * (v[i].ST.T / v[i].RGBAQ.Q));
|
YCord = static_cast<int>((1 << m_context->TEX0.TH) * (v[i].ST.T / v[i].RGBAQ.Q));
|
||||||
else
|
else
|
||||||
YCord = (v[i].V >> 4);
|
YCord = (v[i].V >> 4);
|
||||||
|
|
||||||
|
@ -596,10 +550,10 @@ void GSRendererHW::ConvertSpriteTextureShuffle(bool& write_ba, bool& read_ba)
|
||||||
GSVector4i tmp(v[i].XYZ.Y, v[i].V, v[i + 1].XYZ.Y, v[i + 1].V);
|
GSVector4i tmp(v[i].XYZ.Y, v[i].V, v[i + 1].XYZ.Y, v[i + 1].V);
|
||||||
tmp = GSVector4i(tmp - offset).srl32(1) + offset;
|
tmp = GSVector4i(tmp - offset).srl32(1) + offset;
|
||||||
|
|
||||||
v[i].XYZ.Y = (u16)tmp.x;
|
v[i].XYZ.Y = static_cast<u16>(tmp.x);
|
||||||
v[i].V = (u16)tmp.y;
|
v[i].V = static_cast<u16>(tmp.y);
|
||||||
v[i + 1].XYZ.Y = (u16)tmp.z;
|
v[i + 1].XYZ.Y = static_cast<u16>(tmp.z);
|
||||||
v[i + 1].V = (u16)tmp.w;
|
v[i + 1].V = static_cast<u16>(tmp.w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -629,9 +583,9 @@ void GSRendererHW::ConvertSpriteTextureShuffle(bool& write_ba, bool& read_ba)
|
||||||
tmp = GSVector4i(tmp - offset).srl32(1) + offset;
|
tmp = GSVector4i(tmp - offset).srl32(1) + offset;
|
||||||
|
|
||||||
//fprintf(stderr, "Before %d, After %d\n", v[i + 1].XYZ.Y, tmp.y);
|
//fprintf(stderr, "Before %d, After %d\n", v[i + 1].XYZ.Y, tmp.y);
|
||||||
v[i].XYZ.Y = (u16)tmp.x;
|
v[i].XYZ.Y = static_cast<u16>(tmp.x);
|
||||||
v[i].ST.T /= 2.0f;
|
v[i].ST.T /= 2.0f;
|
||||||
v[i + 1].XYZ.Y = (u16)tmp.y;
|
v[i + 1].XYZ.Y = static_cast<u16>(tmp.y);
|
||||||
v[i + 1].ST.T /= 2.0f;
|
v[i + 1].ST.T /= 2.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -719,8 +673,8 @@ GSVector4 GSRendererHW::RealignTargetTextureCoordinate(const GSTextureCache::Sou
|
||||||
}
|
}
|
||||||
else if (m_vt.m_eq.q)
|
else if (m_vt.m_eq.q)
|
||||||
{
|
{
|
||||||
const float tw = (float)(1 << m_context->TEX0.TW);
|
const float tw = static_cast<float>(1 << m_context->TEX0.TW);
|
||||||
const float th = (float)(1 << m_context->TEX0.TH);
|
const float th = static_cast<float>(1 << m_context->TEX0.TH);
|
||||||
const float q = v[0].RGBAQ.Q;
|
const float q = v[0].RGBAQ.Q;
|
||||||
|
|
||||||
// Tales of Abyss
|
// Tales of Abyss
|
||||||
|
@ -861,14 +815,14 @@ void GSRendererHW::ExpandTarget(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector
|
||||||
|
|
||||||
void GSRendererHW::InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r, bool eewrite)
|
void GSRendererHW::InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r, bool eewrite)
|
||||||
{
|
{
|
||||||
// printf("[%d] InvalidateVideoMem %d,%d - %d,%d %05x (%d)\n", (int)m_perfmon.GetFrame(), r.left, r.top, r.right, r.bottom, (int)BITBLTBUF.DBP, (int)BITBLTBUF.DPSM);
|
// printf("[%d] InvalidateVideoMem %d,%d - %d,%d %05x (%d)\n", static_cast<int>(g_perfmon.GetFrame()), r.left, r.top, r.right, r.bottom, static_cast<int>(BITBLTBUF.DBP), static_cast<int>(BITBLTBUF.DPSM));
|
||||||
|
|
||||||
m_tc->InvalidateVideoMem(m_mem.GetOffset(BITBLTBUF.DBP, BITBLTBUF.DBW, BITBLTBUF.DPSM), r, eewrite);
|
m_tc->InvalidateVideoMem(m_mem.GetOffset(BITBLTBUF.DBP, BITBLTBUF.DBW, BITBLTBUF.DPSM), r, eewrite);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GSRendererHW::InvalidateLocalMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r, bool clut)
|
void GSRendererHW::InvalidateLocalMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r, bool clut)
|
||||||
{
|
{
|
||||||
// printf("[%d] InvalidateLocalMem %d,%d - %d,%d %05x (%d)\n", (int)m_perfmon.GetFrame(), r.left, r.top, r.right, r.bottom, (int)BITBLTBUF.SBP, (int)BITBLTBUF.SPSM);
|
// printf("[%d] InvalidateLocalMem %d,%d - %d,%d %05x (%d)\n", static_cast<int>(g_perfmon.GetFrame()), r.left, r.top, r.right, r.bottom, static_cast<int>(BITBLTBUF.SBP), static_cast<int>(BITBLTBUF.SPSM));
|
||||||
|
|
||||||
if (clut)
|
if (clut)
|
||||||
return; // FIXME
|
return; // FIXME
|
||||||
|
@ -899,19 +853,19 @@ void GSRendererHW::Move()
|
||||||
u16 GSRendererHW::Interpolate_UV(float alpha, int t0, int t1)
|
u16 GSRendererHW::Interpolate_UV(float alpha, int t0, int t1)
|
||||||
{
|
{
|
||||||
const float t = (1.0f - alpha) * t0 + alpha * t1;
|
const float t = (1.0f - alpha) * t0 + alpha * t1;
|
||||||
return (u16)t & ~0xF; // cheap rounding
|
return static_cast<u16>(t) & ~0xF; // cheap rounding
|
||||||
}
|
}
|
||||||
|
|
||||||
float GSRendererHW::alpha0(int L, int X0, int X1)
|
float GSRendererHW::alpha0(int L, int X0, int X1)
|
||||||
{
|
{
|
||||||
const int x = (X0 + 15) & ~0xF; // Round up
|
const int x = (X0 + 15) & ~0xF; // Round up
|
||||||
return float(x - X0) / (float)L;
|
return static_cast<float>(x - X0) / static_cast<float>(L);
|
||||||
}
|
}
|
||||||
|
|
||||||
float GSRendererHW::alpha1(int L, int X0, int X1)
|
float GSRendererHW::alpha1(int L, int X0, int X1)
|
||||||
{
|
{
|
||||||
const int x = (X1 - 1) & ~0xF; // Round down. Note -1 because right pixel isn't included in primitive so 0x100 must return 0.
|
const int x = (X1 - 1) & ~0xF; // Round down. Note -1 because right pixel isn't included in primitive so 0x100 must return 0.
|
||||||
return float(x - X0) / (float)L;
|
return static_cast<float>(x - X0) / static_cast<float>(L);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GSRendererHW::SwSpriteRender()
|
void GSRendererHW::SwSpriteRender()
|
||||||
|
@ -1341,7 +1295,7 @@ void GSRendererHW::Draw()
|
||||||
// So if it doesn't meet the condition, always fail, if it does, always pass (turn off the test).
|
// So if it doesn't meet the condition, always fail, if it does, always pass (turn off the test).
|
||||||
if (IsCoverageAlpha() && context->TEST.ATE && context->TEST.ATST > 1)
|
if (IsCoverageAlpha() && context->TEST.ATE && context->TEST.ATST > 1)
|
||||||
{
|
{
|
||||||
const float aref = (float)context->TEST.AREF;
|
const float aref = static_cast<float>(context->TEST.AREF);
|
||||||
const int old_ATST = context->TEST.ATST;
|
const int old_ATST = context->TEST.ATST;
|
||||||
context->TEST.ATST = 0;
|
context->TEST.ATST = 0;
|
||||||
|
|
||||||
|
@ -1485,9 +1439,9 @@ void GSRendererHW::Draw()
|
||||||
|
|
||||||
int k = (m_context->TEX1.K + 8) >> 4;
|
int k = (m_context->TEX1.K + 8) >> 4;
|
||||||
int lcm = m_context->TEX1.LCM;
|
int lcm = m_context->TEX1.LCM;
|
||||||
const int mxl = std::min<int>((int)m_context->TEX1.MXL, 6);
|
const int mxl = std::min<int>(static_cast<int>(m_context->TEX1.MXL), 6);
|
||||||
|
|
||||||
if ((int)m_vt.m_lod.x >= mxl)
|
if (static_cast<int>(m_vt.m_lod.x) >= mxl)
|
||||||
{
|
{
|
||||||
k = mxl; // set lod to max level
|
k = mxl; // set lod to max level
|
||||||
lcm = 1; // constant lod
|
lcm = 1; // constant lod
|
||||||
|
@ -1512,25 +1466,25 @@ void GSRendererHW::Draw()
|
||||||
if (interpolation == 2)
|
if (interpolation == 2)
|
||||||
{
|
{
|
||||||
// Mipmap Linear. Both layers are sampled, only take the big one
|
// Mipmap Linear. Both layers are sampled, only take the big one
|
||||||
m_lod.x = std::max<int>((int)floor(m_vt.m_lod.x), 0);
|
m_lod.x = std::max<int>(static_cast<int>(floor(m_vt.m_lod.x)), 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// On GS lod is a fixed float number 7:4 (4 bit for the frac part)
|
// On GS lod is a fixed float number 7:4 (4 bit for the frac part)
|
||||||
#if 0
|
#if 0
|
||||||
m_lod.x = std::max<int>((int)round(m_vt.m_lod.x + 0.0625), 0);
|
m_lod.x = std::max<int>(static_cast<int>(round(m_vt.m_lod.x + 0.0625)), 0);
|
||||||
#else
|
#else
|
||||||
// Same as above with a bigger margin on rounding
|
// Same as above with a bigger margin on rounding
|
||||||
// The goal is to avoid 1 undrawn pixels around the edge which trigger the load of the big
|
// The goal is to avoid 1 undrawn pixels around the edge which trigger the load of the big
|
||||||
// layer.
|
// layer.
|
||||||
if (ceil(m_vt.m_lod.x) < m_vt.m_lod.y)
|
if (ceil(m_vt.m_lod.x) < m_vt.m_lod.y)
|
||||||
m_lod.x = std::max<int>((int)round(m_vt.m_lod.x + 0.0625 + 0.01), 0);
|
m_lod.x = std::max<int>(static_cast<int>(round(m_vt.m_lod.x + 0.0625 + 0.01)), 0);
|
||||||
else
|
else
|
||||||
m_lod.x = std::max<int>((int)round(m_vt.m_lod.x + 0.0625), 0);
|
m_lod.x = std::max<int>(static_cast<int>(round(m_vt.m_lod.x + 0.0625)), 0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
m_lod.y = std::max<int>((int)ceil(m_vt.m_lod.y), 0);
|
m_lod.y = std::max<int>(static_cast<int>(ceil(m_vt.m_lod.y)), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_lod.x = std::min<int>(m_lod.x, mxl);
|
m_lod.x = std::min<int>(m_lod.x, mxl);
|
||||||
|
@ -1593,7 +1547,7 @@ void GSRendererHW::Draw()
|
||||||
// If m_src is from a target that isn't the same size as the texture, texture sample edge modes won't work quite the same way
|
// If m_src is from a target that isn't the same size as the texture, texture sample edge modes won't work quite the same way
|
||||||
// If the game actually tries to access stuff outside of the rendered target, it was going to get garbage anyways so whatever
|
// If the game actually tries to access stuff outside of the rendered target, it was going to get garbage anyways so whatever
|
||||||
// But the game could issue reads that wrap to valid areas, so move wrapping to the shader if wrapping is used
|
// But the game could issue reads that wrap to valid areas, so move wrapping to the shader if wrapping is used
|
||||||
GSVector4i unscaled_size = GSVector4i(GSVector4(m_src->m_texture->GetSize()) / GSVector4(m_src->m_texture->GetScale()));
|
const GSVector4i unscaled_size = GSVector4i(GSVector4(m_src->m_texture->GetSize()) / GSVector4(m_src->m_texture->GetScale()));
|
||||||
if (m_context->CLAMP.WMS == CLAMP_REPEAT && (tmm.uses_boundary & TextureMinMaxResult::USES_BOUNDARY_U) && unscaled_size.x != tw)
|
if (m_context->CLAMP.WMS == CLAMP_REPEAT && (tmm.uses_boundary & TextureMinMaxResult::USES_BOUNDARY_U) && unscaled_size.x != tw)
|
||||||
{
|
{
|
||||||
// Our shader-emulated region repeat doesn't upscale :(
|
// Our shader-emulated region repeat doesn't upscale :(
|
||||||
|
@ -1781,8 +1735,8 @@ void GSRendererHW::Draw()
|
||||||
{
|
{
|
||||||
// We still need to make sure the dimensions of the targets match.
|
// We still need to make sure the dimensions of the targets match.
|
||||||
const GSVector2 up_s(GetTextureScaleFactor());
|
const GSVector2 up_s(GetTextureScaleFactor());
|
||||||
int new_w = std::max(t_size.x, std::max(rt ? rt->m_texture->GetWidth() : 0, ds ? ds->m_texture->GetWidth() : 0));
|
const int new_w = std::max(t_size.x, std::max(rt ? rt->m_texture->GetWidth() : 0, ds ? ds->m_texture->GetWidth() : 0));
|
||||||
int new_h = std::max(t_size.y, std::max(rt ? rt->m_texture->GetHeight() : 0, ds ? ds->m_texture->GetHeight() : 0));
|
const int new_h = std::max(t_size.y, std::max(rt ? rt->m_texture->GetHeight() : 0, ds ? ds->m_texture->GetHeight() : 0));
|
||||||
|
|
||||||
if (rt)
|
if (rt)
|
||||||
{
|
{
|
||||||
|
@ -1813,10 +1767,10 @@ void GSRendererHW::Draw()
|
||||||
if (GSConfig.SaveTexture && s_n >= GSConfig.SaveN && m_src)
|
if (GSConfig.SaveTexture && s_n >= GSConfig.SaveN && m_src)
|
||||||
{
|
{
|
||||||
s = GetDrawDumpPath("%05d_f%lld_itex_%05x_%s_%d%d_%02x_%02x_%02x_%02x.dds",
|
s = GetDrawDumpPath("%05d_f%lld_itex_%05x_%s_%d%d_%02x_%02x_%02x_%02x.dds",
|
||||||
s_n, frame, (int)context->TEX0.TBP0, psm_str(context->TEX0.PSM),
|
s_n, frame, static_cast<int>(context->TEX0.TBP0), psm_str(context->TEX0.PSM),
|
||||||
(int)context->CLAMP.WMS, (int)context->CLAMP.WMT,
|
static_cast<int>(context->CLAMP.WMS), static_cast<int>(context->CLAMP.WMT),
|
||||||
(int)context->CLAMP.MINU, (int)context->CLAMP.MAXU,
|
static_cast<int>(context->CLAMP.MINU), static_cast<int>(context->CLAMP.MAXU),
|
||||||
(int)context->CLAMP.MINV, (int)context->CLAMP.MAXV);
|
static_cast<int>(context->CLAMP.MINV), static_cast<int>(context->CLAMP.MAXV));
|
||||||
|
|
||||||
m_src->m_texture->Save(s);
|
m_src->m_texture->Save(s);
|
||||||
|
|
||||||
|
@ -2186,7 +2140,7 @@ void GSRendererHW::EmulateZbuffer()
|
||||||
// On the real GS we appear to do clamping on the max z value the format allows.
|
// On the real GS we appear to do clamping on the max z value the format allows.
|
||||||
// Clamping is done after rasterization.
|
// Clamping is done after rasterization.
|
||||||
const u32 max_z = 0xFFFFFFFF >> (GSLocalMemory::m_psm[m_context->ZBUF.PSM].fmt * 8);
|
const u32 max_z = 0xFFFFFFFF >> (GSLocalMemory::m_psm[m_context->ZBUF.PSM].fmt * 8);
|
||||||
const bool clamp_z = (u32)(GSVector4i(m_vt.m_max.p).z) > max_z;
|
const bool clamp_z = static_cast<u32>(GSVector4i(m_vt.m_max.p).z) > max_z;
|
||||||
|
|
||||||
m_conf.cb_vs.max_depth = GSVector2i(0xFFFFFFFF);
|
m_conf.cb_vs.max_depth = GSVector2i(0xFFFFFFFF);
|
||||||
//ps_cb.MaxDepth = GSVector4(0.0f, 0.0f, 0.0f, 1.0f);
|
//ps_cb.MaxDepth = GSVector4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
@ -2537,10 +2491,10 @@ void GSRendererHW::EmulateChannelShuffle(const GSTextureCache::Source* tex)
|
||||||
// the rendered size of the framebuffer
|
// the rendered size of the framebuffer
|
||||||
|
|
||||||
GSVertex* s = &m_vertex.buff[0];
|
GSVertex* s = &m_vertex.buff[0];
|
||||||
s[0].XYZ.X = (u16)(m_context->XYOFFSET.OFX + 0);
|
s[0].XYZ.X = static_cast<u16>(m_context->XYOFFSET.OFX + 0);
|
||||||
s[1].XYZ.X = (u16)(m_context->XYOFFSET.OFX + 16384);
|
s[1].XYZ.X = static_cast<u16>(m_context->XYOFFSET.OFX + 16384);
|
||||||
s[0].XYZ.Y = (u16)(m_context->XYOFFSET.OFY + 0);
|
s[0].XYZ.Y = static_cast<u16>(m_context->XYOFFSET.OFY + 0);
|
||||||
s[1].XYZ.Y = (u16)(m_context->XYOFFSET.OFY + 16384);
|
s[1].XYZ.Y = static_cast<u16>(m_context->XYOFFSET.OFY + 16384);
|
||||||
|
|
||||||
m_vertex.head = m_vertex.tail = m_vertex.next = 2;
|
m_vertex.head = m_vertex.tail = m_vertex.next = 2;
|
||||||
m_index.tail = 2;
|
m_index.tail = 2;
|
||||||
|
@ -2657,7 +2611,7 @@ void GSRendererHW::EmulateBlending(bool& DATE_PRIMID, bool& DATE_BARRIER, bool&
|
||||||
else
|
else
|
||||||
blend_ad_alpha_masked = false;
|
blend_ad_alpha_masked = false;
|
||||||
|
|
||||||
u8 blend_index = u8(((m_conf.ps.blend_a * 3 + m_conf.ps.blend_b) * 3 + m_conf.ps.blend_c) * 3 + m_conf.ps.blend_d);
|
u8 blend_index = static_cast<u8>(((m_conf.ps.blend_a * 3 + m_conf.ps.blend_b) * 3 + m_conf.ps.blend_c) * 3 + m_conf.ps.blend_d);
|
||||||
const HWBlend blend_preliminary = GSDevice::GetBlend(blend_index, false);
|
const HWBlend blend_preliminary = GSDevice::GetBlend(blend_index, false);
|
||||||
const int blend_flag = blend_preliminary.flags;
|
const int blend_flag = blend_preliminary.flags;
|
||||||
|
|
||||||
|
@ -3317,8 +3271,8 @@ void GSRendererHW::EmulateTextureSampler(const GSTextureCache::Source* tex)
|
||||||
const int w = tex->m_texture->GetWidth();
|
const int w = tex->m_texture->GetWidth();
|
||||||
const int h = tex->m_texture->GetHeight();
|
const int h = tex->m_texture->GetHeight();
|
||||||
|
|
||||||
const int tw = (int)(1 << m_context->TEX0.TW);
|
const int tw = static_cast<int>(1 << m_context->TEX0.TW);
|
||||||
const int th = (int)(1 << m_context->TEX0.TH);
|
const int th = static_cast<int>(1 << m_context->TEX0.TH);
|
||||||
const int miptw = 1 << tex->m_TEX0.TW;
|
const int miptw = 1 << tex->m_TEX0.TW;
|
||||||
const int mipth = 1 << tex->m_TEX0.TH;
|
const int mipth = 1 << tex->m_TEX0.TH;
|
||||||
|
|
||||||
|
@ -3338,10 +3292,10 @@ void GSRendererHW::EmulateTextureSampler(const GSTextureCache::Source* tex)
|
||||||
else if (trilinear_manual)
|
else if (trilinear_manual)
|
||||||
{
|
{
|
||||||
// Reuse uv_min_max for mipmap parameter to avoid an extension of the UBO
|
// Reuse uv_min_max for mipmap parameter to avoid an extension of the UBO
|
||||||
m_conf.cb_ps.MinMax.x = (float)m_context->TEX1.K / 16.0f;
|
m_conf.cb_ps.MinMax.x = static_cast<float>(m_context->TEX1.K) / 16.0f;
|
||||||
m_conf.cb_ps.MinMax.y = float(1 << m_context->TEX1.L);
|
m_conf.cb_ps.MinMax.y = static_cast<float>(1 << m_context->TEX1.L);
|
||||||
m_conf.cb_ps.MinMax.z = float(m_lod.x); // Offset because first layer is m_lod, dunno if we can do better
|
m_conf.cb_ps.MinMax.z = static_cast<float>(m_lod.x); // Offset because first layer is m_lod, dunno if we can do better
|
||||||
m_conf.cb_ps.MinMax.w = float(m_lod.y);
|
m_conf.cb_ps.MinMax.w = static_cast<float>(m_lod.y);
|
||||||
}
|
}
|
||||||
else if (trilinear_auto)
|
else if (trilinear_auto)
|
||||||
{
|
{
|
||||||
|
@ -3359,8 +3313,8 @@ void GSRendererHW::EmulateTextureSampler(const GSTextureCache::Source* tex)
|
||||||
{
|
{
|
||||||
m_conf.ps.invalid_tex0 = 1;
|
m_conf.ps.invalid_tex0 = 1;
|
||||||
// Use invalid size to denormalize ST coordinate
|
// Use invalid size to denormalize ST coordinate
|
||||||
m_conf.cb_ps.WH.x = (float)(1 << m_context->stack.TEX0.TW);
|
m_conf.cb_ps.WH.x = static_cast<float>(1 << m_context->stack.TEX0.TW);
|
||||||
m_conf.cb_ps.WH.y = (float)(1 << m_context->stack.TEX0.TH);
|
m_conf.cb_ps.WH.y = static_cast<float>(1 << m_context->stack.TEX0.TH);
|
||||||
|
|
||||||
// We can't handle m_target with invalid_tex0 atm due to upscaling
|
// We can't handle m_target with invalid_tex0 atm due to upscaling
|
||||||
ASSERT(!tex->m_target);
|
ASSERT(!tex->m_target);
|
||||||
|
@ -3447,32 +3401,32 @@ void GSRendererHW::EmulateATST(float& AREF, GSHWDrawConfig::PSSelector& ps, bool
|
||||||
|
|
||||||
// Check for pass 2, otherwise do pass 1.
|
// Check for pass 2, otherwise do pass 1.
|
||||||
const int atst = pass_2 ? inverted_atst[m_context->TEST.ATST] : m_context->TEST.ATST;
|
const int atst = pass_2 ? inverted_atst[m_context->TEST.ATST] : m_context->TEST.ATST;
|
||||||
|
const float aref = static_cast<float>(m_context->TEST.AREF);
|
||||||
|
|
||||||
switch (atst)
|
switch (atst)
|
||||||
{
|
{
|
||||||
case ATST_LESS:
|
case ATST_LESS:
|
||||||
AREF = static_cast<float>(m_context->TEST.AREF) - 0.1f;
|
AREF = aref - 0.1f;
|
||||||
ps.atst = 1;
|
ps.atst = 1;
|
||||||
break;
|
break;
|
||||||
case ATST_LEQUAL:
|
case ATST_LEQUAL:
|
||||||
AREF = static_cast<float>(m_context->TEST.AREF) - 0.1f + 1.0f;
|
AREF = aref - 0.1f + 1.0f;
|
||||||
ps.atst = 1;
|
ps.atst = 1;
|
||||||
break;
|
break;
|
||||||
case ATST_GEQUAL:
|
case ATST_GEQUAL:
|
||||||
AREF = static_cast<float>(m_context->TEST.AREF) - 0.1f;
|
AREF = aref - 0.1f;
|
||||||
ps.atst = 2;
|
ps.atst = 2;
|
||||||
break;
|
break;
|
||||||
case ATST_GREATER:
|
case ATST_GREATER:
|
||||||
AREF = static_cast<float>(m_context->TEST.AREF) - 0.1f + 1.0f;
|
AREF = aref - 0.1f + 1.0f;
|
||||||
ps.atst = 2;
|
ps.atst = 2;
|
||||||
break;
|
break;
|
||||||
case ATST_EQUAL:
|
case ATST_EQUAL:
|
||||||
AREF = static_cast<float>(m_context->TEST.AREF);
|
AREF = aref;
|
||||||
ps.atst = 3;
|
ps.atst = 3;
|
||||||
break;
|
break;
|
||||||
case ATST_NOTEQUAL:
|
case ATST_NOTEQUAL:
|
||||||
AREF = static_cast<float>(m_context->TEST.AREF);
|
AREF = aref;
|
||||||
ps.atst = 4;
|
ps.atst = 4;
|
||||||
break;
|
break;
|
||||||
case ATST_NEVER: // Draw won't be done so no need to implement it in shader
|
case ATST_NEVER: // Draw won't be done so no need to implement it in shader
|
||||||
|
@ -3681,8 +3635,8 @@ void GSRendererHW::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sourc
|
||||||
const GSVector2 rtscale(m_conf.ds ? m_conf.ds->GetScale() : m_conf.rt->GetScale());
|
const GSVector2 rtscale(m_conf.ds ? m_conf.ds->GetScale() : m_conf.rt->GetScale());
|
||||||
const float sx = 2.0f * rtscale.x / (rtsize.x << 4);
|
const float sx = 2.0f * rtscale.x / (rtsize.x << 4);
|
||||||
const float sy = 2.0f * rtscale.y / (rtsize.y << 4);
|
const float sy = 2.0f * rtscale.y / (rtsize.y << 4);
|
||||||
const float ox = (float)(int)m_context->XYOFFSET.OFX;
|
const float ox = static_cast<float>(static_cast<int>(m_context->XYOFFSET.OFX));
|
||||||
const float oy = (float)(int)m_context->XYOFFSET.OFY;
|
const float oy = static_cast<float>(static_cast<int>(m_context->XYOFFSET.OFY));
|
||||||
float ox2 = -1.0f / rtsize.x;
|
float ox2 = -1.0f / rtsize.x;
|
||||||
float oy2 = -1.0f / rtsize.y;
|
float oy2 = -1.0f / rtsize.y;
|
||||||
|
|
||||||
|
@ -3764,8 +3718,8 @@ void GSRendererHW::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sourc
|
||||||
const bool commutative_depth = (m_conf.depth.ztst == ZTST_GEQUAL && m_vt.m_eq.z) || (m_conf.depth.ztst == ZTST_ALWAYS);
|
const bool commutative_depth = (m_conf.depth.ztst == ZTST_GEQUAL && m_vt.m_eq.z) || (m_conf.depth.ztst == ZTST_ALWAYS);
|
||||||
const bool commutative_alpha = (m_context->ALPHA.C != 1); // when either Alpha Src or a constant
|
const bool commutative_alpha = (m_context->ALPHA.C != 1); // when either Alpha Src or a constant
|
||||||
|
|
||||||
ate_RGBA_then_Z = (m_context->TEST.AFAIL == AFAIL_FB_ONLY) & commutative_depth;
|
ate_RGBA_then_Z = (m_context->TEST.AFAIL == AFAIL_FB_ONLY) && commutative_depth;
|
||||||
ate_RGB_then_ZA = (m_context->TEST.AFAIL == AFAIL_RGB_ONLY) & commutative_depth & commutative_alpha;
|
ate_RGB_then_ZA = (m_context->TEST.AFAIL == AFAIL_RGB_ONLY) && commutative_depth && commutative_alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ate_RGBA_then_Z)
|
if (ate_RGBA_then_Z)
|
||||||
|
@ -4082,7 +4036,7 @@ GSRendererHW::CLUTDrawTestResult GSRendererHW::PossibleCLUTDraw()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GIFRegBITBLTBUF BITBLTBUF;
|
GIFRegBITBLTBUF BITBLTBUF = {};
|
||||||
BITBLTBUF.SBP = m_context->TEX0.TBP0;
|
BITBLTBUF.SBP = m_context->TEX0.TBP0;
|
||||||
BITBLTBUF.SBW = m_context->TEX0.TBW;
|
BITBLTBUF.SBW = m_context->TEX0.TBW;
|
||||||
BITBLTBUF.SPSM = m_context->TEX0.PSM;
|
BITBLTBUF.SPSM = m_context->TEX0.PSM;
|
||||||
|
@ -4366,8 +4320,8 @@ bool GSRendererHW::OI_BlitFMV(GSTextureCache::Target* _rt, GSTextureCache::Sourc
|
||||||
// Bottom of Texture (half height frame, will be the copy of Top texture after the draw)
|
// Bottom of Texture (half height frame, will be the copy of Top texture after the draw)
|
||||||
// -----------------------------------------------------------------
|
// -----------------------------------------------------------------
|
||||||
|
|
||||||
const int tw = (int)(1 << m_context->TEX0.TW);
|
const int tw = static_cast<int>(1 << m_context->TEX0.TW);
|
||||||
const int th = (int)(1 << m_context->TEX0.TH);
|
const int th = static_cast<int>(1 << m_context->TEX0.TH);
|
||||||
|
|
||||||
// Compute the Bottom of texture rectangle
|
// Compute the Bottom of texture rectangle
|
||||||
ASSERT(m_context->TEX0.TBP0 > m_context->FRAME.Block());
|
ASSERT(m_context->TEX0.TBP0 > m_context->FRAME.Block());
|
||||||
|
|
|
@ -138,7 +138,6 @@ public:
|
||||||
void Lines2Sprites();
|
void Lines2Sprites();
|
||||||
bool VerifyIndices();
|
bool VerifyIndices();
|
||||||
template <GSHWDrawConfig::VSExpand Expand> void ExpandIndices();
|
template <GSHWDrawConfig::VSExpand Expand> void ExpandIndices();
|
||||||
void EmulateAtst(GSVector4& FogColor_AREF, u8& atst, const bool pass_2);
|
|
||||||
void ConvertSpriteTextureShuffle(bool& write_ba, bool& read_ba);
|
void ConvertSpriteTextureShuffle(bool& write_ba, bool& read_ba);
|
||||||
GSVector4 RealignTargetTextureCoordinate(const GSTextureCache::Source* tex);
|
GSVector4 RealignTargetTextureCoordinate(const GSTextureCache::Source* tex);
|
||||||
GSVector4i ComputeBoundingBox(const GSVector2& rtscale, const GSVector2i& rtsize);
|
GSVector4i ComputeBoundingBox(const GSVector2& rtscale, const GSVector2i& rtsize);
|
||||||
|
|
Loading…
Reference in New Issue