Skip to content

Commit 30283a3

Browse files
kpiddingtonwebkit-commit-queue
authored andcommitted
[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. 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
1 parent 1c7c7c3 commit 30283a3

File tree

3 files changed

+44
-5
lines changed

3 files changed

+44
-5
lines changed

Source/ThirdParty/ANGLE/ChangeLog

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
2021-04-25 Kyle Piddington <kpiddington@apple.com>
2+
3+
[Metal ANGLE] Select proper IOSurface backing format for WebGL environment
4+
https://bugs.webkit.org/show_bug.cgi?id=224948
5+
<rdar://76284889>
6+
7+
Depending on the architecture, WebCore expects different
8+
IOSurface texture targets for the main buffer. When running catalyst on
9+
Arm64 devices, Metal-ANGLE needs to select the TEXTURE_2D texture target for our
10+
IOSurface/Pbuffer bind point, rather than TEXTURE_RECTANGLE.
11+
12+
Reviewed by Dean Jackson.
13+
14+
* src/libANGLE/renderer/metal/DisplayMtl.h:
15+
* src/libANGLE/renderer/metal/DisplayMtl.mm:
16+
(rx::needsEAGLOnMac):
17+
(rx::DisplayMtl::EGLDrawingBufferTextureTarget):
18+
(rx::DisplayMtl::generateConfigs):
19+
120
2021-04-23 Truitt Savell <tsavell@apple.com>
221

322
Unreviewed, reverting r276190.

Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/DisplayMtl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ class DisplayMtl : public DisplayImpl
165165
void initializeTextureCaps() const;
166166
void initializeFeatures();
167167
void initializeLimitations();
168+
EGLenum EGLDrawingBufferTextureTarget();
168169
id<MTLDevice> getMetalDeviceMatchingAttribute(const egl::AttributeMap &attribs);
169170
angle::Result initializeShaderLibrary();
170171

Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/DisplayMtl.mm

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,29 @@ bool IsMetalDisplayAvailable()
437437

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

440+
#if TARGET_OS_MACCATALYST
441+
static bool needsEAGLOnMac()
442+
{
443+
#if defined(__arm64__) || defined(__aarch64__)
444+
return true;
445+
#else
446+
return false;
447+
#endif
448+
}
449+
#endif
450+
451+
EGLenum DisplayMtl::EGLDrawingBufferTextureTarget()
452+
{
453+
#if TARGET_OS_MACCATALYST
454+
if (needsEAGLOnMac())
455+
return EGL_TEXTURE_2D;
456+
return EGL_TEXTURE_RECTANGLE_ANGLE;
457+
#elif TARGET_OS_OSX
458+
return EGL_TEXTURE_RECTANGLE_ANGLE;
459+
#else
460+
return EGL_TEXTURE_2D;
461+
#endif
462+
}
440463
egl::ConfigSet DisplayMtl::generateConfigs()
441464
{
442465
// NOTE(hqle): generate more config permutations
@@ -460,11 +483,7 @@ bool IsMetalDisplayAvailable()
460483
config.transparentType = EGL_NONE;
461484

462485
// Pbuffer
463-
#if TARGET_OS_OSX || TARGET_OS_MACCATALYST
464-
config.bindToTextureTarget = EGL_TEXTURE_RECTANGLE_ANGLE;
465-
#else
466-
config.bindToTextureTarget = EGL_TEXTURE_2D;
467-
#endif
486+
config.bindToTextureTarget = EGLDrawingBufferTextureTarget();
468487
config.maxPBufferWidth = 4096;
469488
config.maxPBufferHeight = 4096;
470489
config.maxPBufferPixels = 4096 * 4096;

0 commit comments

Comments
 (0)