Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

526 lines
15 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #if defined( _WIN32 ) && !defined( _X360 ) && !defined( DX_TO_GL_ABSTRACTION )
  7. #include <windows.h>
  8. #include "../dx9sdk/include/d3d9types.h"
  9. #endif
  10. #include "bitmap/imageformat.h"
  11. #include "basetypes.h"
  12. #include "tier0/dbg.h"
  13. #include <malloc.h>
  14. #include <memory.h>
  15. #include "nvtc.h"
  16. #include "mathlib/mathlib.h"
  17. #include "mathlib/vector.h"
  18. #include "tier1/utlmemory.h"
  19. #include "tier1/strtools.h"
  20. #include "mathlib/compressed_vector.h"
  21. // Should be last include
  22. #include "tier0/memdbgon.h"
  23. //-----------------------------------------------------------------------------
  24. // Various important function types for each color format
  25. //-----------------------------------------------------------------------------
  26. static const ImageFormatInfo_t g_ImageFormatInfo[] =
  27. {
  28. { "UNKNOWN", 0, 0, 0, 0, 0, false }, // IMAGE_FORMAT_UNKNOWN,
  29. { "RGBA8888", 4, 8, 8, 8, 8, false }, // IMAGE_FORMAT_RGBA8888,
  30. { "ABGR8888", 4, 8, 8, 8, 8, false }, // IMAGE_FORMAT_ABGR8888,
  31. { "RGB888", 3, 8, 8, 8, 0, false }, // IMAGE_FORMAT_RGB888,
  32. { "BGR888", 3, 8, 8, 8, 0, false }, // IMAGE_FORMAT_BGR888,
  33. { "RGB565", 2, 5, 6, 5, 0, false }, // IMAGE_FORMAT_RGB565,
  34. { "I8", 1, 0, 0, 0, 0, false }, // IMAGE_FORMAT_I8,
  35. { "IA88", 2, 0, 0, 0, 8, false }, // IMAGE_FORMAT_IA88
  36. { "P8", 1, 0, 0, 0, 0, false }, // IMAGE_FORMAT_P8
  37. { "A8", 1, 0, 0, 0, 8, false }, // IMAGE_FORMAT_A8
  38. { "RGB888_BLUESCREEN", 3, 8, 8, 8, 0, false }, // IMAGE_FORMAT_RGB888_BLUESCREEN
  39. { "BGR888_BLUESCREEN", 3, 8, 8, 8, 0, false }, // IMAGE_FORMAT_BGR888_BLUESCREEN
  40. { "ARGB8888", 4, 8, 8, 8, 8, false }, // IMAGE_FORMAT_ARGB8888
  41. { "BGRA8888", 4, 8, 8, 8, 8, false }, // IMAGE_FORMAT_BGRA8888
  42. { "DXT1", 0, 0, 0, 0, 0, true }, // IMAGE_FORMAT_DXT1
  43. { "DXT3", 0, 0, 0, 0, 8, true }, // IMAGE_FORMAT_DXT3
  44. { "DXT5", 0, 0, 0, 0, 8, true }, // IMAGE_FORMAT_DXT5
  45. { "BGRX8888", 4, 8, 8, 8, 0, false }, // IMAGE_FORMAT_BGRX8888
  46. { "BGR565", 2, 5, 6, 5, 0, false }, // IMAGE_FORMAT_BGR565
  47. { "BGRX5551", 2, 5, 5, 5, 0, false }, // IMAGE_FORMAT_BGRX5551
  48. { "BGRA4444", 2, 4, 4, 4, 4, false }, // IMAGE_FORMAT_BGRA4444
  49. { "DXT1_ONEBITALPHA", 0, 0, 0, 0, 0, true }, // IMAGE_FORMAT_DXT1_ONEBITALPHA
  50. { "BGRA5551", 2, 5, 5, 5, 1, false }, // IMAGE_FORMAT_BGRA5551
  51. { "UV88", 2, 8, 8, 0, 0, false }, // IMAGE_FORMAT_UV88
  52. { "UVWQ8888", 4, 8, 8, 8, 8, false }, // IMAGE_FORMAT_UVWQ8899
  53. { "RGBA16161616F", 8, 16, 16, 16, 16, false }, // IMAGE_FORMAT_RGBA16161616F
  54. { "RGBA16161616", 8, 16, 16, 16, 16, false }, // IMAGE_FORMAT_RGBA16161616
  55. { "IMAGE_FORMAT_UVLX8888", 4, 8, 8, 8, 8, false }, // IMAGE_FORMAT_UVLX8899
  56. { "IMAGE_FORMAT_R32F", 4, 32, 0, 0, 0, false }, // IMAGE_FORMAT_R32F
  57. { "IMAGE_FORMAT_RGB323232F", 12, 32, 32, 32, 0, false }, // IMAGE_FORMAT_RGB323232F
  58. { "IMAGE_FORMAT_RGBA32323232F", 16, 32, 32, 32, 32, false }, // IMAGE_FORMAT_RGBA32323232F
  59. // Vendor-dependent depth formats used for shadow depth mapping
  60. { "NV_DST16", 2, 16, 0, 0, 0, false }, // IMAGE_FORMAT_NV_DST16
  61. { "NV_DST24", 4, 24, 0, 0, 0, false }, // IMAGE_FORMAT_NV_DST24
  62. { "NV_INTZ", 4, 8, 8, 8, 8, false }, // IMAGE_FORMAT_NV_INTZ
  63. { "NV_RAWZ", 4, 24, 0, 0, 0, false }, // IMAGE_FORMAT_NV_RAWZ
  64. { "ATI_DST16", 2, 16, 0, 0, 0, false }, // IMAGE_FORMAT_ATI_DST16
  65. { "ATI_DST24", 4, 24, 0, 0, 0, false }, // IMAGE_FORMAT_ATI_DST24
  66. { "NV_NULL", 4, 8, 8, 8, 8, false }, // IMAGE_FORMAT_NV_NULL
  67. // Vendor-dependent compressed formats typically used for normal map compression
  68. { "ATI1N", 0, 0, 0, 0, 0, true }, // IMAGE_FORMAT_ATI1N
  69. { "ATI2N", 0, 0, 0, 0, 0, true }, // IMAGE_FORMAT_ATI2N
  70. #ifdef _X360
  71. { "X360_DST16", 2, 16, 0, 0, 0, false }, // IMAGE_FORMAT_X360_DST16
  72. { "X360_DST24", 4, 24, 0, 0, 0, false }, // IMAGE_FORMAT_X360_DST24
  73. { "X360_DST24F", 4, 24, 0, 0, 0, false }, // IMAGE_FORMAT_X360_DST24F
  74. { "LINEAR_BGRX8888", 4, 8, 8, 8, 8, false }, // IMAGE_FORMAT_LINEAR_BGRX8888
  75. { "LINEAR_RGBA8888", 4, 8, 8, 8, 8, false }, // IMAGE_FORMAT_LINEAR_RGBA8888
  76. { "LINEAR_ABGR8888", 4, 8, 8, 8, 8, false }, // IMAGE_FORMAT_LINEAR_ABGR8888
  77. { "LINEAR_ARGB8888", 4, 8, 8, 8, 8, false }, // IMAGE_FORMAT_LINEAR_ARGB8888
  78. { "LINEAR_BGRA8888", 4, 8, 8, 8, 8, false }, // IMAGE_FORMAT_LINEAR_BGRA8888
  79. { "LINEAR_RGB888", 3, 8, 8, 8, 0, false }, // IMAGE_FORMAT_LINEAR_RGB888
  80. { "LINEAR_BGR888", 3, 8, 8, 8, 0, false }, // IMAGE_FORMAT_LINEAR_BGR888
  81. { "LINEAR_BGRX5551", 2, 5, 5, 5, 0, false }, // IMAGE_FORMAT_LINEAR_BGRX5551
  82. { "LINEAR_I8", 1, 0, 0, 0, 0, false }, // IMAGE_FORMAT_LINEAR_I8
  83. { "LINEAR_RGBA16161616", 8, 16, 16, 16, 16, false }, // IMAGE_FORMAT_LINEAR_RGBA16161616
  84. { "LE_BGRX8888", 4, 8, 8, 8, 8, false }, // IMAGE_FORMAT_LE_BGRX8888
  85. { "LE_BGRA8888", 4, 8, 8, 8, 8, false }, // IMAGE_FORMAT_LE_BGRA8888
  86. #endif
  87. { "DXT1_RUNTIME", 0, 0, 0, 0, 0, true, }, // IMAGE_FORMAT_DXT1_RUNTIME
  88. { "DXT5_RUNTIME", 0, 0, 0, 0, 8, true, }, // IMAGE_FORMAT_DXT5_RUNTIME
  89. };
  90. namespace ImageLoader
  91. {
  92. //-----------------------------------------------------------------------------
  93. // Returns info about each image format
  94. //-----------------------------------------------------------------------------
  95. const ImageFormatInfo_t& ImageFormatInfo( ImageFormat fmt )
  96. {
  97. Assert( ( NUM_IMAGE_FORMATS + 1 ) == sizeof( g_ImageFormatInfo ) / sizeof( g_ImageFormatInfo[0] ) );
  98. Assert( unsigned( fmt + 1 ) <= ( NUM_IMAGE_FORMATS ) );
  99. return g_ImageFormatInfo[ fmt + 1 ];
  100. }
  101. int GetMemRequired( int width, int height, int depth, ImageFormat imageFormat, bool mipmap )
  102. {
  103. if ( depth <= 0 )
  104. {
  105. depth = 1;
  106. }
  107. if ( !mipmap )
  108. {
  109. // Block compressed formats
  110. if ( IsCompressed( imageFormat ) )
  111. {
  112. /*
  113. DDSURFACEDESC desc;
  114. memset( &desc, 0, sizeof(desc) );
  115. DWORD dwEncodeType;
  116. dwEncodeType = GetDXTCEncodeType( imageFormat );
  117. desc.dwSize = sizeof( desc );
  118. desc.dwFlags = DDSD_WIDTH | DDSD_HEIGHT;
  119. desc.dwWidth = width;
  120. desc.dwHeight = height;
  121. return S3TCgetEncodeSize( &desc, dwEncodeType );
  122. */
  123. Assert( ( width < 4 ) || !( width % 4 ) );
  124. Assert( ( height < 4 ) || !( height % 4 ) );
  125. Assert( ( depth < 4 ) || !( depth % 4 ) );
  126. if ( width < 4 && width > 0 )
  127. {
  128. width = 4;
  129. }
  130. if ( height < 4 && height > 0 )
  131. {
  132. height = 4;
  133. }
  134. if ( depth < 4 && depth > 1 )
  135. {
  136. depth = 4;
  137. }
  138. int numBlocks = ( width * height ) >> 4;
  139. numBlocks *= depth;
  140. switch ( imageFormat )
  141. {
  142. case IMAGE_FORMAT_DXT1:
  143. case IMAGE_FORMAT_DXT1_RUNTIME:
  144. case IMAGE_FORMAT_ATI1N:
  145. return numBlocks * 8;
  146. case IMAGE_FORMAT_DXT3:
  147. case IMAGE_FORMAT_DXT5:
  148. case IMAGE_FORMAT_DXT5_RUNTIME:
  149. case IMAGE_FORMAT_ATI2N:
  150. return numBlocks * 16;
  151. }
  152. Assert( 0 );
  153. return 0;
  154. }
  155. return width * height * depth * SizeInBytes( imageFormat );
  156. }
  157. // Mipmap version
  158. int memSize = 0;
  159. while ( 1 )
  160. {
  161. memSize += GetMemRequired( width, height, depth, imageFormat, false );
  162. if ( width == 1 && height == 1 && depth == 1 )
  163. {
  164. break;
  165. }
  166. width >>= 1;
  167. height >>= 1;
  168. depth >>= 1;
  169. if ( width < 1 )
  170. {
  171. width = 1;
  172. }
  173. if ( height < 1 )
  174. {
  175. height = 1;
  176. }
  177. if ( depth < 1 )
  178. {
  179. depth = 1;
  180. }
  181. }
  182. return memSize;
  183. }
  184. int GetMipMapLevelByteOffset( int width, int height, ImageFormat imageFormat, int skipMipLevels )
  185. {
  186. int offset = 0;
  187. while( skipMipLevels > 0 )
  188. {
  189. offset += width * height * SizeInBytes(imageFormat);
  190. if( width == 1 && height == 1 )
  191. {
  192. break;
  193. }
  194. width >>= 1;
  195. height >>= 1;
  196. if( width < 1 )
  197. {
  198. width = 1;
  199. }
  200. if( height < 1 )
  201. {
  202. height = 1;
  203. }
  204. skipMipLevels--;
  205. }
  206. return offset;
  207. }
  208. void GetMipMapLevelDimensions( int *width, int *height, int skipMipLevels )
  209. {
  210. while( skipMipLevels > 0 )
  211. {
  212. if( *width == 1 && *height == 1 )
  213. {
  214. break;
  215. }
  216. *width >>= 1;
  217. *height >>= 1;
  218. if( *width < 1 )
  219. {
  220. *width = 1;
  221. }
  222. if( *height < 1 )
  223. {
  224. *height = 1;
  225. }
  226. skipMipLevels--;
  227. }
  228. }
  229. int GetNumMipMapLevels( int width, int height, int depth )
  230. {
  231. if ( depth <= 0 )
  232. {
  233. depth = 1;
  234. }
  235. if( width < 1 || height < 1 || depth < 1 )
  236. return 0;
  237. int numMipLevels = 1;
  238. while( 1 )
  239. {
  240. if( width == 1 && height == 1 && depth == 1 )
  241. break;
  242. width >>= 1;
  243. height >>= 1;
  244. depth >>= 1;
  245. if( width < 1 )
  246. {
  247. width = 1;
  248. }
  249. if( height < 1 )
  250. {
  251. height = 1;
  252. }
  253. if( depth < 1 )
  254. {
  255. depth = 1;
  256. }
  257. numMipLevels++;
  258. }
  259. return numMipLevels;
  260. }
  261. // Turn off warning about FOURCC formats below...
  262. #pragma warning (disable:4063)
  263. #ifdef DX_TO_GL_ABSTRACTION
  264. #ifndef MAKEFOURCC
  265. #define MAKEFOURCC(ch0, ch1, ch2, ch3) \
  266. ((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \
  267. ((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24 ))
  268. #endif //defined(MAKEFOURCC)
  269. #endif
  270. //-----------------------------------------------------------------------------
  271. // convert back and forth from D3D format to ImageFormat, regardless of
  272. // whether it's supported or not
  273. //-----------------------------------------------------------------------------
  274. ImageFormat D3DFormatToImageFormat( D3DFORMAT format )
  275. {
  276. #if defined( _X360 )
  277. if ( IS_D3DFORMAT_SRGB( format ) )
  278. {
  279. // sanitize the format from possible sRGB state for comparison purposes
  280. format = MAKE_NON_SRGB_FMT( format );
  281. }
  282. #endif
  283. switch ( format )
  284. {
  285. #if !defined( _X360 )
  286. case D3DFMT_R8G8B8:
  287. return IMAGE_FORMAT_BGR888;
  288. #endif
  289. case D3DFMT_A8R8G8B8:
  290. return IMAGE_FORMAT_BGRA8888;
  291. case D3DFMT_X8R8G8B8:
  292. return IMAGE_FORMAT_BGRX8888;
  293. case D3DFMT_R5G6B5:
  294. return IMAGE_FORMAT_BGR565;
  295. case D3DFMT_X1R5G5B5:
  296. return IMAGE_FORMAT_BGRX5551;
  297. case D3DFMT_A1R5G5B5:
  298. return IMAGE_FORMAT_BGRA5551;
  299. case D3DFMT_A4R4G4B4:
  300. return IMAGE_FORMAT_BGRA4444;
  301. case D3DFMT_L8:
  302. return IMAGE_FORMAT_I8;
  303. case D3DFMT_A8L8:
  304. return IMAGE_FORMAT_IA88;
  305. case D3DFMT_A8:
  306. return IMAGE_FORMAT_A8;
  307. case D3DFMT_DXT1:
  308. return IMAGE_FORMAT_DXT1;
  309. case D3DFMT_DXT3:
  310. return IMAGE_FORMAT_DXT3;
  311. case D3DFMT_DXT5:
  312. return IMAGE_FORMAT_DXT5;
  313. case D3DFMT_V8U8:
  314. return IMAGE_FORMAT_UV88;
  315. case D3DFMT_Q8W8V8U8:
  316. return IMAGE_FORMAT_UVWQ8888;
  317. case D3DFMT_X8L8V8U8:
  318. return IMAGE_FORMAT_UVLX8888;
  319. case D3DFMT_A16B16G16R16F:
  320. return IMAGE_FORMAT_RGBA16161616F;
  321. case D3DFMT_A16B16G16R16:
  322. return IMAGE_FORMAT_RGBA16161616;
  323. case D3DFMT_R32F:
  324. return IMAGE_FORMAT_R32F;
  325. case D3DFMT_A32B32G32R32F:
  326. return IMAGE_FORMAT_RGBA32323232F;
  327. // DST and FOURCC formats mapped back to ImageFormat (for vendor-dependent shadow depth textures)
  328. case (D3DFORMAT)(MAKEFOURCC('R','A','W','Z')):
  329. return IMAGE_FORMAT_NV_RAWZ;
  330. case (D3DFORMAT)(MAKEFOURCC('I','N','T','Z')):
  331. return IMAGE_FORMAT_NV_INTZ;
  332. case (D3DFORMAT)(MAKEFOURCC('N','U','L','L')):
  333. return IMAGE_FORMAT_NV_NULL;
  334. case D3DFMT_D16:
  335. #if !defined( _X360 )
  336. return IMAGE_FORMAT_NV_DST16;
  337. #else
  338. return IMAGE_FORMAT_X360_DST16;
  339. #endif
  340. case D3DFMT_D24S8:
  341. #if !defined( _X360 )
  342. return IMAGE_FORMAT_NV_DST24;
  343. #else
  344. return IMAGE_FORMAT_X360_DST24;
  345. #endif
  346. case (D3DFORMAT)(MAKEFOURCC('D','F','1','6')):
  347. return IMAGE_FORMAT_ATI_DST16;
  348. case (D3DFORMAT)(MAKEFOURCC('D','F','2','4')):
  349. return IMAGE_FORMAT_ATI_DST24;
  350. // ATIxN FOURCC formats mapped back to ImageFormat
  351. case (D3DFORMAT)(MAKEFOURCC('A','T','I','1')):
  352. return IMAGE_FORMAT_ATI1N;
  353. case (D3DFORMAT)(MAKEFOURCC('A','T','I','2')):
  354. return IMAGE_FORMAT_ATI2N;
  355. #if defined( _X360 )
  356. case D3DFMT_LIN_A8R8G8B8:
  357. return IMAGE_FORMAT_LINEAR_BGRA8888;
  358. case D3DFMT_LIN_X8R8G8B8:
  359. return IMAGE_FORMAT_LINEAR_BGRX8888;
  360. case D3DFMT_LIN_X1R5G5B5:
  361. return IMAGE_FORMAT_LINEAR_BGRX5551;
  362. case D3DFMT_LIN_L8:
  363. return IMAGE_FORMAT_LINEAR_I8;
  364. case D3DFMT_LIN_A16B16G16R16:
  365. return IMAGE_FORMAT_LINEAR_RGBA16161616;
  366. case D3DFMT_LE_X8R8G8B8:
  367. return IMAGE_FORMAT_LE_BGRX8888;
  368. case D3DFMT_LE_A8R8G8B8:
  369. return IMAGE_FORMAT_LE_BGRA8888;
  370. case D3DFMT_D24FS8:
  371. return IMAGE_FORMAT_X360_DST24F;
  372. #endif
  373. }
  374. Assert( 0 );
  375. return IMAGE_FORMAT_UNKNOWN;
  376. }
  377. D3DFORMAT ImageFormatToD3DFormat( ImageFormat format )
  378. {
  379. // This doesn't care whether it's supported or not
  380. switch ( format )
  381. {
  382. case IMAGE_FORMAT_BGR888:
  383. #if !defined( _X360 )
  384. return D3DFMT_R8G8B8;
  385. #else
  386. return D3DFMT_UNKNOWN;
  387. #endif
  388. case IMAGE_FORMAT_BGRA8888:
  389. return D3DFMT_A8R8G8B8;
  390. case IMAGE_FORMAT_BGRX8888:
  391. return D3DFMT_X8R8G8B8;
  392. case IMAGE_FORMAT_BGR565:
  393. return D3DFMT_R5G6B5;
  394. case IMAGE_FORMAT_BGRX5551:
  395. return D3DFMT_X1R5G5B5;
  396. case IMAGE_FORMAT_BGRA5551:
  397. return D3DFMT_A1R5G5B5;
  398. case IMAGE_FORMAT_BGRA4444:
  399. return D3DFMT_A4R4G4B4;
  400. case IMAGE_FORMAT_I8:
  401. return D3DFMT_L8;
  402. case IMAGE_FORMAT_IA88:
  403. return D3DFMT_A8L8;
  404. case IMAGE_FORMAT_A8:
  405. return D3DFMT_A8;
  406. case IMAGE_FORMAT_DXT1:
  407. case IMAGE_FORMAT_DXT1_ONEBITALPHA:
  408. return D3DFMT_DXT1;
  409. case IMAGE_FORMAT_DXT3:
  410. return D3DFMT_DXT3;
  411. case IMAGE_FORMAT_DXT5:
  412. return D3DFMT_DXT5;
  413. case IMAGE_FORMAT_UV88:
  414. return D3DFMT_V8U8;
  415. case IMAGE_FORMAT_UVWQ8888:
  416. return D3DFMT_Q8W8V8U8;
  417. case IMAGE_FORMAT_UVLX8888:
  418. return D3DFMT_X8L8V8U8;
  419. case IMAGE_FORMAT_RGBA16161616F:
  420. return D3DFMT_A16B16G16R16F;
  421. case IMAGE_FORMAT_RGBA16161616:
  422. return D3DFMT_A16B16G16R16;
  423. case IMAGE_FORMAT_R32F:
  424. return D3DFMT_R32F;
  425. case IMAGE_FORMAT_RGBA32323232F:
  426. return D3DFMT_A32B32G32R32F;
  427. // ImageFormat mapped to vendor-dependent FOURCC formats (for shadow depth textures)
  428. case IMAGE_FORMAT_NV_RAWZ:
  429. return (D3DFORMAT)(MAKEFOURCC('R','A','W','Z'));
  430. case IMAGE_FORMAT_NV_INTZ:
  431. return (D3DFORMAT)(MAKEFOURCC('I','N','T','Z'));
  432. case IMAGE_FORMAT_NV_NULL:
  433. return (D3DFORMAT)(MAKEFOURCC('N','U','L','L'));
  434. case IMAGE_FORMAT_NV_DST16:
  435. return D3DFMT_D16;
  436. case IMAGE_FORMAT_NV_DST24:
  437. return D3DFMT_D24S8;
  438. case IMAGE_FORMAT_ATI_DST16:
  439. return (D3DFORMAT)(MAKEFOURCC('D','F','1','6'));
  440. case IMAGE_FORMAT_ATI_DST24:
  441. return (D3DFORMAT)(MAKEFOURCC('D','F','2','4'));
  442. // ImageFormats mapped to ATIxN FOURCC
  443. case IMAGE_FORMAT_ATI1N:
  444. return (D3DFORMAT)(MAKEFOURCC('A','T','I','1'));
  445. case IMAGE_FORMAT_ATI2N:
  446. return (D3DFORMAT)(MAKEFOURCC('A','T','I','2'));
  447. #if defined( _X360 )
  448. case IMAGE_FORMAT_LINEAR_BGRA8888:
  449. return D3DFMT_LIN_A8R8G8B8;
  450. case IMAGE_FORMAT_LINEAR_BGRX8888:
  451. return D3DFMT_LIN_X8R8G8B8;
  452. case IMAGE_FORMAT_LINEAR_BGRX5551:
  453. return D3DFMT_LIN_X1R5G5B5;
  454. case IMAGE_FORMAT_LINEAR_I8:
  455. return D3DFMT_LIN_L8;
  456. case IMAGE_FORMAT_LINEAR_RGBA16161616:
  457. return D3DFMT_LIN_A16B16G16R16;
  458. case IMAGE_FORMAT_LE_BGRX8888:
  459. return D3DFMT_LE_X8R8G8B8;
  460. case IMAGE_FORMAT_LE_BGRA8888:
  461. return D3DFMT_LE_A8R8G8B8;
  462. case IMAGE_FORMAT_X360_DST16:
  463. return D3DFMT_D16;
  464. case IMAGE_FORMAT_X360_DST24:
  465. return D3DFMT_D24S8;
  466. case IMAGE_FORMAT_X360_DST24F:
  467. return D3DFMT_D24FS8;
  468. #endif
  469. case IMAGE_FORMAT_DXT1_RUNTIME:
  470. return D3DFMT_DXT1;
  471. case IMAGE_FORMAT_DXT5_RUNTIME:
  472. return D3DFMT_DXT5;
  473. }
  474. Assert( 0 );
  475. return D3DFMT_UNKNOWN;
  476. }
  477. #pragma warning (default:4063)
  478. } // ImageLoader namespace ends