Commit 1b436e07 by Alexey Knyazev Committed by Commit Bot

Metal: Implement BPTC support

Use autogen for setting compressed format caps. Bug: angleproject:2634 Change-Id: I8cfb57390751615c08f798f223f4db3deed2fff6 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2411979Reviewed-by: 's avatarLe Hoang Quyen <le.hoang.q@gmail.com> Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com> Commit-Queue: Jonah Ryan-Davis <jonahr@google.com>
parent e56ccc49
......@@ -6,7 +6,7 @@
"src/libANGLE/renderer/metal/gen_mtl_format_table.py":
"91579339b484425ef81b0e900a5c04ed",
"src/libANGLE/renderer/metal/mtl_format_map.json":
"b4f515e08814b5a0f148a049139d8392",
"0ef0eef6ce842b9439bfa1cc68b3fb77",
"src/libANGLE/renderer/metal/mtl_format_table_autogen.mm":
"6a8cdb5d09a6ba1521fe9dab3b887451"
"1f563eeba716d013ef39af6937576591"
}
\ No newline at end of file
......@@ -115,7 +115,11 @@
"BC4_RED_UNORM_BLOCK": "MTLPixelFormatBC4_RUnorm",
"BC4_RED_SNORM_BLOCK": "MTLPixelFormatBC4_RSnorm",
"BC5_RG_UNORM_BLOCK": "MTLPixelFormatBC5_RGUnorm",
"BC5_RG_SNORM_BLOCK": "MTLPixelFormatBC5_RGSnorm"
"BC5_RG_SNORM_BLOCK": "MTLPixelFormatBC5_RGSnorm",
"BPTC_RGB_UNSIGNED_FLOAT_BLOCK": "MTLPixelFormatBC6H_RGBUfloat",
"BPTC_RGB_SIGNED_FLOAT_BLOCK": "MTLPixelFormatBC6H_RGBFloat",
"BPTC_RGBA_UNORM_BLOCK": "MTLPixelFormatBC7_RGBAUnorm",
"BPTC_SRGB_ALPHA_UNORM_BLOCK": "MTLPixelFormatBC7_RGBAUnorm_sRGB"
},
"override": {
"L8_UNORM": "R8G8B8A8_UNORM",
......@@ -581,6 +585,48 @@
"resolve": "supportDepthStencilAutoResolve",
"colorRenderable": "false",
"depthRenderable": "display->supportsMacGPUFamily(1)"
},
"MTLPixelFormatBC1_RGBA":{
"filterable": "true"
},
"MTLPixelFormatBC1_RGBA_sRGB":{
"filterable": "true"
},
"MTLPixelFormatBC2_RGBA":{
"filterable": "true"
},
"MTLPixelFormatBC2_RGBA_sRGB":{
"filterable": "true"
},
"MTLPixelFormatBC3_RGBA":{
"filterable": "true"
},
"MTLPixelFormatBC3_RGBA_sRGB":{
"filterable": "true"
},
"MTLPixelFormatBC4_RUnorm":{
"filterable": "true"
},
"MTLPixelFormatBC4_RSnorm":{
"filterable": "true"
},
"MTLPixelFormatBC5_RGUnorm":{
"filterable": "true"
},
"MTLPixelFormatBC5_RGSnorm":{
"filterable": "true"
},
"MTLPixelFormatBC6H_RGBUfloat":{
"filterable": "true"
},
"MTLPixelFormatBC6H_RGBFloat":{
"filterable": "true"
},
"MTLPixelFormatBC7_RGBAUnorm":{
"filterable": "true"
},
"MTLPixelFormatBC7_RGBAUnorm_sRGB":{
"filterable": "true"
}
},
"caps_ios": {
......@@ -615,6 +661,60 @@
"multisample": "true",
"resolve": "true",
"colorRenderable": "true"
},
"MTLPixelFormatPVRTC_RGB_4BPP":{
"filterable": "true"
},
"MTLPixelFormatPVRTC_RGB_2BPP":{
"filterable": "true"
},
"MTLPixelFormatPVRTC_RGBA_4BPP":{
"filterable": "true"
},
"MTLPixelFormatPVRTC_RGBA_2BPP":{
"filterable": "true"
},
"MTLPixelFormatPVRTC_RGB_2BPP_sRGB":{
"filterable": "true"
},
"MTLPixelFormatPVRTC_RGB_4BPP_sRGB":{
"filterable": "true"
},
"MTLPixelFormatPVRTC_RGBA_2BPP_sRGB":{
"filterable": "true"
},
"MTLPixelFormatPVRTC_RGBA_4BPP_sRGB":{
"filterable": "true"
},
"MTLPixelFormatETC2_RGB8":{
"filterable": "true"
},
"MTLPixelFormatETC2_RGB8_sRGB":{
"filterable": "true"
},
"MTLPixelFormatETC2_RGB8A1":{
"filterable": "true"
},
"MTLPixelFormatETC2_RGB8A1_sRGB":{
"filterable": "true"
},
"MTLPixelFormatEAC_RGBA8":{
"filterable": "true"
},
"MTLPixelFormatEAC_RGBA8_sRGB":{
"filterable": "true"
},
"MTLPixelFormatEAC_R11Unorm":{
"filterable": "true"
},
"MTLPixelFormatEAC_R11Snorm":{
"filterable": "true"
},
"MTLPixelFormatEAC_RG11Unorm":{
"filterable": "true"
},
"MTLPixelFormatEAC_RG11Snorm":{
"filterable": "true"
}
}
},
......
......@@ -779,6 +779,42 @@ void Format::init(const DisplayMtl *display, angle::FormatID intendedFormatId_)
this->swizzled = false;
break;
case angle::FormatID::BPTC_RGBA_UNORM_BLOCK:
this->metalFormat = MTLPixelFormatBC7_RGBAUnorm;
this->actualFormatId = angle::FormatID::BPTC_RGBA_UNORM_BLOCK;
this->initFunction = nullptr;
this->swizzled = false;
break;
case angle::FormatID::BPTC_RGB_SIGNED_FLOAT_BLOCK:
this->metalFormat = MTLPixelFormatBC6H_RGBFloat;
this->actualFormatId = angle::FormatID::BPTC_RGB_SIGNED_FLOAT_BLOCK;
this->initFunction = nullptr;
this->swizzled = false;
break;
case angle::FormatID::BPTC_RGB_UNSIGNED_FLOAT_BLOCK:
this->metalFormat = MTLPixelFormatBC6H_RGBUfloat;
this->actualFormatId = angle::FormatID::BPTC_RGB_UNSIGNED_FLOAT_BLOCK;
this->initFunction = nullptr;
this->swizzled = false;
break;
case angle::FormatID::BPTC_SRGB_ALPHA_UNORM_BLOCK:
this->metalFormat = MTLPixelFormatBC7_RGBAUnorm_sRGB;
this->actualFormatId = angle::FormatID::BPTC_SRGB_ALPHA_UNORM_BLOCK;
this->initFunction = nullptr;
this->swizzled = false;
break;
case angle::FormatID::D16_UNORM:
this->metalFormat = MTLPixelFormatDepth16Unorm;
......@@ -2540,6 +2576,62 @@ void FormatTable::initNativeFormatCapsAutogen(const DisplayMtl *display)
/** colorRenderable*/ false, /** depthRenderable*/ true);
#if TARGET_OS_OSX || TARGET_OS_MACCATALYST
setFormatCaps(MTLPixelFormatBC1_RGBA, /** filterable*/ true, /** writable*/ false,
/** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
/** colorRenderable*/ false, /** depthRenderable*/ false);
setFormatCaps(MTLPixelFormatBC1_RGBA_sRGB, /** filterable*/ true, /** writable*/ false,
/** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
/** colorRenderable*/ false, /** depthRenderable*/ false);
setFormatCaps(MTLPixelFormatBC2_RGBA, /** filterable*/ true, /** writable*/ false,
/** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
/** colorRenderable*/ false, /** depthRenderable*/ false);
setFormatCaps(MTLPixelFormatBC2_RGBA_sRGB, /** filterable*/ true, /** writable*/ false,
/** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
/** colorRenderable*/ false, /** depthRenderable*/ false);
setFormatCaps(MTLPixelFormatBC3_RGBA, /** filterable*/ true, /** writable*/ false,
/** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
/** colorRenderable*/ false, /** depthRenderable*/ false);
setFormatCaps(MTLPixelFormatBC3_RGBA_sRGB, /** filterable*/ true, /** writable*/ false,
/** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
/** colorRenderable*/ false, /** depthRenderable*/ false);
setFormatCaps(MTLPixelFormatBC4_RSnorm, /** filterable*/ true, /** writable*/ false,
/** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
/** colorRenderable*/ false, /** depthRenderable*/ false);
setFormatCaps(MTLPixelFormatBC4_RUnorm, /** filterable*/ true, /** writable*/ false,
/** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
/** colorRenderable*/ false, /** depthRenderable*/ false);
setFormatCaps(MTLPixelFormatBC5_RGSnorm, /** filterable*/ true, /** writable*/ false,
/** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
/** colorRenderable*/ false, /** depthRenderable*/ false);
setFormatCaps(MTLPixelFormatBC5_RGUnorm, /** filterable*/ true, /** writable*/ false,
/** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
/** colorRenderable*/ false, /** depthRenderable*/ false);
setFormatCaps(MTLPixelFormatBC6H_RGBFloat, /** filterable*/ true, /** writable*/ false,
/** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
/** colorRenderable*/ false, /** depthRenderable*/ false);
setFormatCaps(MTLPixelFormatBC6H_RGBUfloat, /** filterable*/ true, /** writable*/ false,
/** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
/** colorRenderable*/ false, /** depthRenderable*/ false);
setFormatCaps(MTLPixelFormatBC7_RGBAUnorm, /** filterable*/ true, /** writable*/ false,
/** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
/** colorRenderable*/ false, /** depthRenderable*/ false);
setFormatCaps(MTLPixelFormatBC7_RGBAUnorm_sRGB, /** filterable*/ true, /** writable*/ false,
/** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
/** colorRenderable*/ false, /** depthRenderable*/ false);
setFormatCaps(MTLPixelFormatDepth16Unorm, /** filterable*/ true, /** writable*/ false,
/** blendable*/ false, /** multisample*/ true,
/** resolve*/ supportDepthAutoResolve, /** colorRenderable*/ false,
......@@ -2568,6 +2660,78 @@ void FormatTable::initNativeFormatCapsAutogen(const DisplayMtl *display)
/** blendable*/ true, /** multisample*/ true, /** resolve*/ true,
/** colorRenderable*/ true, /** depthRenderable*/ false);
setFormatCaps(MTLPixelFormatEAC_R11Snorm, /** filterable*/ true, /** writable*/ false,
/** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
/** colorRenderable*/ false, /** depthRenderable*/ false);
setFormatCaps(MTLPixelFormatEAC_R11Unorm, /** filterable*/ true, /** writable*/ false,
/** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
/** colorRenderable*/ false, /** depthRenderable*/ false);
setFormatCaps(MTLPixelFormatEAC_RG11Snorm, /** filterable*/ true, /** writable*/ false,
/** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
/** colorRenderable*/ false, /** depthRenderable*/ false);
setFormatCaps(MTLPixelFormatEAC_RG11Unorm, /** filterable*/ true, /** writable*/ false,
/** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
/** colorRenderable*/ false, /** depthRenderable*/ false);
setFormatCaps(MTLPixelFormatEAC_RGBA8, /** filterable*/ true, /** writable*/ false,
/** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
/** colorRenderable*/ false, /** depthRenderable*/ false);
setFormatCaps(MTLPixelFormatEAC_RGBA8_sRGB, /** filterable*/ true, /** writable*/ false,
/** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
/** colorRenderable*/ false, /** depthRenderable*/ false);
setFormatCaps(MTLPixelFormatETC2_RGB8, /** filterable*/ true, /** writable*/ false,
/** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
/** colorRenderable*/ false, /** depthRenderable*/ false);
setFormatCaps(MTLPixelFormatETC2_RGB8A1, /** filterable*/ true, /** writable*/ false,
/** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
/** colorRenderable*/ false, /** depthRenderable*/ false);
setFormatCaps(MTLPixelFormatETC2_RGB8A1_sRGB, /** filterable*/ true, /** writable*/ false,
/** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
/** colorRenderable*/ false, /** depthRenderable*/ false);
setFormatCaps(MTLPixelFormatETC2_RGB8_sRGB, /** filterable*/ true, /** writable*/ false,
/** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
/** colorRenderable*/ false, /** depthRenderable*/ false);
setFormatCaps(MTLPixelFormatPVRTC_RGBA_2BPP, /** filterable*/ true, /** writable*/ false,
/** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
/** colorRenderable*/ false, /** depthRenderable*/ false);
setFormatCaps(MTLPixelFormatPVRTC_RGBA_2BPP_sRGB, /** filterable*/ true, /** writable*/ false,
/** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
/** colorRenderable*/ false, /** depthRenderable*/ false);
setFormatCaps(MTLPixelFormatPVRTC_RGBA_4BPP, /** filterable*/ true, /** writable*/ false,
/** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
/** colorRenderable*/ false, /** depthRenderable*/ false);
setFormatCaps(MTLPixelFormatPVRTC_RGBA_4BPP_sRGB, /** filterable*/ true, /** writable*/ false,
/** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
/** colorRenderable*/ false, /** depthRenderable*/ false);
setFormatCaps(MTLPixelFormatPVRTC_RGB_2BPP, /** filterable*/ true, /** writable*/ false,
/** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
/** colorRenderable*/ false, /** depthRenderable*/ false);
setFormatCaps(MTLPixelFormatPVRTC_RGB_2BPP_sRGB, /** filterable*/ true, /** writable*/ false,
/** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
/** colorRenderable*/ false, /** depthRenderable*/ false);
setFormatCaps(MTLPixelFormatPVRTC_RGB_4BPP, /** filterable*/ true, /** writable*/ false,
/** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
/** colorRenderable*/ false, /** depthRenderable*/ false);
setFormatCaps(MTLPixelFormatPVRTC_RGB_4BPP_sRGB, /** filterable*/ true, /** writable*/ false,
/** blendable*/ false, /** multisample*/ false, /** resolve*/ false,
/** colorRenderable*/ false, /** depthRenderable*/ false);
#endif // TARGET_OS_OSX || TARGET_OS_MACCATALYST
}
......
......@@ -263,35 +263,6 @@ void FormatTable::setCompressedFormatCaps(MTLPixelFormat formatId, bool filterab
void FormatTable::initNativeFormatCaps(const DisplayMtl *display)
{
initNativeFormatCapsAutogen(display);
#if TARGET_OS_OSX || TARGET_OS_MACCATALYST
setCompressedFormatCaps(MTLPixelFormatBC1_RGBA, true);
setCompressedFormatCaps(MTLPixelFormatBC1_RGBA_sRGB, true);
setCompressedFormatCaps(MTLPixelFormatBC2_RGBA, true);
setCompressedFormatCaps(MTLPixelFormatBC2_RGBA_sRGB, true);
setCompressedFormatCaps(MTLPixelFormatBC3_RGBA, true);
setCompressedFormatCaps(MTLPixelFormatBC3_RGBA_sRGB, true);
#else
setCompressedFormatCaps(MTLPixelFormatPVRTC_RGB_2BPP, true);
setCompressedFormatCaps(MTLPixelFormatPVRTC_RGB_2BPP_sRGB, true);
setCompressedFormatCaps(MTLPixelFormatPVRTC_RGB_4BPP, true);
setCompressedFormatCaps(MTLPixelFormatPVRTC_RGB_4BPP_sRGB, true);
setCompressedFormatCaps(MTLPixelFormatPVRTC_RGBA_2BPP, true);
setCompressedFormatCaps(MTLPixelFormatPVRTC_RGBA_2BPP_sRGB, true);
setCompressedFormatCaps(MTLPixelFormatPVRTC_RGBA_4BPP, true);
setCompressedFormatCaps(MTLPixelFormatPVRTC_RGBA_4BPP_sRGB, true);
setCompressedFormatCaps(MTLPixelFormatEAC_R11Unorm, true);
setCompressedFormatCaps(MTLPixelFormatEAC_R11Snorm, true);
setCompressedFormatCaps(MTLPixelFormatEAC_RG11Unorm, true);
setCompressedFormatCaps(MTLPixelFormatEAC_RG11Snorm, true);
setCompressedFormatCaps(MTLPixelFormatEAC_RGBA8, true);
setCompressedFormatCaps(MTLPixelFormatEAC_RGBA8_sRGB, true);
setCompressedFormatCaps(MTLPixelFormatETC2_RGB8, true);
setCompressedFormatCaps(MTLPixelFormatETC2_RGB8_sRGB, true);
setCompressedFormatCaps(MTLPixelFormatETC2_RGB8A1, true);
setCompressedFormatCaps(MTLPixelFormatETC2_RGB8A1_sRGB, true);
#endif
// clang-format on
}
} // namespace mtl
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment