Remove GraphicsDevice.Default property and APIs

このコミットが含まれているのは:
Sergio Pedri committed 2022-07-31 23:26:11 +02:00
1 親 ea0f792ae6
コミット 4e5acba69c
19ファイル変更
+67 -115

検索条件に一致するファイルはありません

+10 -10
ファイルの表示
@@ -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!);
}
/// <summary>
@@ -149,12 +149,12 @@ public class BlasBenchmark : IDisposable
[Benchmark]
public void GpuWithTemporaryBuffers()
{
using ReadOnlyBuffer<float> x = GraphicsDevice.Default.AllocateReadOnlyBuffer(X!);
using ReadOnlyBuffer<float> w = GraphicsDevice.Default.AllocateReadOnlyBuffer(W!);
using ReadOnlyBuffer<float> b = GraphicsDevice.Default.AllocateReadOnlyBuffer(B!);
using ReadWriteBuffer<float> y = GraphicsDevice.Default.AllocateReadWriteBuffer<float>(Y!.Length);
using ReadOnlyBuffer<float> x = GraphicsDevice.GetDefault().AllocateReadOnlyBuffer(X!);
using ReadOnlyBuffer<float> w = GraphicsDevice.GetDefault().AllocateReadOnlyBuffer(W!);
using ReadOnlyBuffer<float> b = GraphicsDevice.GetDefault().AllocateReadOnlyBuffer(B!);
using ReadWriteBuffer<float> y = GraphicsDevice.GetDefault().AllocateReadWriteBuffer<float>(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);
}
+8 -8
ファイルの表示
@@ -23,7 +23,7 @@ public partial class DispatchingBenchmark : IDisposable
[GlobalSetup]
public void Setup()
{
Buffer = GraphicsDevice.Default.AllocateReadWriteBuffer<float>(128);
Buffer = GraphicsDevice.GetDefault().AllocateReadWriteBuffer<float>(128);
}
/// <inheritdoc/>
@@ -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!));
}
/// <summary>
@@ -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!));
}
/// <summary>
@@ -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!);
+2 -2
ファイルの表示
@@ -26,7 +26,7 @@ public sealed partial class HlslBokehBlurProcessor : IImageProcessor
/// Initializes a new instance of the <see cref="HlslBokehBlurProcessor"/> class.
/// </summary>
public HlslBokehBlurProcessor()
: this(GraphicsDevice.Default, DefaultRadius, DefaultComponents)
: this(GraphicsDevice.GetDefault(), DefaultRadius, DefaultComponents)
{
}
@@ -36,7 +36,7 @@ public sealed partial class HlslBokehBlurProcessor : IImageProcessor
/// <param name="radius">The size of the area to sample.</param>
/// <param name="components">The number of components to use to approximate the original 2D bokeh blur convolution kernel.</param>
public HlslBokehBlurProcessor(int radius, int components)
: this(GraphicsDevice.Default, radius, components)
: this(GraphicsDevice.GetDefault(), radius, components)
{
}
+2 -2
ファイルの表示
@@ -21,7 +21,7 @@ public sealed partial class HlslGaussianBlurProcessor : IImageProcessor
/// Initializes a new instance of the <see cref="HlslGaussianBlurProcessor"/> class.
/// </summary>
public HlslGaussianBlurProcessor()
: this(GraphicsDevice.Default, DefaultSigma, 9)
: this(GraphicsDevice.GetDefault(), DefaultSigma, 9)
{
}
@@ -30,7 +30,7 @@ public sealed partial class HlslGaussianBlurProcessor : IImageProcessor
/// </summary>
/// <param name="radius">The radius value representing the size of the area to sample.</param>
public HlslGaussianBlurProcessor(int radius)
: this(GraphicsDevice.Default, radius / 3F, radius)
: this(GraphicsDevice.GetDefault(), radius / 3F, radius)
{
}
+2 -2
ファイルの表示
@@ -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"
+2 -2
ファイルの表示
@@ -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<float> gpuBuffer = GraphicsDevice.Default.AllocateReadWriteBuffer(array);
using ReadWriteBuffer<float> 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");
+3 -3
ファイルの表示
@@ -90,7 +90,7 @@ internal sealed class SwapChainApplication<T> : Win32Application
// Get the underlying ID3D12Device in use
fixed (ID3D12Device** d3D12Device = this.d3D12Device)
{
_ = InteropServices.TryGetID3D12Device(GraphicsDevice.Default, Windows.__uuidof<ID3D12Device>(), (void**)d3D12Device);
_ = InteropServices.TryGetID3D12Device(GraphicsDevice.GetDefault(), Windows.__uuidof<ID3D12Device>(), (void**)d3D12Device);
}
// Create the direct command queue to use
@@ -217,7 +217,7 @@ internal sealed class SwapChainApplication<T> : 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<Rgba32, float4>(
this.texture = GraphicsDevice.GetDefault().AllocateReadWriteTexture2D<Rgba32, float4>(
(int)d3D12Resource0Description.Width,
(int)d3D12Resource0Description.Height);
}
@@ -233,7 +233,7 @@ internal sealed class SwapChainApplication<T> : Win32Application
}
// Generate the new frame
GraphicsDevice.Default.ForEach(this.texture!, this.shaderFactory(time));
GraphicsDevice.GetDefault().ForEach(this.texture!, this.shaderFactory(time));
using ComPtr<ID3D12Resource> d3D12Resource = default;
+1 -1
ファイルの表示
@@ -77,6 +77,6 @@ class Program
{
string filename = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Textures", $"{name}.png");
return GraphicsDevice.Default.LoadReadOnlyTexture2D<Rgba32, float4>(filename);
return GraphicsDevice.GetDefault().LoadReadOnlyTexture2D<Rgba32, float4>(filename);
}
}
+2 -2
ファイルの表示
@@ -239,7 +239,7 @@ internal sealed unsafe partial class SwapChainManager<TOwner> : NativeObject
// Get the underlying ID3D12Device in use
fixed (ID3D12Device** d3D12Device = this.d3D12Device)
{
GraphicsDevice.Default.D3D12Device->QueryInterface(Win32.__uuidof<ID3D12Device>(), (void**)d3D12Device).Assert();
GraphicsDevice.GetDefault().D3D12Device->QueryInterface(Win32.__uuidof<ID3D12Device>(), (void**)d3D12Device).Assert();
}
// Create the direct command queue to use
@@ -394,7 +394,7 @@ internal sealed unsafe partial class SwapChainManager<TOwner> : 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<Rgba32, Float4>((int)resizedWidth, (int)resizeHeight);
this.texture = GraphicsDevice.GetDefault().AllocateReadWriteTexture2D<Rgba32, Float4>((int)resizedWidth, (int)resizeHeight);
}
}
-12
ファイルの表示
@@ -8,18 +8,6 @@ namespace ComputeSharp;
/// <inheritdoc/>
partial class GraphicsDevice
{
/// <summary>
/// Gets the default <see cref="GraphicsDevice"/> 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.
/// </summary>
/// <remarks>
/// 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 <see href="https://docs.microsoft.com/windows/win32/direct3darticles/directx-warp"/>.
/// </remarks>
public static GraphicsDevice Default => DeviceHelper.DefaultFactory.Value;
/// <summary>
/// Gets or creates the default <see cref="GraphicsDevice"/> instance for the current machine.
/// <para>
-24
ファイルの表示
@@ -27,30 +27,6 @@ internal static partial class DeviceHelper
/// </summary>
private const uint WarpDeviceId = 0x8C;
/// <summary>
/// The <see cref="Lazy{T}"/> instance used to produce the default <see cref="GraphicsDevice"/> instance.
/// </summary>
public static readonly Lazy<GraphicsDevice> DefaultFactory = new(GetOrCreateDefaultDevice);
/// <summary>
/// Gets the <see cref="Luid"/> of the default device.
/// </summary>
/// <returns>The <see cref="Luid"/> of the default device supporting <see cref="D3D_FEATURE_LEVEL_11_0"/> and <see cref="D3D_SHADER_MODEL_6_0"/>.</returns>
/// <remarks>This methods assumes that a default device is available.</remarks>
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);
}
/// <summary>
/// Gets the default <see cref="GraphicsDevice"/> instance.
/// </summary>
-12
ファイルの表示
@@ -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<GraphicsDevice>(this).Luid)
{
return;
}
if (Interlocked.CompareExchange(ref this.isDisposed, 1, 0) == 0)
{
[MethodImpl(MethodImplOptions.NoInlining)]
+2 -2
ファイルの表示
@@ -5,10 +5,10 @@ using ComputeSharp;
float[] array = Enumerable.Range(1, 100).Select(static i => (float)i).ToArray();
// Create the graphics buffer
using ReadWriteBuffer<float> gpuBuffer = GraphicsDevice.Default.AllocateReadWriteBuffer(array);
using ReadWriteBuffer<float> 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();
+2 -2
ファイルの表示
@@ -5,10 +5,10 @@ using ComputeSharp;
float[] array = Enumerable.Range(1, 100).Select(static i => (float)i).ToArray();
// Create the graphics buffer
using ReadWriteBuffer<float> gpuBuffer = GraphicsDevice.Default.AllocateReadWriteBuffer(array);
using ReadWriteBuffer<float> 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();
+2 -2
ファイルの表示
@@ -5,10 +5,10 @@ using ComputeSharp;
float[] array = Enumerable.Range(1, 100).Select(static i => (float)i).ToArray();
// Create the graphics buffer
using ReadWriteBuffer<float> gpuBuffer = GraphicsDevice.Default.AllocateReadWriteBuffer(array);
using ReadWriteBuffer<float> 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");
+1 -1
ファイルの表示
@@ -18,7 +18,7 @@ public class DeviceDisposalTests
{
using ComPtr<ID3D12Device> d3D12Device = default;
using (GraphicsDevice graphicsDevice = GraphicsDevice.Default)
using (GraphicsDevice graphicsDevice = GraphicsDevice.GetDefault())
{
InteropServices.GetID3D12Device(graphicsDevice, Windows.__uuidof<ID3D12Device>(), (void**)d3D12Device.GetAddressOf());
}
+20 -20
ファイルの表示
@@ -23,11 +23,11 @@ public partial class ShaderDataLoaderTests
[TestMethod]
public unsafe void CapturedResource()
{
using ReadWriteBuffer<float> buffer = GraphicsDevice.Default.AllocateReadWriteBuffer<float>(16);
using ReadWriteBuffer<float> buffer = GraphicsDevice.GetDefault().AllocateReadWriteBuffer<float>(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<float> buffer0 = GraphicsDevice.Default.AllocateReadWriteBuffer<float>(16);
using ReadWriteBuffer<float> buffer1 = GraphicsDevice.Default.AllocateReadWriteBuffer<float>(16);
using ReadWriteBuffer<float> buffer0 = GraphicsDevice.GetDefault().AllocateReadWriteBuffer<float>(16);
using ReadWriteBuffer<float> buffer1 = GraphicsDevice.GetDefault().AllocateReadWriteBuffer<float>(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<float> buffer = GraphicsDevice.Default.AllocateReadWriteBuffer<float>(16);
using ReadWriteBuffer<float> buffer = GraphicsDevice.GetDefault().AllocateReadWriteBuffer<float>(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<float> buffer = GraphicsDevice.Default.AllocateReadWriteBuffer<float>(16);
using ReadWriteBuffer<float> buffer = GraphicsDevice.GetDefault().AllocateReadWriteBuffer<float>(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<float> buffer = GraphicsDevice.Default.AllocateReadWriteBuffer<float>(16);
using ReadWriteBuffer<float> buffer = GraphicsDevice.GetDefault().AllocateReadWriteBuffer<float>(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<float> buffer = GraphicsDevice.Default.AllocateReadWriteBuffer<float>(16);
using ReadWriteBuffer<float> buffer = GraphicsDevice.GetDefault().AllocateReadWriteBuffer<float>(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<float> a = GraphicsDevice.Default.AllocateReadWriteBuffer<float>(16);
using ReadWriteBuffer<float> b = GraphicsDevice.Default.AllocateReadWriteBuffer<float>(16);
using ReadWriteBuffer<float> c = GraphicsDevice.Default.AllocateReadWriteBuffer<float>(16);
using ReadWriteBuffer<float> x = GraphicsDevice.Default.AllocateReadWriteBuffer<float>(16);
using ReadWriteBuffer<float> y = GraphicsDevice.Default.AllocateReadWriteBuffer<float>(16);
using ReadWriteBuffer<float> z = GraphicsDevice.Default.AllocateReadWriteBuffer<float>(16);
using ReadWriteBuffer<float> a = GraphicsDevice.GetDefault().AllocateReadWriteBuffer<float>(16);
using ReadWriteBuffer<float> b = GraphicsDevice.GetDefault().AllocateReadWriteBuffer<float>(16);
using ReadWriteBuffer<float> c = GraphicsDevice.GetDefault().AllocateReadWriteBuffer<float>(16);
using ReadWriteBuffer<float> x = GraphicsDevice.GetDefault().AllocateReadWriteBuffer<float>(16);
using ReadWriteBuffer<float> y = GraphicsDevice.GetDefault().AllocateReadWriteBuffer<float>(16);
using ReadWriteBuffer<float> z = GraphicsDevice.GetDefault().AllocateReadWriteBuffer<float>(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);
+2 -2
ファイルの表示
@@ -25,7 +25,7 @@ public partial class ShaderHashCodeTests
public void ShaderWithNoCapturedDelegates()
{
float value = 10;
using ReadWriteBuffer<float> buffer = GraphicsDevice.Default.AllocateReadWriteBuffer<float>(1);
using ReadWriteBuffer<float> buffer = GraphicsDevice.GetDefault().AllocateReadWriteBuffer<float>(1);
Shader1 shader1 = new() { A = value, B = buffer };
@@ -58,7 +58,7 @@ public partial class ShaderHashCodeTests
{
Func<float, float> f = static x => x * x;
using ReadWriteBuffer<float> buffer = GraphicsDevice.Default.AllocateReadWriteBuffer<float>(1);
using ReadWriteBuffer<float> buffer = GraphicsDevice.GetDefault().AllocateReadWriteBuffer<float>(1);
Shader2 shader1 = new() { A = 1, B = buffer, F = f };
+6 -6
ファイルの表示
@@ -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<float>(128);
using var before = GraphicsDevice.GetDefault().AllocateReadOnlyBuffer<float>(128);
GraphicsDevice.Default.Dispose();
GraphicsDevice.GetDefault().Dispose();
using var after = GraphicsDevice.Default.AllocateReadOnlyBuffer<float>(128);
using var after = GraphicsDevice.GetDefault().AllocateReadOnlyBuffer<float>(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<int> buffer = device.AllocateReadWriteBuffer<int>(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<int> buffer = device.AllocateReadWriteBuffer<int>(128);