mirror of https://github.com/PCSX2/pcsx2.git
GSdx-hw: Add automatic detection of half-bottom in TS
Typical shuffle case is 1/2 height so other half is undesired In dbz we split the depth buffer. - Sample first half, write to `0x0`. - Sample second half, write to `0x800` - Finally, sample `0x0` though `0xffc` Crash Twinsanity is a similar case.
This commit is contained in:
parent
97612edd58
commit
7eb0b0ac65
|
@ -448,6 +448,20 @@ void GSRendererHW::ConvertSpriteTextureShuffle(bool& write_ba, bool& read_ba)
|
|||
tex_pos &= 0xFF;
|
||||
read_ba = (tex_pos > 112 && tex_pos < 144);
|
||||
|
||||
// Here's the idea
|
||||
// TS effect is 16 bits but we emulate it on a 32 bits format
|
||||
// Normally this means we need to divide size by 2.
|
||||
//
|
||||
// Some games do two TS effects on each half of the buffer.
|
||||
// This makes a mess for us in the TC because we end up with two targets
|
||||
// when we only want one, thus half screen bug.
|
||||
//
|
||||
// 32bits emulation means we can do the effect once but double the size.
|
||||
// Test cases: Crash Twinsantiy and DBZ BT3
|
||||
int height_delta = m_src->m_valid_rect.height() - m_r.height();
|
||||
// Test Case: NFS: HP2 splits the effect h:256 and h:192 so 64
|
||||
bool half_bottom = abs(height_delta) <= 64;
|
||||
|
||||
if (PRIM->FST) {
|
||||
GL_INS("First vertex is P: %d => %d T: %d => %d", v[0].XYZ.X, v[1].XYZ.X, v[0].U, v[1].U);
|
||||
|
||||
|
@ -462,6 +476,7 @@ void GSRendererHW::ConvertSpriteTextureShuffle(bool& write_ba, bool& read_ba)
|
|||
else
|
||||
v[i+1].U += 128u;
|
||||
|
||||
if (!half_bottom){
|
||||
// Height is too big (2x).
|
||||
int tex_offset = v[i].V & 0xF;
|
||||
GSVector4i offset(o.OFY, tex_offset, o.OFY, tex_offset);
|
||||
|
@ -474,6 +489,7 @@ void GSRendererHW::ConvertSpriteTextureShuffle(bool& write_ba, bool& read_ba)
|
|||
v[i + 1].XYZ.Y = (uint16)tmp.z;
|
||||
v[i + 1].V = (uint16)tmp.w;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const float offset_8pix = 8.0f / tw;
|
||||
GL_INS("First vertex is P: %d => %d T: %f => %f (offset %f)", v[0].XYZ.X, v[1].XYZ.X, v[0].ST.S, v[1].ST.S, offset_8pix);
|
||||
|
@ -489,6 +505,7 @@ void GSRendererHW::ConvertSpriteTextureShuffle(bool& write_ba, bool& read_ba)
|
|||
else
|
||||
v[i+1].ST.S += offset_8pix;
|
||||
|
||||
if (!half_bottom) {
|
||||
// Height is too big (2x).
|
||||
GSVector4i offset(o.OFY, o.OFY);
|
||||
|
||||
|
@ -502,6 +519,7 @@ void GSRendererHW::ConvertSpriteTextureShuffle(bool& write_ba, bool& read_ba)
|
|||
v[i + 1].ST.T /= 2.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update vertex trace too. Avoid issue to compute bounding box
|
||||
if (write_ba)
|
||||
|
@ -509,18 +527,21 @@ void GSRendererHW::ConvertSpriteTextureShuffle(bool& write_ba, bool& read_ba)
|
|||
else
|
||||
m_vt.m_max.p.x += 8.0f;
|
||||
|
||||
|
||||
if (!half_bottom) {
|
||||
float delta_Y = m_vt.m_max.p.y - m_vt.m_min.p.y;
|
||||
m_vt.m_max.p.y -= delta_Y / 2.0f;
|
||||
}
|
||||
|
||||
if (read_ba)
|
||||
m_vt.m_min.t.x -= 8.0f;
|
||||
else
|
||||
m_vt.m_max.t.x += 8.0f;
|
||||
|
||||
if (!half_bottom) {
|
||||
float delta_T = m_vt.m_max.t.y - m_vt.m_min.t.y;
|
||||
m_vt.m_max.t.y -= delta_T / 2.0f;
|
||||
}
|
||||
}
|
||||
|
||||
GSVector4 GSRendererHW::RealignTargetTextureCoordinate(const GSTextureCache::Source* tex)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue