summaryrefslogtreecommitdiff
path: root/src/video_core/rasterizer.cpp
diff options
context:
space:
mode:
authorGravatar Yuri Kunde Schlesner2016-07-02 02:18:46 -0700
committerGravatar GitHub2016-07-02 02:18:46 -0700
commit45c91bf87b5419184630931fcd62b304d2c547b6 (patch)
tree52aea0b215230dd40606698d123999e53bb5957f /src/video_core/rasterizer.cpp
parentMerge pull request #1869 from wwylele/dont-be-lazy (diff)
parentOpenGL: Add scaled resolution support to scissor (diff)
downloadyuzu-45c91bf87b5419184630931fcd62b304d2c547b6.tar.gz
yuzu-45c91bf87b5419184630931fcd62b304d2c547b6.tar.xz
yuzu-45c91bf87b5419184630931fcd62b304d2c547b6.zip
Merge pull request #1933 from yuriks/scissor
PICA: Implement scissor test
Diffstat (limited to 'src/video_core/rasterizer.cpp')
-rw-r--r--src/video_core/rasterizer.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/video_core/rasterizer.cpp b/src/video_core/rasterizer.cpp
index a84170094..6f369a00e 100644
--- a/src/video_core/rasterizer.cpp
+++ b/src/video_core/rasterizer.cpp
@@ -338,12 +338,26 @@ static void ProcessTriangleInternal(const Shader::OutputVertex& v0,
338 return; 338 return;
339 } 339 }
340 340
341 // TODO: Proper scissor rect test!
342 u16 min_x = std::min({vtxpos[0].x, vtxpos[1].x, vtxpos[2].x}); 341 u16 min_x = std::min({vtxpos[0].x, vtxpos[1].x, vtxpos[2].x});
343 u16 min_y = std::min({vtxpos[0].y, vtxpos[1].y, vtxpos[2].y}); 342 u16 min_y = std::min({vtxpos[0].y, vtxpos[1].y, vtxpos[2].y});
344 u16 max_x = std::max({vtxpos[0].x, vtxpos[1].x, vtxpos[2].x}); 343 u16 max_x = std::max({vtxpos[0].x, vtxpos[1].x, vtxpos[2].x});
345 u16 max_y = std::max({vtxpos[0].y, vtxpos[1].y, vtxpos[2].y}); 344 u16 max_y = std::max({vtxpos[0].y, vtxpos[1].y, vtxpos[2].y});
346 345
346 // Convert the scissor box coordinates to 12.4 fixed point
347 u16 scissor_x1 = (u16)( regs.scissor_test.x1 << 4);
348 u16 scissor_y1 = (u16)( regs.scissor_test.y1 << 4);
349 // x2,y2 have +1 added to cover the entire sub-pixel area
350 u16 scissor_x2 = (u16)((regs.scissor_test.x2 + 1) << 4);
351 u16 scissor_y2 = (u16)((regs.scissor_test.y2 + 1) << 4);
352
353 if (regs.scissor_test.mode == Regs::ScissorMode::Include) {
354 // Calculate the new bounds
355 min_x = std::max(min_x, scissor_x1);
356 min_y = std::max(min_y, scissor_y1);
357 max_x = std::min(max_x, scissor_x2);
358 max_y = std::min(max_y, scissor_y2);
359 }
360
347 min_x &= Fix12P4::IntMask(); 361 min_x &= Fix12P4::IntMask();
348 min_y &= Fix12P4::IntMask(); 362 min_y &= Fix12P4::IntMask();
349 max_x = ((max_x + Fix12P4::FracMask()) & Fix12P4::IntMask()); 363 max_x = ((max_x + Fix12P4::FracMask()) & Fix12P4::IntMask());
@@ -383,6 +397,13 @@ static void ProcessTriangleInternal(const Shader::OutputVertex& v0,
383 for (u16 y = min_y + 8; y < max_y; y += 0x10) { 397 for (u16 y = min_y + 8; y < max_y; y += 0x10) {
384 for (u16 x = min_x + 8; x < max_x; x += 0x10) { 398 for (u16 x = min_x + 8; x < max_x; x += 0x10) {
385 399
400 // Do not process the pixel if it's inside the scissor box and the scissor mode is set to Exclude
401 if (regs.scissor_test.mode == Regs::ScissorMode::Exclude) {
402 if (x >= scissor_x1 && x < scissor_x2 &&
403 y >= scissor_y1 && y < scissor_y2)
404 continue;
405 }
406
386 // Calculate the barycentric coordinates w0, w1 and w2 407 // Calculate the barycentric coordinates w0, w1 and w2
387 int w0 = bias0 + SignedArea(vtxpos[1].xy(), vtxpos[2].xy(), {x, y}); 408 int w0 = bias0 + SignedArea(vtxpos[1].xy(), vtxpos[2].xy(), {x, y});
388 int w1 = bias1 + SignedArea(vtxpos[2].xy(), vtxpos[0].xy(), {x, y}); 409 int w1 = bias1 + SignedArea(vtxpos[2].xy(), vtxpos[0].xy(), {x, y});