basisu.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. // basisu.h
  2. // Copyright (C) 2019-2024 Binomial LLC. All Rights Reserved.
  3. // Important: If compiling with gcc, be sure strict aliasing is disabled: -fno-strict-aliasing
  4. //
  5. // Licensed under the Apache License, Version 2.0 (the "License");
  6. // you may not use this file except in compliance with the License.
  7. // You may obtain a copy of the License at
  8. //
  9. // http://www.apache.org/licenses/LICENSE-2.0
  10. //
  11. // Unless required by applicable law or agreed to in writing, software
  12. // distributed under the License is distributed on an "AS IS" BASIS,
  13. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. // See the License for the specific language governing permissions and
  15. // limitations under the License.
  16. #pragma once
  17. #ifdef _MSC_VER
  18. #pragma warning (disable : 4201)
  19. #pragma warning (disable : 4127) // warning C4127: conditional expression is constant
  20. #pragma warning (disable : 4530) // C++ exception handler used, but unwind semantics are not enabled.
  21. // Slamming this off always for v1.16 because we've gotten rid of most std containers.
  22. #ifndef BASISU_NO_ITERATOR_DEBUG_LEVEL
  23. #define BASISU_NO_ITERATOR_DEBUG_LEVEL (1)
  24. #endif
  25. #ifndef BASISU_NO_ITERATOR_DEBUG_LEVEL
  26. //#define _HAS_ITERATOR_DEBUGGING 0
  27. #if defined(_DEBUG) || defined(DEBUG)
  28. // This is madness, but we need to disable iterator debugging in debug builds or the encoder is unsable because MSVC's iterator debugging implementation is totally broken.
  29. #ifndef _ITERATOR_DEBUG_LEVEL
  30. #define _ITERATOR_DEBUG_LEVEL 1
  31. #endif
  32. #ifndef _SECURE_SCL
  33. #define _SECURE_SCL 1
  34. #endif
  35. #else // defined(_DEBUG) || defined(DEBUG)
  36. #ifndef _SECURE_SCL
  37. #define _SECURE_SCL 0
  38. #endif
  39. #ifndef _ITERATOR_DEBUG_LEVEL
  40. #define _ITERATOR_DEBUG_LEVEL 0
  41. #endif
  42. #endif // defined(_DEBUG) || defined(DEBUG)
  43. #endif // BASISU_NO_ITERATOR_DEBUG_LEVEL
  44. #endif // _MSC_VER
  45. #include <stdlib.h>
  46. #include <stdio.h>
  47. #include <math.h>
  48. #include <stdarg.h>
  49. #include <string.h>
  50. #include <memory.h>
  51. #include <limits.h>
  52. #include <stdint.h>
  53. #include <algorithm>
  54. #include <limits>
  55. #include <functional>
  56. #include <iterator>
  57. #include <type_traits>
  58. #include <assert.h>
  59. #include <random>
  60. #include "basisu_containers.h"
  61. #ifdef max
  62. #undef max
  63. #endif
  64. #ifdef min
  65. #undef min
  66. #endif
  67. #ifdef _WIN32
  68. #define strcasecmp _stricmp
  69. #endif
  70. // Set to one to enable debug printf()'s when any errors occur, for development/debugging. Especially useful for WebGL development.
  71. #ifndef BASISU_FORCE_DEVEL_MESSAGES
  72. #define BASISU_FORCE_DEVEL_MESSAGES 0
  73. #endif
  74. #define BASISU_NOTE_UNUSED(x) (void)(x)
  75. #define BASISU_ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
  76. #define BASISU_NO_EQUALS_OR_COPY_CONSTRUCT(x) x(const x &) = delete; x& operator= (const x &) = delete;
  77. #define BASISU_ASSUME(x) static_assert(x, #x);
  78. #define BASISU_OFFSETOF(s, m) offsetof(s, m)
  79. #define BASISU_STRINGIZE(x) #x
  80. #define BASISU_STRINGIZE2(x) BASISU_STRINGIZE(x)
  81. #if BASISU_FORCE_DEVEL_MESSAGES
  82. #define BASISU_DEVEL_ERROR(...) do { basisu::debug_printf(__VA_ARGS__); } while(0)
  83. #else
  84. #define BASISU_DEVEL_ERROR(...)
  85. #endif
  86. namespace basisu
  87. {
  88. // Types/utilities
  89. #ifdef _WIN32
  90. const char BASISU_PATH_SEPERATOR_CHAR = '\\';
  91. #else
  92. const char BASISU_PATH_SEPERATOR_CHAR = '/';
  93. #endif
  94. typedef basisu::vector<uint8_t> uint8_vec;
  95. typedef basisu::vector<int16_t> int16_vec;
  96. typedef basisu::vector<uint16_t> uint16_vec;
  97. typedef basisu::vector<uint32_t> uint_vec;
  98. typedef basisu::vector<uint64_t> uint64_vec;
  99. typedef basisu::vector<int> int_vec;
  100. typedef basisu::vector<bool> bool_vec;
  101. typedef basisu::vector<float> float_vec;
  102. void enable_debug_printf(bool enabled);
  103. void debug_printf(const char *pFmt, ...);
  104. #ifndef __EMSCRIPTEN__
  105. #ifdef __GNUC__
  106. #pragma GCC diagnostic push
  107. #pragma GCC diagnostic ignored "-Wclass-memaccess"
  108. #endif
  109. #endif
  110. template <typename T> inline void clear_obj(T& obj) { memset(&obj, 0, sizeof(obj)); }
  111. #ifndef __EMSCRIPTEN__
  112. #ifdef __GNUC__
  113. #pragma GCC diagnostic pop
  114. #endif
  115. #endif
  116. template <typename T0, typename T1> inline T0 lerp(T0 a, T0 b, T1 c) { return a + (b - a) * c; }
  117. template <typename S> inline S maximum(S a, S b) { return (a > b) ? a : b; }
  118. template <typename S> inline S maximum(S a, S b, S c) { return maximum(maximum(a, b), c); }
  119. template <typename S> inline S maximum(S a, S b, S c, S d) { return maximum(maximum(maximum(a, b), c), d); }
  120. template <typename S> inline S minimum(S a, S b) { return (a < b) ? a : b; }
  121. template <typename S> inline S minimum(S a, S b, S c) { return minimum(minimum(a, b), c); }
  122. template <typename S> inline S minimum(S a, S b, S c, S d) { return minimum(minimum(minimum(a, b), c), d); }
  123. inline float clampf(float value, float low, float high) { if (value < low) value = low; else if (value > high) value = high; return value; }
  124. inline float saturate(float value) { return clampf(value, 0, 1.0f); }
  125. inline uint8_t minimumub(uint8_t a, uint8_t b) { return (a < b) ? a : b; }
  126. inline uint32_t minimumu(uint32_t a, uint32_t b) { return (a < b) ? a : b; }
  127. inline int32_t minimumi(int32_t a, int32_t b) { return (a < b) ? a : b; }
  128. inline float minimumf(float a, float b) { return (a < b) ? a : b; }
  129. inline uint8_t maximumub(uint8_t a, uint8_t b) { return (a > b) ? a : b; }
  130. inline uint32_t maximumu(uint32_t a, uint32_t b) { return (a > b) ? a : b; }
  131. inline int32_t maximumi(int32_t a, int32_t b) { return (a > b) ? a : b; }
  132. inline float maximumf(float a, float b) { return (a > b) ? a : b; }
  133. inline int squarei(int i) { return i * i; }
  134. inline float squaref(float i) { return i * i; }
  135. template<typename T> inline T square(T a) { return a * a; }
  136. template <typename S> inline S clamp(S value, S low, S high) { return (value < low) ? low : ((value > high) ? high : value); }
  137. inline uint32_t iabs(int32_t i) { return (i < 0) ? static_cast<uint32_t>(-i) : static_cast<uint32_t>(i); }
  138. inline uint64_t iabs64(int64_t i) { return (i < 0) ? static_cast<uint64_t>(-i) : static_cast<uint64_t>(i); }
  139. template<typename T> inline void clear_vector(T &vec) { vec.erase(vec.begin(), vec.end()); }
  140. template<typename T> inline typename T::value_type *enlarge_vector(T &vec, size_t n) { size_t cs = vec.size(); vec.resize(cs + n); return &vec[cs]; }
  141. inline bool is_pow2(uint32_t x) { return x && ((x & (x - 1U)) == 0U); }
  142. inline bool is_pow2(uint64_t x) { return x && ((x & (x - 1U)) == 0U); }
  143. template<typename T> inline T open_range_check(T v, T minv, T maxv) { assert(v >= minv && v < maxv); BASISU_NOTE_UNUSED(minv); BASISU_NOTE_UNUSED(maxv); return v; }
  144. template<typename T> inline T open_range_check(T v, T maxv) { assert(v < maxv); BASISU_NOTE_UNUSED(maxv); return v; }
  145. // Open interval
  146. inline bool in_bounds(int v, int l, int h)
  147. {
  148. return (v >= l) && (v < h);
  149. }
  150. // Closed interval
  151. inline bool in_range(int v, int l, int h)
  152. {
  153. return (v >= l) && (v <= h);
  154. }
  155. inline uint32_t total_bits(uint32_t v) { uint32_t l = 0; for ( ; v > 0U; ++l) v >>= 1; return l; }
  156. template<typename T> inline T saturate(T val) { return clamp(val, 0.0f, 1.0f); }
  157. inline uint32_t get_bit(uint32_t src, int ndx)
  158. {
  159. assert(in_bounds(ndx, 0, 32));
  160. return (src >> ndx) & 1;
  161. }
  162. inline bool is_bit_set(uint32_t src, int ndx)
  163. {
  164. return get_bit(src, ndx) != 0;
  165. }
  166. inline uint32_t get_bits(uint32_t val, int low, int high)
  167. {
  168. const int num_bits = (high - low) + 1;
  169. assert(in_range(num_bits, 1, 32));
  170. val >>= low;
  171. if (num_bits != 32)
  172. val &= ((1u << num_bits) - 1);
  173. return val;
  174. }
  175. template<typename T, typename R> inline void append_vector(T &vec, const R *pObjs, size_t n)
  176. {
  177. if (n)
  178. {
  179. if (vec.size())
  180. {
  181. assert((pObjs + n) <= vec.begin() || (pObjs >= vec.end()));
  182. }
  183. const size_t cur_s = vec.size();
  184. vec.resize(cur_s + n);
  185. memcpy(&vec[cur_s], pObjs, sizeof(R) * n);
  186. }
  187. }
  188. template<typename T> inline void append_vector(T &vec, const T &other_vec)
  189. {
  190. assert(&vec != &other_vec);
  191. if (other_vec.size())
  192. append_vector(vec, &other_vec[0], other_vec.size());
  193. }
  194. template<typename T> inline void vector_ensure_element_is_valid(T &vec, size_t idx)
  195. {
  196. if (idx >= vec.size())
  197. vec.resize(idx + 1);
  198. }
  199. template<typename T> inline void vector_sort(T &vec)
  200. {
  201. if (vec.size())
  202. std::sort(vec.begin(), vec.end());
  203. }
  204. template<typename T, typename U> inline bool unordered_set_contains(T& set, const U&obj)
  205. {
  206. return set.find(obj) != set.end();
  207. }
  208. template<typename T> int vector_find(const T &vec, const typename T::value_type &obj)
  209. {
  210. assert(vec.size() <= INT_MAX);
  211. for (size_t i = 0; i < vec.size(); i++)
  212. if (vec[i] == obj)
  213. return static_cast<int>(i);
  214. return -1;
  215. }
  216. template<typename T> void vector_set_all(T &vec, const typename T::value_type &obj)
  217. {
  218. for (size_t i = 0; i < vec.size(); i++)
  219. vec[i] = obj;
  220. }
  221. inline uint64_t read_be64(const void *p)
  222. {
  223. uint64_t val = 0;
  224. for (uint32_t i = 0; i < 8; i++)
  225. val |= (static_cast<uint64_t>(static_cast<const uint8_t *>(p)[7 - i]) << (i * 8));
  226. return val;
  227. }
  228. inline void write_be64(void *p, uint64_t x)
  229. {
  230. for (uint32_t i = 0; i < 8; i++)
  231. static_cast<uint8_t *>(p)[7 - i] = static_cast<uint8_t>(x >> (i * 8));
  232. }
  233. static inline uint16_t byteswap16(uint16_t x) { return static_cast<uint16_t>((x << 8) | (x >> 8)); }
  234. static inline uint32_t byteswap32(uint32_t x) { return ((x << 24) | ((x << 8) & 0x00FF0000) | ((x >> 8) & 0x0000FF00) | (x >> 24)); }
  235. inline uint32_t floor_log2i(uint32_t v)
  236. {
  237. uint32_t b = 0;
  238. for (; v > 1U; ++b)
  239. v >>= 1;
  240. return b;
  241. }
  242. inline uint32_t ceil_log2i(uint32_t v)
  243. {
  244. uint32_t b = floor_log2i(v);
  245. if ((b != 32) && (v > (1U << b)))
  246. ++b;
  247. return b;
  248. }
  249. inline int posmod(int x, int y)
  250. {
  251. if (x >= 0)
  252. return (x < y) ? x : (x % y);
  253. int m = (-x) % y;
  254. return (m != 0) ? (y - m) : m;
  255. }
  256. inline bool do_excl_ranges_overlap(int la, int ha, int lb, int hb)
  257. {
  258. assert(la < ha && lb < hb);
  259. if ((ha <= lb) || (la >= hb)) return false;
  260. return true;
  261. }
  262. static inline uint32_t read_le_word(const uint8_t* pBytes)
  263. {
  264. return (pBytes[1] << 8U) | (pBytes[0]);
  265. }
  266. static inline uint32_t read_le_dword(const uint8_t *pBytes)
  267. {
  268. return (pBytes[3] << 24U) | (pBytes[2] << 16U) | (pBytes[1] << 8U) | (pBytes[0]);
  269. }
  270. static inline void write_le_dword(uint8_t* pBytes, uint32_t val)
  271. {
  272. pBytes[0] = (uint8_t)val;
  273. pBytes[1] = (uint8_t)(val >> 8U);
  274. pBytes[2] = (uint8_t)(val >> 16U);
  275. pBytes[3] = (uint8_t)(val >> 24U);
  276. }
  277. // Always little endian 1-8 byte unsigned int
  278. template<uint32_t NumBytes>
  279. struct packed_uint
  280. {
  281. uint8_t m_bytes[NumBytes];
  282. inline packed_uint() { static_assert(NumBytes <= sizeof(uint64_t), "Invalid NumBytes"); }
  283. inline packed_uint(uint64_t v) { *this = v; }
  284. inline packed_uint(const packed_uint& other) { *this = other; }
  285. inline packed_uint& operator= (uint64_t v)
  286. {
  287. for (uint32_t i = 0; i < NumBytes; i++)
  288. m_bytes[i] = static_cast<uint8_t>(v >> (i * 8));
  289. return *this;
  290. }
  291. inline packed_uint& operator= (const packed_uint& rhs)
  292. {
  293. memcpy(m_bytes, rhs.m_bytes, sizeof(m_bytes));
  294. return *this;
  295. }
  296. #ifdef __GNUC__
  297. #pragma GCC diagnostic push
  298. #pragma GCC diagnostic ignored "-Warray-bounds"
  299. #endif
  300. inline operator uint32_t() const
  301. {
  302. switch (NumBytes)
  303. {
  304. case 1:
  305. {
  306. return m_bytes[0];
  307. }
  308. case 2:
  309. {
  310. return (m_bytes[1] << 8U) | m_bytes[0];
  311. }
  312. case 3:
  313. {
  314. return (m_bytes[2] << 16U) | (m_bytes[1] << 8U) | m_bytes[0];
  315. }
  316. case 4:
  317. {
  318. return read_le_dword(m_bytes);
  319. }
  320. case 5:
  321. {
  322. uint32_t l = read_le_dword(m_bytes);
  323. uint32_t h = m_bytes[4];
  324. return static_cast<uint64_t>(l) | (static_cast<uint64_t>(h) << 32U);
  325. }
  326. case 6:
  327. {
  328. uint32_t l = read_le_dword(m_bytes);
  329. uint32_t h = (m_bytes[5] << 8U) | m_bytes[4];
  330. return static_cast<uint64_t>(l) | (static_cast<uint64_t>(h) << 32U);
  331. }
  332. case 7:
  333. {
  334. uint32_t l = read_le_dword(m_bytes);
  335. uint32_t h = (m_bytes[6] << 16U) | (m_bytes[5] << 8U) | m_bytes[4];
  336. return static_cast<uint64_t>(l) | (static_cast<uint64_t>(h) << 32U);
  337. }
  338. case 8:
  339. {
  340. uint32_t l = read_le_dword(m_bytes);
  341. uint32_t h = read_le_dword(m_bytes + 4);
  342. return static_cast<uint64_t>(l) | (static_cast<uint64_t>(h) << 32U);
  343. }
  344. default:
  345. {
  346. assert(0);
  347. return 0;
  348. }
  349. }
  350. }
  351. #ifdef __GNUC__
  352. #pragma GCC diagnostic pop
  353. #endif
  354. };
  355. enum eZero { cZero };
  356. enum eNoClamp { cNoClamp };
  357. // Rice/Huffman entropy coding
  358. // This is basically Deflate-style canonical Huffman, except we allow for a lot more symbols.
  359. enum
  360. {
  361. cHuffmanMaxSupportedCodeSize = 16, cHuffmanMaxSupportedInternalCodeSize = 31,
  362. cHuffmanFastLookupBits = 10,
  363. cHuffmanMaxSymsLog2 = 14, cHuffmanMaxSyms = 1 << cHuffmanMaxSymsLog2,
  364. // Small zero runs
  365. cHuffmanSmallZeroRunSizeMin = 3, cHuffmanSmallZeroRunSizeMax = 10, cHuffmanSmallZeroRunExtraBits = 3,
  366. // Big zero run
  367. cHuffmanBigZeroRunSizeMin = 11, cHuffmanBigZeroRunSizeMax = 138, cHuffmanBigZeroRunExtraBits = 7,
  368. // Small non-zero run
  369. cHuffmanSmallRepeatSizeMin = 3, cHuffmanSmallRepeatSizeMax = 6, cHuffmanSmallRepeatExtraBits = 2,
  370. // Big non-zero run
  371. cHuffmanBigRepeatSizeMin = 7, cHuffmanBigRepeatSizeMax = 134, cHuffmanBigRepeatExtraBits = 7,
  372. cHuffmanTotalCodelengthCodes = 21, cHuffmanSmallZeroRunCode = 17, cHuffmanBigZeroRunCode = 18, cHuffmanSmallRepeatCode = 19, cHuffmanBigRepeatCode = 20
  373. };
  374. static const uint8_t g_huffman_sorted_codelength_codes[] = { cHuffmanSmallZeroRunCode, cHuffmanBigZeroRunCode, cHuffmanSmallRepeatCode, cHuffmanBigRepeatCode, 0, 8, 7, 9, 6, 0xA, 5, 0xB, 4, 0xC, 3, 0xD, 2, 0xE, 1, 0xF, 0x10 };
  375. const uint32_t cHuffmanTotalSortedCodelengthCodes = sizeof(g_huffman_sorted_codelength_codes) / sizeof(g_huffman_sorted_codelength_codes[0]);
  376. // GPU texture formats
  377. enum class texture_format
  378. {
  379. cInvalidTextureFormat = -1,
  380. // Block-based formats
  381. cETC1, // ETC1
  382. cETC1S, // ETC1 (subset: diff colors only, no subblocks)
  383. cETC2_RGB, // ETC2 color block (basisu doesn't support ETC2 planar/T/H modes - just basic ETC1)
  384. cETC2_RGBA, // ETC2 EAC alpha block followed by ETC2 color block
  385. cETC2_ALPHA, // ETC2 EAC alpha block
  386. cBC1, // DXT1
  387. cBC3, // DXT5 (BC4/DXT5A block followed by a BC1/DXT1 block)
  388. cBC4, // DXT5A
  389. cBC5, // 3DC/DXN (two BC4/DXT5A blocks)
  390. cBC6HSigned, // HDR
  391. cBC6HUnsigned, // HDR
  392. cBC7,
  393. cASTC_LDR_4x4, // ASTC 4x4 LDR only
  394. cASTC_HDR_4x4, // ASTC 4x4 HDR only (but may use LDR ASTC blocks internally)
  395. cPVRTC1_4_RGB,
  396. cPVRTC1_4_RGBA,
  397. cATC_RGB,
  398. cATC_RGBA_INTERPOLATED_ALPHA,
  399. cFXT1_RGB,
  400. cPVRTC2_4_RGBA,
  401. cETC2_R11_EAC,
  402. cETC2_RG11_EAC,
  403. cUASTC4x4,
  404. cUASTC_HDR_4x4,
  405. cBC1_NV,
  406. cBC1_AMD,
  407. // Uncompressed/raw pixels
  408. cRGBA32,
  409. cRGB565,
  410. cBGR565,
  411. cRGBA4444,
  412. cABGR4444,
  413. cRGBA_HALF,
  414. cRGB_HALF,
  415. cRGB_9E5
  416. };
  417. // This is bytes per block for GPU formats, or bytes per texel for uncompressed formats.
  418. inline uint32_t get_bytes_per_block(texture_format fmt)
  419. {
  420. switch (fmt)
  421. {
  422. case texture_format::cETC1:
  423. case texture_format::cETC1S:
  424. case texture_format::cETC2_RGB:
  425. case texture_format::cETC2_ALPHA:
  426. case texture_format::cBC1:
  427. case texture_format::cBC1_NV:
  428. case texture_format::cBC1_AMD:
  429. case texture_format::cBC4:
  430. case texture_format::cPVRTC1_4_RGB:
  431. case texture_format::cPVRTC1_4_RGBA:
  432. case texture_format::cATC_RGB:
  433. case texture_format::cPVRTC2_4_RGBA:
  434. case texture_format::cETC2_R11_EAC:
  435. return 8;
  436. case texture_format::cRGBA32:
  437. case texture_format::cRGB_9E5:
  438. return sizeof(uint32_t);
  439. case texture_format::cRGB_HALF:
  440. return sizeof(uint16_t) * 3;
  441. case texture_format::cRGBA_HALF:
  442. return sizeof(uint16_t) * 4;
  443. case texture_format::cRGB565:
  444. case texture_format::cBGR565:
  445. case texture_format::cRGBA4444:
  446. case texture_format::cABGR4444:
  447. return sizeof(uint16_t);
  448. default:
  449. break;
  450. }
  451. // Everything else is 16 bytes/block.
  452. return 16;
  453. }
  454. // This is qwords per block for GPU formats, or not valid for uncompressed formats.
  455. inline uint32_t get_qwords_per_block(texture_format fmt)
  456. {
  457. return get_bytes_per_block(fmt) >> 3;
  458. }
  459. inline uint32_t get_block_width(texture_format fmt)
  460. {
  461. BASISU_NOTE_UNUSED(fmt);
  462. switch (fmt)
  463. {
  464. case texture_format::cFXT1_RGB:
  465. return 8;
  466. default:
  467. break;
  468. }
  469. return 4;
  470. }
  471. inline uint32_t get_block_height(texture_format fmt)
  472. {
  473. BASISU_NOTE_UNUSED(fmt);
  474. return 4;
  475. }
  476. inline bool is_hdr_texture_format(texture_format fmt)
  477. {
  478. if (fmt == texture_format::cASTC_HDR_4x4)
  479. return true;
  480. if (fmt == texture_format::cUASTC_HDR_4x4)
  481. return true;
  482. if ((fmt == texture_format::cBC6HSigned) || (fmt == texture_format::cBC6HUnsigned))
  483. return true;
  484. return false;
  485. }
  486. } // namespace basisu