From cd07b46f6a06c45cf65fd81c8177a76d950c9700 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 14 Jan 2023 21:39:46 +0100 Subject: [PATCH] Switch ComputeSharp.Tests.DeviceLost to Vortice.Win32 --- .../ComputeSharp.Tests.DeviceLost.csproj | 12 ++----- .../DeviceDisposalTests.cs | 10 ++++-- .../DeviceLostTests.cs | 4 +-- .../GetDefaultDeviceTests.cs | 11 +++++-- .../Helpers/GraphicsDeviceHelper.cs | 10 ++++-- .../TerraFX.Interop.Windows/ID3D12Device5.cs | 32 ------------------- 6 files changed, 26 insertions(+), 53 deletions(-) delete mode 100644 tests/ComputeSharp.Tests.DeviceLost/TerraFX.Interop.Windows/ID3D12Device5.cs diff --git a/tests/ComputeSharp.Tests.DeviceLost/ComputeSharp.Tests.DeviceLost.csproj b/tests/ComputeSharp.Tests.DeviceLost/ComputeSharp.Tests.DeviceLost.csproj index 611ab6e7..fed652d4 100644 --- a/tests/ComputeSharp.Tests.DeviceLost/ComputeSharp.Tests.DeviceLost.csproj +++ b/tests/ComputeSharp.Tests.DeviceLost/ComputeSharp.Tests.DeviceLost.csproj @@ -11,6 +11,8 @@ + + @@ -19,16 +21,6 @@ - - - - - - - - $(NoWarn);CS0649 - diff --git a/tests/ComputeSharp.Tests.DeviceLost/DeviceDisposalTests.cs b/tests/ComputeSharp.Tests.DeviceLost/DeviceDisposalTests.cs index f2d367f0..477405a0 100644 --- a/tests/ComputeSharp.Tests.DeviceLost/DeviceDisposalTests.cs +++ b/tests/ComputeSharp.Tests.DeviceLost/DeviceDisposalTests.cs @@ -4,11 +4,15 @@ using ComputeSharp.Tests.Attributes; using ComputeSharp.Tests.DeviceLost.Helpers; using ComputeSharp.Tests.Extensions; using Microsoft.VisualStudio.TestTools.UnitTesting; -using TerraFX.Interop.DirectX; -using TerraFX.Interop.Windows; +using Win32; +using Win32.Graphics.Direct3D12; + +#pragma warning disable IDE0065 namespace ComputeSharp.Tests.DeviceLost; +using Win32 = Win32.Apis; + [TestClass] [TestCategory("DeviceDisposal")] public partial class DeviceDisposalTests @@ -51,7 +55,7 @@ public partial class DeviceDisposalTests graphicsDevice.Dispose(); - InteropServices.GetID3D12Device(graphicsDevice, Windows.__uuidof(), (void**)d3D12Device.GetAddressOf()); + InteropServices.GetID3D12Device(graphicsDevice, Win32.__uuidof(), (void**)d3D12Device.GetAddressOf()); } [CombinatorialTestMethod] diff --git a/tests/ComputeSharp.Tests.DeviceLost/DeviceLostTests.cs b/tests/ComputeSharp.Tests.DeviceLost/DeviceLostTests.cs index 5a59f3f7..708c79ae 100644 --- a/tests/ComputeSharp.Tests.DeviceLost/DeviceLostTests.cs +++ b/tests/ComputeSharp.Tests.DeviceLost/DeviceLostTests.cs @@ -5,8 +5,8 @@ using ComputeSharp.Tests.Attributes; using ComputeSharp.Tests.DeviceLost.Helpers; using ComputeSharp.Tests.Extensions; using Microsoft.VisualStudio.TestTools.UnitTesting; -using TerraFX.Interop.DirectX; -using TerraFX.Interop.Windows; +using Win32; +using Win32.Graphics.Direct3D12; namespace ComputeSharp.Tests.DeviceLost; diff --git a/tests/ComputeSharp.Tests.DeviceLost/GetDefaultDeviceTests.cs b/tests/ComputeSharp.Tests.DeviceLost/GetDefaultDeviceTests.cs index 0f20decd..c0a9bd1d 100644 --- a/tests/ComputeSharp.Tests.DeviceLost/GetDefaultDeviceTests.cs +++ b/tests/ComputeSharp.Tests.DeviceLost/GetDefaultDeviceTests.cs @@ -2,11 +2,16 @@ using System; using System.Threading.Tasks; using ComputeSharp.Tests.DeviceLost.Helpers; using Microsoft.VisualStudio.TestTools.UnitTesting; -using TerraFX.Interop.DirectX; -using TerraFX.Interop.Windows; +using Win32; +using Win32.Graphics.Direct3D12; + +#pragma warning disable IDE0065 namespace ComputeSharp.Tests.DeviceLost; +using DXGI = Win32.Graphics.Dxgi.Apis; +using HRESULT = Win32.HResult; + [TestClass] [TestCategory("GetDefaultDevice")] public class GetDefaultDeviceTests @@ -75,7 +80,7 @@ public class GetDefaultDeviceTests HRESULT removalReason = d3D12Device.Get()->GetDeviceRemovedReason(); // Sanity check that the device is in fact removed - Assert.AreEqual(DXGI.DXGI_ERROR_DEVICE_REMOVED, (int)removalReason); + Assert.AreEqual(DXGI.DXGI_ERROR_DEVICE_REMOVED, removalReason); } // Calling GraphicsDevice.GetDefault() will now throw, because the native device has not been disposed properly diff --git a/tests/ComputeSharp.Tests.DeviceLost/Helpers/GraphicsDeviceHelper.cs b/tests/ComputeSharp.Tests.DeviceLost/Helpers/GraphicsDeviceHelper.cs index de319cdf..b99e8dc2 100644 --- a/tests/ComputeSharp.Tests.DeviceLost/Helpers/GraphicsDeviceHelper.cs +++ b/tests/ComputeSharp.Tests.DeviceLost/Helpers/GraphicsDeviceHelper.cs @@ -2,11 +2,15 @@ using System; using System.Threading.Tasks; using ComputeSharp.Interop; using Microsoft.VisualStudio.TestTools.UnitTesting; -using TerraFX.Interop.DirectX; -using TerraFX.Interop.Windows; +using Win32; +using Win32.Graphics.Direct3D12; + +#pragma warning disable IDE0065 namespace ComputeSharp.Tests.DeviceLost.Helpers; +using Win32 = Win32.Apis; + /// /// A helper to do common checks on native device objects. /// @@ -21,7 +25,7 @@ internal static class GraphicsDeviceHelper { fixed (ID3D12Device** ppvObject = d3D12Device) { - InteropServices.GetID3D12Device(graphicsDevice, Windows.__uuidof(), (void**)ppvObject); + InteropServices.GetID3D12Device(graphicsDevice, Win32.__uuidof(), (void**)ppvObject); } } diff --git a/tests/ComputeSharp.Tests.DeviceLost/TerraFX.Interop.Windows/ID3D12Device5.cs b/tests/ComputeSharp.Tests.DeviceLost/TerraFX.Interop.Windows/ID3D12Device5.cs deleted file mode 100644 index 6f0fa4ea..00000000 --- a/tests/ComputeSharp.Tests.DeviceLost/TerraFX.Interop.Windows/ID3D12Device5.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -// Ported from um/d3d12.h in the Windows SDK for Windows 10.0.20348.0 -// Original source is Copyright © Microsoft. All rights reserved. - -#if !NET6_0_OR_GREATER - -using System; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace TerraFX.Interop.DirectX; - -[Guid("8B4F173B-2FEA-4B80-8F58-4307191AB95D")] -public unsafe partial struct ID3D12Device5 -{ - public void** lpVtbl; - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public uint Release() - { - return ((delegate* unmanaged[Stdcall])this.lpVtbl[2])((ID3D12Device5*)Unsafe.AsPointer(ref this)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void RemoveDevice() - { - ((delegate* unmanaged[Stdcall])this.lpVtbl[58])((ID3D12Device5*)Unsafe.AsPointer(ref this)); - } -} - -#endif \ No newline at end of file