summaryrefslogtreecommitdiffstats
path: root/src/video_core/rasterizer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core/rasterizer.cpp')
-rw-r--r--src/video_core/rasterizer.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/video_core/rasterizer.cpp b/src/video_core/rasterizer.cpp
index a84170094..514d64208 100644
--- a/src/video_core/rasterizer.cpp
+++ b/src/video_core/rasterizer.cpp
@@ -338,12 +338,25 @@ static void ProcessTriangleInternal(const Shader::OutputVertex& v0,
return;
}
- // TODO: Proper scissor rect test!
u16 min_x = std::min({vtxpos[0].x, vtxpos[1].x, vtxpos[2].x});
u16 min_y = std::min({vtxpos[0].y, vtxpos[1].y, vtxpos[2].y});
u16 max_x = std::max({vtxpos[0].x, vtxpos[1].x, vtxpos[2].x});
u16 max_y = std::max({vtxpos[0].y, vtxpos[1].y, vtxpos[2].y});
+ // Convert the scissor box coordinates to 12.4 fixed point
+ u16 scissor_left = (u16)(regs.scissor_test.GetLeft() << 4);
+ u16 scissor_top = (u16)(regs.scissor_test.GetTop() << 4);
+ u16 scissor_right = (u16)(regs.scissor_test.right << 4);
+ u16 scissor_bottom = (u16)(regs.scissor_test.bottom << 4);
+
+ if (regs.scissor_test.mode == Regs::ScissorMode::Include) {
+ // Calculate the new bounds
+ min_x = std::max(min_x, scissor_right);
+ min_y = std::max(min_y, scissor_bottom);
+ max_x = std::min(max_x, scissor_left);
+ max_y = std::min(max_y, scissor_top);
+ }
+
min_x &= Fix12P4::IntMask();
min_y &= Fix12P4::IntMask();
max_x = ((max_x + Fix12P4::FracMask()) & Fix12P4::IntMask());
@@ -383,6 +396,13 @@ static void ProcessTriangleInternal(const Shader::OutputVertex& v0,
for (u16 y = min_y + 8; y < max_y; y += 0x10) {
for (u16 x = min_x + 8; x < max_x; x += 0x10) {
+ // Do not process the pixel if it's inside the scissor box and the scissor mode is set to Exclude
+ if (regs.scissor_test.mode == Regs::ScissorMode::Exclude &&
+ x >= scissor_right && x <= scissor_left &&
+ y >= scissor_bottom && y <= scissor_top) {
+ continue;
+ }
+
// Calculate the barycentric coordinates w0, w1 and w2
int w0 = bias0 + SignedArea(vtxpos[1].xy(), vtxpos[2].xy(), {x, y});
int w1 = bias1 + SignedArea(vtxpos[2].xy(), vtxpos[0].xy(), {x, y});