diff options
author | aaronp64 <aaronp.code@gmail.com> | 2024-05-20 19:40:39 -0400 |
---|---|---|
committer | aaronp64 <aaronp.code@gmail.com> | 2024-05-20 19:40:39 -0400 |
commit | f81e0fcbf41f4f39766390bc00ced61f53c7d932 (patch) | |
tree | a3b6312221e64bfa2bda41e8c9749accf9397729 /core/math/transform_interpolator.cpp | |
parent | bd2300d77a6008167043f23fd91bcc562cde0a19 (diff) | |
download | redot-engine-f81e0fcbf41f4f39766390bc00ced61f53c7d932.tar.gz |
Improve memory usage for image import and PortableCompressedTexture2D
When importing images, we store a compressed version of the image to a .ctex file with ResourceImporterTexture::save_to_ctex_format. When importing many large images at once, this can use a large amount of memory, especially when the .ctex file uses WebP format.
This change is for ResourceImporterTexture::save_to_ctex_format to use the original Image object instead of p_image->get_image_from_mipmap(0), to avoid creating a copy of the full uncompressed image when looping through the base Image and mipmaps. This reduces the import memory usage for large images by around 10% when using WebP, and 35-40% when Project Settings/Rendering/Textures/Lossless Compression/Force PNG is enabled, may vary depending on the image and number of import threads running. Same change applied to PortableCompressedTexture2D::create_from_image, which has similar logic.
This helps with #92084, but does not fully resolve the issue on its own, as compressing with WebP on many threads can still use a large amount of memory - this just lowers that amount, and makes it more likely that enabling "Force PNG" will reduce memory usage enough to import the files.
Diffstat (limited to 'core/math/transform_interpolator.cpp')
0 files changed, 0 insertions, 0 deletions