Skip to content

Commit

Permalink
Fix wrong EAC_R11G11_UNORM_BLOCK mapping.
Browse files Browse the repository at this point in the history
ETC1_R8G8B8_UNORM_BLOCK will be converted to ETC2_R8G8B8_UNORM_BLOCK.
instead of mapped directly to metal format.
  • Loading branch information
kakashidinho committed Jul 31, 2020
1 parent 277864a commit a457b90
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/libANGLE/renderer/metal/mtl_format_map.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
"PVRTC1_RGB_4BPP_UNORM_SRGB_BLOCK": "MTLPixelFormatPVRTC_RGB_4BPP_sRGB",
"PVRTC1_RGBA_2BPP_UNORM_SRGB_BLOCK": "MTLPixelFormatPVRTC_RGBA_2BPP_sRGB",
"PVRTC1_RGBA_4BPP_UNORM_SRGB_BLOCK": "MTLPixelFormatPVRTC_RGBA_4BPP_sRGB",
"ETC1_R8G8B8_UNORM_BLOCK": "MTLPixelFormatETC2_RGB8",
"ETC2_R8G8B8_UNORM_BLOCK": "MTLPixelFormatETC2_RGB8",
"ETC2_R8G8B8_SRGB_BLOCK": "MTLPixelFormatETC2_RGB8_sRGB",
"ETC2_R8G8B8A1_UNORM_BLOCK": "MTLPixelFormatETC2_RGB8A1",
Expand All @@ -71,7 +70,7 @@
"ETC2_R8G8B8A8_SRGB_BLOCK": "MTLPixelFormatEAC_RGBA8_sRGB",
"EAC_R11_UNORM_BLOCK": "MTLPixelFormatEAC_R11Unorm",
"EAC_R11_SNORM_BLOCK": "MTLPixelFormatEAC_R11Snorm",
"EAC_R11G11_UNORM_BLOCK": "MTLPixelFormatEAC_R11Unorm",
"EAC_R11G11_UNORM_BLOCK": "MTLPixelFormatEAC_RG11Unorm",
"EAC_R11G11_SNORM_BLOCK": "MTLPixelFormatEAC_RG11Snorm"
},
"map_mac": {
Expand Down Expand Up @@ -111,7 +110,8 @@
},
"override_ios": {
"D24_UNORM_S8_UINT": "D32_FLOAT_S8X24_UINT",
"D16_UNORM": "D32_FLOAT"
"D16_UNORM": "D32_FLOAT",
"ETC1_R8G8B8_UNORM_BLOCK": "ETC2_R8G8B8_UNORM_BLOCK"
},
"override_mac": {
"R5G6B5_UNORM": "R8G8B8A8_UNORM",
Expand Down
20 changes: 10 additions & 10 deletions src/libANGLE/renderer/metal/mtl_format_table_autogen.mm
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@

case angle::FormatID::EAC_R11G11_UNORM_BLOCK:

this->metalFormat = MTLPixelFormatEAC_R11Unorm;
this->metalFormat = MTLPixelFormatEAC_RG11Unorm;
this->actualFormatId = angle::FormatID::EAC_R11G11_UNORM_BLOCK;
this->initFunction = nullptr;

Expand All @@ -993,15 +993,6 @@
this->swizzled = false;
break;

case angle::FormatID::ETC1_R8G8B8_UNORM_BLOCK:

this->metalFormat = MTLPixelFormatETC2_RGB8;
this->actualFormatId = angle::FormatID::ETC1_R8G8B8_UNORM_BLOCK;
this->initFunction = nullptr;

this->swizzled = false;
break;

case angle::FormatID::ETC2_R8G8B8A1_SRGB_BLOCK:

this->metalFormat = MTLPixelFormatETC2_RGB8A1_sRGB;
Expand Down Expand Up @@ -1173,6 +1164,15 @@
this->swizzled = false;
break;

case angle::FormatID::ETC1_R8G8B8_UNORM_BLOCK:

this->metalFormat = MTLPixelFormatETC2_RGB8;
this->actualFormatId = angle::FormatID::ETC2_R8G8B8_UNORM_BLOCK;
this->initFunction = nullptr;

this->swizzled = false;
break;

#endif // TARGET_OS_OSX || TARGET_OS_MACCATALYST
default:
this->metalFormat = MTLPixelFormatInvalid;
Expand Down
6 changes: 6 additions & 0 deletions src/libANGLE/renderer/metal/mtl_format_utils.mm
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ void GenerateTextureCapsMap(const FormatTable &formatTable,
ASSERT(swizzled);
return false;
}
if (srcFormatId == angle::FormatID::ETC1_R8G8B8_UNORM_BLOCK &&
actualFormatId == angle::FormatID::ETC2_R8G8B8_UNORM_BLOCK)
{
// ETC1 RGB & ETC2 RGB are technically the same.
return false;
}
return srcFormatId != actualFormatId;
}

Expand Down

0 comments on commit a457b90

Please sign in to comment.