Skip to content

Commit

Permalink
Switch ComputeSharp.Tests.DeviceLost to Vortice.Win32
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio0694 committed Jan 14, 2023
1 parent c3dfecf commit 113f2ba
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="MSTest.TestAdapter" Version="3.0.2" />
<PackageReference Include="MSTest.TestFramework" Version="3.0.2" />
<PackageReference Include="Vortice.Win32.Graphics.Direct3D12" Version="1.9.13" />
<PackageReference Include="Vortice.Win32.Graphics.Dxgi" Version="1.9.13" />
</ItemGroup>

<ItemGroup>
Expand All @@ -19,16 +21,6 @@
<ProjectReference Include="..\..\src\ComputeSharp\ComputeSharp.csproj" />
<ProjectReference Include="..\..\src\ComputeSharp.SourceGenerators\ComputeSharp.SourceGenerators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" PrivateAssets="contentfiles;build" />
</ItemGroup>

<!-- When the .NET Standard 2.0 version of ComputeSharp is resolved, the TerraFX APIs are internal, as they
are referenced from the shared project. The same reference is needed here to make all tests build fine. -->
<Import Condition="'$(TargetFramework)' != 'net6.0' AND '$(TargetFramework)' != 'net7.0'" Project="..\..\src\TerraFX.Interop.Windows\TerraFX.Interop.Windows.projitems" />
<Import Condition="'$(TargetFramework)' != 'net6.0' AND '$(TargetFramework)' != 'net7.0'" Project="..\..\src\ComputeSharp.NetStandard\ComputeSharp.NetStandard.projitems" />

<!-- Only when the local TerraFX is referenced, ignore warnings from there -->
<PropertyGroup Condition="'$(TargetFramework)' != 'net6.0' AND '$(TargetFramework)' != 'net7.0'">
<NoWarn>$(NoWarn);CS0649</NoWarn>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\..\src\ComputeSharp.Core\Properties\Polyfills\UnscopedRefAttribute.cs" Link="Properties\Polyfills\UnscopedRefAttribute.cs" />
Expand Down
10 changes: 7 additions & 3 deletions tests/ComputeSharp.Tests.DeviceLost/DeviceDisposalTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
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
Expand Down Expand Up @@ -51,7 +55,7 @@ public unsafe void DeviceDisposal_InteropServicesThrowsObjectDisposedException(D

graphicsDevice.Dispose();

InteropServices.GetID3D12Device(graphicsDevice, Windows.__uuidof<ID3D12Device>(), (void**)d3D12Device.GetAddressOf());
InteropServices.GetID3D12Device(graphicsDevice, Win32.__uuidof<ID3D12Device>(), (void**)d3D12Device.GetAddressOf());
}

[CombinatorialTestMethod]
Expand Down
4 changes: 2 additions & 2 deletions tests/ComputeSharp.Tests.DeviceLost/DeviceLostTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
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;

Expand Down
11 changes: 8 additions & 3 deletions tests/ComputeSharp.Tests.DeviceLost/GetDefaultDeviceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@
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
Expand Down Expand Up @@ -75,7 +80,7 @@ public async Task GetDefault_VerifyContract()
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@
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;

/// <summary>
/// A helper to do common checks on native device objects.
/// </summary>
Expand All @@ -21,7 +25,7 @@ public static unsafe void GetD3D12Device(GraphicsDevice graphicsDevice, in ComPt
{
fixed (ID3D12Device** ppvObject = d3D12Device)
{
InteropServices.GetID3D12Device(graphicsDevice, Windows.__uuidof<ID3D12Device>(), (void**)ppvObject);
InteropServices.GetID3D12Device(graphicsDevice, Win32.__uuidof<ID3D12Device>(), (void**)ppvObject);
}
}

Expand Down

This file was deleted.

0 comments on commit 113f2ba

Please sign in to comment.