   24-bit textures in DirectX and OpenGL
  Hey,I've got some concern regarding 24-bit textures in DirectX. In OpenGL I can specify "real" 24-bit texture format by passing GL_RGB/GL_RGB8 and stuff like that. This way I can fill my texture with data that really is of form RGBRGB[...].On the other hand in DX it seems there is simply no 24-bit format. I have to use 32-bit D3DFMT_X8R8G8B8 instead, what makes me pass in 1/3 more data than in case of OGL. Well, there is actually 24-bit format D3DFMT_R8G8B8 but everytime I try to use it I getDirect3D9: (ERROR) :Invalid format specified for textureSo, I'm wondering how it is. Is OGL in fact converting textures into 32-bit format internally or something? Maybe all textures in GPU are stored in 1-, 2- or 4-byte format only, to keep the data organization more memory-friendly? And maybe that's why DX doesn't support 24-bit format?Any suggestions regarding this matter are welcome   
Quote:Original post by maxestWell, there is actually 24-bit format D3DFMT_R8G8B8 but everytime I try to use it I getDirect3D9: (ERROR) :Invalid format specified for textureSo, I'm wondering how it is. Is OGL in fact converting textures into 32-bit format internally or something? Maybe all textures in GPU are stored in 1-, 2- or 4-byte format only, to keep the data organization more memory-friendly? And maybe that's why DX doesn't support 24-bit format?It ultimately depends on the driver. If you driver doesn't support 24-bit formats in DirectX, you can't use them. I don't really know why they'd be supported in OpenGL and not DirectX though. 24-bit formats are usually lower performance than 32-bit data, since it can be more work for the GPU to fetch 3 8-bit values and combine them than one 32-bit value.You can check what texture formats are available by using the CheckDeviceFormat function (Assuming D3D 9), or if you just want to know offline, you can check out the DirectX Caps Viewer (Which is part of the SDK).   ;  Can't say how textures are layout in hardware, but actually some hardware even supports compression. If you want to load a texture in DirectX you have to check if the driver/hardware supports it, otherwise you get this error when you try to load. This is done with IDirect3D9::CheckDeviceFormat. Note that it not only depends on the format you wish to use but also on what resource type, what format the adapter will be set to or is (e.g. fullscreen), which adapter, adapter type... pretty tedious.By the way: Looking at some device capability dumps from different machines I could get my hands on that D3DFMT_R8G8B8 is not supported by any of them.Edit: Of course, ninja-ed by Steve [smile]   ;  In OpenGL how GPU internally stores your texture is implementation specific.For Nvidia cards you can check this table to determine how internally GPU will store your texture: http://developer.nvidia.com/object/nv_ogl_texture_formats.htmlGL_RGB8 will be stored as RGBA8 on most of cards. That means when you pass texture data, it will do pixel conversion for you anyway and store 1/3 ore data same as in DX case.For ATI see this document: http://developer.amd.com/media/gpu_assets/ATI_OpenGL_Programming_and_Optimization_Guide.pdf (Appendix G)GL_RGB8 will be stored also as 32-bit format with 8 unused bits.   ;  Thank you bubu LV very much for those links. Now it's all clear :)   