Skip to content

[rlsw] Replace SW_TEXTURE_REPEAT_POT_FAST with SW_SUPPORT_NPOT_TEXTURE#5901

Merged
raysan5 merged 3 commits into
raysan5:masterfrom
Bigfoot71:rlsw-cleanup
May 30, 2026
Merged

[rlsw] Replace SW_TEXTURE_REPEAT_POT_FAST with SW_SUPPORT_NPOT_TEXTURE#5901
raysan5 merged 3 commits into
raysan5:masterfrom
Bigfoot71:rlsw-cleanup

Conversation

@Bigfoot71

Copy link
Copy Markdown
Contributor

Following the discussion in #5827, the opt-in SW_TEXTURE_REPEAT_POT_FAST (runtime POT check per sample) is replaced by a compile-time SW_SUPPORT_NPOT_TEXTURE (on by default).

When disabled, POT is assumed globally, no isPOT field and no extra branches, and swTexParameteri emits SW_INVALID_OPERATION if SW_REPEAT is set on an NPOT axis.

SW_CLAMP remains supported per-axis regardless.

I also removed what seemed to be an off-topic AI-generated comment which appeared in a previous PR.

@raysan5
raysan5 merged commit 10a889c into raysan5:master May 30, 2026
16 checks passed
Comment thread src/external/rlsw.h
{
if (!sw_is_texture_wrap_valid(value)) { RLSW.errCode = SW_INVALID_ENUM; return; }
#if !SW_SUPPORT_NPOT_TEXTURE
if (value == SW_REPEAT && (RLSW.boundTexture->width & RLSW.boundTexture->wMinus1) != 0)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I don't fully understand why it's not allowed to set SW_REPEAT wrap mode on a NPOT texture when SW_SUPPORT_NPOT_TEXTURE is not enabled, is it because the fast path optimization on texel/pixel fetching? 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's related to the bit masking used to wrap the coordinates, which means the axis has to be POT.

For now, this is the only optimization, so I kept the "not supported" behavior fairly loose, you can still create NPOT textures and use clamp wrapping on the NPOT axes.

More things may be possible in the future, such as computing addresses with shifts, simplifying bilinear filtering, and other more specific specializations, depending on how strict we want to be about that.

So if you'd rather simply prevent NPOT texture creation in anticipation of that, we can do that.

@raysan5

raysan5 commented May 30, 2026

Copy link
Copy Markdown
Owner

@Bigfoot71 thanks for the improvement! Just added a small comment about a part I don't understand...

@Bigfoot71
Bigfoot71 deleted the rlsw-cleanup branch July 13, 2026 13:44
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.

2 participants