Fix issues presenting MetalSurfaces

MetalSurfaceEXT and MacOSSurfaceMVK were inheriting incorrectly from
the base class MetalSurface, and were improperly initialized.
Additionally, none of the drawables were ever released, meaning there
were no re-used drawables. Add an @autoreleasepool around the drawable
retrival path, as per the spec: https://developer.apple.com/documentation/quartzcore/cametallayer?language=objc#3172024

Bug: chromium:1015454
Change-Id: Idd2f1842977a6f5dccecf31d152d454a44e9261c
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/37948
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Jonah Ryan-Davis <jonahr@google.com>
diff --git a/src/WSI/BUILD.gn b/src/WSI/BUILD.gn
index 17cf87b..a7233db 100644
--- a/src/WSI/BUILD.gn
+++ b/src/WSI/BUILD.gn
@@ -61,4 +61,6 @@
     "../../third_party/marl:Marl_headers",
     "../Vulkan:swiftshader_libvulkan_headers",
   ]
+
+  configs = [ "../Vulkan:swiftshader_libvulkan_private_config", ]
 }
diff --git a/src/WSI/MetalSurface.h b/src/WSI/MetalSurface.h
index 29972a4..a5fd708 100644
--- a/src/WSI/MetalSurface.h
+++ b/src/WSI/MetalSurface.h
@@ -28,7 +28,7 @@
 
 class MetalLayer;
 
-class MetalSurface : public SurfaceKHR, public ObjectBase<MetalSurface, VkSurfaceKHR> {
+class MetalSurface : public SurfaceKHR {
 public:
     MetalSurface(const void *pCreateInfo, void *mem);
 
@@ -47,13 +47,15 @@
 };
 
 #ifdef VK_USE_PLATFORM_METAL_EXT
-class MetalSurfaceEXT : public MetalSurface {
+class MetalSurfaceEXT : public MetalSurface, public ObjectBase<MetalSurfaceEXT, VkSurfaceKHR> {
+public:
     MetalSurfaceEXT(const VkMetalSurfaceCreateInfoEXT *pCreateInfo, void *mem);
 };
 #endif
 
 #ifdef VK_USE_PLATFORM_MACOS_MVK
-class MacOSSurfaceMVK : public MetalSurface {
+class MacOSSurfaceMVK : public MetalSurface, public ObjectBase<MacOSSurfaceMVK, VkSurfaceKHR> {
+public:
     MacOSSurfaceMVK(const VkMacOSSurfaceCreateInfoMVK *pCreateInfo, void *mem);
 };
 #endif
diff --git a/src/WSI/MetalSurface.mm b/src/WSI/MetalSurface.mm
index 29dfa67..1db25f3 100644
--- a/src/WSI/MetalSurface.mm
+++ b/src/WSI/MetalSurface.mm
@@ -139,15 +139,19 @@
 
 VkResult MetalSurface::present(PresentImage* image) API_AVAILABLE(macosx(10.11))
 {
-    auto drawable = metalLayer->getNextDrawable();
-    if(drawable)
+    @autoreleasepool
     {
-        VkExtent3D extent = image->getImage()->getMipLevelExtent(VK_IMAGE_ASPECT_COLOR_BIT, 0);
-        [drawable.texture replaceRegion:MTLRegionMake2D(0, 0, extent.width, extent.height)
-                          mipmapLevel:0
-                          withBytes:image->getImageMemory()->getOffsetPointer(0)
-                          bytesPerRow:image->getImage()->rowPitchBytes(VK_IMAGE_ASPECT_COLOR_BIT, 0)];
-        [drawable present];
+        auto drawable = metalLayer->getNextDrawable();
+        if(drawable)
+        {
+            VkExtent3D extent = image->getImage()->getMipLevelExtent(VK_IMAGE_ASPECT_COLOR_BIT, 0);
+            [drawable.texture replaceRegion:MTLRegionMake2D(0, 0, extent.width, extent.height)
+                              mipmapLevel:0
+                              withBytes:image->getImageMemory()->getOffsetPointer(0)
+                              bytesPerRow:image->getImage()->rowPitchBytes(VK_IMAGE_ASPECT_COLOR_BIT, 0)];
+            [drawable present];
+
+        }
     }
     return VK_SUCCESS;
 }