mirror of https://github.com/PCSX2/pcsx2.git
gsdx-ogl: fix bad detection of overlapping
avoid rendering corruption with SW blending
This commit is contained in:
parent
fff59f547d
commit
eb0fa8c7dc
|
@ -460,20 +460,44 @@ GSRendererOGL::PRIM_OVERLAP GSRendererOGL::PrimitiveOverlap()
|
||||||
size_t count = m_vertex.next;
|
size_t count = m_vertex.next;
|
||||||
GSVertex* v = &m_vertex.buff[0];
|
GSVertex* v = &m_vertex.buff[0];
|
||||||
|
|
||||||
for(size_t i = 0; i < count; i += 2) {
|
// You have no guarantee on the sprite order, first vertex can be either top-left or bottom-left
|
||||||
// Very bad code
|
// There is a high probability that the draw call will uses same ordering for all vertices.
|
||||||
GSVector4i vi(v[i].XYZ.X, v[i].XYZ.Y, v[i+1].XYZ.X, v[i+1].XYZ.Y);
|
// In order to keep a small performance impact only the first sprite will be checked
|
||||||
for (size_t j = i+2; j < count; j += 2) {
|
//
|
||||||
GSVector4i vj(v[j].XYZ.X, v[j].XYZ.Y, v[j+1].XYZ.X, v[j+1].XYZ.Y);
|
// Some safe-guard will be added in the outer-loop to avoid corruption with a limited perf impact
|
||||||
GSVector4i inter = vi.rintersect(vj);
|
if (v[1].XYZ.Y < v[0].XYZ.Y) {
|
||||||
if (!inter.rempty()) {
|
// First vertex is Top-Left
|
||||||
//fprintf(stderr, "Overlap found between %d and %d (draw of %d vertices)\n", i, j, count);
|
for(size_t i = 0; i < count; i += 2) {
|
||||||
return PRIM_OVERLAP_YES;
|
if (v[i+1].XYZ.Y > v[i].XYZ.Y) {
|
||||||
|
return PRIM_OVERLAP_UNKNOW;
|
||||||
|
}
|
||||||
|
GSVector4i vi(v[i].XYZ.X, v[i+1].XYZ.Y, v[i+1].XYZ.X, v[i].XYZ.Y);
|
||||||
|
for (size_t j = i+2; j < count; j += 2) {
|
||||||
|
GSVector4i vj(v[j].XYZ.X, v[j+1].XYZ.Y, v[j+1].XYZ.X, v[j].XYZ.Y);
|
||||||
|
GSVector4i inter = vi.rintersect(vj);
|
||||||
|
if (!inter.rempty()) {
|
||||||
|
return PRIM_OVERLAP_YES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// First vertex is Bottom-Left
|
||||||
|
for(size_t i = 0; i < count; i += 2) {
|
||||||
|
if (v[i+1].XYZ.Y < v[i].XYZ.Y) {
|
||||||
|
return PRIM_OVERLAP_UNKNOW;
|
||||||
|
}
|
||||||
|
GSVector4i vi(v[i].XYZ.X, v[i].XYZ.Y, v[i+1].XYZ.X, v[i+1].XYZ.Y);
|
||||||
|
for (size_t j = i+2; j < count; j += 2) {
|
||||||
|
GSVector4i vj(v[j].XYZ.X, v[j].XYZ.Y, v[j+1].XYZ.X, v[j+1].XYZ.Y);
|
||||||
|
GSVector4i inter = vi.rintersect(vj);
|
||||||
|
if (!inter.rempty()) {
|
||||||
|
return PRIM_OVERLAP_YES;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//fprintf(stderr, "Yes, code can be optimized (draw of %d vertices)\n", count);
|
//fprintf(stderr, "%d: Yes, code can be optimized (draw of %d vertices)\n", s_n, count);
|
||||||
return PRIM_OVERLAP_NO;
|
return PRIM_OVERLAP_NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue