Skip to content

Commit

Permalink
GPU: Try a bit harder to determine safe size.
Browse files Browse the repository at this point in the history
  • Loading branch information
unknownbrackets committed May 23, 2020
1 parent ea1f0a1 commit 1432cc9
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion GPU/Common/SoftwareTransformCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ void SoftwareTransform::Decode(int prim, u32 vertType, const DecVtxFormat &decVt
int scissorX2 = gstate.getScissorX2() + 1;
int scissorY2 = gstate.getScissorY2() + 1;
reallyAClear = IsReallyAClear(transformed, maxIndex, scissorX2, scissorY2);
if (reallyAClear) {
if (reallyAClear && gstate.getColorMask() != 0 && gstate.getClearModeColorMask() != 0) {
result->setSafeSize = true;
result->safeWidth = scissorX2;
result->safeHeight = scissorY2;
Expand All @@ -466,6 +466,22 @@ void SoftwareTransform::Decode(int prim, u32 vertType, const DecVtxFormat &decVt
return;
}
}

// Detect full screen "clears" that might not be so obvious, to set the safe size if possible.
if (!result->setSafeSize && prim == GE_PRIM_RECTANGLES && maxIndex == 2) {
bool clearingColor = gstate.isModeClear() && gstate.getClearModeColorMask() != 0;
bool writingColor = gstate.getColorMask() != 0;
bool startsZeroX = transformed[0].x <= 0.0f && transformed[1].x > transformed[0].x;
bool startsZeroY = transformed[0].y <= 0.0f && transformed[1].y > transformed[0].y;

if (startsZeroX && startsZeroY && (clearingColor || writingColor)) {
int scissorX2 = gstate.getScissorX2() + 1;
int scissorY2 = gstate.getScissorY2() + 1;
result->setSafeSize = true;
result->safeWidth = std::min(scissorX2, (int)transformed[1].x);
result->safeHeight = std::min(scissorY2, (int)transformed[1].y);
}
}
}

// Also, this assumes SetTexture() has already figured out the actual texture height.
Expand Down

0 comments on commit 1432cc9

Please sign in to comment.