Skip to content

[rlsw] Fix alpha tracking for persistent current colors#5964

Open
iztanos wants to merge 1 commit into
raysan5:masterfrom
iztanos:fix-rlsw-persistent-alpha
Open

[rlsw] Fix alpha tracking for persistent current colors#5964
iztanos wants to merge 1 commit into
raysan5:masterfrom
iztanos:fix-rlsw-persistent-alpha

Conversation

@iztanos

@iztanos iztanos commented Jul 10, 2026

Copy link
Copy Markdown

Fixes #5961.

This follows the root-cause analysis from @HurricanVD in #5961.

The issue suggested preserving hasColorAlpha from the persistent current color
at primitive boundaries. This PR takes a slightly narrower approach: it updates
hasColorAlpha when a vertex copies the current color.

That keeps the flag tied to the primitive contents themselves. A primitive is
marked as containing alpha only if one of its submitted vertices actually has
alpha below 1.0f, while persistent translucent colors still remain correctly
tracked across multiple primitives.

@raysan5 raysan5 changed the title Fix rlsw alpha tracking for persistent current colors [rlsw] Fix alpha tracking for persistent current colors Jul 11, 2026
@raysan5

raysan5 commented Jul 11, 2026

Copy link
Copy Markdown
Owner

@Bigfoot71 please, could you takee a look to this PR?

Comment thread src/external/rlsw.h Outdated
Comment on lines 3905 to 3912

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 propose that we also remove RLSW.primitive.hasColorAlpha |= (color[3] < 1.0f); from sw_immediate_set_color(), and doing this check only in sw_immediate_push_vertex()

Comment thread src/external/rlsw.h
Comment on lines 3948 to +3950
for (int i = 0; i < 4; i++) vertex->color[i] = RLSW.primitive.color[i];
for (int i = 0; i < 2; i++) vertex->texcoord[i] = RLSW.primitive.texcoord[i];
RLSW.primitive.hasColorAlpha |= (vertex->color[3] < 1.0f);

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.

And while we're at it, we could also make the intent explicit, for example:

    // Track whether any vertex in this primitive has alpha < 1.0
    RLSW.primitive.hasColorAlpha |= (vertex->color[3] < 1.0f);

@Bigfoot71

Copy link
Copy Markdown
Contributor

Yes, there is indeed a logic issue, and the proposed fix is correct.

I just suggested removing a line that becomes unnecessary with this change, and perhaps adding a comment to make the intent explicit for everyone.

Otherwise, looks good to me.

@raysan5

raysan5 commented Jul 13, 2026

Copy link
Copy Markdown
Owner

@iztanos please, could you implement and test proposed changes? thanks!

@raysan5 raysan5 added the bug This is a bug label Jul 13, 2026
@iztanos iztanos force-pushed the fix-rlsw-persistent-alpha branch from cae03aa to aa5e02a Compare July 14, 2026 07:17
@iztanos

iztanos commented Jul 14, 2026

Copy link
Copy Markdown
Author

Updated, thanks for the review @Bigfoot71.

I removed the old hasColorAlpha update from sw_immediate_set_color() and kept the check only when a vertex is actually pushed. That makes the flag describe the primitive being built, instead of the current color state.

I also added the small comment you suggested near the new check.

Rebased on current master and reran the small rlsw.h regression test in Docker. The persistent translucent color case still renders both triangles blended.

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

Labels

bug This is a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[rlsw] Persistent translucent current color loses blending after first primitive

3 participants