From 1acd4c7d256ea51cb6780f2cc8c745cdbeb5f755 Mon Sep 17 00:00:00 2001 From: Szymon Ulewicz Date: Tue, 2 Mar 2021 13:19:14 -0800 Subject: [PATCH 1/3] Use MetalANGLE wrapper classes. --- .gitmodules | 3 + platform/ios/ios.cmake | 4 +- .../platform/darwin/src/MGLOpenGLStyleLayer.h | 3 +- .../darwin/src/MGLOpenGLStyleLayer.mm | 2 +- .../ios/ios.xcodeproj/project.pbxproj | 21 ++++- .../ios.xcworkspace/contents.xcworkspacedata | 5 +- .../ios/platform/ios/src/MGLMapView+Impl.h | 3 +- .../ios/platform/ios/src/MGLMapView+OpenGL.h | 2 +- .../ios/platform/ios/src/MGLMapView+OpenGL.mm | 79 ++++--------------- platform/ios/platform/ios/src/MGLMapView.mm | 2 +- .../ios/platform/ios/src/MGLMapView_Private.h | 4 +- platform/ios/platform/ios/vendor/metalangle | 1 + src/mbgl/gl/context.cpp | 6 +- src/mbgl/gl/renderer_backend.cpp | 6 ++ 14 files changed, 60 insertions(+), 81 deletions(-) create mode 160000 platform/ios/platform/ios/vendor/metalangle diff --git a/.gitmodules b/.gitmodules index 8222d841661..553aebe738e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -49,3 +49,6 @@ [submodule "maplibre-gl-js"] path = maplibre-gl-js url = https://github.com/maplibre/maplibre-gl-js.git +[submodule "platform/ios/platform/ios/vendor/metalangle"] + path = platform/ios/platform/ios/vendor/metalangle + url = https://github.com/kakashidinho/metalangle.git diff --git a/platform/ios/ios.cmake b/platform/ios/ios.cmake index f16b2ed905c..95188b429c3 100644 --- a/platform/ios/ios.cmake +++ b/platform/ios/ios.cmake @@ -22,7 +22,7 @@ set_target_properties(mbgl-core PROPERTIES XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC if(MBGL_WITH_OPENGL) target_compile_definitions( mbgl-core - PUBLIC MBGL_USE_GLES2 GLES_SILENCE_DEPRECATION + PUBLIC MBGL_USE_GLES2 ) target_sources( mbgl-core @@ -32,7 +32,7 @@ if(MBGL_WITH_OPENGL) ) target_link_libraries( mbgl-core - PRIVATE "-framework GLKit" "-framework OpenGLES" + PRIVATE "-framework MetalANGLE" ) endif() diff --git a/platform/ios/platform/darwin/src/MGLOpenGLStyleLayer.h b/platform/ios/platform/darwin/src/MGLOpenGLStyleLayer.h index fd82a4a69dc..2e425df3008 100644 --- a/platform/ios/platform/darwin/src/MGLOpenGLStyleLayer.h +++ b/platform/ios/platform/darwin/src/MGLOpenGLStyleLayer.h @@ -11,6 +11,7 @@ NS_ASSUME_NONNULL_BEGIN @class MGLMapView; @class MGLStyle; +@class MGLContext; typedef struct MGLStyleLayerDrawingContext { CGSize size; @@ -30,7 +31,7 @@ MGL_EXPORT #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" #if TARGET_OS_IPHONE -@property (nonatomic, readonly) EAGLContext *context; +@property (nonatomic, readonly) MGLContext *context; #else @property (nonatomic, readonly) CGLContextObj context; #endif diff --git a/platform/ios/platform/darwin/src/MGLOpenGLStyleLayer.mm b/platform/ios/platform/darwin/src/MGLOpenGLStyleLayer.mm index 8502a3ff6dc..3016252e9d7 100644 --- a/platform/ios/platform/darwin/src/MGLOpenGLStyleLayer.mm +++ b/platform/ios/platform/darwin/src/MGLOpenGLStyleLayer.mm @@ -76,7 +76,7 @@ - (MGLMapView *)mapView { } #if TARGET_OS_IPHONE -- (EAGLContext *)context { +- (MGLContext *)context { return self.mapView.context; } #else diff --git a/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj index 5da4776e426..2f1f5eea9e4 100644 --- a/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj @@ -185,7 +185,6 @@ 35E79F201D41266300957B9E /* MGLStyleLayer_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 35E79F1F1D41266300957B9E /* MGLStyleLayer_Private.h */; }; 35E79F211D41266300957B9E /* MGLStyleLayer_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 35E79F1F1D41266300957B9E /* MGLStyleLayer_Private.h */; }; 3E6465D62065767A00685536 /* LimeGreenStyleLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 3E6465D42065767A00685536 /* LimeGreenStyleLayer.m */; }; - 3E8770612074297100B7E842 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 554180411D2E97DE00012372 /* OpenGLES.framework */; }; 3EA93369F61CF70AFA50465D /* MGLRendererConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = 3EA931BC4F087E166D538F21 /* MGLRendererConfiguration.m */; }; 3EA934623AD0000B7D99C3FB /* MGLRendererConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 3EA9337830C7738BF7F5493C /* MGLRendererConfiguration.h */; }; 3EA9363147E77DD29FA06063 /* MGLRendererConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 3EA9337830C7738BF7F5493C /* MGLRendererConfiguration.h */; }; @@ -370,6 +369,8 @@ A4DE3DCB23038C98005B3473 /* MGLMockGestureRecognizers.h in Sources */ = {isa = PBXBuildFile; fileRef = A4DE3DCA23038A7F005B3473 /* MGLMockGestureRecognizers.h */; }; A4DE3DCC23038CCA005B3473 /* MGLMockGestureRecognizers.m in Sources */ = {isa = PBXBuildFile; fileRef = A4DE3DC823038A07005B3473 /* MGLMockGestureRecognizers.m */; }; A4F3FB1D2254865900A30170 /* missing_icon.json in Resources */ = {isa = PBXBuildFile; fileRef = A4F3FB1C2254865900A30170 /* missing_icon.json */; }; + AC3302A425EEEDB0004890E9 /* MetalANGLE.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AC3302A325EEEDB0004890E9 /* MetalANGLE.framework */; }; + AC3302A525EEEDB0004890E9 /* MetalANGLE.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = AC3302A325EEEDB0004890E9 /* MetalANGLE.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; CA0B3C022329DE9A00E4B493 /* MGLTestAssertionHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = CAAA65D82321BBA900F08A39 /* MGLTestAssertionHandler.m */; }; CA0C27922076C804001CE5B7 /* MGLShapeSourceTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CA0C27912076C804001CE5B7 /* MGLShapeSourceTests.m */; }; CA0C27942076CA19001CE5B7 /* MGLMapViewIntegrationTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CA0C27932076CA19001CE5B7 /* MGLMapViewIntegrationTest.m */; }; @@ -428,7 +429,6 @@ DA1DC99F1CB6E088006E619F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DA1DC99E1CB6E088006E619F /* Assets.xcassets */; }; DA1F8F3D1EBD287B00367E42 /* MGLDocumentationGuideTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA1F8F3C1EBD287B00367E42 /* MGLDocumentationGuideTests.swift */; }; DA2784FC1DF02FF4001D5B8D /* Media.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DA2784FB1DF02FF4001D5B8D /* Media.xcassets */; }; - DA27C24E1CBB3811000B0ECD /* GLKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA27C24D1CBB3811000B0ECD /* GLKit.framework */; }; DA27C24F1CBB4C11000B0ECD /* MGLAccountManager_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = DA8847FF1CBAFA6200AB86E3 /* MGLAccountManager_Private.h */; }; DA2DBBCE1D51E80400D38FF9 /* MGLStyleLayerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DA2DBBCD1D51E80400D38FF9 /* MGLStyleLayerTests.m */; }; DA2E88611CC0382C00F24E7B /* MGLGeometryTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = DA2E885C1CC0382C00F24E7B /* MGLGeometryTests.mm */; }; @@ -706,6 +706,17 @@ /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ + AC3302A625EEEDB0004890E9 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + AC3302A525EEEDB0004890E9 /* MetalANGLE.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; CA0FA9E62379C39C00C9F3C9 /* Embed Frameworks */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; @@ -1011,6 +1022,7 @@ A4DE3DC823038A07005B3473 /* MGLMockGestureRecognizers.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLMockGestureRecognizers.m; sourceTree = ""; }; A4DE3DCA23038A7F005B3473 /* MGLMockGestureRecognizers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLMockGestureRecognizers.h; sourceTree = ""; }; A4F3FB1C2254865900A30170 /* missing_icon.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = missing_icon.json; sourceTree = ""; }; + AC3302A325EEEDB0004890E9 /* MetalANGLE.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = MetalANGLE.framework; sourceTree = BUILT_PRODUCTS_DIR; }; CA0C27912076C804001CE5B7 /* MGLShapeSourceTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLShapeSourceTests.m; sourceTree = ""; }; CA0C27932076CA19001CE5B7 /* MGLMapViewIntegrationTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLMapViewIntegrationTest.m; sourceTree = ""; wrapsLines = 0; }; CA0C27952076CA50001CE5B7 /* MGLMapViewIntegrationTest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLMapViewIntegrationTest.h; sourceTree = ""; }; @@ -1343,12 +1355,12 @@ files = ( DA0BDD202407C12600DAA576 /* libmbgl-core.a in Frameworks */, CAB369E5237471D600592F74 /* libz.tbd in Frameworks */, + AC3302A425EEEDB0004890E9 /* MetalANGLE.framework in Frameworks */, DA35D9CE240920AB0013ECB0 /* libmbgl-vendor-csscolorparser.a in Frameworks */, 358B3DBB2359EA0F007BEB26 /* libmbgl-vendor-icu.a in Frameworks */, DA35D9D1240920B60013ECB0 /* libmbgl-vendor-parsedate.a in Frameworks */, 358B3DB92359E4A0007BEB26 /* libsqlite3.tbd in Frameworks */, 96802766226556C5006BA4A1 /* libmbxaccounts.a in Frameworks */, - DA27C24E1CBB3811000B0ECD /* GLKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1370,7 +1382,6 @@ buildActionMask = 2147483647; files = ( DAA4E4081CBB6C9500178DFB /* Mapbox.framework in Frameworks */, - 3E8770612074297100B7E842 /* OpenGLES.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1772,6 +1783,7 @@ DA1DC9921CB6DF24006E619F /* Frameworks */ = { isa = PBXGroup; children = ( + AC3302A325EEEDB0004890E9 /* MetalANGLE.framework */, DA27C24D1CBB3811000B0ECD /* GLKit.framework */, DA4A26961CB6E795000B7809 /* Mapbox.framework */, 554180411D2E97DE00012372 /* OpenGLES.framework */, @@ -2568,6 +2580,7 @@ DA8847CE1CBAF91600AB86E3 /* Frameworks */, DA8847CF1CBAF91600AB86E3 /* Headers */, DA8847D01CBAF91600AB86E3 /* Resources */, + AC3302A625EEEDB0004890E9 /* Embed Frameworks */, ); buildRules = ( ); diff --git a/platform/ios/platform/ios/ios.xcworkspace/contents.xcworkspacedata b/platform/ios/platform/ios/ios.xcworkspace/contents.xcworkspacedata index f6c6295bad1..7bc2228fe4a 100644 --- a/platform/ios/platform/ios/ios.xcworkspace/contents.xcworkspacedata +++ b/platform/ios/platform/ios/ios.xcworkspace/contents.xcworkspacedata @@ -6,5 +6,8 @@ - + + + diff --git a/platform/ios/platform/ios/src/MGLMapView+Impl.h b/platform/ios/platform/ios/src/MGLMapView+Impl.h index 232215bd1b9..0361abc16f5 100644 --- a/platform/ios/platform/ios/src/MGLMapView+Impl.h +++ b/platform/ios/platform/ios/src/MGLMapView+Impl.h @@ -1,6 +1,7 @@ #import #import #import +#import #import #import @@ -18,7 +19,7 @@ class MGLMapViewImpl : public mbgl::MapObserver { virtual mbgl::gfx::RendererBackend& getRendererBackend() = 0; // Returns a handle to the OpenGL context object if this view is rendered with OpenGL. - virtual EAGLContext* getEAGLContext() { + virtual MGLContext* getEAGLContext() { return nullptr; } diff --git a/platform/ios/platform/ios/src/MGLMapView+OpenGL.h b/platform/ios/platform/ios/src/MGLMapView+OpenGL.h index b1c13724cbc..1e55a65534d 100644 --- a/platform/ios/platform/ios/src/MGLMapView+OpenGL.h +++ b/platform/ios/platform/ios/src/MGLMapView+OpenGL.h @@ -47,7 +47,7 @@ class MGLMapViewOpenGLImpl final : public MGLMapViewImpl, return *this; } - EAGLContext* getEAGLContext() override; + MGLContext* getEAGLContext() override; void setOpaque(bool) override; void display() override; void setPresentsWithTransaction(bool) override; diff --git a/platform/ios/platform/ios/src/MGLMapView+OpenGL.mm b/platform/ios/platform/ios/src/MGLMapView+OpenGL.mm index c96bfa9e87c..aa8b6fcb1a8 100644 --- a/platform/ios/platform/ios/src/MGLMapView+OpenGL.mm +++ b/platform/ios/platform/ios/src/MGLMapView+OpenGL.mm @@ -4,11 +4,7 @@ #include -#import -#import -#import - -@interface MGLMapViewImplDelegate : NSObject +@interface MGLMapViewImplDelegate : NSObject @end @implementation MGLMapViewImplDelegate { @@ -22,7 +18,7 @@ - (instancetype)initWithImpl:(MGLMapViewOpenGLImpl*)impl { return self; } -- (void)glkView:(nonnull GLKView*)view drawInRect:(CGRect)rect { +- (void)mglkView:(MGLKView *)view drawInRect:(CGRect)rect { _impl->render(); } @@ -60,8 +56,8 @@ void bind() override { public: MGLMapViewImplDelegate* delegate = nil; - GLKView *glView = nil; - EAGLContext *context = nil; + MGLKView *glView = nil; + MGLContext *context = nil; const bool atLeastiOS_12_2_0; // We count how often the context was activated/deactivated so that we can truly deactivate it @@ -77,8 +73,8 @@ void bind() override { MGLMapViewOpenGLImpl::~MGLMapViewOpenGLImpl() { auto& resource = getResource(); - if (resource.context && [[EAGLContext currentContext] isEqual:resource.context]) { - [EAGLContext setCurrentContext:nil]; + if (resource.context && [[MGLContext currentContext] isEqual:resource.context]) { + [MGLContext setCurrentContext:nil]; } } @@ -89,9 +85,7 @@ void bind() override { } void MGLMapViewOpenGLImpl::setPresentsWithTransaction(const bool value) { - auto& resource = getResource(); - CAEAGLLayer* eaglLayer = MGL_OBJC_DYNAMIC_CAST(resource.glView.layer, CAEAGLLayer); - eaglLayer.presentsWithTransaction = value; + // No-op on Metal. } void MGLMapViewOpenGLImpl::display() { @@ -124,22 +118,20 @@ void bind() override { } if (!resource.context) { - resource.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; + resource.context = [[MGLContext alloc] initWithAPI:kMGLRenderingAPIOpenGLES2]; assert(resource.context); } - resource.glView = [[GLKView alloc] initWithFrame:mapView.bounds context:resource.context]; + resource.glView = [[MGLKView alloc] initWithFrame:mapView.bounds context:resource.context]; resource.glView.delegate = resource.delegate; resource.glView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; resource.glView.contentScaleFactor = contentScaleFactor(); resource.glView.contentMode = UIViewContentModeCenter; - resource.glView.drawableStencilFormat = GLKViewDrawableStencilFormat8; - resource.glView.drawableDepthFormat = GLKViewDrawableDepthFormat16; + resource.glView.drawableStencilFormat = MGLDrawableStencilFormat8; + resource.glView.drawableDepthFormat = MGLDrawableDepthFormat16; resource.glView.opaque = mapView.opaque; resource.glView.layer.opaque = mapView.opaque; resource.glView.enableSetNeedsDisplay = NO; - CAEAGLLayer* eaglLayer = MGL_OBJC_DYNAMIC_CAST(resource.glView.layer, CAEAGLLayer); - eaglLayer.presentsWithTransaction = NO; [mapView insertSubview:resource.glView atIndex:0]; } @@ -150,49 +142,8 @@ void bind() override { } void MGLMapViewOpenGLImpl::deleteView() { - auto& resource = getResource(); - [resource.glView deleteDrawable]; -} - -#ifdef MGL_RECREATE_GL_IN_AN_EMERGENCY -// See https://github.com/mapbox/mapbox-gl-native/issues/14232 -void MGLMapViewOpenGLImpl::emergencyRecreateGL() { - auto& resource = getResource(); - MGLLogError(@"Rendering took too long - creating GL views"); - - CAEAGLLayer* eaglLayer = MGL_OBJC_DYNAMIC_CAST(resource.glView.layer, CAEAGLLayer); - eaglLayer.presentsWithTransaction = NO; - - [mapView pauseRendering:nil]; - - // Just performing a pauseRendering:/resumeRendering: pair isn't sufficient - in this case - // we can still get errors when calling bindDrawable. Here we completely - // recreate the GLKView - - [mapView.userLocationAnnotationView removeFromSuperview]; - [resource.glView removeFromSuperview]; - - // Recreate the view - resource.glView = nil; - createView(); - - if (mapView.annotationContainerView) { - [resource.glView insertSubview:mapView.annotationContainerView atIndex:0]; - } - - [mapView updateUserLocationAnnotationView]; - - // Do not bind...yet - - if (mapView.window) { - [mapView resumeRendering:nil]; - eaglLayer = MGL_OBJC_DYNAMIC_CAST(resource.glView.layer, CAEAGLLayer); - eaglLayer.presentsWithTransaction = mapView.enablePresentsWithTransaction; - } else { - MGLLogDebug(@"No window - skipping resumeRendering"); - } + // No-op on Metal } -#endif mbgl::gl::ProcAddress MGLMapViewOpenGLImpl::getExtensionFunctionPointer(const char* name) { static CFBundleRef framework = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengles")); @@ -210,7 +161,7 @@ void bind() override { return; } - [EAGLContext setCurrentContext:resource.context]; + [MGLContext setCurrentContext:resource.context]; } void MGLMapViewOpenGLImpl::deactivate() { @@ -219,7 +170,7 @@ void bind() override { return; } - [EAGLContext setCurrentContext:nil]; + [MGLContext setCurrentContext:nil]; } /// This function is called before we start rendering, when iOS invokes our rendering method. @@ -257,7 +208,7 @@ void bind() override { static_cast(mapView.bounds.size.height * scaleFactor) }; } -EAGLContext* MGLMapViewOpenGLImpl::getEAGLContext() { +MGLContext* MGLMapViewOpenGLImpl::getEAGLContext() { auto& resource = getResource(); return resource.context; } diff --git a/platform/ios/platform/ios/src/MGLMapView.mm b/platform/ios/platform/ios/src/MGLMapView.mm index c17ba1bec91..2c90a798b22 100644 --- a/platform/ios/platform/ios/src/MGLMapView.mm +++ b/platform/ios/platform/ios/src/MGLMapView.mm @@ -1504,7 +1504,7 @@ - (void)didBecomeActive:(NSNotification *)notification #pragma mark - GL / display link wake/sleep -- (EAGLContext *)context { +- (MGLContext *)context { return _mbglView->getEAGLContext(); } diff --git a/platform/ios/platform/ios/src/MGLMapView_Private.h b/platform/ios/platform/ios/src/MGLMapView_Private.h index bb34644f2ab..03f63a76812 100644 --- a/platform/ios/platform/ios/src/MGLMapView_Private.h +++ b/platform/ios/platform/ios/src/MGLMapView_Private.h @@ -1,6 +1,8 @@ #import "MGLMapView.h" #import "MGLUserLocationAnnotationView.h" #import "MGLAnnotationContainerView.h" +#import +#import #include @@ -24,7 +26,7 @@ FOUNDATION_EXTERN MGL_EXPORT MGLExceptionName const _Nonnull MGLUnderlyingMapUna @interface MGLMapView (Private) /// The map view’s OpenGL rendering context. -@property (nonatomic, readonly, nullable) EAGLContext *context; +@property (nonatomic, readonly, nullable) MGLContext *context; /// Currently shown popover representing the selected annotation. @property (nonatomic, nonnull) UIView *calloutViewForSelectedAnnotation; diff --git a/platform/ios/platform/ios/vendor/metalangle b/platform/ios/platform/ios/vendor/metalangle new file mode 160000 index 00000000000..cb39155cdb7 --- /dev/null +++ b/platform/ios/platform/ios/vendor/metalangle @@ -0,0 +1 @@ +Subproject commit cb39155cdb7b5258d503ac094008caa0959ba4bc diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp index 9c7898cc1df..62e4c97f6ba 100644 --- a/src/mbgl/gl/context.cpp +++ b/src/mbgl/gl/context.cpp @@ -219,10 +219,8 @@ UniqueTexture Context::createUniqueTexture() { } bool Context::supportsVertexArrays() const { - return vertexArray && - vertexArray->genVertexArrays && - vertexArray->bindVertexArray && - vertexArray->deleteVertexArrays; + // TODO: Metal: Metal does not work with vertex arrays. + return false; } VertexArray Context::createVertexArray() { diff --git a/src/mbgl/gl/renderer_backend.cpp b/src/mbgl/gl/renderer_backend.cpp index 1f52ce06a9b..a3da9d54e9b 100644 --- a/src/mbgl/gl/renderer_backend.cpp +++ b/src/mbgl/gl/renderer_backend.cpp @@ -33,6 +33,9 @@ void RendererBackend::assumeFramebufferBinding(const gl::FramebufferID fbo) { void RendererBackend::assumeViewport(int32_t x, int32_t y, const Size& size) { getContext().viewport.setCurrentValue({ x, y, size }); + if (gl::value::Viewport::Get() != getContext().viewport.getCurrentValue()) { + gl::value::Viewport::Set(getContext().viewport.getCurrentValue()); + } assert(gl::value::Viewport::Get() == getContext().viewport.getCurrentValue()); } @@ -54,6 +57,9 @@ void RendererBackend::setFramebufferBinding(const gl::FramebufferID fbo) { void RendererBackend::setViewport(int32_t x, int32_t y, const Size& size) { getContext().viewport = { x, y, size }; + if (gl::value::Viewport::Get() != getContext().viewport.getCurrentValue()) { + gl::value::Viewport::Set(getContext().viewport.getCurrentValue()); + } assert(gl::value::Viewport::Get() == getContext().viewport.getCurrentValue()); } From fb45d96725bf43424aff9b96cbab4807fc0a65df Mon Sep 17 00:00:00 2001 From: "RobLabs.com" Date: Tue, 9 Mar 2021 15:03:00 -0800 Subject: [PATCH 2/3] Only HostApp (`iosapp`) but no other frameworks should embed any dependent frameworks in their respective Build Phase --- .../ios/platform/ios/ios.xcodeproj/project.pbxproj | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj index 2f1f5eea9e4..1d419bfa030 100644 --- a/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj @@ -370,7 +370,6 @@ A4DE3DCC23038CCA005B3473 /* MGLMockGestureRecognizers.m in Sources */ = {isa = PBXBuildFile; fileRef = A4DE3DC823038A07005B3473 /* MGLMockGestureRecognizers.m */; }; A4F3FB1D2254865900A30170 /* missing_icon.json in Resources */ = {isa = PBXBuildFile; fileRef = A4F3FB1C2254865900A30170 /* missing_icon.json */; }; AC3302A425EEEDB0004890E9 /* MetalANGLE.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AC3302A325EEEDB0004890E9 /* MetalANGLE.framework */; }; - AC3302A525EEEDB0004890E9 /* MetalANGLE.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = AC3302A325EEEDB0004890E9 /* MetalANGLE.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; CA0B3C022329DE9A00E4B493 /* MGLTestAssertionHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = CAAA65D82321BBA900F08A39 /* MGLTestAssertionHandler.m */; }; CA0C27922076C804001CE5B7 /* MGLShapeSourceTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CA0C27912076C804001CE5B7 /* MGLShapeSourceTests.m */; }; CA0C27942076CA19001CE5B7 /* MGLMapViewIntegrationTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CA0C27932076CA19001CE5B7 /* MGLMapViewIntegrationTest.m */; }; @@ -706,17 +705,6 @@ /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ - AC3302A625EEEDB0004890E9 /* Embed Frameworks */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = ""; - dstSubfolderSpec = 10; - files = ( - AC3302A525EEEDB0004890E9 /* MetalANGLE.framework in Embed Frameworks */, - ); - name = "Embed Frameworks"; - runOnlyForDeploymentPostprocessing = 0; - }; CA0FA9E62379C39C00C9F3C9 /* Embed Frameworks */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; @@ -2580,7 +2568,6 @@ DA8847CE1CBAF91600AB86E3 /* Frameworks */, DA8847CF1CBAF91600AB86E3 /* Headers */, DA8847D01CBAF91600AB86E3 /* Resources */, - AC3302A625EEEDB0004890E9 /* Embed Frameworks */, ); buildRules = ( ); From 27e342c08f89da684a7da3da98e33e83eb1e806a Mon Sep 17 00:00:00 2001 From: "RobLabs.com" Date: Tue, 9 Mar 2021 17:26:02 -0800 Subject: [PATCH 3/3] Add to your ios app, the MetalANGLE.framework from 'MetalANGLE' target --- platform/ios/platform/ios/ios.xcodeproj/project.pbxproj | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj index 1d419bfa030..9fcd4e0a972 100644 --- a/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj @@ -406,6 +406,8 @@ CAFB3C15234505D500399265 /* MGLMapSnapshotter_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = CAFB3C13234505D500399265 /* MGLMapSnapshotter_Private.h */; }; CF75A91522D85E860058A5C4 /* MGLLoggingConfiguration.mm in Sources */ = {isa = PBXBuildFile; fileRef = CF75A91422D85E860058A5C4 /* MGLLoggingConfiguration.mm */; }; CF75A91622D85E860058A5C4 /* MGLLoggingConfiguration.mm in Sources */ = {isa = PBXBuildFile; fileRef = CF75A91422D85E860058A5C4 /* MGLLoggingConfiguration.mm */; }; + D77F9D3D25F856CE00292F45 /* MetalANGLE.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D77F9D3C25F856CE00292F45 /* MetalANGLE.framework */; }; + D77F9D3E25F856CE00292F45 /* MetalANGLE.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D77F9D3C25F856CE00292F45 /* MetalANGLE.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; DA00FC8E1D5EEB0D009AABC8 /* MGLAttributionInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = DA00FC8C1D5EEB0D009AABC8 /* MGLAttributionInfo.h */; settings = {ATTRIBUTES = (Public, ); }; }; DA00FC8F1D5EEB0D009AABC8 /* MGLAttributionInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = DA00FC8C1D5EEB0D009AABC8 /* MGLAttributionInfo.h */; settings = {ATTRIBUTES = (Public, ); }; }; DA00FC901D5EEB0D009AABC8 /* MGLAttributionInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = DA00FC8D1D5EEB0D009AABC8 /* MGLAttributionInfo.mm */; }; @@ -711,6 +713,7 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( + D77F9D3E25F856CE00292F45 /* MetalANGLE.framework in Embed Frameworks */, CA94E5FC237D21030037AEA0 /* Mapbox.framework in Embed Frameworks */, ); name = "Embed Frameworks"; @@ -1038,6 +1041,7 @@ CAE7AD5420F46EF5003B6782 /* MGLMapSnapshotterSwiftTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MGLMapSnapshotterSwiftTests.swift; sourceTree = ""; }; CAFB3C13234505D500399265 /* MGLMapSnapshotter_Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLMapSnapshotter_Private.h; sourceTree = ""; }; CF75A91422D85E860058A5C4 /* MGLLoggingConfiguration.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLLoggingConfiguration.mm; sourceTree = ""; }; + D77F9D3C25F856CE00292F45 /* MetalANGLE.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = MetalANGLE.framework; sourceTree = BUILT_PRODUCTS_DIR; }; DA00FC8C1D5EEB0D009AABC8 /* MGLAttributionInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLAttributionInfo.h; sourceTree = ""; }; DA00FC8D1D5EEB0D009AABC8 /* MGLAttributionInfo.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLAttributionInfo.mm; sourceTree = ""; }; DA0CD58F1CF56F6A00A5F5A5 /* MGLFeatureTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLFeatureTests.mm; path = ../../darwin/test/MGLFeatureTests.mm; sourceTree = ""; }; @@ -1321,6 +1325,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + D77F9D3D25F856CE00292F45 /* MetalANGLE.framework in Frameworks */, CA94E5FB237D21030037AEA0 /* Mapbox.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1771,6 +1776,7 @@ DA1DC9921CB6DF24006E619F /* Frameworks */ = { isa = PBXGroup; children = ( + D77F9D3C25F856CE00292F45 /* MetalANGLE.framework */, AC3302A325EEEDB0004890E9 /* MetalANGLE.framework */, DA27C24D1CBB3811000B0ECD /* GLKit.framework */, DA4A26961CB6E795000B7809 /* Mapbox.framework */,