Remove GraphicsDevice.Default property and APIs

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

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

+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)]