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

KTX: Add support for loading most ETC-compressed formats #100524

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions modules/ktx/texture_loader_ktx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,32 +208,33 @@ static Ref<Image> load_from_file_access(Ref<FileAccess> f, Error *r_error) {
case GL_COMPRESSED_RGBA_BPTC_UNORM:
format = Image::FORMAT_BPTC_RGBA;
break;
#if 0 // TODO: ETC compression is bogus.
case GL_ETC1_RGB8_OES:
format = Image::FORMAT_ETC;
break;
case GL_COMPRESSED_R11_EAC:
format = Image::FORMAT_ETC2_R11;
break;
case GL_COMPRESSED_SIGNED_R11_EAC:
// Decompression is not supported for this format.
/*case GL_COMPRESSED_SIGNED_R11_EAC:
format = Image::FORMAT_ETC2_R11S;
break;
break;*/
Comment on lines +218 to +220
Copy link
Member

Choose a reason for hiding this comment

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

I'd add a comment to describe why this is commented out (most likely because etcpak doesn't support it?).

Same for other commented out blocks below.

case GL_COMPRESSED_RG11_EAC:
format = Image::FORMAT_ETC2_RG11;
break;
case GL_COMPRESSED_SIGNED_RG11_EAC:
// Decompression is not supported for this format.
/*case GL_COMPRESSED_SIGNED_RG11_EAC:
format = Image::FORMAT_ETC2_RG11S;
break;
break;*/
case GL_COMPRESSED_RGB8_ETC2:
format = Image::FORMAT_ETC2_RGB8;
break;
case GL_COMPRESSED_RGBA8_ETC2_EAC:
format = Image::FORMAT_ETC2_RGBA8;
break;
case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
// Decompression is not supported for this format.
/*case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
format = Image::FORMAT_ETC2_RGB8A1;
break;
#endif
break;*/
case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:
format = Image::FORMAT_ASTC_4x4;
break;
Expand Down Expand Up @@ -406,29 +407,30 @@ static Ref<Image> load_from_file_access(Ref<FileAccess> f, Error *r_error) {
case VK_FORMAT_BC7_UNORM_BLOCK:
format = Image::FORMAT_BPTC_RGBA;
break;
#if 0 // TODO: ETC compression is bogus.
case VK_FORMAT_EAC_R11_UNORM_BLOCK:
format = Image::FORMAT_ETC2_R11;
break;
case VK_FORMAT_EAC_R11_SNORM_BLOCK:
// Decompression is not supported for this format.
/*case VK_FORMAT_EAC_R11_SNORM_BLOCK:
format = Image::FORMAT_ETC2_R11S;
break;
break;*/
case VK_FORMAT_EAC_R11G11_UNORM_BLOCK:
format = Image::FORMAT_ETC2_RG11;
break;
case VK_FORMAT_EAC_R11G11_SNORM_BLOCK:
// Decompression is not supported for this format.
/*case VK_FORMAT_EAC_R11G11_SNORM_BLOCK:
format = Image::FORMAT_ETC2_RG11S;
break;
break;*/
case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK:
format = Image::FORMAT_ETC2_RGB8;
break;
case VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK:
format = Image::FORMAT_ETC2_RGBA8;
break;
case VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK:
// Decompression is not supported for this format.
/*case VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK:
format = Image::FORMAT_ETC2_RGB8A1;
break;
#endif
break;*/
case VK_FORMAT_ASTC_4x4_SRGB_BLOCK:
format = Image::FORMAT_ASTC_4x4;
break;
Expand Down