diff --git a/samples/ComputeSharp.Benchmark/Blas/BlasBenchmark.cs b/samples/ComputeSharp.Benchmark/Blas/BlasBenchmark.cs
index 0dd6f5a4..326d0527 100644
--- a/samples/ComputeSharp.Benchmark/Blas/BlasBenchmark.cs
+++ b/samples/ComputeSharp.Benchmark/Blas/BlasBenchmark.cs
@@ -100,10 +100,10 @@ public class BlasBenchmark : IDisposable
B = CreateRandomArray(P);
Y = CreateRandomArray(C * N * P);
- BufferX = GraphicsDevice.Default.AllocateReadOnlyBuffer(X);
- BufferW = GraphicsDevice.Default.AllocateReadOnlyBuffer(W);
- BufferB = GraphicsDevice.Default.AllocateReadOnlyBuffer(B);
- BufferY = GraphicsDevice.Default.AllocateReadWriteBuffer(Y);
+ BufferX = GraphicsDevice.GetDefault().AllocateReadOnlyBuffer(X);
+ BufferW = GraphicsDevice.GetDefault().AllocateReadOnlyBuffer(W);
+ BufferB = GraphicsDevice.GetDefault().AllocateReadOnlyBuffer(B);
+ BufferY = GraphicsDevice.GetDefault().AllocateReadWriteBuffer(Y);
Cpu();
GpuWithNoTemporaryBuffers();
@@ -140,7 +140,7 @@ public class BlasBenchmark : IDisposable
[Benchmark]
public void GpuWithNoTemporaryBuffers()
{
- BlasHelpers.FullyConnectedForwardGpu(GraphicsDevice.Default, C, N, M, P, BufferX!, BufferW!, BufferB!, BufferY!);
+ BlasHelpers.FullyConnectedForwardGpu(GraphicsDevice.GetDefault(), C, N, M, P, BufferX!, BufferW!, BufferB!, BufferY!);
}
///
@@ -149,12 +149,12 @@ public class BlasBenchmark : IDisposable
[Benchmark]
public void GpuWithTemporaryBuffers()
{
- using ReadOnlyBuffer x = GraphicsDevice.Default.AllocateReadOnlyBuffer(X!);
- using ReadOnlyBuffer w = GraphicsDevice.Default.AllocateReadOnlyBuffer(W!);
- using ReadOnlyBuffer b = GraphicsDevice.Default.AllocateReadOnlyBuffer(B!);
- using ReadWriteBuffer y = GraphicsDevice.Default.AllocateReadWriteBuffer(Y!.Length);
+ using ReadOnlyBuffer x = GraphicsDevice.GetDefault().AllocateReadOnlyBuffer(X!);
+ using ReadOnlyBuffer w = GraphicsDevice.GetDefault().AllocateReadOnlyBuffer(W!);
+ using ReadOnlyBuffer b = GraphicsDevice.GetDefault().AllocateReadOnlyBuffer(B!);
+ using ReadWriteBuffer y = GraphicsDevice.GetDefault().AllocateReadWriteBuffer(Y!.Length);
- BlasHelpers.FullyConnectedForwardGpu(GraphicsDevice.Default, C, N, M, P, x, w, b, y);
+ BlasHelpers.FullyConnectedForwardGpu(GraphicsDevice.GetDefault(), C, N, M, P, x, w, b, y);
y.CopyTo(Y);
}
diff --git a/samples/ComputeSharp.Benchmark/Dispatching/DispatchingBenchmark.cs b/samples/ComputeSharp.Benchmark/Dispatching/DispatchingBenchmark.cs
index e94a1e95..f7c71449 100644
--- a/samples/ComputeSharp.Benchmark/Dispatching/DispatchingBenchmark.cs
+++ b/samples/ComputeSharp.Benchmark/Dispatching/DispatchingBenchmark.cs
@@ -23,7 +23,7 @@ public partial class DispatchingBenchmark : IDisposable
[GlobalSetup]
public void Setup()
{
- Buffer = GraphicsDevice.Default.AllocateReadWriteBuffer(128);
+ Buffer = GraphicsDevice.GetDefault().AllocateReadWriteBuffer(128);
}
///
@@ -40,7 +40,7 @@ public partial class DispatchingBenchmark : IDisposable
[BenchmarkCategory("SINGLE")]
public void Compute_Single()
{
- GraphicsDevice.Default.For(64, new TestShader(Buffer!));
+ GraphicsDevice.GetDefault().For(64, new TestShader(Buffer!));
}
///
@@ -50,7 +50,7 @@ public partial class DispatchingBenchmark : IDisposable
[BenchmarkCategory("SINGLE")]
public void Compute_Single_WithContext()
{
- using var context = GraphicsDevice.Default.CreateComputeContext();
+ using var context = GraphicsDevice.GetDefault().CreateComputeContext();
context.For(64, new TestShader(Buffer!));
}
@@ -62,7 +62,7 @@ public partial class DispatchingBenchmark : IDisposable
[BenchmarkCategory("SINGLE")]
public async Task Compute_Single_WithContext_Async()
{
- await using var context = GraphicsDevice.Default.CreateComputeContext();
+ await using var context = GraphicsDevice.GetDefault().CreateComputeContext();
context.For(64, new TestShader(Buffer!));
}
@@ -74,8 +74,8 @@ public partial class DispatchingBenchmark : IDisposable
[BenchmarkCategory("MULTIPLE")]
public void Compute_Multiple()
{
- GraphicsDevice.Default.For(64, new TestShader(Buffer!));
- GraphicsDevice.Default.For(64, new TestShader(Buffer!));
+ GraphicsDevice.GetDefault().For(64, new TestShader(Buffer!));
+ GraphicsDevice.GetDefault().For(64, new TestShader(Buffer!));
}
///
@@ -85,7 +85,7 @@ public partial class DispatchingBenchmark : IDisposable
[BenchmarkCategory("MULTIPLE")]
public void Compute_Multiple_WithContext()
{
- using var context = GraphicsDevice.Default.CreateComputeContext();
+ using var context = GraphicsDevice.GetDefault().CreateComputeContext();
context.For(64, new TestShader(Buffer!));
context.Barrier(Buffer!);
@@ -99,7 +99,7 @@ public partial class DispatchingBenchmark : IDisposable
[BenchmarkCategory("MULTIPLE")]
public async Task Compute_Multiple_WithContext_Async()
{
- await using var context = GraphicsDevice.Default.CreateComputeContext();
+ await using var context = GraphicsDevice.GetDefault().CreateComputeContext();
context.For(64, new TestShader(Buffer!));
context.Barrier(Buffer!);
diff --git a/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor.cs b/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor.cs
index c6372d8e..f2b1f4c7 100644
--- a/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor.cs
+++ b/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor.cs
@@ -26,7 +26,7 @@ public sealed partial class HlslBokehBlurProcessor : IImageProcessor
/// Initializes a new instance of the class.
///
public HlslBokehBlurProcessor()
- : this(GraphicsDevice.Default, DefaultRadius, DefaultComponents)
+ : this(GraphicsDevice.GetDefault(), DefaultRadius, DefaultComponents)
{
}
@@ -36,7 +36,7 @@ public sealed partial class HlslBokehBlurProcessor : IImageProcessor
/// The size of the area to sample.
/// The number of components to use to approximate the original 2D bokeh blur convolution kernel.
public HlslBokehBlurProcessor(int radius, int components)
- : this(GraphicsDevice.Default, radius, components)
+ : this(GraphicsDevice.GetDefault(), radius, components)
{
}
diff --git a/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor.cs b/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor.cs
index 95cd2a2f..b046b334 100644
--- a/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor.cs
+++ b/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor.cs
@@ -21,7 +21,7 @@ public sealed partial class HlslGaussianBlurProcessor : IImageProcessor
/// Initializes a new instance of the class.
///
public HlslGaussianBlurProcessor()
- : this(GraphicsDevice.Default, DefaultSigma, 9)
+ : this(GraphicsDevice.GetDefault(), DefaultSigma, 9)
{
}
@@ -30,7 +30,7 @@ public sealed partial class HlslGaussianBlurProcessor : IImageProcessor
///
/// The radius value representing the size of the area to sample.
public HlslGaussianBlurProcessor(int radius)
- : this(GraphicsDevice.Default, radius / 3F, radius)
+ : this(GraphicsDevice.GetDefault(), radius / 3F, radius)
{
}
diff --git a/samples/ComputeSharp.Sample.FSharp/Program.fs b/samples/ComputeSharp.Sample.FSharp/Program.fs
index 8782690a..aa376b86 100644
--- a/samples/ComputeSharp.Sample.FSharp/Program.fs
+++ b/samples/ComputeSharp.Sample.FSharp/Program.fs
@@ -32,12 +32,12 @@ let main _ =
let array = [| for i in 1 .. 100 -> (float32)i |]
// Create the graphics buffer
- use buffer = GraphicsDevice.Default.AllocateReadWriteBuffer(array)
+ use buffer = GraphicsDevice.GetDefault().AllocateReadWriteBuffer(array)
let shader = new MultiplyByTwo(buffer)
// Run the shader (passed by reference)
- GraphicsDevice.Default.For(100, &shader)
+ GraphicsDevice.GetDefault().For(100, &shader)
// Print the initial matrix
printMatrix array 10 10 "BEFORE"
diff --git a/samples/ComputeSharp.Sample/Program.cs b/samples/ComputeSharp.Sample/Program.cs
index c1962f0a..64294e81 100644
--- a/samples/ComputeSharp.Sample/Program.cs
+++ b/samples/ComputeSharp.Sample/Program.cs
@@ -6,10 +6,10 @@ using ComputeSharp.Sample;
float[] array = Enumerable.Range(1, 100).Select(static i => (float)i).ToArray();
// Create the graphics buffer
-using ReadWriteBuffer gpuBuffer = GraphicsDevice.Default.AllocateReadWriteBuffer(array);
+using ReadWriteBuffer gpuBuffer = GraphicsDevice.GetDefault().AllocateReadWriteBuffer(array);
// Run the shader
-GraphicsDevice.Default.For(100, new MultiplyByTwo(gpuBuffer));
+GraphicsDevice.GetDefault().For(100, new MultiplyByTwo(gpuBuffer));
// Print the initial matrix
Formatting.PrintMatrix(array, 10, 10, "BEFORE");
diff --git a/samples/ComputeSharp.SwapChain/Backend/SwapChainApplication{T}.cs b/samples/ComputeSharp.SwapChain/Backend/SwapChainApplication{T}.cs
index 18077d7f..cc15dc39 100644
--- a/samples/ComputeSharp.SwapChain/Backend/SwapChainApplication{T}.cs
+++ b/samples/ComputeSharp.SwapChain/Backend/SwapChainApplication{T}.cs
@@ -90,7 +90,7 @@ internal sealed class SwapChainApplication : Win32Application
// Get the underlying ID3D12Device in use
fixed (ID3D12Device** d3D12Device = this.d3D12Device)
{
- _ = InteropServices.TryGetID3D12Device(GraphicsDevice.Default, Windows.__uuidof(), (void**)d3D12Device);
+ _ = InteropServices.TryGetID3D12Device(GraphicsDevice.GetDefault(), Windows.__uuidof(), (void**)d3D12Device);
}
// Create the direct command queue to use
@@ -217,7 +217,7 @@ internal sealed class SwapChainApplication : Win32Application
D3D12_RESOURCE_DESC d3D12Resource0Description = this.d3D12Resource0.Get()->GetDesc();
// Create the 2D texture to use to generate frames to display
- this.texture = GraphicsDevice.Default.AllocateReadWriteTexture2D(
+ this.texture = GraphicsDevice.GetDefault().AllocateReadWriteTexture2D(
(int)d3D12Resource0Description.Width,
(int)d3D12Resource0Description.Height);
}
@@ -233,7 +233,7 @@ internal sealed class SwapChainApplication : Win32Application
}
// Generate the new frame
- GraphicsDevice.Default.ForEach(this.texture!, this.shaderFactory(time));
+ GraphicsDevice.GetDefault().ForEach(this.texture!, this.shaderFactory(time));
using ComPtr d3D12Resource = default;
diff --git a/samples/ComputeSharp.SwapChain/Program.cs b/samples/ComputeSharp.SwapChain/Program.cs
index 0601b382..f34c3b3c 100644
--- a/samples/ComputeSharp.SwapChain/Program.cs
+++ b/samples/ComputeSharp.SwapChain/Program.cs
@@ -77,6 +77,6 @@ class Program
{
string filename = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Textures", $"{name}.png");
- return GraphicsDevice.Default.LoadReadOnlyTexture2D(filename);
+ return GraphicsDevice.GetDefault().LoadReadOnlyTexture2D(filename);
}
}
diff --git a/src/ComputeSharp.UI/Helpers/SwapChainManager.cs b/src/ComputeSharp.UI/Helpers/SwapChainManager.cs
index 66417e4d..32af7800 100644
--- a/src/ComputeSharp.UI/Helpers/SwapChainManager.cs
+++ b/src/ComputeSharp.UI/Helpers/SwapChainManager.cs
@@ -239,7 +239,7 @@ internal sealed unsafe partial class SwapChainManager : NativeObject
// Get the underlying ID3D12Device in use
fixed (ID3D12Device** d3D12Device = this.d3D12Device)
{
- GraphicsDevice.Default.D3D12Device->QueryInterface(Win32.__uuidof(), (void**)d3D12Device).Assert();
+ GraphicsDevice.GetDefault().D3D12Device->QueryInterface(Win32.__uuidof(), (void**)d3D12Device).Assert();
}
// Create the direct command queue to use
@@ -394,7 +394,7 @@ internal sealed unsafe partial class SwapChainManager : NativeObject
// Dispose the previous texture, if present, and create the new 2D texture to use to generate frames to display
this.texture?.Dispose();
- this.texture = GraphicsDevice.Default.AllocateReadWriteTexture2D((int)resizedWidth, (int)resizeHeight);
+ this.texture = GraphicsDevice.GetDefault().AllocateReadWriteTexture2D((int)resizedWidth, (int)resizeHeight);
}
}
diff --git a/src/ComputeSharp/Graphics/GraphicsDevice.GetDevice.cs b/src/ComputeSharp/Graphics/GraphicsDevice.GetDevice.cs
index 68e678c8..e17a64dd 100644
--- a/src/ComputeSharp/Graphics/GraphicsDevice.GetDevice.cs
+++ b/src/ComputeSharp/Graphics/GraphicsDevice.GetDevice.cs
@@ -8,18 +8,6 @@ namespace ComputeSharp;
///
partial class GraphicsDevice
{
- ///
- /// Gets the default instance for the current machine.
- /// This instance cannot be manually disposed - attempting to do so is safe and it will
- /// not cause an exception, but it will simply do nothing and not dispose the device.
- ///
- ///
- /// This device will always be available, even when there isn't a compatible physical GPU
- /// or integrated GPU in the system in use. In that case, the WARP device will be used.
- /// For more info, see .
- ///
- public static GraphicsDevice Default => DeviceHelper.DefaultFactory.Value;
-
///
/// Gets or creates the default instance for the current machine.
///
diff --git a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.cs b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.cs
index ab635502..256e4eab 100644
--- a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.cs
+++ b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.cs
@@ -27,30 +27,6 @@ internal static partial class DeviceHelper
///
private const uint WarpDeviceId = 0x8C;
- ///
- /// The instance used to produce the default instance.
- ///
- public static readonly Lazy DefaultFactory = new(GetOrCreateDefaultDevice);
-
- ///
- /// Gets the of the default device.
- ///
- /// The of the default device supporting and .
- /// This methods assumes that a default device is available.
- public static unsafe Luid GetDefaultDeviceLuid()
- {
- if (DefaultFactory.IsValueCreated)
- {
- return DefaultFactory.Value.Luid;
- }
-
- DXGI_ADAPTER_DESC1 dxgiDescription1;
-
- _ = TryGetDefaultDevice(null, null, &dxgiDescription1) || TryGetWarpDevice(null, null, &dxgiDescription1);
-
- return Luid.FromLUID(dxgiDescription1.AdapterLuid);
- }
-
///
/// Gets the default instance.
///
diff --git a/src/ComputeSharp/Graphics/Interop/NativeObject.cs b/src/ComputeSharp/Graphics/Interop/NativeObject.cs
index 01cab286..f0310f90 100644
--- a/src/ComputeSharp/Graphics/Interop/NativeObject.cs
+++ b/src/ComputeSharp/Graphics/Interop/NativeObject.cs
@@ -1,7 +1,6 @@
using System;
using System.Runtime.CompilerServices;
using System.Threading;
-using ComputeSharp.Graphics.Helpers;
namespace ComputeSharp.Interop;
@@ -39,17 +38,6 @@ public abstract class NativeObject : IDisposable
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Dispose()
{
- // If the current instance is a graphics device, check that the LUID doesn't
- // match the one for the default device, which is deliberately never disposed.
- // This type check is inlined and then resolved at JIT time if the target instance
- // is visible to the compiler. That is, if Dispose() is explicitly called on a
- // sealed type that is not GraphicsDevice, this entire path will just be removed.
- if (GetType() == typeof(GraphicsDevice) &&
- DeviceHelper.GetDefaultDeviceLuid() == Unsafe.As(this).Luid)
- {
- return;
- }
-
if (Interlocked.CompareExchange(ref this.isDisposed, 1, 0) == 0)
{
[MethodImpl(MethodImplOptions.NoInlining)]
diff --git a/tests/ComputeSharp.Dynamic.NuGet/Program.cs b/tests/ComputeSharp.Dynamic.NuGet/Program.cs
index 31b654f0..7792c298 100644
--- a/tests/ComputeSharp.Dynamic.NuGet/Program.cs
+++ b/tests/ComputeSharp.Dynamic.NuGet/Program.cs
@@ -5,10 +5,10 @@ using ComputeSharp;
float[] array = Enumerable.Range(1, 100).Select(static i => (float)i).ToArray();
// Create the graphics buffer
-using ReadWriteBuffer gpuBuffer = GraphicsDevice.Default.AllocateReadWriteBuffer(array);
+using ReadWriteBuffer gpuBuffer = GraphicsDevice.GetDefault().AllocateReadWriteBuffer(array);
// Run the shader
-GraphicsDevice.Default.For(100, new MultiplyByTwo(gpuBuffer));
+GraphicsDevice.GetDefault().For(100, new MultiplyByTwo(gpuBuffer));
// Get the data back
float[] result = gpuBuffer.ToArray();
diff --git a/tests/ComputeSharp.NuGet/Program.cs b/tests/ComputeSharp.NuGet/Program.cs
index 591d80de..a0b3885d 100644
--- a/tests/ComputeSharp.NuGet/Program.cs
+++ b/tests/ComputeSharp.NuGet/Program.cs
@@ -5,10 +5,10 @@ using ComputeSharp;
float[] array = Enumerable.Range(1, 100).Select(static i => (float)i).ToArray();
// Create the graphics buffer
-using ReadWriteBuffer gpuBuffer = GraphicsDevice.Default.AllocateReadWriteBuffer(array);
+using ReadWriteBuffer gpuBuffer = GraphicsDevice.GetDefault().AllocateReadWriteBuffer(array);
// Run the shader
-GraphicsDevice.Default.For(100, new MultiplyByTwo(gpuBuffer));
+GraphicsDevice.GetDefault().For(100, new MultiplyByTwo(gpuBuffer));
// Get the data back
float[] result = gpuBuffer.ToArray();
diff --git a/tests/ComputeSharp.Pix.NuGet/Program.cs b/tests/ComputeSharp.Pix.NuGet/Program.cs
index c2119998..9544e448 100644
--- a/tests/ComputeSharp.Pix.NuGet/Program.cs
+++ b/tests/ComputeSharp.Pix.NuGet/Program.cs
@@ -5,10 +5,10 @@ using ComputeSharp;
float[] array = Enumerable.Range(1, 100).Select(static i => (float)i).ToArray();
// Create the graphics buffer
-using ReadWriteBuffer gpuBuffer = GraphicsDevice.Default.AllocateReadWriteBuffer(array);
+using ReadWriteBuffer gpuBuffer = GraphicsDevice.GetDefault().AllocateReadWriteBuffer(array);
// Run the shader
-using (var context = GraphicsDevice.Default.CreateComputeContext())
+using (var context = GraphicsDevice.GetDefault().CreateComputeContext())
{
context.Log("Dispatching shader");
context.BeginEvent("Dispatching event");
diff --git a/tests/ComputeSharp.Tests.DeviceLost/DeviceDisposalTests.cs b/tests/ComputeSharp.Tests.DeviceLost/DeviceDisposalTests.cs
index a132eabd..55d851f5 100644
--- a/tests/ComputeSharp.Tests.DeviceLost/DeviceDisposalTests.cs
+++ b/tests/ComputeSharp.Tests.DeviceLost/DeviceDisposalTests.cs
@@ -18,7 +18,7 @@ public class DeviceDisposalTests
{
using ComPtr d3D12Device = default;
- using (GraphicsDevice graphicsDevice = GraphicsDevice.Default)
+ using (GraphicsDevice graphicsDevice = GraphicsDevice.GetDefault())
{
InteropServices.GetID3D12Device(graphicsDevice, Windows.__uuidof(), (void**)d3D12Device.GetAddressOf());
}
diff --git a/tests/ComputeSharp.Tests.Internals/ShaderDataLoaderTests.cs b/tests/ComputeSharp.Tests.Internals/ShaderDataLoaderTests.cs
index 6b6274fd..4071dbb1 100644
--- a/tests/ComputeSharp.Tests.Internals/ShaderDataLoaderTests.cs
+++ b/tests/ComputeSharp.Tests.Internals/ShaderDataLoaderTests.cs
@@ -23,11 +23,11 @@ public partial class ShaderDataLoaderTests
[TestMethod]
public unsafe void CapturedResource()
{
- using ReadWriteBuffer buffer = GraphicsDevice.Default.AllocateReadWriteBuffer(16);
+ using ReadWriteBuffer buffer = GraphicsDevice.GetDefault().AllocateReadWriteBuffer(16);
DebugDispatchDataLoader dataLoader = DebugDispatchDataLoader.Create();
- ((IShader)new CapturedResourceShader(buffer)).LoadDispatchData(ref dataLoader, GraphicsDevice.Default, 111, 222, 333);
+ ((IShader)new CapturedResourceShader(buffer)).LoadDispatchData(ref dataLoader, GraphicsDevice.GetDefault(), 111, 222, 333);
Assert.AreEqual(3, dataLoader.Values.Length);
Assert.AreEqual(1, dataLoader.Resources.Length);
@@ -55,12 +55,12 @@ public partial class ShaderDataLoaderTests
[TestMethod]
public unsafe void LoadMultipleResourcesAndPrimitives()
{
- using ReadWriteBuffer buffer0 = GraphicsDevice.Default.AllocateReadWriteBuffer(16);
- using ReadWriteBuffer buffer1 = GraphicsDevice.Default.AllocateReadWriteBuffer(16);
+ using ReadWriteBuffer buffer0 = GraphicsDevice.GetDefault().AllocateReadWriteBuffer(16);
+ using ReadWriteBuffer buffer1 = GraphicsDevice.GetDefault().AllocateReadWriteBuffer(16);
DebugDispatchDataLoader dataLoader = DebugDispatchDataLoader.Create();
- ((IShader)new MultipleResourcesAndPrimitivesShader(buffer0, buffer1, 1, 22, 77)).LoadDispatchData(ref dataLoader, GraphicsDevice.Default, 111, 222, 333);
+ ((IShader)new MultipleResourcesAndPrimitivesShader(buffer0, buffer1, 1, 22, 77)).LoadDispatchData(ref dataLoader, GraphicsDevice.GetDefault(), 111, 222, 333);
Assert.AreEqual(6, dataLoader.Values.Length);
Assert.AreEqual(2, dataLoader.Resources.Length);
@@ -94,12 +94,12 @@ public partial class ShaderDataLoaderTests
[TestMethod]
public unsafe void LoadScalarAndVectorTypes()
{
- using ReadWriteBuffer buffer = GraphicsDevice.Default.AllocateReadWriteBuffer(16);
+ using ReadWriteBuffer buffer = GraphicsDevice.GetDefault().AllocateReadWriteBuffer(16);
DebugDispatchDataLoader dataLoader = DebugDispatchDataLoader.Create();
ScalarAndVectorTypesShader shader = new(buffer, new(55, 44, 888), 22, 77, new(3.14, 6.28), 42, 9999);
- ((IShader)shader).LoadDispatchData(ref dataLoader, GraphicsDevice.Default, 111, 222, 333);
+ ((IShader)shader).LoadDispatchData(ref dataLoader, GraphicsDevice.GetDefault(), 111, 222, 333);
Assert.AreEqual(18, dataLoader.Values.Length);
Assert.AreEqual(1, dataLoader.Resources.Length);
@@ -147,7 +147,7 @@ public partial class ShaderDataLoaderTests
[TestMethod]
public unsafe void LoadScalarVectorAndMatrixTypes()
{
- using ReadWriteBuffer buffer = GraphicsDevice.Default.AllocateReadWriteBuffer(16);
+ using ReadWriteBuffer buffer = GraphicsDevice.GetDefault().AllocateReadWriteBuffer(16);
DebugDispatchDataLoader dataLoader = DebugDispatchDataLoader.Create();
ScalarVectorAndMatrixTypesShader shader = new(
@@ -161,7 +161,7 @@ public partial class ShaderDataLoaderTests
i2x2: new(11, 22, 33, 44),
d: 9999);
- ((IShader)shader).LoadDispatchData(ref dataLoader, GraphicsDevice.Default, 111, 222, 333);
+ ((IShader)shader).LoadDispatchData(ref dataLoader, GraphicsDevice.GetDefault(), 111, 222, 333);
Assert.AreEqual(31, dataLoader.Values.Length);
Assert.AreEqual(1, dataLoader.Resources.Length);
@@ -226,7 +226,7 @@ public partial class ShaderDataLoaderTests
[TestMethod]
public unsafe void LoadFlatCustomTypeShader()
{
- using ReadWriteBuffer buffer = GraphicsDevice.Default.AllocateReadWriteBuffer(16);
+ using ReadWriteBuffer buffer = GraphicsDevice.GetDefault().AllocateReadWriteBuffer(16);
DebugDispatchDataLoader dataLoader = DebugDispatchDataLoader.Create();
FlatCustomTypeShader shader = new(
@@ -241,7 +241,7 @@ public partial class ShaderDataLoaderTests
i2x2: new(11, 22, 33, 44),
d: 9999));
- ((IShader)shader).LoadDispatchData(ref dataLoader, GraphicsDevice.Default, 111, 222, 333);
+ ((IShader)shader).LoadDispatchData(ref dataLoader, GraphicsDevice.GetDefault(), 111, 222, 333);
Assert.AreEqual(31, dataLoader.Values.Length);
Assert.AreEqual(1, dataLoader.Resources.Length);
@@ -318,7 +318,7 @@ public partial class ShaderDataLoaderTests
[TestMethod]
public unsafe void LoadNestedCustomTypes()
{
- using ReadWriteBuffer buffer = GraphicsDevice.Default.AllocateReadWriteBuffer(16);
+ using ReadWriteBuffer buffer = GraphicsDevice.GetDefault().AllocateReadWriteBuffer(16);
DebugDispatchDataLoader dataLoader = DebugDispatchDataLoader.Create();
NestedCustomTypesShader shader = new(
@@ -345,7 +345,7 @@ public partial class ShaderDataLoaderTests
a: 888888,
b: new(333.3f, 444.4f))));
- ((IShader)shader).LoadDispatchData(ref dataLoader, GraphicsDevice.Default, 111, 222, 333);
+ ((IShader)shader).LoadDispatchData(ref dataLoader, GraphicsDevice.GetDefault(), 111, 222, 333);
Assert.AreEqual(47, dataLoader.Values.Length);
Assert.AreEqual(1, dataLoader.Resources.Length);
@@ -417,16 +417,16 @@ public partial class ShaderDataLoaderTests
[TestMethod]
public unsafe void AmbiguousNames()
{
- using ReadWriteBuffer a = GraphicsDevice.Default.AllocateReadWriteBuffer(16);
- using ReadWriteBuffer b = GraphicsDevice.Default.AllocateReadWriteBuffer(16);
- using ReadWriteBuffer c = GraphicsDevice.Default.AllocateReadWriteBuffer(16);
- using ReadWriteBuffer x = GraphicsDevice.Default.AllocateReadWriteBuffer(16);
- using ReadWriteBuffer y = GraphicsDevice.Default.AllocateReadWriteBuffer(16);
- using ReadWriteBuffer z = GraphicsDevice.Default.AllocateReadWriteBuffer(16);
+ using ReadWriteBuffer a = GraphicsDevice.GetDefault().AllocateReadWriteBuffer(16);
+ using ReadWriteBuffer b = GraphicsDevice.GetDefault().AllocateReadWriteBuffer(16);
+ using ReadWriteBuffer c = GraphicsDevice.GetDefault().AllocateReadWriteBuffer(16);
+ using ReadWriteBuffer x = GraphicsDevice.GetDefault().AllocateReadWriteBuffer(16);
+ using ReadWriteBuffer y = GraphicsDevice.GetDefault().AllocateReadWriteBuffer(16);
+ using ReadWriteBuffer z = GraphicsDevice.GetDefault().AllocateReadWriteBuffer(16);
DebugDispatchDataLoader dataLoader = DebugDispatchDataLoader.Create();
- ((IShader)new AmbiguousNamesShader(a, b, c, x, y, z, 7777, 8888, 9999)).LoadDispatchData(ref dataLoader, GraphicsDevice.Default, 111, 222, 333);
+ ((IShader)new AmbiguousNamesShader(a, b, c, x, y, z, 7777, 8888, 9999)).LoadDispatchData(ref dataLoader, GraphicsDevice.GetDefault(), 111, 222, 333);
Assert.AreEqual(6, dataLoader.Values.Length);
Assert.AreEqual(6, dataLoader.Resources.Length);
diff --git a/tests/ComputeSharp.Tests.Internals/ShaderHashCodeTests.cs b/tests/ComputeSharp.Tests.Internals/ShaderHashCodeTests.cs
index f90251a9..0dcc496d 100644
--- a/tests/ComputeSharp.Tests.Internals/ShaderHashCodeTests.cs
+++ b/tests/ComputeSharp.Tests.Internals/ShaderHashCodeTests.cs
@@ -25,7 +25,7 @@ public partial class ShaderHashCodeTests
public void ShaderWithNoCapturedDelegates()
{
float value = 10;
- using ReadWriteBuffer buffer = GraphicsDevice.Default.AllocateReadWriteBuffer(1);
+ using ReadWriteBuffer buffer = GraphicsDevice.GetDefault().AllocateReadWriteBuffer(1);
Shader1 shader1 = new() { A = value, B = buffer };
@@ -58,7 +58,7 @@ public partial class ShaderHashCodeTests
{
Func f = static x => x * x;
- using ReadWriteBuffer buffer = GraphicsDevice.Default.AllocateReadWriteBuffer(1);
+ using ReadWriteBuffer buffer = GraphicsDevice.GetDefault().AllocateReadWriteBuffer(1);
Shader2 shader1 = new() { A = 1, B = buffer, F = f };
diff --git a/tests/ComputeSharp.Tests/InitializationTests.cs b/tests/ComputeSharp.Tests/InitializationTests.cs
index fa703600..0b5f1496 100644
--- a/tests/ComputeSharp.Tests/InitializationTests.cs
+++ b/tests/ComputeSharp.Tests/InitializationTests.cs
@@ -13,7 +13,7 @@ public partial class InitializationTests
[TestMethod]
public void IsSupported()
{
- Assert.IsTrue(GraphicsDevice.Default is not null);
+ Assert.IsTrue(GraphicsDevice.GetDefault() is not null);
}
[CombinatorialTestMethod]
@@ -31,11 +31,11 @@ public partial class InitializationTests
[TestMethod]
public void DisposeDefault()
{
- using var before = GraphicsDevice.Default.AllocateReadOnlyBuffer(128);
+ using var before = GraphicsDevice.GetDefault().AllocateReadOnlyBuffer(128);
- GraphicsDevice.Default.Dispose();
+ GraphicsDevice.GetDefault().Dispose();
- using var after = GraphicsDevice.Default.AllocateReadOnlyBuffer(128);
+ using var after = GraphicsDevice.GetDefault().AllocateReadOnlyBuffer(128);
}
[TestMethod]
@@ -45,7 +45,7 @@ public partial class InitializationTests
foreach (GraphicsDevice device in GraphicsDevice.EnumerateDevices())
{
- if (i++ == 0) Assert.AreSame(GraphicsDevice.Default, device);
+ if (i++ == 0) Assert.AreSame(GraphicsDevice.GetDefault(), device);
using ReadWriteBuffer buffer = device.AllocateReadWriteBuffer(128);
@@ -64,7 +64,7 @@ public partial class InitializationTests
foreach (GraphicsDevice device in GraphicsDevice.QueryDevices(info => info.DedicatedMemorySize >= 1024))
{
- if (i++ == 0) Assert.AreSame(GraphicsDevice.Default, device);
+ if (i++ == 0) Assert.AreSame(GraphicsDevice.GetDefault(), device);
using ReadWriteBuffer buffer = device.AllocateReadWriteBuffer(128);