mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-30 09:35:40 +00:00
GPU: Skip primitives where clip area is invalid
Fixes palettes being overwritten/menus being broken in Yoshimoto Mahjong Club Deluxe.
This commit is contained in:
parent
16c47f4553
commit
fc0560087f
|
@ -394,6 +394,9 @@ protected:
|
||||||
BoolToUInt8(m_render_command.shading_enable);
|
BoolToUInt8(m_render_command.shading_enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns true if the drawing area is valid (i.e. left <= right, top <= bottom).
|
||||||
|
ALWAYS_INLINE bool IsDrawingAreaIsValid() const { return m_drawing_area.Valid(); }
|
||||||
|
|
||||||
void AddCommandTicks(TickCount ticks);
|
void AddCommandTicks(TickCount ticks);
|
||||||
|
|
||||||
void WriteGP1(u32 value);
|
void WriteGP1(u32 value);
|
||||||
|
|
|
@ -217,6 +217,9 @@ void GPU_HW::LoadVertices()
|
||||||
if (rc.quad_polygon && m_resolution_scale > 1)
|
if (rc.quad_polygon && m_resolution_scale > 1)
|
||||||
HandleFlippedQuadTextureCoordinates(vertices.data());
|
HandleFlippedQuadTextureCoordinates(vertices.data());
|
||||||
|
|
||||||
|
if (!IsDrawingAreaIsValid())
|
||||||
|
return;
|
||||||
|
|
||||||
// Cull polygons which are too large.
|
// Cull polygons which are too large.
|
||||||
const s32 min_x_12 = std::min(vertices[1].x, vertices[2].x);
|
const s32 min_x_12 = std::min(vertices[1].x, vertices[2].x);
|
||||||
const s32 max_x_12 = std::max(vertices[1].x, vertices[2].x);
|
const s32 max_x_12 = std::max(vertices[1].x, vertices[2].x);
|
||||||
|
@ -328,6 +331,9 @@ void GPU_HW::LoadVertices()
|
||||||
// we can split the rectangle up into potentially 8 quads
|
// we can split the rectangle up into potentially 8 quads
|
||||||
DebugAssert(GetBatchVertexSpace() >= MAX_VERTICES_FOR_RECTANGLE);
|
DebugAssert(GetBatchVertexSpace() >= MAX_VERTICES_FOR_RECTANGLE);
|
||||||
|
|
||||||
|
if (!IsDrawingAreaIsValid())
|
||||||
|
return;
|
||||||
|
|
||||||
// Split the rectangle into multiple quads if it's greater than 256x256, as the texture page should repeat.
|
// Split the rectangle into multiple quads if it's greater than 256x256, as the texture page should repeat.
|
||||||
u16 tex_top = orig_tex_top;
|
u16 tex_top = orig_tex_top;
|
||||||
for (s32 y_offset = 0; y_offset < rectangle_height;)
|
for (s32 y_offset = 0; y_offset < rectangle_height;)
|
||||||
|
@ -395,6 +401,9 @@ void GPU_HW::LoadVertices()
|
||||||
pos1.bits = m_fifo.Pop();
|
pos1.bits = m_fifo.Pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!IsDrawingAreaIsValid())
|
||||||
|
return;
|
||||||
|
|
||||||
BatchVertex start, end;
|
BatchVertex start, end;
|
||||||
start.Set(m_drawing_offset.x + pos0.x, m_drawing_offset.y + pos0.y, color0, 0, 0);
|
start.Set(m_drawing_offset.x + pos0.x, m_drawing_offset.y + pos0.y, color0, 0, 0);
|
||||||
end.Set(m_drawing_offset.x + pos1.x, m_drawing_offset.y + pos1.y, color1, 0, 0);
|
end.Set(m_drawing_offset.x + pos1.x, m_drawing_offset.y + pos1.y, color1, 0, 0);
|
||||||
|
@ -428,6 +437,9 @@ void GPU_HW::LoadVertices()
|
||||||
const u32 num_vertices = GetPolyLineVertexCount();
|
const u32 num_vertices = GetPolyLineVertexCount();
|
||||||
DebugAssert(GetBatchVertexSpace() >= (num_vertices * 2));
|
DebugAssert(GetBatchVertexSpace() >= (num_vertices * 2));
|
||||||
|
|
||||||
|
if (!IsDrawingAreaIsValid())
|
||||||
|
return;
|
||||||
|
|
||||||
const u32 first_color = rc.color_for_first_vertex;
|
const u32 first_color = rc.color_for_first_vertex;
|
||||||
const bool shaded = rc.shading_enable;
|
const bool shaded = rc.shading_enable;
|
||||||
|
|
||||||
|
|
|
@ -248,6 +248,9 @@ void GPU_SW::DispatchRenderCommand()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!IsDrawingAreaIsValid())
|
||||||
|
return;
|
||||||
|
|
||||||
const DrawTriangleFunction DrawFunction = GetDrawTriangleFunction(
|
const DrawTriangleFunction DrawFunction = GetDrawTriangleFunction(
|
||||||
rc.shading_enable, rc.texture_enable, rc.raw_texture_enable, rc.transparency_enable, dithering_enable);
|
rc.shading_enable, rc.texture_enable, rc.raw_texture_enable, rc.transparency_enable, dithering_enable);
|
||||||
|
|
||||||
|
@ -296,6 +299,9 @@ void GPU_SW::DispatchRenderCommand()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!IsDrawingAreaIsValid())
|
||||||
|
return;
|
||||||
|
|
||||||
const DrawRectangleFunction DrawFunction =
|
const DrawRectangleFunction DrawFunction =
|
||||||
GetDrawRectangleFunction(rc.texture_enable, rc.raw_texture_enable, rc.transparency_enable);
|
GetDrawRectangleFunction(rc.texture_enable, rc.raw_texture_enable, rc.transparency_enable);
|
||||||
|
|
||||||
|
@ -334,6 +340,8 @@ void GPU_SW::DispatchRenderCommand()
|
||||||
p1->SetPosition(VertexPosition{m_fifo.Pop()});
|
p1->SetPosition(VertexPosition{m_fifo.Pop()});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// down here because of the FIFO pops
|
||||||
|
if (IsDrawingAreaIsValid())
|
||||||
(this->*DrawFunction)(p0, p1);
|
(this->*DrawFunction)(p0, p1);
|
||||||
|
|
||||||
// swap p0/p1 so that the last vertex is used as the first for the next line
|
// swap p0/p1 so that the last vertex is used as the first for the next line
|
||||||
|
|
Loading…
Reference in a new issue