Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix iOS Simulator performance with Metal #3156

Merged
merged 7 commits into from
Feb 17, 2025
Merged

Conversation

taublast
Copy link
Contributor

@taublast taublast commented Feb 6, 2025

This comes from a new synced branch.

Had iOS simulator lagging on M1 at 9 fps with SKGLView, so had to adjust its platform-related code for iOS to unlock 60 fps.
Just followed Apple guidelines for simulator: https://developer.apple.com/documentation/metal/developing-metal-apps-that-run-in-simulator?language=objc

replacing SampleCount = 1; (no MSAA) inside SKMetalView with:

			if (DeviceInfo.Current.DeviceType == DeviceType.Virtual)
			{
				DepthStencilStorageMode = MTLStorageMode.Private;
				SampleCount = 4;
			}
			else
			{
				DepthStencilStorageMode = MTLStorageMode.Shared;
				SampleCount = 2;
			}

Works fine in DrawnUi now, wanted to share.

@taublast taublast closed this Feb 6, 2025
@taublast taublast deleted the synched branch February 6, 2025 07:12
@taublast taublast restored the synched branch February 6, 2025 07:13
@taublast taublast reopened this Feb 6, 2025
@mattleibow
Copy link
Contributor

/rebase

@mattleibow
Copy link
Contributor

/azp run

Copy link

Azure Pipelines could not run because the pipeline triggers exclude this branch/path.

Copy link
Contributor

@mattleibow mattleibow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR and catching this special case!

The DeviceInfo type is a .NET MAUI Essentials type and can't be used here, but we can copy the implementation:

bool IsSimulator =>
#if __MACCATALYST__ || __MACOS__
    false;
#else
    ObjCRuntime.Runtime.Arch == Arch.SIMULATOR;
#endif

And then use this as part of the if.

Copy link
Contributor Author

@taublast taublast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Catalyst has same settings as iOS here, MacOS+Simulator have them different

@taublast taublast requested a review from mattleibow February 12, 2025 15:03
@taublast taublast requested a review from mattleibow February 12, 2025 15:24
Copy link
Contributor Author

@taublast taublast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yay lets go

@mattleibow mattleibow merged commit c2a1fde into mono:main Feb 17, 2025
1 check passed
@taublast taublast deleted the synched branch February 17, 2025 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants