From b68d51f75e98fe855123e757d50b17a7e3aed9f1 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Fri, 5 Nov 2021 11:57:59 +0100 Subject: [PATCH] Fixed running unit tests with multiple devices --- .../Extensions/DeviceExtensions.cs | 33 ++----------------- 1 file changed, 2 insertions(+), 31 deletions(-) diff --git a/tests/ComputeSharp.Tests/Extensions/DeviceExtensions.cs b/tests/ComputeSharp.Tests/Extensions/DeviceExtensions.cs index 3a521eb2..500b6a80 100644 --- a/tests/ComputeSharp.Tests/Extensions/DeviceExtensions.cs +++ b/tests/ComputeSharp.Tests/Extensions/DeviceExtensions.cs @@ -9,35 +9,6 @@ namespace ComputeSharp.Tests.Extensions; /// public static class DeviceExtensions { - /// - /// The instance for the default discrete device. - /// - private static readonly GraphicsDevice? DiscreteDevice; - - /// - /// The instance for the WARP device. - /// - private static readonly GraphicsDevice WarpDevice; - - /// - /// Initializes and . - /// - static DeviceExtensions() - { - GraphicsDevice defaultDevice = Gpu.Default; - - if (defaultDevice.IsHardwareAccelerated) - { - DiscreteDevice = defaultDevice; - WarpDevice = Gpu.QueryDevices(info => !info.IsHardwareAccelerated).First(); - } - else - { - DiscreteDevice = null; - WarpDevice = defaultDevice; - } - } - /// /// Gets a instance matching a specified type. /// @@ -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("Invalid device") };