Skip to content

Commit 9a9d41c

Browse files
committed
GS: Clamp UV coordinates in vertex trace to prevent floating to integer casting overflow.
1 parent 6a0f811 commit 9a9d41c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pcsx2/GS/Renderers/Common/GSVertexTraceFMM.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,12 @@ void GSVertexTraceFMM::FindMinMax(GSVertexTrace& vt, const void* vertex, const u
246246

247247
vt.m_min.t = tmin * s;
248248
vt.m_max.t = tmax * s;
249+
250+
// Clamp the min/max values to the min/max valid UV values
251+
// This is needed in certain cases where buggy GS input results
252+
// in huge floating points values for ST.
253+
vt.m_min.t = vt.m_min.t.min(GSVector4(2047.0f)).max(GSVector4(-2047.0f)).xyxy(vt.m_min.t);
254+
vt.m_max.t = vt.m_max.t.min(GSVector4(2047.0f)).max(GSVector4(-2047.0f)).xyxy(vt.m_max.t);
249255
}
250256
else
251257
{

0 commit comments

Comments
 (0)