From 0bbe8c54cd9dcd0b78bd17092dabe78235500bfc Mon Sep 17 00:00:00 2001 From: Jannik Vogel Date: Mon, 14 Mar 2016 15:38:16 +0100 Subject: [PATCH] SWRasterizer: Don't draw outside of framebuffer --- src/video_core/rasterizer.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/video_core/rasterizer.cpp b/src/video_core/rasterizer.cpp index fd02aa652..6a335483e 100644 --- a/src/video_core/rasterizer.cpp +++ b/src/video_core/rasterizer.cpp @@ -380,6 +380,12 @@ 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) { + // Don't draw pixels outside of framebuffer + // framebuffer.height is actually "framebuffer height - 1" + const auto& framebuffer = g_state.regs.framebuffer; + if (x >> 4 >= framebuffer.width || y >> 4 > framebuffer.height) + 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});