Граф коммитов

50 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge 6aca92cd74
[Metal] Implement Xcode 16.0 beta 1-6 changes. (#20895)
Note: there were no changes in beta 3, beta 4 or beta 5.
2024-09-09 19:42:49 +02:00
Rolf Bjarne Kvinge b51bcfa531
[tests] Fix all the remaining warnings in monotouch-test, EmbeddedResources and bindings-test. (#19722)
And also make sure we don't introduce any new warnings by making them errors.
2024-01-08 07:41:48 +01:00
Manuel de la Pena 7ad1837e7d
[Metal] Add support for Xcode15. (#19379)
This PR brings all the changes from the new Metal APIs. During the
review pay special attention to the changes done in the Protocols in
order to add tvOS support.

The main problem we have had doing this PR is that tvOS was not done on
time before the NET branching, that left us with a lot of memebers that
were NOT added in tvOS that are abstract on dotnet, which has left use
in a pickle.

Lets use the following code as an example.

Code found before this commit:

```csharp
	[Mac (11, 0), iOS (14, 0), NoTV]
	[MacCatalyst (14, 0)]
#if NET
	[Abstract]
#endif
	[Export ("accelerationStructureCommandEncoder")]
	IMTLAccelerationStructureCommandEncoder CreateAccelerationStructureCommandEncoder ();
```

A naive approach would be to add just the tvOS suppor as follows:

```csharp
	[Mac (11, 0), iOS (14, 0), TV (16,0)]
	[MacCatalyst (14, 0)]
#if NET
	[Abstract]
#endif
	[Export ("accelerationStructureCommandEncoder")]
	IMTLAccelerationStructureCommandEncoder CreateAccelerationStructureCommandEncoder ();
```

The above change represents and API braking change on the donet tvOS dll
because it adds a new Abstrtact members, so this is no an acceptable
solution.

There is a second naive approach we can take which is as follows:

```csharp
	[Mac (11, 0), iOS (14, 0), TV (16,0)]
	[MacCatalyst (14, 0)]
#if NET &!TVOS
	[Abstract]
#endif
	[Export ("accelerationStructureCommandEncoder")]
	IMTLAccelerationStructureCommandEncoder CreateAccelerationStructureCommandEncoder ();
```

Yet again, the naive approach has an issue with it. In this case, all
the extension methods that are generated for tvOS (something the
generator writes when methods are not abstract) will be decorated with
availability attributes for all the other platforms, which is incorrect
and will make developers life worse.

That leaves us with the following approach:

```csharp
#if NET
#if !TVOS
	[Mac (11, 0), iOS (14, 0), NoTV, MacCatalyst (14, 0)]
	[Abstract]
#else
	[NoMac, NoiOS, TV (16,0), NoMacCatalyst]
#endif
#else
	[Mac (11, 0), iOS (14, 0), TV (16,0), MacCatalyst (14, 0)]
#endif
	[Export ("accelerationStructureCommandEncoder")]
	IMTLAccelerationStructureCommandEncoder CreateAccelerationStructureCommandEncoder ();
```

With the above change, we do not add an abstract method in tvOS and we
only add the tvOS abailabity attribute to the extension methods, and use
NoiOS etc for all the other platforms.

The change had to be done to ALL methods that added tvOS support. The
good news are that our cecil tests and our introspection tests catch the
two naive approaces :)

---------

Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Co-authored-by: Haritha Mohan <harithamohan@microsoft.com>
Co-authored-by: Alex Soto <alex@alexsoto.me>
2023-12-12 17:39:56 -05:00
Rolf Bjarne Kvinge 9e2143032f
Use Enum.GetValues<T> instead of Enum.GetValues in numerous places for .NET. (#18382)
NativeAOT warns about Enum.GetValues and suggests using Enum.GetValues<T>
instead, so do just that.
2023-06-07 08:47:55 +02:00
Rolf Bjarne Kvinge ac6b1e0a1c
[monotouch-test] Ignore MTLArgumentEncoderTest on older devices. (#18315)
The test fails on iOS 12.4, and works on iOS 16.5, so for now ignore if <iOS 13.0.
2023-05-24 16:58:49 +02:00
Rolf Bjarne Kvinge 36af029204
Change all null checking expressions to use 'is' and 'is not'. (#18176)
Change all null checking expressions to use 'is null' and 'is not null'
instead of '== null' and '!= null'.

This was mostly done with sed, so code can probably be improved in many
other ways with manual inspection, but that will come over time.

Also add code to the autoformat script to automatically fix these issues in the future.
2023-05-05 17:52:19 +02:00
Rolf Bjarne Kvinge 6f45caa84d
[autoformat] Add monotouch-test (#16701) 2022-11-10 17:59:26 +01:00
Rolf Bjarne Kvinge 2d81a92270
[tests] Adopt XAMCORE_4_0 changes in monotouch-test .NET. (#14099) 2022-02-08 10:36:20 +01:00
Rolf Bjarne Kvinge b169c806fc
[dotnet] Remove Runtime.Arch and ObjCRuntime.Arch from Mac Catalyst. Fixes #10312. (#13562)
Remove Runtime.Arch and ObjCRuntime.Arch from Mac Catalyst, because they don't
apply for a Mac Catalyst app (which is neither a simulator environment, nor a
device environment).

This means that code using these APIs will have to be re-evaluated to
determine what's the correct behavior for Mac Catalyst.

Also update our tests accordingly.

Fixes https://github.com/xamarin/xamarin-macios/issues/10312.
2021-12-15 22:32:14 +01:00
Rolf Bjarne Kvinge c93cd3a99c
[Metal] Usher the Metal API into the golden age of .NET. (#13533)
* Change all XAMCORE_4_0 conditions to NET conditions.
* Add numerous Release attributes that xtro started complaining about.
* Misc other minor API changes/updates.
2021-12-13 20:40:29 +01:00
Rolf Bjarne Kvinge 19c2765156 [tests][monotouch-test] Adjust code to cope with NativeHandle. 2021-11-26 14:25:21 +01:00
Rolf Bjarne Kvinge 66e596e9d9
[tests] Change TestRuntime.CheckSystemVersion to take a ApplePlatform value instead of a PlatformName enum. (#13350)
The PlatformName enum will be removed from .NET soon.
2021-11-15 08:06:36 +01:00
Manuel de la Pena 67e1ca5459
[Metal] Add support for xcode 13 beta5 . (#12875)
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2021-10-05 13:32:48 -04:00
Rolf Bjarne Kvinge 3d182c5c54
[Metal] Fix a few issues in MTLDevice. (#12861)
* MTLCopyAllDevices returns a retained object, so we need to release it.
* MTLCopyAllDevicesWithObserver returns an observer (no need to provide one). This
  means we can obsolete the 'ref NSObject' overload (the API doesn't make sense),
  and instead add an 'out NSObject' overload.
* The returned observer from MTLCopyAllDevicesWithObserver is retained, so we must
  release it.
* The returned array from MTLCopyAllDevicesWithObserver is a retained object, so
  we need to release it.
* Simpify the supporting block code for the calls to MTLCopyAllDevicesWithObserver.
* Clean up the block we passed to MTLCopyAllDevicesWithObserver.
2021-09-29 07:54:42 +02:00
Rolf Bjarne Kvinge 2972e1b715
Fix some whitespace issues in various files. (#12399)
* Remove BOM
* Add EOL at end of file.
2021-08-11 10:06:46 +02:00
Rolf Bjarne Kvinge c898f19f18 [monotouch-test] Improve the MTLDeviceTest to work on Mac Catalyst. 2021-07-22 10:37:28 +02:00
Rolf Bjarne Kvinge b7f87340a5
[tests] Don't run the MTLDeviceTest.ReturnReleaseTest unless Metal is available. (#11742) 2021-05-31 15:25:26 +02:00
Rolf Bjarne Kvinge 7ac3c658e0
[tests] Preserve all test fixtures. (#10870)
* [tests] Preserve all test fixtures.

This fixes the wildly diffetent number of tests when running xammac tests with and without linking.

Without linking:

> Tests run: 2446 Passed: 2321 Inconclusive: 9 Failed: 0 Ignored: 125

vs with linking:

> Tests run: 1885 Passed: 1802 Inconclusive: 4 Failed: 0 Ignored: 83

Now we run the same tests either with or without linking.

One test was updated to not fail when linking is enabled.

Also add a test to ensure all future test fixtures are preserved.

* Remove whitespace noise.
2021-03-16 15:15:30 +01:00
Rolf Bjarne Kvinge 52e29c4130 [monotouch-test] Adjust version checks according to how they're done now for Mac Catalyst. 2021-01-28 08:07:58 +01:00
Rolf Bjarne Kvinge aa1bf71cd6 [monotouch-test] Make it work with Mac Catalyst.
* Fix system version checks to work properly on Mac Catalyst (which uses the macOS
  version as its system version).

* Add the framework-specific defines to the build for monotouch-test.csproj (using
  the generated response files), this way we can use them in the tests.

* Sprinkle conditionals in numerous places - I tried using either framework-specific
  or XAMCORE_3_0 whenever that made since (instead of using Mac Catalyst as a condition).

* Updated a few tests to use non-deprecated API (because the deprecated API often
  doesn't exist in Mac Catalyst).

* Also a few minor API fixes to make any corresponding tests compile.
2021-01-15 17:52:28 +01:00
Manuel de la Pena 0f7bc75e50 Merge branch 'xcode12.2' into main-xcode12.2 2020-11-17 11:09:15 -05:00
Alex Soto 9d1988a3c8
[tests][xcode12.2] Fix xammac tests (#9935)
* [tests][xcode12.2] Fix xammac tests

* Update tests/common/TestRuntime.cs

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>

* [xammac] Avoid multiple #if statements

* [xammac] Fix missing cases amd reduce amount of changes

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2020-10-21 17:12:48 -04:00
Manuel de la Pena 2c78255dbe
[Metal][Generator] Fix the SetBuffers methods in protocols. Fixes #9649 (#9651)
Add fixes for Metal for XAM_CORE_4. Fixing the methods takes us to a dangerous path, so we do not do it unless we have issues about the methods.

Fixes https://github.com/xamarin/xamarin-macios/issues/9649
2020-10-01 14:27:55 -04:00
Manuel de la Pena dcb0c93ab0 [Xcode12] Bring xcode 12 changes into main. 2020-09-23 16:05:22 -04:00
Manuel de la Pena eb9b690fe0 Merge xcode12 into d16-8. 2020-09-18 17:51:52 -04:00
Manuel de la Pena 2147976458
[Metal] Update framework for xcode 12 beta 6. (#9569)
Co-authored-by: Alex Soto <alex@alexsoto.me>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2020-09-11 16:06:22 -04:00
Rolf Bjarne Kvinge 2995cd086a
[tests] Update tests to make native type vs normal type comparison explicit (#9097)
We've modified our NUnitLite to special-case the native types, so that they
can easily be compared with the standard types, but that doesn't work anymore
when switching to the official NUnit[Lite], so change all asserts to
explicitly convert whenever needed.
2020-07-17 08:48:09 +02:00
Rolf Bjarne Kvinge 6ad1cba473
[monotouch-test] Lower indirect command buffer availability. (#8886)
Apple's charts say indirect command buffers are available with MTLGpuFamilyCommon2.

That's not quite so, devices that support MTLGpuFamilyCommon2 may crash when
MTLDevice.CreateIndirectCommandBuffer is called.

So make the conditions for calling CreateIndirectCommandBuffer an intersection
of the previous condition for macOS (MTLFeatureSet.macOS_GPUFamily2_v1) + the
new condition (MTLGpuFamily.Common2) + Xcode 11+ (just to make things
simpler).

I've tested this on all our macOS bots, and it worked on all of them.

If it fails anywhere else (iOS devices), the next patch will remove the entire
test.
2020-06-18 17:55:20 +02:00
Rolf Bjarne Kvinge 1d269a12d0
[monotouch-test] Check for Metal compatibility for all platforms before creating indirect command buffers. Fixes #xamarin/maccore@2235. (#8863)
This fixes an iOS assertion (crash) when running on iPhone 6 with iOS 12+:

    2020-06-15 13:52:35.138 monotouchtest[6887:5713672] failed assertion 0 at line 54 in NopIndirectCommandBuffer

    =================================================================
    	Native Crash Reporting
    =================================================================
    Got a abrt while executing native code. This usually indicates
    a fatal error in the mono runtime or one of the native libraries
    used by your application.
    =================================================================

    =================================================================
    	Native stacktrace:
    =================================================================
    	0x1060b23fc - /private/var/containers/Bundle/Application/B3C2F137-4C0F-48EF-A50A-8972FF268069/monotouchtest.app/libmonosgen-2.0.dylib : mono_dump_native_crash_info
    	0x1060a8674 - /private/var/containers/Bundle/Application/B3C2F137-4C0F-48EF-A50A-8972FF268069/monotouchtest.app/libmonosgen-2.0.dylib : mono_handle_native_crash
    	0x1060b1948 - /private/var/containers/Bundle/Application/B3C2F137-4C0F-48EF-A50A-8972FF268069/monotouchtest.app/libmonosgen-2.0.dylib : sigabrt_signal_handler
    	0x20049e9fc - /usr/lib/system/libsystem_platform.dylib : <redacted>
    	0x2004a4094 - /usr/lib/system/libsystem_pthread.dylib : <redacted>
    	0x200383ea8 - /usr/lib/system/libsystem_c.dylib : abort
    	0x2029c5dac - /System/Library/Frameworks/Metal.framework/Metal : MTLGetWarningMode
    	0x2210cff78 - /System/Library/Extensions/AGXMetalA8.bundle/AGXMetalA8 :
    	0x20299fb80 - /System/Library/Frameworks/Metal.framework/Metal : <redacted>
    	0x103143c58 - /private/var/containers/Bundle/Application/B3C2F137-4C0F-48EF-A50A-8972FF268069/monotouchtest.app/libXamarin.iOS.dll.dylib : wrapper_managed_to_native_ObjCRuntime_Messaging_IntPtr_objc_msgSend_IntPtr_nuint_UInt64_intptr_intptr_intptr_System_nuint_ulong
    	0x102f4cbdc - /private/var/containers/Bundle/Application/B3C2F137-4C0F-48EF-A50A-8972FF268069/monotouchtest.app/libXamarin.iOS.dll.dylib : Metal_MTLDevice_Extensions_CreateIndirectCommandBuffer_Metal_IMTLDevice_Metal_MTLIndirectCommandBufferDescriptor_System_nuint_Metal_MTLResourceOptions
    	0x101a8bd58 - /private/var/containers/Bundle/Application/B3C2F137-4C0F-48EF-A50A-8972FF268069/monotouchtest.app/libmonotouchtest.exe.dylib : MonoTouchFixtures_Metal_MTLDeviceTests_ReturnReleaseTest
    	[...]

Fixes https://github.com/xamarin/maccore/issues/2235.
2020-06-18 08:59:35 +02:00
Rolf Bjarne Kvinge 952037b7a3
[tests] Remove Classic code from all tests. (#8707) 2020-05-29 16:43:06 +02:00
Rolf Bjarne Kvinge 2b2f1d08dc
[tests] Remove Classic code from all tests. (#8702) 2020-05-28 16:35:09 +02:00
Rolf Bjarne Kvinge dc2c269f40
[tests] Use built-in feature checks to check for API non-crashyness. (#6640)
This also required adding a few missing Metal version enum values.

Fixes https://github.com/xamarin/maccore/issues/1800.
Fixes https://github.com/xamarin/maccore/issues/1801.
2019-07-24 07:10:10 -07:00
Rolf Bjarne Kvinge 8ab907a91e [monotouch-test] Don't check for the macOS system version when running on other platforms. 2019-07-11 19:04:14 +02:00
Rolf Bjarne Kvinge 58fcbe0189 [monotouch-test] Don't test API that crashes. 2019-06-26 14:17:14 +02:00
Rolf Bjarne Kvinge 46f098349e [tests] Version check fixes. 2019-06-26 10:15:46 +02:00
Rolf Bjarne Kvinge 9ed942659d Simplify nested usings. 2019-05-31 06:32:58 +00:00
Rolf Bjarne Kvinge 222a482fea Fix whitespace. 2019-05-31 06:32:58 +00:00
Rolf Bjarne Kvinge 40096a1eaf [tests] Use a higher offset when calling MTLBuffer.CreateTexture to try to comply with the requirements for the API.
Hopefully fixes this assertion:

> 07:42:06.7701360 validateStrideTextureParameters:1512: failed assertion `Linear texture: bytesPerRow (64) must be aligned to 256 bytes'

which doesn't happen on my machine.
2019-05-31 06:32:58 +00:00
Rolf Bjarne Kvinge 16e1b85289 [tests] MTLFunctionConstantValues didn't have a default ctor until Xcode 9. 2019-05-31 06:32:58 +00:00
Rolf Bjarne Kvinge 96517671f6 [Metal] Sprinkle [return: Release] on all 'new*' selectors. Fixes #5941.
Also add tests for all the API I could figure out how to use.

Fixes https://github.com/xamarin/xamarin-macios/issues/5941.
2019-05-31 06:32:58 +00:00
Manuel de la Pena ddb0948376 [Metal] Fixe the size of structures. Fixes #4611 (#4838)
The structs MTLQuadTessellationFactorsHalf and
MTLTriangleTessellationFactorsHalf are wrong as per the header
definition:

```c
typedef struct {
    /* NOTE: edgeTessellationFactor and insideTessellationFactor are interpreted as half (16-bit floats) */
    uint16_t edgeTessellationFactor[4];
    uint16_t insideTessellationFactor[2];
} MTLQuadTessellationFactorsHalf;

typedef struct {
    /* NOTE: edgeTessellationFactor and insideTessellationFactor are interpreted as half (16-bit floats) */
    uint16_t edgeTessellationFactor[3];
    uint16_t insideTessellationFactor;
} MTLTriangleTessellationFactorsHalf;
```

We set the arrays size to be the correct one.

Fixes https://github.com/xamarin/xamarin-macios/issues/4611

* Add tests that ensure that the size of the managed structs is the same
as the native ones.

The values used have been checked against a native app compiled on 32
and 64 (iphone 5 and iphone X).
2018-09-21 09:33:27 -04:00
Vincent Dondain 3548c44782
[metal] Update for Xcode 10 beta 1, 2, 3 & 4 (#4562) 2018-08-15 10:09:23 -04:00
Rolf Bjarne Kvinge 17093d4311 [tests] Make MTLDeviceTests work on macOS systems that don't support metal. (#4059) 2018-07-04 00:21:45 +02:00
Timothy Risi 46f4875422 [Xcode 9] Update Metal for GM (#2689) 2017-09-14 21:42:40 -04:00
Timothy Risi c628320cda [Metal] New bindings from Xcode 9 betas (#2457) 2017-09-05 08:45:03 -04:00
Sebastien Pouliot 5db30f619e [metal] Fix MTLHeapDescriptor and test it only on devices (#782)
It turns out `MTLHeapDescriptor` does not exists on the simulator.

```Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_MTLHeapDescriptor", referenced from:
      objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture x86_64```

A `[DisableDefaultCtor]` was used (by mistake / lack of documentation)
and this was hiding the issue (on our bots).

However on device introspection was not happy:

iOSApiSelectorTest
[FAIL] Selector not found for Metal.MTLHeapDescriptor : cpuCacheMode
[FAIL] Selector not found for Metal.MTLHeapDescriptor : setCpuCacheMode:
[FAIL] Selector not found for Metal.MTLHeapDescriptor : size
[FAIL] Selector not found for Metal.MTLHeapDescriptor : setSize:
[FAIL] Selector not found for Metal.MTLHeapDescriptor : storageMode
[FAIL] Selector not found for Metal.MTLHeapDescriptor : setStorageMode:
    [FAIL] iOSApiSelectorTest.ApiSelectorTest.InstanceMethods :   6 errors found in 18339 instance selector validated

Note that these are the properties, not the `init` that's mentioned here.

So first `init` is possible, on devices, from Xcode:

	MTLHeapDescriptor *hd = [[MTLHeapDescriptor alloc] init];
	NSLog (@"%@", [hd description]);

gives

	<MTLHeapDescriptorInternal: 0x17401da50>
	{
		cpuCacheMode = MTLCPUCacheModeDefaultCache;
		size = 0;
		storageMode = MTLStorageModePrivate;
		}

so we need to remove our `[DisableDefaultCtor]`.

That does not fix the selectors above... but note the *Internal type
returned, they are forwarded and that's generally something that
respondToSelector (that introspection uses) does not cover.

But, to be sure, we add unit tests showing all the properties are
working like expected :-)
2016-09-07 08:03:14 -04:00
Sebastien Pouliot 3428fdc400 [tests] Update monotouch-test to add version checks when executing on older iOS versions. Fixes #43920 (#729)
Tested with iOS 9.3, 8.4 and 6.1.

https://bugzilla.xamarin.com/show_bug.cgi?id=43920
2016-08-31 23:08:54 -04:00
Manuel de la Pena d5bb9326ec [Metal] Update bindings for Xcode 8. (#663) 2016-08-29 08:21:06 -04:00
Sebastien Pouliot d2c1b63ec0 Fix monotouch-tests failures on older iOS versions (#401)
Tested with iOS 7.1 on an iPad 3

- Dynamic registrar needs to ignore new CBManager base class;
- CGImageMetadataTag.Value returns a mutable array on iOS10;
- MPMediaItem properties needed 9.2 / 10.0 check;
- MSMessage not available before Xcode 8;
- Metal not available before Xcode 6;
- MetalPerformanceShaders not available before Xcode 7;
2016-07-14 22:00:52 -04:00
Rolf Bjarne Kvinge ecfdea9508 [tests] Import 2016-05-26 15:06:52 +02:00