mirror of https://github.com/PCSX2/pcsx2.git
gsdx mipmap: improve robustness to avoid potential crash
This commit is contained in:
parent
ebb2a8ad5a
commit
be9995bd1e
|
@ -516,12 +516,23 @@ void GSRendererHW::Draw()
|
|||
|
||||
TEX0 = GetTex0Layer(lod);
|
||||
|
||||
// FIXME: previous round lod is likely wrong. Following code is a workaround until it is done properly
|
||||
// Ratchet & Clank set an address of 0 on invalid layer. Address 0 will be really awkward
|
||||
// for a mipmap layer. So use it to avoid invalid data
|
||||
if (TEX0.TBP0 == 0) {
|
||||
GL_INS("Warning invalid lod %d", lod);
|
||||
if (lod < mxl) {
|
||||
lod++;
|
||||
} else {
|
||||
lod--;
|
||||
}
|
||||
TEX0 = GetTex0Layer(lod);
|
||||
|
||||
// Experience: will people complain more about missing or invalid texture ? The bets are open :)
|
||||
if (TEX0.TBP0 == 0) {
|
||||
fprintf(stderr, "Invalid mipmap layer\n");
|
||||
throw GSDXRecoverableError();
|
||||
}
|
||||
}
|
||||
|
||||
MIP_CLAMP.MINU >>= lod;
|
||||
|
|
|
@ -3120,7 +3120,10 @@ GIFRegTEX0 GSState::GetTex0Layer(int lod)
|
|||
TEX0.TBW = m_context->MIPTBP2.TBW6;
|
||||
break;
|
||||
default:
|
||||
__assume(0);
|
||||
fprintf(stderr, "GetTex0Layer bad parameter. Fix your code!\n");
|
||||
lod = 6;
|
||||
TEX0.TBP0 = m_context->MIPTBP2.TBP6;
|
||||
TEX0.TBW = m_context->MIPTBP2.TBW6;
|
||||
}
|
||||
|
||||
// Correct the texture size
|
||||
|
|
Loading…
Reference in New Issue