Swizzle() and bitmapConvertRGB_to_RGBX_c() and load times.
by Edward Rotberg · in Torque 3D Professional · 06/29/2010 (2:23 pm) · 2 replies
We are trying to speed up our load time, and some profiling seems to indicate we are spending an inordinate amount of time in both the swizzle() and bitmapConvertRGB_to_RGBX_c() functions. It's pretty obvious, looking at the code for these, that the functions were never written to be particularly efficient - especially swizzle().
Our textures are in DDS and PNG format. We need to insure that whatever format we use (at least for texture files), that we get mipmapping enabled. However, we are more than willing to convert our texture assets to whatever formats will avoid these costly functions.
Can someone suggest a better format(s) that would work for us and avoid both swizzle() and bitmapConvertRGB_to_RGBX_c()?
Thanks in advance,
= Ed =
Our textures are in DDS and PNG format. We need to insure that whatever format we use (at least for texture files), that we get mipmapping enabled. However, we are more than willing to convert our texture assets to whatever formats will avoid these costly functions.
Can someone suggest a better format(s) that would work for us and avoid both swizzle() and bitmapConvertRGB_to_RGBX_c()?
Thanks in advance,
= Ed =
About the author
Torque 3D Owner Pat Wilson
These two functions solve two different problems:
1. Swizzle (anything) adjusts the byte ordering of the colors. Most things are stored in RGBA, and the desired format is either: RGBA, BGRA, or ARGB. Swizzling the bytes puts the byte order of data into the order which the API/platform desires.
To eliminate swizzling, use the DDS format.
2. 'bitmapConvertRGB_to_RGBX_c' converts 24-bit (RGB) to 32-bit (RGBX) textures. The reason is memory alignment; an array of 24-bit values will not allow for any kind of memory alignment.
To prevent upconverting 24-bit to 32-bit textures, use 32-bit DDS format textures (In the DirectX conversion tool, this is: PixelFormat X8R8G8B8).
To recap: Swizzling happens if the texture requires a byte-ordering adjustment, and RGB->RGBx happens to up-convert 24-bit to 32-bit.
For more details see GFXD3D9TextureManager::_loadTexture()