Skip to content

Commit

Permalink
[msbuild] Add support for Metal in the simulator. Fixes #7392. (#7983) (
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfbjarne authored Feb 27, 2020
1 parent 514991e commit aa94c5f
Show file tree
Hide file tree
Showing 36 changed files with 1,332 additions and 14 deletions.
1 change: 1 addition & 0 deletions msbuild/Xamarin.Mac.Tasks/Xamarin.Mac.Common.targets
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ Copyright (C) 2014 Xamarin. All rights reserved.
TargetFrameworkIdentifier="$(TargetFrameworkIdentifier)"
ResourcePrefix="$(XamMacResourcePrefix)"
SdkDevPath="$(_SdkDevPath)"
SdkIsSimulator="false"
SdkRoot="$(_SdkRoot)"
SdkVersion="$(MacOSXSdkVersion)"
SourceFile="@(Metal)">
Expand Down
9 changes: 6 additions & 3 deletions msbuild/Xamarin.MacDev.Tasks.Core/Tasks/MetalTaskBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public abstract class MetalTaskBase : ToolTask
[Required]
public string SdkVersion { get; set; }

[Required]
public bool SdkIsSimulator { get; set; }

[Required]
public string SdkRoot { get; set; }

Expand All @@ -55,13 +58,13 @@ protected virtual string OperatingSystem {
get {
switch (PlatformFrameworkHelper.GetFramework (TargetFrameworkIdentifier)) {
case PlatformFramework.WatchOS:
return "watchos";
return SdkIsSimulator ? "watchos-simulator" : "watchos";
case PlatformFramework.TVOS:
return "tvos";
return SdkIsSimulator ? "tvos-simulator" : "tvos";
case PlatformFramework.MacOS:
return "macosx";
case PlatformFramework.iOS:
return "ios";
return SdkIsSimulator ? "iphonesimulator" : "ios";
default:
Log.LogError ($"Unknown target framework identifier: {TargetFrameworkIdentifier}.");
return string.Empty;
Expand Down
3 changes: 1 addition & 2 deletions msbuild/Xamarin.iOS.Tasks.Core/Xamarin.iOS.Common.targets
Original file line number Diff line number Diff line change
Expand Up @@ -595,8 +595,6 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.
</Target>

<Target Name="_SmeltMetal" Condition="'$(_CanOutputAppBundle)' == 'true' And '@(Metal)' != ''" DependsOnTargets="_DetectSdkLocations">
<Error Condition="'$(ComputedPlatform)' == 'iPhoneSimulator'" Text="The iOS Simulator does not support metal. Build for a device instead."/>

<Metal
SessionId="$(BuildSessionId)"
Condition="'$(IsMacEnabled)' == 'true' and '%(Metal.Identity)' != ''"
Expand All @@ -606,6 +604,7 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.
TargetFrameworkIdentifier="$(TargetFrameworkIdentifier)"
ResourcePrefix="$(IPhoneResourcePrefix)"
SdkDevPath="$(_SdkDevPath)"
SdkIsSimulator="$(_SdkIsSimulator)"
SdkRoot="$(_SdkRoot)"
SdkVersion="$(MtouchSdkVersion)"
SourceFile="@(Metal)">
Expand Down
2 changes: 2 additions & 0 deletions msbuild/tests/MyMetalGame/GameViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ void SetupRenderPassDescriptorForTexture (IMTLTexture texture)
// If we need a depth texture and don't have one, or if the depth texture we have is the wrong size
// Then allocate one of the proper size
MTLTextureDescriptor desc = MTLTextureDescriptor.CreateTexture2DDescriptor (MTLPixelFormat.Depth32Float, texture.Width, texture.Height, false);
if (ObjCRuntime.Runtime.Arch == ObjCRuntime.Arch.SIMULATOR)
desc.StorageMode = MTLStorageMode.Private;
depthTex = device.CreateTexture (desc);
depthTex.Label = "Depth";

Expand Down
23 changes: 23 additions & 0 deletions msbuild/tests/MyMetalGame/MyMetalGame.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyMetalGame", "MyMetalGame.csproj", "{4598E620-3F15-4F66-B01A-B7F9E45CE659}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|iPhoneSimulator = Debug|iPhoneSimulator
Release|iPhoneSimulator = Release|iPhoneSimulator
Debug|iPhone = Debug|iPhone
Release|iPhone = Release|iPhone
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4598E620-3F15-4F66-B01A-B7F9E45CE659}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
{4598E620-3F15-4F66-B01A-B7F9E45CE659}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
{4598E620-3F15-4F66-B01A-B7F9E45CE659}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
{4598E620-3F15-4F66-B01A-B7F9E45CE659}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
{4598E620-3F15-4F66-B01A-B7F9E45CE659}.Debug|iPhone.ActiveCfg = Debug|iPhone
{4598E620-3F15-4F66-B01A-B7F9E45CE659}.Debug|iPhone.Build.0 = Debug|iPhone
{4598E620-3F15-4F66-B01A-B7F9E45CE659}.Release|iPhone.ActiveCfg = Release|iPhone
{4598E620-3F15-4F66-B01A-B7F9E45CE659}.Release|iPhone.Build.0 = Release|iPhone
EndGlobalSection
EndGlobal
56 changes: 56 additions & 0 deletions msbuild/tests/MyTVMetalGame/AppDelegate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using Foundation;
using UIKit;

namespace MyTVMetalGame {
// The UIApplicationDelegate for the application. This class is responsible for launching the
// User Interface of the application, as well as listening (and optionally responding) to application events from iOS.
[Register ("AppDelegate")]
public class AppDelegate : UIApplicationDelegate {
// class-level declarations

public override UIWindow Window {
get;
set;
}

public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
{
// Override point for customization after application launch.
// If not required for your application you can safely delete this method

return true;
}

public override void OnResignActivation (UIApplication application)
{
// Invoked when the application is about to move from active to inactive state.
// This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message)
// or when the user quits the application and it begins the transition to the background state.
// Games should use this method to pause the game.
}

public override void DidEnterBackground (UIApplication application)
{
// Use this method to release shared resources, save user data, invalidate timers and store the application state.
// If your application supports background exection this method is called instead of WillTerminate when the user quits.
}

public override void WillEnterForeground (UIApplication application)
{
// Called as part of the transiton from background to active state.
// Here you can undo many of the changes made on entering the background.
}

public override void OnActivated (UIApplication application)
{
// Restart any tasks that were paused (or not yet started) while the application was inactive.
// If the application was previously in the background, optionally refresh the user interface.
}

public override void WillTerminate (UIApplication application)
{
// Called when the application is about to terminate. Save data, if needed. See also DidEnterBackground.
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"images": [
{
"idiom": "universal"
},
{
"scale": "1x",
"idiom": "universal"
},
{
"scale": "2x",
"idiom": "universal"
},
{
"scale": "3x",
"idiom": "universal"
},
{
"idiom": "iphone"
},
{
"scale": "1x",
"idiom": "iphone"
},
{
"scale": "2x",
"idiom": "iphone"
},
{
"subtype": "retina4",
"scale": "2x",
"idiom": "iphone"
},
{
"scale": "3x",
"idiom": "iphone"
},
{
"idiom": "ipad"
},
{
"scale": "1x",
"idiom": "ipad"
},
{
"scale": "2x",
"idiom": "ipad"
}
],
"info": {
"version": 1,
"author": "xcode"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"layers" : [
{
"filename" : "Front.imagestacklayer"
},
{
"filename" : "Middle.imagestacklayer"
},
{
"filename" : "Back.imagestacklayer"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"images": [
{
"idiom": "universal"
},
{
"scale": "1x",
"idiom": "universal"
},
{
"scale": "2x",
"idiom": "universal"
},
{
"scale": "3x",
"idiom": "universal"
},
{
"idiom": "iphone"
},
{
"scale": "1x",
"idiom": "iphone"
},
{
"scale": "2x",
"idiom": "iphone"
},
{
"subtype": "retina4",
"scale": "2x",
"idiom": "iphone"
},
{
"scale": "3x",
"idiom": "iphone"
},
{
"idiom": "ipad"
},
{
"scale": "1x",
"idiom": "ipad"
},
{
"scale": "2x",
"idiom": "ipad"
}
],
"info": {
"version": 1,
"author": "xcode"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"images": [
{
"idiom": "universal"
},
{
"scale": "1x",
"idiom": "universal"
},
{
"scale": "2x",
"idiom": "universal"
},
{
"scale": "3x",
"idiom": "universal"
},
{
"idiom": "iphone"
},
{
"scale": "1x",
"idiom": "iphone"
},
{
"scale": "2x",
"idiom": "iphone"
},
{
"subtype": "retina4",
"scale": "2x",
"idiom": "iphone"
},
{
"scale": "3x",
"idiom": "iphone"
},
{
"idiom": "ipad"
},
{
"scale": "1x",
"idiom": "ipad"
},
{
"scale": "2x",
"idiom": "ipad"
}
],
"info": {
"version": 1,
"author": "xcode"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading

11 comments on commit aa94c5f

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

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

Build was (probably) aborted

🔥 Jenkins job (on internal Jenkins) failed in stage(s) 'Install Provisioning Profiles' 🔥 : org.jenkinsci.plugins.workflow.steps.FlowInterruptedException

Build succeeded
✅ Packages:

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

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

🚧 Experimental DDFun pipeline

🔥 Device tests completed (Failed) on iOS-DDFun on Azure DevOps(iOS-DDFun) 🔥

Test results

11 tests failed, 139 tests passed.

Failed tests

  • [NUnit] Mono BCL tests group 2/iOS Unified 64-bits - device/Debug: Failed
  • monotouch-test/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug): TimedOut
  • monotouch-test/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug, profiling): TimedOut
  • monotouch-test/iOS Unified 64-bits - device/Debug (interpreter): TimedOut
  • monotouch-test/iOS Unified 64-bits - device/Debug (interpreter -mscorlib): TimedOut
  • [NUnit] Mono BCL tests group 2/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug): Failed
  • [NUnit] Mono BCL tests group 2/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug): Failed
  • [NUnit] Mono BCL tests group 2/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug, profiling): Failed
  • [NUnit] Mono BCL tests group 2/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug, profiling): Failed
  • [NUnit] Mono BCL tests group 2/iOS Unified 64-bits - device/Release: Failed
  • [NUnit] Mono BCL tests group 2/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (release): Failed

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

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

✅ Device tests passed on iOS on Azure DevOps(iOS): Html Report

🎉 All 150 tests passed 🎉

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

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

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

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

🚧 Experimental DDFun pipeline

🔥 Device tests completed (Failed) on iOS-DDFun on Azure DevOps(iOS-DDFun) 🔥

Test results

15 tests failed, 135 tests passed.

Failed tests

  • monotouch-test/iOS Unified 64-bits - device/Debug: Failed
  • monotouch-test/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug): Failed
  • monotouch-test/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug): Failed
  • monotouch-test/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug, profiling): Failed
  • monotouch-test/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug, profiling): Failed
  • monotouch-test/iOS Unified 64-bits - device/Release: Failed
  • monotouch-test/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (release): Failed
  • monotouch-test/iOS Unified 64-bits - device/Debug (dynamic registrar): Failed
  • monotouch-test/iOS Unified 64-bits - device/Release (all optimizations): Failed
  • monotouch-test/iOS Unified 64-bits - device/Debug (all optimizations): Failed
  • monotouch-test/iOS Unified 64-bits - device/Debug: SGenConc: Failed
  • monotouch-test/iOS Unified 64-bits - device/Debug (interpreter): Failed
  • monotouch-test/iOS Unified 64-bits - device/Debug (interpreter -mscorlib): Failed
  • monotouch-test/iOS Unified 64-bits - device/Release (interpreter -mscorlib): Failed
  • [NUnit] Mono BCL tests group 2/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug): Failed

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

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

