Skip to content

Conversation

@coldhex
Copy link

@coldhex coldhex commented Nov 3, 2025

If output screen x,y coordinates from vertex shader are large, e.g. 1e22, multiplying them will overflow the maximum exponent of single-precision floating point numbers. This occurs when calculating determinants in barycentric coordinates calculations.

This fixes such overflows by using a power of 2 scaling factor to clamp the exponent at 60. If x is the largest floating-point with exponent 62, then xx + xx is just barely below infinity. Here 60 is used instead of 62 in order to have a small safety buffer.

An alternative solution would be to just discard fragments if barycentric coordinates are NaN. At least Radeon RX 6600 and also Intel UHD 770 hardware fail to properly rasterize anyway when coordinates are very large.

Fixes #2501

…lows

If output screen x,y coordinates from vertex shader are large, e.g.
1e22, multiplying them will overflow the maximum exponent of
single-precision floating point numbers. This occurs when calculating
determinants in barycentric coordinates calculations.

This fixes such overflows by using a power of 2 scaling factor to clamp
the exponent at 60. If x is the largest floating-point with exponent 62,
then x*x + x*x is just barely below infinity. Here 60 is used instead of
62 in order to have a small safety buffer.

An alternative solution would be to just discard fragments if
barycentric coordinates are NaN. At least Radeon RX 6600 and also Intel
UHD 770 hardware fail to properly rasterize anyway when coordinates are
very large.
@Triticum0
Copy link
Collaborator

Haven't look into this yet but might fix this as well.
https://www.reddit.com/r/tenchu/comments/1ofqbat/psa_tenchu_return_from_darkness_flashing_screen/

@Triticum0
Copy link
Collaborator

Triticum0 commented Nov 3, 2025

Here a video on masters.

SEIZURE WARNING

2025-11-03.20-02-30.mp4

Edit: This pr does reduce the issue but still occurs but is less way less frequent.

Pr build

2025-11-03.20-17-24.mp4

@Triticum0
Copy link
Collaborator

Confirmation that does fix Capcom vs. SNK 2 EO

2025-11-03.20-08-23.mp4

PS: hope audio issue get fixed someday as it affect some games.

@Triticum0
Copy link
Collaborator

Also fixes #2539 not sure about first issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Capcom vs. SNK 2 EO pre game vs screen white.

2 participants