| 254 | // |
| 255 | template < typename OutT, u32 InFiddle, u32 OutFiddle > |
| 256 | static inline void ConvertRow( OutT * dst, const u8 * src, u32 src_offset, u32 width ) |
| 257 | { |
| 258 | #ifdef DAEDALUS_ENABLE_ASSERTS |
| 259 | DAEDALUS_DL_ASSERT( IsAligned( src_offset, sizeof( InT ) ), "Offset should be correctly aligned" ); |
| 260 | #endif |
| 261 | // |
| 262 | // Need to be careful of this - ensure that it's doing the right thing in all cases and not overflowing rows. |
| 263 | // This is to ensure that we correctly convert all the texels in a row, even when we're fiddling. |
| 264 | // If we have a fiddle of 2 for instance, and the row is not a multiple of the fiddle amount |
| 265 | // then we don't convert enough pixels (we actually poke some values in past the end of the row) |
| 266 | // and get some random noise at the end instead. |
| 267 | // |
| 268 | // There may well be an easier (and less gross) way of doing this if we move the OutFiddle calculation |
| 269 | // into the source pixel lookup, and just have dst[x] = ... |
| 270 | // |
| 271 | width = AlignPow2( width, 1<<OutFiddle ); |
| 272 | |
| 273 | for (u32 x {}; x < width; x++) |
| 274 | { |
| 275 | InT colour( *reinterpret_cast< const InT * >( &src[src_offset ^ InFiddle] ) ); |
| 276 | |
| 277 | dst[x ^ OutFiddle] = ConvertPixelFormat< OutT, InT >( colour ); |
| 278 | |
| 279 | src_offset += sizeof( InT ); |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | template < typename OutT > |
| 284 | static inline void ConvertTextureT( const TextureDestInfo & dsti, const TextureInfo & ti ) |