🔥 Device tests completed (Failed) on iOS on Azure DevOps(iOS): Html Report 🔥

Test results

7 tests failed, 143 tests passed.

Failed tests

  • [NUnit] Mono BCL tests group 2/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug): Failed
  • [NUnit] Mono BCL tests group 2/iOS Unified 64-bits - device/Release: Failed
  • mscorlib Part 3/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug): Failed
  • mscorlib Part 3/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug, profiling): Failed
  • mscorlib Part 3/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug, profiling): Failed
  • mscorlib Part 3/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (release): Failed
  • mscorlib Part 3/iOS Unified 64-bits - device/Debug: SGenConc: Failed

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

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

🔥 Device tests completed (Failed) on TvOS on Azure DevOps(TvOS): Html Report 🔥

Test results

14 tests failed, 136 tests passed.

Failed tests

  • monotouch-test/tvOS - device/Debug: TimedOut
  • monotouch-test/tvOS - device/AssemblyBuildTarget: dylib (debug): TimedOut
  • monotouch-test/tvOS - device/AssemblyBuildTarget: SDK framework (debug): TimedOut
  • monotouch-test/tvOS - device/AssemblyBuildTarget: dylib (debug, profiling): TimedOut
  • monotouch-test/tvOS - device/AssemblyBuildTarget: SDK framework (debug, profiling): TimedOut
  • monotouch-test/tvOS - device/Release: TimedOut
  • monotouch-test/tvOS - device/AssemblyBuildTarget: SDK framework (release): TimedOut
  • monotouch-test/tvOS - device/Debug (dynamic registrar): TimedOut
  • monotouch-test/tvOS - device/Release (all optimizations): TimedOut
  • monotouch-test/tvOS - device/Debug (all optimizations): TimedOut
  • monotouch-test/tvOS - device/Debug: SGenConc: TimedOut
  • monotouch-test/tvOS - device/Debug (interpreter): TimedOut
  • monotouch-test/tvOS - device/Debug (interpreter -mscorlib): TimedOut
  • monotouch-test/tvOS - device/Release (interpreter -mscorlib): TimedOut

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

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

