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

RenderingDevice: Fix certain RD to Image format conversions #102805

Merged
merged 1 commit into from
Feb 13, 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
11 changes: 7 additions & 4 deletions servers/rendering/renderer_rd/storage_rd/texture_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2358,7 +2358,7 @@ void TextureStorage::_texture_format_from_rd(RD::DataFormat p_rd_format, Texture
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_ONE;
} break;
case RD::DATA_FORMAT_R32G32B32A32_SFLOAT: {
r_format.image_format = Image::FORMAT_RGBF;
r_format.image_format = Image::FORMAT_RGBAF;
r_format.rd_format = RD::DATA_FORMAT_R32G32B32A32_SFLOAT;
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_G;
Expand Down Expand Up @@ -2531,7 +2531,6 @@ void TextureStorage::_texture_format_from_rd(RD::DataFormat p_rd_format, Texture
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_ONE;

} break;
/* already maps to FORMAT_ETC2_RGBA8
case RD::DATA_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK:
case RD::DATA_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK: {
r_format.image_format = Image::FORMAT_ETC2_RGBA8;
Expand All @@ -2542,7 +2541,6 @@ void TextureStorage::_texture_format_from_rd(RD::DataFormat p_rd_format, Texture
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_B;
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_A;
} break;
*/
case RD::DATA_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK:
case RD::DATA_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK: {
r_format.image_format = Image::FORMAT_ETC2_RGB8A1;
Expand All @@ -2553,6 +2551,7 @@ void TextureStorage::_texture_format_from_rd(RD::DataFormat p_rd_format, Texture
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_B;
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_A;
} break;
/* already maps to FORMAT_ETC2_RGBA8
Copy link
Member

Choose a reason for hiding this comment

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

We tend to delete code rather than comment out, is there a specific reason we're not doing that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's done to explicitly state that there are certain Image formats to which we're not mapping to, since they're just swizzled variants of other formats.

case RD::DATA_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK:
case RD::DATA_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK: {
r_format.image_format = Image::FORMAT_ETC2_RA_AS_RG;
Expand All @@ -2562,7 +2561,7 @@ void TextureStorage::_texture_format_from_rd(RD::DataFormat p_rd_format, Texture
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_A;
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_ZERO;
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_ONE;
} break;
} break;*/
/* already maps to FORMAT_DXT5
case RD::DATA_FORMAT_BC3_UNORM_BLOCK:
case RD::DATA_FORMAT_BC3_SRGB_BLOCK: {
Expand Down Expand Up @@ -2598,6 +2597,10 @@ void TextureStorage::_texture_format_from_rd(RD::DataFormat p_rd_format, Texture
// Q: Do we do as we do below, just create the sRGB variant?
r_format.image_format = Image::FORMAT_ASTC_8x8;
r_format.rd_format = RD::DATA_FORMAT_ASTC_8x8_UNORM_BLOCK;
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_G;
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_B;
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_A;
} break;
case RD::DATA_FORMAT_ASTC_8x8_SRGB_BLOCK: {
r_format.image_format = Image::FORMAT_ASTC_8x8_HDR;
Expand Down