SWRasterizer: Don't draw outside of framebuffer
This commit is contained in:
parent
a2024d7497
commit
0bbe8c54cd
1 changed files with 6 additions and 0 deletions
|
@ -380,6 +380,12 @@ static void ProcessTriangleInternal(const Shader::OutputVertex& v0,
|
||||||
for (u16 y = min_y + 8; y < max_y; y += 0x10) {
|
for (u16 y = min_y + 8; y < max_y; y += 0x10) {
|
||||||
for (u16 x = min_x + 8; x < max_x; x += 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
|
// Calculate the barycentric coordinates w0, w1 and w2
|
||||||
int w0 = bias0 + SignedArea(vtxpos[1].xy(), vtxpos[2].xy(), {x, y});
|
int w0 = bias0 + SignedArea(vtxpos[1].xy(), vtxpos[2].xy(), {x, y});
|
||||||
int w1 = bias1 + SignedArea(vtxpos[2].xy(), vtxpos[0].xy(), {x, y});
|
int w1 = bias1 + SignedArea(vtxpos[2].xy(), vtxpos[0].xy(), {x, y});
|
||||||
|
|
Loading…
Reference in a new issue