Skip to content

Commit c2a1fde

Browse files
taublastmattleibow
andauthored
Fix iOS Simulator performance with Metal (#3156)
* Fix iOS Simulator performance with Metal * Cross-platform build fix * make DepthStencilModePrivate readonly * rebase field from outer space * Fix indentation and formatting in SKMetalView.cs * Fix ObjCRuntime.Arch comparison in SKMetalView --------- Co-authored-by: Matthew Leibowitz <[email protected]>
1 parent 2245753 commit c2a1fde

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

source/SkiaSharp.Views/SkiaSharp.Views/Platform/Apple/SKMetalView.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ event EventHandler IComponent.Disposed
3232

3333
private bool designMode;
3434

35+
private bool DepthStencilModePrivate =>
36+
#if __MACCATALYST__
37+
false;
38+
#elif __MACOS__
39+
true;
40+
#else
41+
ObjCRuntime.Runtime.Arch == ObjCRuntime.Arch.SIMULATOR;
42+
#endif
43+
3544
private GRMtlBackendContext backendContext;
3645
private GRContext context;
3746

@@ -84,7 +93,16 @@ private void Initialize()
8493

8594
ColorPixelFormat = MTLPixelFormat.BGRA8Unorm;
8695
DepthStencilPixelFormat = MTLPixelFormat.Depth32Float_Stencil8;
87-
SampleCount = 1;
96+
if (DepthStencilModePrivate)
97+
{
98+
DepthStencilStorageMode = MTLStorageMode.Private;
99+
SampleCount = 4;
100+
}
101+
else
102+
{
103+
DepthStencilStorageMode = MTLStorageMode.Shared;
104+
SampleCount = 2;
105+
}
88106
FramebufferOnly = false;
89107
Device = device;
90108
backendContext = new GRMtlBackendContext

0 commit comments

Comments
 (0)