Skip to content
Permalink
Browse files
[Metal ANGLE] Select proper IOSurface backing format for WebGL enviro…
…nment

https://bugs.webkit.org/show_bug.cgi?id=224948
<rdar://76284889>

Depending on the architecture, WebCore expects different
IOSurface texture targets for the main buffer. When running catalyst on
Arm64 devices, Metal-ANGLE needs to select the TEXTURE_2D texture target for our
IOSurface/Pbuffer bind point, rather than TEXTURE_RECTANGLE.

	Reviewed by Dean Jackson.

Patch by Kyle Piddington <kpiddington@apple.com> on 2021-04-25

* src/libANGLE/renderer/metal/DisplayMtl.h:
* src/libANGLE/renderer/metal/DisplayMtl.mm:
(rx::needsEAGLOnMac):
(rx::DisplayMtl::EGLDrawingBufferTextureTarget):
(rx::DisplayMtl::generateConfigs):

Canonical link: https://commits.webkit.org/237003@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276567 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
kpiddington authored and webkit-commit-queue committed Apr 25, 2021
1 parent 1c7c7c3 commit 30283a35865c5b11d2b4c86a3c11cce8b83c998e
Showing 3 changed files with 44 additions and 5 deletions.
@@ -1,3 +1,22 @@
2021-04-25 Kyle Piddington <kpiddington@apple.com>

[Metal ANGLE] Select proper IOSurface backing format for WebGL environment
https://bugs.webkit.org/show_bug.cgi?id=224948
<rdar://76284889>

Depending on the architecture, WebCore expects different
IOSurface texture targets for the main buffer. When running catalyst on
Arm64 devices, Metal-ANGLE needs to select the TEXTURE_2D texture target for our
IOSurface/Pbuffer bind point, rather than TEXTURE_RECTANGLE.

Reviewed by Dean Jackson.

* src/libANGLE/renderer/metal/DisplayMtl.h:
* src/libANGLE/renderer/metal/DisplayMtl.mm:
(rx::needsEAGLOnMac):
(rx::DisplayMtl::EGLDrawingBufferTextureTarget):
(rx::DisplayMtl::generateConfigs):

2021-04-23 Truitt Savell <tsavell@apple.com>

Unreviewed, reverting r276190.
@@ -165,6 +165,7 @@ class DisplayMtl : public DisplayImpl
void initializeTextureCaps() const;
void initializeFeatures();
void initializeLimitations();
EGLenum EGLDrawingBufferTextureTarget();
id<MTLDevice> getMetalDeviceMatchingAttribute(const egl::AttributeMap &attribs);
angle::Result initializeShaderLibrary();

@@ -437,6 +437,29 @@ bool IsMetalDisplayAvailable()

void DisplayMtl::populateFeatureList(angle::FeatureList *features) {}

#if TARGET_OS_MACCATALYST
static bool needsEAGLOnMac()
{
#if defined(__arm64__) || defined(__aarch64__)
return true;
#else
return false;
#endif
}
#endif

EGLenum DisplayMtl::EGLDrawingBufferTextureTarget()
{
#if TARGET_OS_MACCATALYST
if (needsEAGLOnMac())
return EGL_TEXTURE_2D;
return EGL_TEXTURE_RECTANGLE_ANGLE;
#elif TARGET_OS_OSX
return EGL_TEXTURE_RECTANGLE_ANGLE;
#else
return EGL_TEXTURE_2D;
#endif
}
egl::ConfigSet DisplayMtl::generateConfigs()
{
// NOTE(hqle): generate more config permutations
@@ -460,11 +483,7 @@ bool IsMetalDisplayAvailable()
config.transparentType = EGL_NONE;

// Pbuffer
#if TARGET_OS_OSX || TARGET_OS_MACCATALYST
config.bindToTextureTarget = EGL_TEXTURE_RECTANGLE_ANGLE;
#else
config.bindToTextureTarget = EGL_TEXTURE_2D;
#endif
config.bindToTextureTarget = EGLDrawingBufferTextureTarget();
config.maxPBufferWidth = 4096;
config.maxPBufferHeight = 4096;
config.maxPBufferPixels = 4096 * 4096;

0 comments on commit 30283a3

Please sign in to comment.