softgpu: Correct clear rect off by one issues.

This commit is contained in:
Unknown W. Brackets 2022-09-20 12:52:06 -07:00
parent dc22fd2205
commit 7483923d07
2 changed files with 14 additions and 7 deletions

View File

@ -1136,13 +1136,20 @@ void DrawPoint(const VertexData &v0, const BinCoords &range, const RasterizerSta
}
void ClearRectangle(const VertexData &v0, const VertexData &v1, const BinCoords &range, const RasterizerState &state) {
DrawingCoords pprime = TransformUnit::ScreenToDrawing(range.x1, range.y1);
DrawingCoords pend = TransformUnit::ScreenToDrawing(range.x2, range.y2);
int entireX1 = std::min(v0.screenpos.x, v1.screenpos.x);
int entireY1 = std::min(v0.screenpos.y, v1.screenpos.y);
int entireX2 = std::max(v0.screenpos.x, v1.screenpos.x) - 1;
int entireY2 = std::max(v0.screenpos.y, v1.screenpos.y) - 1;
int minX = std::max(entireX1, range.x1) | (SCREEN_SCALE_FACTOR / 2 - 1);
int minY = std::max(entireY1, range.y1) | (SCREEN_SCALE_FACTOR / 2 - 1);
int maxX = std::min(entireX2, range.x2);
int maxY = std::min(entireY2, range.y2);
const DrawingCoords pprime = TransformUnit::ScreenToDrawing(minX, minY);
const DrawingCoords pend = TransformUnit::ScreenToDrawing(maxX, maxY);
auto &pixelID = state.pixelID;
auto &samplerID = state.samplerID;
// Min and max are in PSP fixed point screen coordinates, 16 here is for the 4 subpixel bits.
const int w = (range.x2 - range.x1 + 1) / SCREEN_SCALE_FACTOR;
const int w = pend.x - pprime.x + 1;
if (w <= 0)
return;

View File

@ -147,6 +147,7 @@ tests_good = [
"gpu/commands/blend",
"gpu/commands/blend565",
"gpu/commands/blocktransfer",
"gpu/commands/cull",
"gpu/commands/fog",
"gpu/commands/material",
"gpu/displaylist/alignment",
@ -159,6 +160,7 @@ tests_good = [
"gpu/ge/queue",
"gpu/primitives/indices",
"gpu/primitives/invalidprim",
"gpu/primitives/points",
"gpu/primitives/trianglefan",
"gpu/primitives/trianglestrip",
"gpu/primitives/triangles",
@ -181,6 +183,7 @@ tests_good = [
"gpu/texfunc/replace",
"gpu/textures/mipmap",
"gpu/textures/rotate",
"gpu/vertices/colors",
"hash/hash",
"hle/check_not_used_uids",
"intr/intr",
@ -387,7 +390,6 @@ tests_next = [
"font/shadowglyphimageclip",
"font/shadowinfo",
"gpu/clipping/guardband",
"gpu/commands/cull",
"gpu/commands/light",
"gpu/complex/complex",
"gpu/depth/precision",
@ -404,7 +406,6 @@ tests_next = [
"gpu/primitives/immediate",
"gpu/primitives/lines",
"gpu/primitives/linestrip",
"gpu/primitives/points",
"gpu/primitives/rectangles",
"gpu/primitives/spline",
"gpu/reflection/reflection",
@ -415,7 +416,6 @@ tests_next = [
"gpu/simple/simple",
"gpu/textures/size",
"gpu/triangle/triangle",
"gpu/vertices/colors",
"gpu/vertices/texcoords",
"intr/registersub",
"intr/releasesub",