Add DeviceLostEventArgs type

このコミットが含まれているのは:
Sergio Pedri committed 2022-07-31 23:26:14 +02:00
1 親 7396d0c974
コミット 480004be21
4ファイル変更
+28 -5

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

+23
ファイルの表示
@@ -0,0 +1,23 @@
using System;
namespace ComputeSharp;
/// <summary>
/// The arguments for the <see cref="GraphicsDevice.DeviceLost"/> event.
/// </summary>
public sealed class DeviceLostEventArgs : EventArgs
{
/// <summary>
/// Creates a new <see cref="DeviceLostEventArgs"/> instance with the specified arguments.
/// </summary>
/// <param name="reason">The <see cref="DeviceLostReason"/> value for the event.</param>
internal DeviceLostEventArgs(DeviceLostReason reason)
{
Reason = reason;
}
/// <summary>
/// Gets the reason that caused the device to be lost.
/// </summary>
public DeviceLostReason Reason { get; }
}
+1 -1
ファイルの表示
@@ -96,7 +96,7 @@ unsafe partial class GraphicsDevice
_ => DeviceLostReason.UnspecifiedError
};
device.DeviceLost?.Invoke(device, reason);
device.DeviceLost?.Invoke(device, new DeviceLostEventArgs(reason));
}
ThreadPool.QueueUserWorkItem(static state => RaiseDeviceLostEvent((GraphicsDevice)state!), this);
+1 -1
ファイルの表示
@@ -137,7 +137,7 @@ public sealed unsafe partial class GraphicsDevice : NativeObject
/// the event is raised asynchronously with respect to the device being lost, and on a thread pool thread.
/// </para>
/// </remarks>
public event EventHandler<DeviceLostReason>? DeviceLost;
public event EventHandler<DeviceLostEventArgs>? DeviceLost;
/// <summary>
/// Creates a new <see cref="GraphicsDevice"/> instance for the input <see cref="ID3D12Device"/>.
+3 -3
ファイルの表示
@@ -18,7 +18,7 @@ public class DeviceLostTests
{
using GraphicsDevice graphicsDevice = device.Get();
List<(object? Sender, DeviceLostReason Reason)> args = new();
List<(object? Sender, DeviceLostEventArgs Args)> args = new();
// Register the device lost callback
graphicsDevice.DeviceLost += (s, e) => args.Add((s, e));
@@ -27,9 +27,9 @@ public class DeviceLostTests
Assert.AreEqual(1, args.Count);
Assert.IsNotNull(args[0].Sender);
Assert.IsNotNull(args[0].Reason);
Assert.IsNotNull(args[0].Args);
Assert.AreSame(args[0].Sender, graphicsDevice);
Assert.AreEqual(args[0].Reason, DeviceLostReason.DeviceRemoved);
Assert.AreEqual(args[0].Args.Reason, DeviceLostReason.DeviceRemoved);
// Trying to remove the device again does nothing
GraphicsDeviceHelper.RemoveDevice(graphicsDevice);