Commit c2f1f618 by Le Quyen Committed by Commit Bot

Always use MTLPixelFormatBGRA8Unorm for SurfaceMtl.

Apple Features Table says BGRA8 is not always available but it turned out not the case based on response from Apple dev. Bug: angleproject:2634 Change-Id: I9e3465420f45fcd362cbdd385bb78169463a759d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1906606 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com>
parent 60a396a8
...@@ -31,7 +31,6 @@ namespace rx ...@@ -31,7 +31,6 @@ namespace rx
namespace namespace
{ {
constexpr angle::FormatID kDefaultFrameBufferColorFormatId = angle::FormatID::B8G8R8A8_UNORM;
constexpr angle::FormatID kDefaultFrameBufferDepthFormatId = angle::FormatID::D32_FLOAT; constexpr angle::FormatID kDefaultFrameBufferDepthFormatId = angle::FormatID::D32_FLOAT;
constexpr angle::FormatID kDefaultFrameBufferStencilFormatId = angle::FormatID::S8_UINT; constexpr angle::FormatID kDefaultFrameBufferStencilFormatId = angle::FormatID::S8_UINT;
constexpr angle::FormatID kDefaultFrameBufferDepthStencilFormatId = constexpr angle::FormatID kDefaultFrameBufferDepthStencilFormatId =
...@@ -177,7 +176,14 @@ SurfaceMtl::SurfaceMtl(DisplayMtl *display, ...@@ -177,7 +176,14 @@ SurfaceMtl::SurfaceMtl(DisplayMtl *display,
: SurfaceImpl(state), mLayer((__bridge CALayer *)(window)) : SurfaceImpl(state), mLayer((__bridge CALayer *)(window))
{ {
// NOTE(hqle): Width and height attributes is ignored for now. // NOTE(hqle): Width and height attributes is ignored for now.
mColorFormat = display->getPixelFormat(kDefaultFrameBufferColorFormatId);
// https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf says that BGRA8Unorm is
// only supported if depth24Stencil8PixelFormatSupported capabilitiy is YES. Yet
// CAMetalLayer can be created with pixelFormat MTLPixelFormatBGRA8Unorm. So the mtl::Format
// used for SurfaceMtl is initialized a bit differently from normal TextureMtl's mtl::Format.
// It won't use format table, instead we initialize its values here to use BGRA8Unorm directly:
mColorFormat.intendedFormatId = mColorFormat.actualFormatId = angle::FormatID::B8G8R8A8_UNORM;
mColorFormat.metalFormat = MTLPixelFormatBGRA8Unorm;
int depthBits = 0; int depthBits = 0;
int stencilBits = 0; int stencilBits = 0;
......
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