Added check to avoid disposing of default device

このコミットが含まれているのは:
Sergio Pedri committed 2020-11-21 21:53:05 +01:00
1 親 aa55ac5043
コミット c2a1980596
3ファイル変更
+18 -1

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

+2
ファイルの表示
@@ -203,6 +203,8 @@ namespace ComputeSharp.Graphics
/// <inheritdoc/>
protected override void OnDispose()
{
if (DeviceHelper.GetDefaultDeviceLuid() == Luid) return;
DeviceHelper.NotifyDisposedDevice(this);
this.d3D12Device.Dispose();
+1 -1
ファイルの表示
@@ -13,7 +13,7 @@ namespace ComputeSharp.Graphics
/// <param name="description">The available info for the associate device.</param>
internal unsafe GraphicsDeviceInfo(DXGI_ADAPTER_DESC1* dxgiDescription1)
{
Luid = *(Luid*)&dxgiDescription1->AdapterLuid;
Luid = Luid.FromLUID(dxgiDescription1->AdapterLuid);
Name = new string((char*)dxgiDescription1->Description);
MemorySize = dxgiDescription1->DedicatedVideoMemory;
}
+15
ファイルの表示
@@ -26,6 +26,21 @@ namespace ComputeSharp.Graphics.Helpers
return TryGetDefaultDevice(null, &dxgiDescription1);
}
/// <summary>
/// Gets the <see cref="Luid"/> of the default device.
/// </summary>
/// <returns>The <see cref="Luid"/> of the default device supporting at least DX12.0.</returns>
/// <remarks>This methods assumes that a default device is available.</remarks>
[Pure]
public static unsafe Luid GetDefaultDeviceLuid()
{
DXGI_ADAPTER_DESC1 dxgiDescription1;
_ = TryGetDefaultDevice(null, &dxgiDescription1);
return Luid.FromLUID(dxgiDescription1.AdapterLuid);
}
/// <summary>
/// Gets the default <see cref="GraphicsDevice"/> instance.
/// </summary>