From 1a379d18054ff264620f513fb8f1c2ccd99a07ea Mon Sep 17 00:00:00 2001 From: BlueCube3310 <53150244+BlueCube3310@users.noreply.github.com> Date: Fri, 7 Mar 2025 15:26:03 +0100 Subject: [PATCH] BasisUniversal: Ensure ASTC's HDR variant is supported when transcoding (cherry picked from commit 4d46ef8e8e3f8c9cb57902ef18a21ba49b38514d) --- drivers/gles3/storage/utilities.cpp | 3 +++ modules/basis_universal/image_compress_basisu.cpp | 3 ++- servers/rendering/renderer_rd/storage_rd/utilities.cpp | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/gles3/storage/utilities.cpp b/drivers/gles3/storage/utilities.cpp index 4fa6444471b..b096a8a7f30 100644 --- a/drivers/gles3/storage/utilities.cpp +++ b/drivers/gles3/storage/utilities.cpp @@ -421,6 +421,9 @@ bool Utilities::has_os_feature(const String &p_feature) const { if (p_feature == "etc2") { return config->etc2_supported; } + if (p_feature == "astc_hdr") { + return config->astc_hdr_supported; + } return false; } diff --git a/modules/basis_universal/image_compress_basisu.cpp b/modules/basis_universal/image_compress_basisu.cpp index be28d895082..5027b8a48cc 100644 --- a/modules/basis_universal/image_compress_basisu.cpp +++ b/modules/basis_universal/image_compress_basisu.cpp @@ -275,6 +275,7 @@ Ref basis_universal_unpacker_ptr(const uint8_t *p_data, int p_size) { bool rgtc_supported = RS::get_singleton()->has_os_feature("rgtc"); bool s3tc_supported = RS::get_singleton()->has_os_feature("s3tc"); bool etc2_supported = RS::get_singleton()->has_os_feature("etc2"); + bool astc_hdr_supported = RS::get_singleton()->has_os_feature("astc_hdr"); bool needs_ra_rg_swap = false; bool needs_rg_trim = false; @@ -379,7 +380,7 @@ Ref basis_universal_unpacker_ptr(const uint8_t *p_data, int p_size) { if (bptc_supported) { basisu_format = basist::transcoder_texture_format::cTFBC6H; image_format = Image::FORMAT_BPTC_RGBFU; - } else if (astc_supported) { + } else if (astc_hdr_supported) { basisu_format = basist::transcoder_texture_format::cTFASTC_HDR_4x4_RGBA; image_format = Image::FORMAT_ASTC_4x4_HDR; } else { diff --git a/servers/rendering/renderer_rd/storage_rd/utilities.cpp b/servers/rendering/renderer_rd/storage_rd/utilities.cpp index 068d82d47cd..9e0c9476500 100644 --- a/servers/rendering/renderer_rd/storage_rd/utilities.cpp +++ b/servers/rendering/renderer_rd/storage_rd/utilities.cpp @@ -286,6 +286,10 @@ bool Utilities::has_os_feature(const String &p_feature) const { return true; } + if (p_feature == "astc_hdr" && RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_ASTC_4x4_SFLOAT_BLOCK, RD::TEXTURE_USAGE_SAMPLING_BIT)) { + return true; + } + return false; }