Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BasisUniversal: Fix texture decompression #88676

Merged
merged 1 commit into from
Feb 22, 2024

Conversation

BlueCube3310
Copy link
Contributor

@BlueCube3310 BlueCube3310 commented Feb 22, 2024

BasisU requires providing an image's pixel count for transcoding textures to uncompressed formats. Previously it would always be given the compressed block count, and thus decompression would always fail.

This is a difficult bug to reproduce, since it only happens on hardware which doesn't support any compressed formats.

MRP: BasisuDecompressed.zip
Testing requires applying the diff posted below.

@BlueCube3310 BlueCube3310 requested a review from a team as a code owner February 22, 2024 18:19
@AThousandShips AThousandShips added this to the 4.3 milestone Feb 22, 2024
Copy link
Member

@fire fire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no reproduction project but the code uses the enumeration to check if it's compressed and switch on the result. Seems correct, but I can't test it on hardware.

uint32_t mip_block_or_pixel_count = image_format >= Image::FORMAT_DXT1 ? basisu_level.m_total_blocks : basisu_level.m_orig_width * basisu_level.m_orig_height;

@fire fire requested a review from a team February 22, 2024 20:13
@BlueCube3310
Copy link
Contributor Author

It's possible to force disable transcoding to all compressed formats with this diff:

diff --git a/modules/basis_universal/image_compress_basisu.cpp b/modules/basis_universal/image_compress_basisu.cpp
index 72e7977eef..9321923739 100644
--- a/modules/basis_universal/image_compress_basisu.cpp
+++ b/modules/basis_universal/image_compress_basisu.cpp
@@ -153,10 +153,10 @@ Ref<Image> basis_universal_unpacker_ptr(const uint8_t *p_data, int p_size) {
 	Image::Format image_format = Image::FORMAT_MAX;
 
 	// Get supported compression formats.
-	bool bptc_supported = RS::get_singleton()->has_os_feature("bptc");
-	bool astc_supported = RS::get_singleton()->has_os_feature("astc");
-	bool s3tc_supported = RS::get_singleton()->has_os_feature("s3tc");
-	bool etc2_supported = RS::get_singleton()->has_os_feature("etc2");
+	bool bptc_supported = false; // RS::get_singleton()->has_os_feature("bptc");
+	bool astc_supported = false; // RS::get_singleton()->has_os_feature("astc");
+	bool s3tc_supported = false; // RS::get_singleton()->has_os_feature("s3tc");
+	bool etc2_supported = false; // RS::get_singleton()->has_os_feature("etc2");
 
 	bool needs_ra_rg_swap = false;

@akien-mga akien-mga merged commit 8e1fa57 into godotengine:master Feb 22, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants