image_compress_basisu.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. /**************************************************************************/
  2. /* image_compress_basisu.cpp */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #include "image_compress_basisu.h"
  31. #include "core/config/project_settings.h"
  32. #include "core/io/image.h"
  33. #include "core/os/os.h"
  34. #include "core/string/print_string.h"
  35. #include "servers/rendering/rendering_server.h"
  36. GODOT_GCC_WARNING_PUSH
  37. GODOT_GCC_WARNING_IGNORE("-Wenum-conversion")
  38. GODOT_GCC_WARNING_IGNORE("-Wshadow")
  39. GODOT_GCC_WARNING_IGNORE("-Wunused-value")
  40. #include <transcoder/basisu_transcoder.h>
  41. #ifdef TOOLS_ENABLED
  42. #include <encoder/basisu_comp.h>
  43. static Mutex init_mutex;
  44. static bool initialized = false;
  45. #endif
  46. GODOT_GCC_WARNING_POP
  47. void basis_universal_init() {
  48. basist::basisu_transcoder_init();
  49. }
  50. #ifdef TOOLS_ENABLED
  51. template <typename T>
  52. inline void _basisu_pad_mipmap(const uint8_t *p_image_mip_data, Vector<uint8_t> &r_mip_data_padded, int p_next_width, int p_next_height, int p_width, int p_height, int64_t p_size) {
  53. // Source mip's data interpreted as 32-bit RGBA blocks to help with copying pixel data.
  54. const T *mip_src_data = reinterpret_cast<const T *>(p_image_mip_data);
  55. // Reserve space in the padded buffer.
  56. r_mip_data_padded.resize(p_next_width * p_next_height * sizeof(T));
  57. T *data_padded_ptr = reinterpret_cast<T *>(r_mip_data_padded.ptrw());
  58. // Pad mipmap to the nearest block by smearing.
  59. int x = 0, y = 0;
  60. for (y = 0; y < p_height; y++) {
  61. for (x = 0; x < p_width; x++) {
  62. data_padded_ptr[p_next_width * y + x] = mip_src_data[p_width * y + x];
  63. }
  64. // First, smear in x.
  65. for (; x < p_next_width; x++) {
  66. data_padded_ptr[p_next_width * y + x] = data_padded_ptr[p_next_width * y + x - 1];
  67. }
  68. }
  69. // Then, smear in y.
  70. for (; y < p_next_height; y++) {
  71. for (x = 0; x < p_next_width; x++) {
  72. data_padded_ptr[p_next_width * y + x] = data_padded_ptr[p_next_width * y + x - p_next_width];
  73. }
  74. }
  75. }
  76. Vector<uint8_t> basis_universal_packer(const Ref<Image> &p_image, Image::UsedChannels p_channels, const Image::BasisUniversalPackerParams &p_basisu_params) {
  77. init_mutex.lock();
  78. if (!initialized) {
  79. basisu::basisu_encoder_init();
  80. initialized = true;
  81. }
  82. init_mutex.unlock();
  83. uint64_t start_time = OS::get_singleton()->get_ticks_msec();
  84. Ref<Image> image = p_image->duplicate();
  85. bool is_hdr = false;
  86. if (image->get_format() <= Image::FORMAT_RGB565) {
  87. image->convert(Image::FORMAT_RGBA8);
  88. } else if (image->get_format() <= Image::FORMAT_RGBE9995) {
  89. image->convert(Image::FORMAT_RGBAF);
  90. is_hdr = true;
  91. }
  92. int rdo_dict_size = GLOBAL_GET_CACHED(int, "rendering/textures/basis_universal/rdo_dict_size");
  93. bool zstd_supercompression = GLOBAL_GET_CACHED(bool, "rendering/textures/basis_universal/zstd_supercompression");
  94. int zstd_supercompression_level = GLOBAL_GET_CACHED(int, "rendering/textures/basis_universal/zstd_supercompression_level");
  95. basisu::basis_compressor_params params;
  96. params.m_uastc = true;
  97. params.m_pack_uastc_ldr_4x4_flags &= ~basisu::cPackUASTCLevelMask;
  98. params.m_pack_uastc_ldr_4x4_flags |= p_basisu_params.uastc_level;
  99. params.m_rdo_uastc_ldr_4x4 = p_basisu_params.rdo_quality_loss >= 0.01;
  100. params.m_rdo_uastc_ldr_4x4_quality_scalar = p_basisu_params.rdo_quality_loss;
  101. params.m_rdo_uastc_ldr_4x4_dict_size = rdo_dict_size;
  102. params.m_create_ktx2_file = true;
  103. params.m_ktx2_uastc_supercompression = zstd_supercompression ? basist::KTX2_SS_ZSTANDARD : basist::KTX2_SS_NONE;
  104. params.m_ktx2_zstd_supercompression_level = zstd_supercompression_level;
  105. params.m_mip_fast = true;
  106. params.m_multithreading = true;
  107. params.m_check_for_alpha = false;
  108. if (!OS::get_singleton()->is_stdout_verbose()) {
  109. params.m_print_stats = false;
  110. params.m_compute_stats = false;
  111. params.m_status_output = false;
  112. }
  113. basisu::job_pool job_pool(OS::get_singleton()->get_processor_count());
  114. params.m_pJob_pool = &job_pool;
  115. BasisDecompressFormat decompress_format = BASIS_DECOMPRESS_MAX;
  116. if (is_hdr) {
  117. decompress_format = BASIS_DECOMPRESS_HDR_RGB;
  118. params.m_hdr = true;
  119. params.m_uastc_hdr_4x4_options.set_quality_level(p_basisu_params.uastc_level);
  120. } else {
  121. switch (p_channels) {
  122. case Image::USED_CHANNELS_L: {
  123. decompress_format = BASIS_DECOMPRESS_RGB;
  124. } break;
  125. case Image::USED_CHANNELS_LA: {
  126. params.m_force_alpha = true;
  127. decompress_format = BASIS_DECOMPRESS_RGBA;
  128. } break;
  129. case Image::USED_CHANNELS_R: {
  130. decompress_format = BASIS_DECOMPRESS_R;
  131. } break;
  132. case Image::USED_CHANNELS_RG: {
  133. params.m_force_alpha = true;
  134. image->convert_rg_to_ra_rgba8();
  135. decompress_format = BASIS_DECOMPRESS_RG;
  136. } break;
  137. case Image::USED_CHANNELS_RGB: {
  138. decompress_format = BASIS_DECOMPRESS_RGB;
  139. } break;
  140. case Image::USED_CHANNELS_RGBA: {
  141. params.m_force_alpha = true;
  142. decompress_format = BASIS_DECOMPRESS_RGBA;
  143. } break;
  144. }
  145. }
  146. ERR_FAIL_COND_V(decompress_format == BASIS_DECOMPRESS_MAX, Vector<uint8_t>());
  147. // Copy the source image data with mipmaps into BasisU.
  148. {
  149. const int orig_width = image->get_width();
  150. const int orig_height = image->get_height();
  151. bool is_res_div_4 = (orig_width % 4 == 0) && (orig_height % 4 == 0);
  152. // Image's resolution rounded up to the nearest values divisible by 4.
  153. int next_width = orig_width <= 2 ? orig_width : (orig_width + 3) & ~3;
  154. int next_height = orig_height <= 2 ? orig_height : (orig_height + 3) & ~3;
  155. Vector<uint8_t> image_data = image->get_data();
  156. basisu::vector<basisu::image> basisu_mipmaps;
  157. basisu::vector<basisu::imagef> basisu_mipmaps_hdr;
  158. // Buffer for storing padded mipmap data.
  159. Vector<uint8_t> mip_data_padded;
  160. for (int32_t i = 0; i <= image->get_mipmap_count(); i++) {
  161. int64_t ofs, size;
  162. int width, height;
  163. image->get_mipmap_offset_size_and_dimensions(i, ofs, size, width, height);
  164. const uint8_t *image_mip_data = image_data.ptr() + ofs;
  165. // Pad the mipmap's data if its resolution isn't divisible by 4.
  166. if (image->has_mipmaps() && !is_res_div_4 && (width > 2 && height > 2) && (width != next_width || height != next_height)) {
  167. if (is_hdr) {
  168. _basisu_pad_mipmap<BasisRGBAF>(image_mip_data, mip_data_padded, next_width, next_height, width, height, size);
  169. } else {
  170. _basisu_pad_mipmap<uint32_t>(image_mip_data, mip_data_padded, next_width, next_height, width, height, size);
  171. }
  172. // Override the image_mip_data pointer with our temporary Vector.
  173. image_mip_data = reinterpret_cast<const uint8_t *>(mip_data_padded.ptr());
  174. // Override the mipmap's properties.
  175. width = next_width;
  176. height = next_height;
  177. size = mip_data_padded.size();
  178. }
  179. // Get the next mipmap's resolution.
  180. next_width /= 2;
  181. next_height /= 2;
  182. // Copy the source mipmap's data to a BasisU image.
  183. if (is_hdr) {
  184. basisu::imagef basisu_image(width, height);
  185. memcpy(reinterpret_cast<uint8_t *>(basisu_image.get_ptr()), image_mip_data, size);
  186. if (i == 0) {
  187. params.m_source_images_hdr.push_back(basisu_image);
  188. } else {
  189. basisu_mipmaps_hdr.push_back(basisu_image);
  190. }
  191. } else {
  192. basisu::image basisu_image(width, height);
  193. memcpy(basisu_image.get_ptr(), image_mip_data, size);
  194. if (i == 0) {
  195. params.m_source_images.push_back(basisu_image);
  196. } else {
  197. basisu_mipmaps.push_back(basisu_image);
  198. }
  199. }
  200. }
  201. if (is_hdr) {
  202. params.m_source_mipmap_images_hdr.push_back(basisu_mipmaps_hdr);
  203. } else {
  204. params.m_source_mipmap_images.push_back(basisu_mipmaps);
  205. }
  206. }
  207. // Encode the image data.
  208. basisu::basis_compressor compressor;
  209. compressor.init(params);
  210. int basisu_err = compressor.process();
  211. ERR_FAIL_COND_V(basisu_err != basisu::basis_compressor::cECSuccess, Vector<uint8_t>());
  212. const basisu::uint8_vec &basisu_encoded = compressor.get_output_ktx2_file();
  213. Vector<uint8_t> basisu_data;
  214. basisu_data.resize(basisu_encoded.size() + 4);
  215. uint8_t *basisu_data_ptr = basisu_data.ptrw();
  216. // Copy the encoded BasisU data into the output buffer.
  217. *(uint32_t *)basisu_data_ptr = decompress_format | BASIS_DECOMPRESS_FLAG_KTX2;
  218. memcpy(basisu_data_ptr + 4, basisu_encoded.get_ptr(), basisu_encoded.size());
  219. print_verbose(vformat("BasisU: Encoding a %dx%d image with %d mipmaps took %d ms.", p_image->get_width(), p_image->get_height(), p_image->get_mipmap_count(), OS::get_singleton()->get_ticks_msec() - start_time));
  220. return basisu_data;
  221. }
  222. #endif // TOOLS_ENABLED
  223. Ref<Image> basis_universal_unpacker_ptr(const uint8_t *p_data, int p_size) {
  224. uint64_t start_time = OS::get_singleton()->get_ticks_msec();
  225. Ref<Image> image;
  226. ERR_FAIL_NULL_V_MSG(p_data, image, "Cannot unpack invalid BasisUniversal data.");
  227. const uint8_t *src_ptr = p_data;
  228. int src_size = p_size;
  229. basist::transcoder_texture_format basisu_format = basist::transcoder_texture_format::cTFTotalTextureFormats;
  230. Image::Format image_format = Image::FORMAT_MAX;
  231. // Get supported compression formats.
  232. bool bptc_supported = RS::get_singleton()->has_os_feature("bptc");
  233. bool astc_supported = RS::get_singleton()->has_os_feature("astc");
  234. bool rgtc_supported = RS::get_singleton()->has_os_feature("rgtc");
  235. bool s3tc_supported = RS::get_singleton()->has_os_feature("s3tc");
  236. bool etc2_supported = RS::get_singleton()->has_os_feature("etc2");
  237. bool astc_hdr_supported = RS::get_singleton()->has_os_feature("astc_hdr");
  238. bool needs_ra_rg_swap = false;
  239. bool needs_rg_trim = false;
  240. uint32_t decompress_format = *(uint32_t *)(src_ptr);
  241. bool is_ktx2 = decompress_format & BASIS_DECOMPRESS_FLAG_KTX2;
  242. decompress_format &= ~BASIS_DECOMPRESS_FLAG_KTX2;
  243. switch (decompress_format) {
  244. case BASIS_DECOMPRESS_R: {
  245. if (rgtc_supported) {
  246. basisu_format = basist::transcoder_texture_format::cTFBC4_R;
  247. image_format = Image::FORMAT_RGTC_R;
  248. } else if (s3tc_supported) {
  249. basisu_format = basist::transcoder_texture_format::cTFBC1;
  250. image_format = Image::FORMAT_DXT1;
  251. } else if (etc2_supported) {
  252. basisu_format = basist::transcoder_texture_format::cTFETC2_EAC_R11;
  253. image_format = Image::FORMAT_ETC2_R11;
  254. } else {
  255. // No supported VRAM compression formats, decompress.
  256. basisu_format = basist::transcoder_texture_format::cTFRGBA32;
  257. image_format = Image::FORMAT_RGBA8;
  258. needs_rg_trim = true;
  259. }
  260. } break;
  261. case BASIS_DECOMPRESS_RG: {
  262. if (rgtc_supported) {
  263. basisu_format = basist::transcoder_texture_format::cTFBC5_RG;
  264. image_format = Image::FORMAT_RGTC_RG;
  265. } else if (s3tc_supported) {
  266. basisu_format = basist::transcoder_texture_format::cTFBC3;
  267. image_format = Image::FORMAT_DXT5_RA_AS_RG;
  268. } else if (etc2_supported) {
  269. basisu_format = basist::transcoder_texture_format::cTFETC2_EAC_RG11;
  270. image_format = Image::FORMAT_ETC2_RG11;
  271. } else {
  272. // No supported VRAM compression formats, decompress.
  273. basisu_format = basist::transcoder_texture_format::cTFRGBA32;
  274. image_format = Image::FORMAT_RGBA8;
  275. needs_ra_rg_swap = true;
  276. needs_rg_trim = true;
  277. }
  278. } break;
  279. case BASIS_DECOMPRESS_RG_AS_RA: {
  280. if (s3tc_supported) {
  281. basisu_format = basist::transcoder_texture_format::cTFBC3;
  282. image_format = Image::FORMAT_DXT5_RA_AS_RG;
  283. } else if (etc2_supported) {
  284. basisu_format = basist::transcoder_texture_format::cTFETC2;
  285. image_format = Image::FORMAT_ETC2_RA_AS_RG;
  286. } else {
  287. // No supported VRAM compression formats, decompress.
  288. basisu_format = basist::transcoder_texture_format::cTFRGBA32;
  289. image_format = Image::FORMAT_RGBA8;
  290. needs_ra_rg_swap = true;
  291. needs_rg_trim = true;
  292. }
  293. } break;
  294. case BASIS_DECOMPRESS_RGB: {
  295. if (bptc_supported) {
  296. basisu_format = basist::transcoder_texture_format::cTFBC7_M6_OPAQUE_ONLY;
  297. image_format = Image::FORMAT_BPTC_RGBA;
  298. } else if (astc_supported) {
  299. basisu_format = basist::transcoder_texture_format::cTFASTC_4x4_RGBA;
  300. image_format = Image::FORMAT_ASTC_4x4;
  301. } else if (s3tc_supported) {
  302. basisu_format = basist::transcoder_texture_format::cTFBC1;
  303. image_format = Image::FORMAT_DXT1;
  304. } else if (etc2_supported) {
  305. basisu_format = basist::transcoder_texture_format::cTFETC1;
  306. image_format = Image::FORMAT_ETC2_RGB8;
  307. } else {
  308. // No supported VRAM compression formats, decompress.
  309. basisu_format = basist::transcoder_texture_format::cTFRGBA32;
  310. image_format = Image::FORMAT_RGBA8;
  311. }
  312. } break;
  313. case BASIS_DECOMPRESS_RGBA: {
  314. if (bptc_supported) {
  315. basisu_format = basist::transcoder_texture_format::cTFBC7_M5;
  316. image_format = Image::FORMAT_BPTC_RGBA;
  317. } else if (astc_supported) {
  318. basisu_format = basist::transcoder_texture_format::cTFASTC_4x4_RGBA;
  319. image_format = Image::FORMAT_ASTC_4x4;
  320. } else if (s3tc_supported) {
  321. basisu_format = basist::transcoder_texture_format::cTFBC3;
  322. image_format = Image::FORMAT_DXT5;
  323. } else if (etc2_supported) {
  324. basisu_format = basist::transcoder_texture_format::cTFETC2;
  325. image_format = Image::FORMAT_ETC2_RGBA8;
  326. } else {
  327. // No supported VRAM compression formats, decompress.
  328. basisu_format = basist::transcoder_texture_format::cTFRGBA32;
  329. image_format = Image::FORMAT_RGBA8;
  330. }
  331. } break;
  332. case BASIS_DECOMPRESS_HDR_RGB: {
  333. if (bptc_supported) {
  334. basisu_format = basist::transcoder_texture_format::cTFBC6H;
  335. image_format = Image::FORMAT_BPTC_RGBFU;
  336. } else if (astc_hdr_supported) {
  337. basisu_format = basist::transcoder_texture_format::cTFASTC_HDR_4x4_RGBA;
  338. image_format = Image::FORMAT_ASTC_4x4_HDR;
  339. } else {
  340. // No supported VRAM compression formats, decompress.
  341. basisu_format = basist::transcoder_texture_format::cTFRGB_9E5;
  342. image_format = Image::FORMAT_RGBE9995;
  343. }
  344. } break;
  345. default: {
  346. ERR_FAIL_V(image);
  347. } break;
  348. }
  349. src_ptr += 4;
  350. src_size -= 4;
  351. if (is_ktx2) {
  352. basist::ktx2_transcoder transcoder;
  353. ERR_FAIL_COND_V(!transcoder.init(src_ptr, src_size), image);
  354. transcoder.start_transcoding();
  355. // Create the buffer for transcoded/decompressed data.
  356. Vector<uint8_t> out_data;
  357. out_data.resize(Image::get_image_data_size(transcoder.get_width(), transcoder.get_height(), image_format, transcoder.get_levels() > 1));
  358. uint8_t *dst = out_data.ptrw();
  359. memset(dst, 0, out_data.size());
  360. for (uint32_t i = 0; i < transcoder.get_levels(); i++) {
  361. basist::ktx2_image_level_info basisu_level;
  362. transcoder.get_image_level_info(basisu_level, i, 0, 0);
  363. uint32_t mip_block_or_pixel_count = Image::is_format_compressed(image_format) ? basisu_level.m_total_blocks : basisu_level.m_orig_width * basisu_level.m_orig_height;
  364. int64_t ofs = Image::get_image_mipmap_offset(transcoder.get_width(), transcoder.get_height(), image_format, i);
  365. bool result = transcoder.transcode_image_level(i, 0, 0, dst + ofs, mip_block_or_pixel_count, basisu_format);
  366. if (!result) {
  367. print_line(vformat("BasisUniversal cannot unpack level %d.", i));
  368. break;
  369. }
  370. }
  371. image = Image::create_from_data(transcoder.get_width(), transcoder.get_height(), transcoder.get_levels() > 1, image_format, out_data);
  372. } else {
  373. basist::basisu_transcoder transcoder;
  374. ERR_FAIL_COND_V(!transcoder.validate_header(src_ptr, src_size), image);
  375. transcoder.start_transcoding(src_ptr, src_size);
  376. basist::basisu_image_info basisu_info;
  377. transcoder.get_image_info(src_ptr, src_size, basisu_info, 0);
  378. // Create the buffer for transcoded/decompressed data.
  379. Vector<uint8_t> out_data;
  380. out_data.resize(Image::get_image_data_size(basisu_info.m_width, basisu_info.m_height, image_format, basisu_info.m_total_levels > 1));
  381. uint8_t *dst = out_data.ptrw();
  382. memset(dst, 0, out_data.size());
  383. for (uint32_t i = 0; i < basisu_info.m_total_levels; i++) {
  384. basist::basisu_image_level_info basisu_level;
  385. transcoder.get_image_level_info(src_ptr, src_size, basisu_level, 0, i);
  386. uint32_t mip_block_or_pixel_count = Image::is_format_compressed(image_format) ? basisu_level.m_total_blocks : basisu_level.m_orig_width * basisu_level.m_orig_height;
  387. int64_t ofs = Image::get_image_mipmap_offset(basisu_info.m_width, basisu_info.m_height, image_format, i);
  388. bool result = transcoder.transcode_image_level(src_ptr, src_size, 0, i, dst + ofs, mip_block_or_pixel_count, basisu_format);
  389. if (!result) {
  390. print_line(vformat("BasisUniversal cannot unpack level %d.", i));
  391. break;
  392. }
  393. }
  394. image = Image::create_from_data(basisu_info.m_width, basisu_info.m_height, basisu_info.m_total_levels > 1, image_format, out_data);
  395. }
  396. if (needs_ra_rg_swap) {
  397. // Swap uncompressed RA-as-RG texture's color channels.
  398. image->convert_ra_rgba8_to_rg();
  399. }
  400. if (needs_rg_trim) {
  401. // Remove unnecessary color channels from uncompressed textures.
  402. if (decompress_format == BASIS_DECOMPRESS_R) {
  403. image->convert(Image::FORMAT_R8);
  404. } else if (decompress_format == BASIS_DECOMPRESS_RG || decompress_format == BASIS_DECOMPRESS_RG_AS_RA) {
  405. image->convert(Image::FORMAT_RG8);
  406. }
  407. }
  408. print_verbose(vformat("BasisU: Transcoding a %dx%d image with %d mipmaps into %s took %d ms.",
  409. image->get_width(), image->get_height(), image->get_mipmap_count(), Image::get_format_name(image_format), OS::get_singleton()->get_ticks_msec() - start_time));
  410. return image;
  411. }
  412. Ref<Image> basis_universal_unpacker(const Vector<uint8_t> &p_buffer) {
  413. return basis_universal_unpacker_ptr(p_buffer.ptr(), p_buffer.size());
  414. }