gsdx hack: use a dumb implementation for UserHacks_round_sprite_offset = 2

It works as bad as a "clever" implementation.

It seems to be enough for games such as venus/taisho-monoke/FFX

Note: it might creates glitches. Code will never be nice, so it is just
a trade-off
This commit is contained in:
Gregory Hainaut 2015-04-16 18:27:27 +02:00
parent 41e5be0673
commit 670bcc1818
1 changed files with 13 additions and 17 deletions

View File

@ -226,8 +226,9 @@ void GSRendererHW::RoundSpriteOffset()
{ {
//#define DEBUG_U //#define DEBUG_U
//#define DEBUG_V //#define DEBUG_V
#if defined(DEBUG_V) || defined(DEBUG_U)
bool debug = linear; bool debug = linear;
const int half = linear ? 8 : 0; #endif
size_t count = m_vertex.next; size_t count = m_vertex.next;
GSVertex* v = &m_vertex.buff[0]; GSVertex* v = &m_vertex.buff[0];
@ -280,17 +281,15 @@ void GSRendererHW::RoundSpriteOffset()
// Use rounded value of the newly computed texture coordinate. It ensures // Use rounded value of the newly computed texture coordinate. It ensures
// that sampling will remains inside texture boundary // that sampling will remains inside texture boundary
// //
// Note for bilinear: in this mode the PS2 add -0.5 offset (aka half) and 4 texels // Note for bilinear: by definition it will never work correctly! A sligh modification
// will be sampled so (t0 - 8) and (t1 - 8 + 16) must be valid. // of interpolation migth trigger a discard (with alpha testing)
// // Let's use something simple that correct really bad case (for a couple of 2D games).
// Minus half for t1 case might be too much // I hope it won't create too much glitches.
if (linear) { if (linear) {
if (tx0 <= tx1) { int Lu = v[i+1].U - v[i].U;
v[i].U = tx0 + half; // Note 32 is based on taisho-mononoke
v[i+1].U = tx1 - half + 16; if ((Lu > 0) && (Lu <= (Lx+32))) {
} else { v[i+1].U -= 8;
v[i].U = tx0 + 15;
v[i+1].U = tx1;
} }
} else { } else {
if (tx0 <= tx1) { if (tx0 <= tx1) {
@ -304,12 +303,9 @@ void GSRendererHW::RoundSpriteOffset()
#endif #endif
#if 1 #if 1
if (linear) { if (linear) {
if (ty0 <= ty1) { int Lv = v[i+1].V - v[i].V;
v[i].V = ty0 + half; if ((Lv > 0) && (Lv <= (Ly+32))) {
v[i+1].V = ty1 - half + 16; v[i+1].V -= 8;
} else {
v[i].V = ty0 + 15;
v[i+1].V = ty1;
} }
} else { } else {
if (ty0 <= ty1) { if (ty0 <= ty1) {