🔥 Device tests completed (Failed) on TvOS on Azure DevOps(TvOS): Html Report 🔥

Test results

# Test run in progress: Building: 1, BuildQueued: 1, Running: 1, Succeeded: 145, Ignored: 1111, TimedOut: 2

Failed tests

  • [xUnit] Mono BCL tests group 4/tvOS - device/AssemblyBuildTarget: dylib (debug, profiling): TimedOut
  • mscorlib Part 3/tvOS - device/Debug: SGenConc: TimedOut

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

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

🔥 Device tests completed (Failed) on iOS32b on Azure DevOps(iOS32b): Html Report 🔥

Test results

# Test run in progress: Running: 1, RunQueued: 2, Succeeded: 138, Failed: 14, Ignored: 1100, Crashed: 1, TimedOut: 2, BuildFailure: 3

Failed tests

  • [xUnit] Mono BCL tests group 4/iOS Unified 32-bits - device/Debug: Failed
  • mscorlib Part 2/iOS Unified 32-bits - device/Debug: Failed
  • dont link/iOS Unified 32-bits - device/AssemblyBuildTarget: SDK framework (release): Crashed
  • [NUnit] Mono BCL tests group 2/iOS Unified 32-bits - device/Release: UseThumb: TimedOut
  • [xUnit] Mono BCL tests group 4/iOS Unified 32-bits - device/AssemblyBuildTarget: dylib (debug): Failed
  • [xUnit] Mono BCL tests group 4/iOS Unified 32-bits - device/AssemblyBuildTarget: SDK framework (debug): Failed
  • [xUnit] Mono BCL tests group 4/iOS Unified 32-bits - device/AssemblyBuildTarget: dylib (debug, profiling): Failed
  • [xUnit] Mono BCL tests group 4/iOS Unified 32-bits - device/AssemblyBuildTarget: SDK framework (debug, profiling): Failed
  • mscorlib Part 1/iOS Unified 32-bits - device/AssemblyBuildTarget: dylib (debug, profiling): TimedOut
  • mscorlib Part 1/iOS Unified 32-bits - device/Release: BuildFailure
  • mscorlib Part 1/iOS Unified 32-bits - device/Release: UseThumb: BuildFailure
  • mscorlib Part 1/iOS Unified 32-bits - device/AssemblyBuildTarget: SDK framework (release): BuildFailure
  • mscorlib Part 2/iOS Unified 32-bits - device/AssemblyBuildTarget: dylib (debug): Failed
  • mscorlib Part 2/iOS Unified 32-bits - device/AssemblyBuildTarget: SDK framework (debug): Failed
  • mscorlib Part 2/iOS Unified 32-bits - device/AssemblyBuildTarget: dylib (debug, profiling): Failed
  • mscorlib Part 2/iOS Unified 32-bits - device/AssemblyBuildTarget: SDK framework (debug, profiling): Failed
  • mscorlib Part 2/iOS Unified 32-bits - device/Release: Failed
  • mscorlib Part 2/iOS Unified 32-bits - device/Release: UseThumb: Failed
  • mscorlib Part 2/iOS Unified 32-bits - device/AssemblyBuildTarget: SDK framework (release): Failed
  • mscorlib Part 2/iOS Unified 32-bits - device/Debug: SGenConc: Failed

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

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

✅ Status for 'xamarin-macios - sample testing (build)': success.

  • ✅ Debug_iPhone_AF: Succeeded
  • ✅ Debug_iPhone_GR: Succeeded
  • ✅ Debug_iPhone_SZ: Succeeded
  • ✅ Debug_iPhoneSimulator: Succeeded
  • ✅ Release_iPhone_AF: Succeeded
  • ✅ Release_iPhone_GR: Succeeded
  • ✅ Release_iPhone_SZ: Succeeded
  • ✅ Release_iPhoneSimulator: Succeeded
  • ✅ Debug_Mac: Succeeded
  • ✅ Release_Mac: Succeeded
  • ✅ PublishPerformanceData: Succeeded

@mandel-macaque
Copy link
Member

Choose a reason for hiding this comment

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

Setting state to success where context is VSTS: device tests (TvOS).

Known issue: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1074884

Please sign in to comment.