diff options
author | Juan Linietsky <reduzio@gmail.com> | 2023-01-25 12:17:11 +0100 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2023-01-30 15:53:23 +0100 |
commit | 28f51ba547722d1283882ec5dee9bcab070bc33e (patch) | |
tree | 81a2ef0bc8aa468876bf5edb65df16e2fcc9f4ee /drivers | |
parent | 17a85973559fae0cd2c33d13c4b53f16cf7419ba (diff) |
Refactor high quality texture import
* Only two texture import modes for low/high quality now:
* S3TC/BPTC
* ETC2/ASTC
* Makes sense given this is the general preferred and most compatible combination in most platforms.
* Removed lossy_quality from VRAM texture compression options. It was unused everywhere.
* Added a new "high_quality" option to texture import. When enabled, it uses BPTC/ASTC (BC7/ASTC4x4) instead of S3TC/ETC2 (DXT1-5/ETC2,ETCA).
* Changed MacOS export settings so required texture formats depend on the architecture selected.
This solves the following problems:
* Makes it simpler to import textures as high quality, without having to worry about the specific format used.
* As the editor can now run on platforms such as web, Mac OS with Apple Silicion and Android, it should no longer be assumed that S3TC/BPTC is available by default for it.
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gles3/storage/config.cpp | 4 | ||||
-rw-r--r-- | drivers/gles3/storage/config.h | 3 | ||||
-rw-r--r-- | drivers/gles3/storage/texture_storage.cpp | 44 | ||||
-rw-r--r-- | drivers/gles3/storage/texture_storage.h | 30 | ||||
-rw-r--r-- | drivers/gles3/storage/utilities.cpp | 3 |
5 files changed, 84 insertions, 0 deletions
diff --git a/drivers/gles3/storage/config.cpp b/drivers/gles3/storage/config.cpp index d1a83e6851..77a4553c76 100644 --- a/drivers/gles3/storage/config.cpp +++ b/drivers/gles3/storage/config.cpp @@ -65,6 +65,10 @@ Config::Config() { } bptc_supported = extensions.has("GL_ARB_texture_compression_bptc") || extensions.has("EXT_texture_compression_bptc"); + astc_supported = extensions.has("GL_KHR_texture_compression_astc") || extensions.has("GL_OES_texture_compression_astc") || extensions.has("GL_KHR_texture_compression_astc_ldr") || extensions.has("GL_KHR_texture_compression_astc_hdr"); + astc_hdr_supported = extensions.has("GL_KHR_texture_compression_astc_ldr"); + astc_layered_supported = extensions.has("GL_KHR_texture_compression_astc_sliced_3d"); + #ifdef GLES_OVER_GL float_texture_supported = true; etc2_supported = false; diff --git a/drivers/gles3/storage/config.h b/drivers/gles3/storage/config.h index 8399502675..623f0442bd 100644 --- a/drivers/gles3/storage/config.h +++ b/drivers/gles3/storage/config.h @@ -77,6 +77,9 @@ public: bool rgtc_supported = false; bool bptc_supported = false; bool etc2_supported = false; + bool astc_supported = false; + bool astc_hdr_supported = false; + bool astc_layered_supported = false; bool force_vertex_shading = false; diff --git a/drivers/gles3/storage/texture_storage.cpp b/drivers/gles3/storage/texture_storage.cpp index 67526bc003..97698af0a0 100644 --- a/drivers/gles3/storage/texture_storage.cpp +++ b/drivers/gles3/storage/texture_storage.cpp @@ -594,6 +594,50 @@ Ref<Image> TextureStorage::_get_gl_image_and_format(const Ref<Image> &p_image, I } decompress_ra_to_rg = true; } break; + case Image::FORMAT_ASTC_4x4: { + if (config->astc_supported) { + r_gl_internal_format = _EXT_COMPRESSED_RGBA_ASTC_4x4_KHR; + r_gl_format = GL_RGBA; + r_gl_type = GL_UNSIGNED_BYTE; + r_compressed = true; + + } else { + need_decompress = true; + } + } break; + case Image::FORMAT_ASTC_4x4_HDR: { + if (config->astc_hdr_supported) { + r_gl_internal_format = _EXT_COMPRESSED_RGBA_ASTC_4x4_KHR; + r_gl_format = GL_RGBA; + r_gl_type = GL_UNSIGNED_BYTE; + r_compressed = true; + + } else { + need_decompress = true; + } + } break; + case Image::FORMAT_ASTC_8x8: { + if (config->astc_supported) { + r_gl_internal_format = _EXT_COMPRESSED_RGBA_ASTC_8x8_KHR; + r_gl_format = GL_RGBA; + r_gl_type = GL_UNSIGNED_BYTE; + r_compressed = true; + + } else { + need_decompress = true; + } + } break; + case Image::FORMAT_ASTC_8x8_HDR: { + if (config->astc_hdr_supported) { + r_gl_internal_format = _EXT_COMPRESSED_RGBA_ASTC_8x8_KHR; + r_gl_format = GL_RGBA; + r_gl_type = GL_UNSIGNED_BYTE; + r_compressed = true; + + } else { + need_decompress = true; + } + } break; default: { ERR_FAIL_V_MSG(Ref<Image>(), "Image Format: " + itos(p_format) + " is not supported by the OpenGL3 Renderer"); } diff --git a/drivers/gles3/storage/texture_storage.h b/drivers/gles3/storage/texture_storage.h index 9d3f407226..522be64d35 100644 --- a/drivers/gles3/storage/texture_storage.h +++ b/drivers/gles3/storage/texture_storage.h @@ -84,6 +84,36 @@ namespace GLES3 { #define _EXT_COMPRESSED_RGBA8_ETC2_EAC 0x9278 #define _EXT_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 +#define _EXT_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 +#define _EXT_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 +#define _EXT_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 +#define _EXT_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 +#define _EXT_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 +#define _EXT_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 +#define _EXT_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 +#define _EXT_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 +#define _EXT_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 +#define _EXT_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 +#define _EXT_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA +#define _EXT_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB +#define _EXT_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC +#define _EXT_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD + +#define _EXT_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 +#define _EXT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 +#define _EXT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 +#define _EXT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 +#define _EXT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 +#define _EXT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 +#define _EXT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 +#define _EXT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 +#define _EXT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 +#define _EXT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 +#define _EXT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA +#define _EXT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB +#define _EXT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC +#define _EXT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD + #define _GL_TEXTURE_EXTERNAL_OES 0x8D65 #define _EXT_TEXTURE_CUBE_MAP_SEAMLESS 0x884F diff --git a/drivers/gles3/storage/utilities.cpp b/drivers/gles3/storage/utilities.cpp index e72240c69b..30c3e61ee7 100644 --- a/drivers/gles3/storage/utilities.cpp +++ b/drivers/gles3/storage/utilities.cpp @@ -309,6 +309,9 @@ bool Utilities::has_os_feature(const String &p_feature) const { if (p_feature == "bptc") { return config->bptc_supported; } + if (p_feature == "astc") { + return config->astc_supported; + } if (p_feature == "etc" || p_feature == "etc2") { return config->etc2_supported; |