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.

164 lines
11 KiB

  1. //=====================================================================
  2. // Copyright (c) 2007-2011 Advanced Micro Devices, Inc. All rights reserved.
  3. // Copyright (c) 2004-2006 ATI Technologies Inc.
  4. //
  5. /// \author GPU Developer Tools
  6. /// \author [email protected]
  7. /// \file ATI_Compress.h
  8. /// \version 1.80
  9. /// \brief Declares the interface to the ATI_Compress library.
  10. //
  11. //=====================================================================
  12. #ifndef ATI_COMPRESS
  13. #define ATI_COMPRESS
  14. #define ATI_COMPRESS_VERSION_MAJOR 1 ///< The major version number of this release.
  15. #define ATI_COMPRESS_VERSION_MINOR 80 ///< The minor version number of this release.
  16. typedef unsigned long ATI_TC_DWORD; ///< A 32-bit integer format.
  17. typedef unsigned short ATI_TC_WORD; ///< A 16-bit integer format.
  18. typedef unsigned char ATI_TC_BYTE; ///< An 8-bit integer format.
  19. #if defined(WIN32) || defined(_WIN64)
  20. # define ATI_TC_API __cdecl
  21. #else
  22. # define ATI_TC_API
  23. #endif
  24. #ifdef ATI_COMPRESS_INTERNAL_BUILD
  25. # include "ATI_Compress_Internal.h"
  26. #else // ATI_COMPRESS_INTERNAL_BUILD
  27. /// Texture format.
  28. typedef enum
  29. {
  30. ATI_TC_FORMAT_Unknown, ///< An undefined texture format.
  31. ATI_TC_FORMAT_ARGB_8888, ///< An ARGB format with 8-bit fixed channels.
  32. ATI_TC_FORMAT_RGB_888, ///< A RGB format with 8-bit fixed channels.
  33. ATI_TC_FORMAT_RG_8, ///< A two component format with 8-bit fixed channels.
  34. ATI_TC_FORMAT_R_8, ///< A single component format with 8-bit fixed channels.
  35. ATI_TC_FORMAT_ARGB_2101010, ///< An ARGB format with 10-bit fixed channels for color & a 2-bit fixed channel for alpha.
  36. ATI_TC_FORMAT_ARGB_16, ///< A ARGB format with 16-bit fixed channels.
  37. ATI_TC_FORMAT_RG_16, ///< A two component format with 16-bit fixed channels.
  38. ATI_TC_FORMAT_R_16, ///< A single component format with 16-bit fixed channels.
  39. ATI_TC_FORMAT_ARGB_16F, ///< An ARGB format with 16-bit floating-point channels.
  40. ATI_TC_FORMAT_RG_16F, ///< A two component format with 16-bit floating-point channels.
  41. ATI_TC_FORMAT_R_16F, ///< A single component with 16-bit floating-point channels.
  42. ATI_TC_FORMAT_ARGB_32F, ///< An ARGB format with 32-bit floating-point channels.
  43. ATI_TC_FORMAT_RG_32F, ///< A two component format with 32-bit floating-point channels.
  44. ATI_TC_FORMAT_R_32F, ///< A single component with 32-bit floating-point channels.
  45. ATI_TC_FORMAT_DXT1, ///< An opaque (or 1-bit alpha) DXTC compressed texture format. Four bits per pixel.
  46. ATI_TC_FORMAT_DXT3, ///< A DXTC compressed texture format with explicit alpha. Eight bits per pixel.
  47. ATI_TC_FORMAT_DXT5, ///< A DXTC compressed texture format with interpolated alpha. Eight bits per pixel.
  48. ATI_TC_FORMAT_DXT5_xGBR, ///< A DXT5 with the red component swizzled into the alpha channel. Eight bits per pixel.
  49. ATI_TC_FORMAT_DXT5_RxBG, ///< A swizzled DXT5 format with the green component swizzled into the alpha channel. Eight bits per pixel.
  50. ATI_TC_FORMAT_DXT5_RBxG, ///< A swizzled DXT5 format with the green component swizzled into the alpha channel & the blue component swizzled into the green channel. Eight bits per pixel.
  51. ATI_TC_FORMAT_DXT5_xRBG, ///< A swizzled DXT5 format with the green component swizzled into the alpha channel & the red component swizzled into the green channel. Eight bits per pixel.
  52. ATI_TC_FORMAT_DXT5_RGxB, ///< A swizzled DXT5 format with the blue component swizzled into the alpha channel. Eight bits per pixel.
  53. ATI_TC_FORMAT_DXT5_xGxR, ///< A two-component swizzled DXT5 format with the red component swizzled into the alpha channel & the green component in the green channel. Eight bits per pixel.
  54. ATI_TC_FORMAT_ATI1N, ///< A single component compression format using the same technique as DXT5 alpha. Four bits per pixel.
  55. ATI_TC_FORMAT_ATI2N, ///< A two component compression format using the same technique as DXT5 alpha. Designed for compression object space normal maps. Eight bits per pixel.
  56. ATI_TC_FORMAT_ATI2N_XY, ///< A two component compression format using the same technique as DXT5 alpha. The same as ATI2N but with the channels swizzled. Eight bits per pixel.
  57. ATI_TC_FORMAT_ATI2N_DXT5, ///< An ATI2N like format using DXT5. Intended for use on GPUs that do not natively support ATI2N. Eight bits per pixel.
  58. ATI_TC_FORMAT_BC1, ///< A four component opaque (or 1-bit alpha) compressed texture format for Microsoft DirectX10. Identical to DXT1. Four bits per pixel.
  59. ATI_TC_FORMAT_BC2, ///< A four component compressed texture format with explicit alpha for Microsoft DirectX10. Identical to DXT3. Eight bits per pixel.
  60. ATI_TC_FORMAT_BC3, ///< A four component compressed texture format with interpolated alpha for Microsoft DirectX10. Identical to DXT5. Eight bits per pixel.
  61. ATI_TC_FORMAT_BC4, ///< A single component compressed texture format for Microsoft DirectX10. Identical to ATI1N. Four bits per pixel.
  62. ATI_TC_FORMAT_BC5, ///< A two component compressed texture format for Microsoft DirectX10. Identical to ATI2N. Eight bits per pixel.
  63. ATI_TC_FORMAT_ATC_RGB, ///< ATI_TC - a compressed RGB format for cellphones & hand-held devices.
  64. ATI_TC_FORMAT_ATC_RGBA_Explicit, ///< ATI_TC - a compressed ARGB format with explicit alpha for cellphones & hand-held devices.
  65. ATI_TC_FORMAT_ATC_RGBA_Interpolated, ///< ATI_TC - a compressed ARGB format with interpolated alpha for cellphones & hand-held devices.
  66. ATI_TC_FORMAT_ETC_RGB, ///< ETC (aka Ericsson Texture Compression) - a compressed RGB format for cellphones.
  67. ATI_TC_FORMAT_MAX = ATI_TC_FORMAT_ETC_RGB
  68. } ATI_TC_FORMAT;
  69. /// An enum selecting the speed vs. quality trade-off.
  70. typedef enum
  71. {
  72. ATI_TC_Speed_Normal, ///< Highest quality mode
  73. ATI_TC_Speed_Fast, ///< Slightly lower quality but much faster compression mode - DXTn & ATInN only
  74. ATI_TC_Speed_SuperFast, ///< Slightly lower quality but much, much faster compression mode - DXTn & ATInN only
  75. } ATI_TC_Speed;
  76. /// ATI_Compress error codes
  77. typedef enum
  78. {
  79. ATI_TC_OK = 0, ///< Ok.
  80. ATI_TC_ABORTED, ///< The conversion was aborted.
  81. ATI_TC_ERR_INVALID_SOURCE_TEXTURE, ///< The source texture is invalid.
  82. ATI_TC_ERR_INVALID_DEST_TEXTURE, ///< The destination texture is invalid.
  83. ATI_TC_ERR_UNSUPPORTED_SOURCE_FORMAT, ///< The source format is not a supported format.
  84. ATI_TC_ERR_UNSUPPORTED_DEST_FORMAT, ///< The destination format is not a supported format.
  85. ATI_TC_ERR_SIZE_MISMATCH, ///< The source and destination texture sizes do not match.
  86. ATI_TC_ERR_UNABLE_TO_INIT_CODEC, ///< ATI_Compress was unable to initialize the codec needed for conversion.
  87. ATI_TC_ERR_GENERIC ///< An unknown error occurred.
  88. } ATI_TC_ERROR;
  89. /// Options for the compression.
  90. /// Passing this structure is optional
  91. typedef struct
  92. {
  93. ATI_TC_DWORD dwSize; ///< The size of this structure.
  94. BOOL bUseChannelWeighting; ///< Use channel weightings. With swizzled formats the weighting applies to the data within the specified channel not the channel itself.
  95. double fWeightingRed; ///< The weighting of the Red or X Channel.
  96. double fWeightingGreen; ///< The weighting of the Green or Y Channel.
  97. double fWeightingBlue; ///< The weighting of the Blue or Z Channel.
  98. BOOL bUseAdaptiveWeighting; ///< Adapt weighting on a per-block basis.
  99. BOOL bDXT1UseAlpha; ///< Encode single-bit alpha data. Only valid when compressing to DXT1 & BC1.
  100. ATI_TC_BYTE nAlphaThreshold; ///< The alpha threshold to use when compressing to DXT1 & BC1 with bDXT1UseAlpha. Texels with an alpha value less than the threshold are treated as transparent.
  101. BOOL bDisableMultiThreading; ///< Disable multi-threading of the compression. This will slow the compression but can be useful if you're managing threads in your application.
  102. ATI_TC_Speed nCompressionSpeed; ///< The trade-off between compression speed & quality.
  103. } ATI_TC_CompressOptions;
  104. #endif // !ATI_COMPRESS_INTERNAL_BUILD
  105. /// The structure describing a texture.
  106. typedef struct
  107. {
  108. ATI_TC_DWORD dwSize; ///< Size of this structure.
  109. ATI_TC_DWORD dwWidth; ///< Width of the texture.
  110. ATI_TC_DWORD dwHeight; ///< Height of the texture.
  111. ATI_TC_DWORD dwPitch; ///< Distance to start of next line - necessary only for uncompressed textures.
  112. ATI_TC_FORMAT format; ///< Format of the texture.
  113. ATI_TC_DWORD dwDataSize; ///< Size of the allocated texture data.
  114. ATI_TC_BYTE* pData; ///< Pointer to the texture data
  115. } ATI_TC_Texture;
  116. #define MINIMUM_WEIGHT_VALUE 0.01f
  117. #ifdef __cplusplus
  118. extern "C" {
  119. #endif
  120. /// ATI_TC_Feedback_Proc
  121. /// Feedback function for conversion.
  122. /// \param[in] fProgress The percentage progress of the texture compression.
  123. /// \param[in] pUser1 User data as passed to ATI_TC_ConvertTexture.
  124. /// \param[in] pUser2 User data as passed to ATI_TC_ConvertTexture.
  125. /// \return non-NULL(true) value to abort conversion
  126. typedef bool (ATI_TC_API * ATI_TC_Feedback_Proc)(float fProgress, DWORD_PTR pUser1, DWORD_PTR pUser2);
  127. /// Calculates the required buffer size for the specified texture
  128. /// \param[in] pTexture A pointer to the texture.
  129. /// \return The size of the buffer required to hold the texture data.
  130. ATI_TC_DWORD ATI_TC_API ATI_TC_CalculateBufferSize(const ATI_TC_Texture* pTexture);
  131. /// Converts the source texture to the destination texture
  132. /// This can be compression, decompression or converting between two uncompressed formats.
  133. /// \param[in] pSourceTexture A pointer to the source texture.
  134. /// \param[in] pDestTexture A pointer to the destination texture.
  135. /// \param[in] pOptions A pointer to the compression options - can be NULL.
  136. /// \param[in] pFeedbackProc A pointer to the feedback function - can be NULL.
  137. /// \param[in] pUser1 User data to pass to the feedback function.
  138. /// \param[in] pUser2 User data to pass to the feedback function.
  139. /// \return ATI_TC_OK if successful, otherwise the error code.
  140. ATI_TC_ERROR ATI_TC_API ATI_TC_ConvertTexture(const ATI_TC_Texture* pSourceTexture, ATI_TC_Texture* pDestTexture,
  141. const ATI_TC_CompressOptions* pOptions,
  142. ATI_TC_Feedback_Proc pFeedbackProc, DWORD_PTR pUser1, DWORD_PTR pUser2);
  143. #ifdef __cplusplus
  144. };
  145. #endif
  146. #endif // !ATI_COMPRESS