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);
}
}