diff options
Diffstat (limited to 'modules/etc')
-rw-r--r-- | modules/etc/image_etc.cpp | 66 | ||||
-rw-r--r-- | modules/etc/texture_loader_pkm.cpp | 2 |
2 files changed, 16 insertions, 52 deletions
diff --git a/modules/etc/image_etc.cpp b/modules/etc/image_etc.cpp index b80138c99d..24ee8e458e 100644 --- a/modules/etc/image_etc.cpp +++ b/modules/etc/image_etc.cpp @@ -36,18 +36,18 @@ #include "core/os/os.h" #include "core/print_string.h" -static Image::Format _get_etc2_mode(Image::DetectChannels format) { +static Image::Format _get_etc2_mode(Image::UsedChannels format) { switch (format) { - case Image::DETECTED_R: + case Image::USED_CHANNELS_R: return Image::FORMAT_ETC2_R11; - case Image::DETECTED_RG: + case Image::USED_CHANNELS_RG: return Image::FORMAT_ETC2_RG11; - case Image::DETECTED_RGB: + case Image::USED_CHANNELS_RGB: return Image::FORMAT_ETC2_RGB8; - case Image::DETECTED_RGBA: + case Image::USED_CHANNELS_RGBA: return Image::FORMAT_ETC2_RGBA8; // TODO: would be nice if we could use FORMAT_ETC2_RGB8A1 for FORMAT_RGBA5551 @@ -88,47 +88,8 @@ static Etc::Image::Format _image_format_to_etc2comp_format(Image::Format format) } } -static void _compress_etc(Image *p_img, float p_lossy_quality, bool force_etc1_format, Image::CompressSource p_source) { +static void _compress_etc(Image *p_img, float p_lossy_quality, bool force_etc1_format, Image::UsedChannels p_channels) { Image::Format img_format = p_img->get_format(); - Image::DetectChannels detected_channels = p_img->get_detected_channels(); - - if (p_source == Image::COMPRESS_SOURCE_LAYERED) { - //keep what comes in - switch (p_img->get_format()) { - case Image::FORMAT_L8: { - detected_channels = Image::DETECTED_L; - } break; - case Image::FORMAT_LA8: { - detected_channels = Image::DETECTED_LA; - } break; - case Image::FORMAT_R8: { - detected_channels = Image::DETECTED_R; - } break; - case Image::FORMAT_RG8: { - detected_channels = Image::DETECTED_RG; - } break; - case Image::FORMAT_RGB8: { - detected_channels = Image::DETECTED_RGB; - } break; - case Image::FORMAT_RGBA8: - case Image::FORMAT_RGBA4444: - case Image::FORMAT_RGBA5551: { - detected_channels = Image::DETECTED_RGBA; - } break; - default: { - } - } - } - - if (p_source == Image::COMPRESS_SOURCE_SRGB && (detected_channels == Image::DETECTED_R || detected_channels == Image::DETECTED_RG)) { - //R and RG do not support SRGB - detected_channels = Image::DETECTED_RGB; - } - - if (p_source == Image::COMPRESS_SOURCE_NORMAL) { - //use RG channels only for normal - detected_channels = Image::DETECTED_RG; - } if (img_format >= Image::FORMAT_DXT1) { return; //do not compress, already compressed @@ -139,21 +100,24 @@ static void _compress_etc(Image *p_img, float p_lossy_quality, bool force_etc1_f return; } + // FIXME: Commented out during Vulkan rebase. + /* if (force_etc1_format) { // If VRAM compression is using ETC, but image has alpha, convert to RGBA4444 or LA8 // This saves space while maintaining the alpha channel - if (detected_channels == Image::DETECTED_RGBA) { + if (detected_channels == Image::USED_CHANNELS_RGBA) { p_img->convert(Image::FORMAT_RGBA4444); return; - } else if (detected_channels == Image::DETECTED_LA) { + } else if (detected_channels == Image::USE_CHANNELS_LA) { p_img->convert(Image::FORMAT_LA8); return; } } + */ uint32_t imgw = p_img->get_width(), imgh = p_img->get_height(); - Image::Format etc_format = force_etc1_format ? Image::FORMAT_ETC : _get_etc2_mode(detected_channels); + Image::Format etc_format = force_etc1_format ? Image::FORMAT_ETC : _get_etc2_mode(p_channels); Ref<Image> img = p_img->duplicate(); @@ -241,11 +205,11 @@ static void _compress_etc(Image *p_img, float p_lossy_quality, bool force_etc1_f } static void _compress_etc1(Image *p_img, float p_lossy_quality) { - _compress_etc(p_img, p_lossy_quality, true, Image::COMPRESS_SOURCE_GENERIC); + _compress_etc(p_img, p_lossy_quality, true, Image::USED_CHANNELS_RGB); } -static void _compress_etc2(Image *p_img, float p_lossy_quality, Image::CompressSource p_source) { - _compress_etc(p_img, p_lossy_quality, false, p_source); +static void _compress_etc2(Image *p_img, float p_lossy_quality, Image::UsedChannels p_channels) { + _compress_etc(p_img, p_lossy_quality, false, p_channels); } void _register_etc_compress_func() { diff --git a/modules/etc/texture_loader_pkm.cpp b/modules/etc/texture_loader_pkm.cpp index 27c2358306..facdc2e473 100644 --- a/modules/etc/texture_loader_pkm.cpp +++ b/modules/etc/texture_loader_pkm.cpp @@ -103,7 +103,7 @@ void ResourceFormatPKM::get_recognized_extensions(List<String> *p_extensions) co bool ResourceFormatPKM::handles_type(const String &p_type) const { - return ClassDB::is_parent_class(p_type, "Texture"); + return ClassDB::is_parent_class(p_type, "Texture2D"); } String ResourceFormatPKM::get_resource_type(const String &p_path) const { |