[rlsw] Replace SW_TEXTURE_REPEAT_POT_FAST with SW_SUPPORT_NPOT_TEXTURE#5901
Conversation
| { | ||
| 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) |
There was a problem hiding this comment.
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? 🤔
There was a problem hiding this comment.
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.
|
@Bigfoot71 thanks for the improvement! Just added a small comment about a part I don't understand... |
Following the discussion in #5827, the opt-in
SW_TEXTURE_REPEAT_POT_FAST(runtime POT check per sample) is replaced by a compile-timeSW_SUPPORT_NPOT_TEXTURE(on by default).When disabled, POT is assumed globally, no
isPOTfield and no extra branches, andswTexParameteriemitsSW_INVALID_OPERATIONifSW_REPEATis set on an NPOT axis.SW_CLAMPremains supported per-axis regardless.I also removed what seemed to be an off-topic AI-generated comment which appeared in a previous PR.