Fixed running unit tests with multiple devices
このコミットが含まれているのは:
1 親
b796a0a4c7
コミット
b68d51f75e
1ファイル変更
+2
-31
@@ -9,35 +9,6 @@ namespace ComputeSharp.Tests.Extensions;
|
||||
/// </summary>
|
||||
public static class DeviceExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="GraphicsDevice"/> instance for the default discrete device.
|
||||
/// </summary>
|
||||
private static readonly GraphicsDevice? DiscreteDevice;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="GraphicsDevice"/> instance for the WARP device.
|
||||
/// </summary>
|
||||
private static readonly GraphicsDevice WarpDevice;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes <see cref="DiscreteDevice"/> and <see cref="WarpDevice"/>.
|
||||
/// </summary>
|
||||
static DeviceExtensions()
|
||||
{
|
||||
GraphicsDevice defaultDevice = Gpu.Default;
|
||||
|
||||
if (defaultDevice.IsHardwareAccelerated)
|
||||
{
|
||||
DiscreteDevice = defaultDevice;
|
||||
WarpDevice = Gpu.QueryDevices(info => !info.IsHardwareAccelerated).First();
|
||||
}
|
||||
else
|
||||
{
|
||||
DiscreteDevice = null;
|
||||
WarpDevice = defaultDevice;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="GraphicsDevice"/> instance matching a specified type.
|
||||
/// </summary>
|
||||
@@ -48,8 +19,8 @@ public static class DeviceExtensions
|
||||
{
|
||||
GraphicsDevice? device = type switch
|
||||
{
|
||||
Device.Discrete => DiscreteDevice,
|
||||
Device.Warp => WarpDevice,
|
||||
Device.Discrete => Gpu.QueryDevices(info => info.IsHardwareAccelerated).FirstOrDefault(),
|
||||
Device.Warp => Gpu.QueryDevices(info => !info.IsHardwareAccelerated).First(),
|
||||
_ => ThrowHelper.ThrowArgumentException<GraphicsDevice>("Invalid device")
|
||||
};
|
||||
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする