Skip to content

Use max() to bring negative floats up to 0.0 before uint conversion. - #19255

Merged
AniLeo merged 2 commits into
RPCS3:masterfrom
NeilMonday:undefined-negative-float-conversion
Aug 17, 2026
Merged

AniLeo merged 2 commits into
RPCS3:masterfrom
NeilMonday:undefined-negative-float-conversion

Conversation

@NeilMonday

Copy link
Copy Markdown

Some games show unexpected colors due to conversions with scalar constructors from a float to a uint. The GLSL spec says that these conversions are undefined if the float is negative. These same conversion rules apply for vector constructors (like uvec4).

The solution here is to use max(x, 0.0) to bring the negative float value up to 0.0 before converting to uint.

@NeilMonday

Copy link
Copy Markdown
Author

fixes #19254

@AniLeo

AniLeo commented Aug 17, 2026

Copy link
Copy Markdown
Member

Should fix #19001, needs testing

@kd-11 kd-11 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran some PS3 tests over the weekend and this is in line with what the console does.

@AniLeo
AniLeo merged commit f9f88aa into RPCS3:master Aug 17, 2026
10 checks passed
@MSuih

MSuih commented Aug 17, 2026

Copy link
Copy Markdown
Member

Probaly fixes #6254, but I don't have AMD card anymore to test with.

@digant73

Copy link
Copy Markdown
Contributor

maybe it fixes also #15571 ?

@AniLeo

AniLeo commented Aug 18, 2026 •

Copy link
Copy Markdown
Member

The bug was exposed by a recent driver update. If the issue is older than 2026, the answer is most likely no.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants