From 7483923d073cb32207353d122b3226f340b7c011 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 20 Sep 2022 12:52:06 -0700 Subject: [PATCH] softgpu: Correct clear rect off by one issues. --- GPU/Software/Rasterizer.cpp | 15 +++++++++++---- test.py | 6 +++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/GPU/Software/Rasterizer.cpp b/GPU/Software/Rasterizer.cpp index 2336ff6bef..b4d13fa6f6 100644 --- a/GPU/Software/Rasterizer.cpp +++ b/GPU/Software/Rasterizer.cpp @@ -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; diff --git a/test.py b/test.py index 47f5c36034..d8585b50dd 100755 --- a/test.py +++ b/test.py @@ -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",