Fix incorrect cleanup of device lost event handle

このコミットが含まれているのは:
Sergio Pedri committed 2022-07-31 23:26:10 +02:00
1 親 3f77e0a9b5
コミット b50de2528f
2ファイル変更
+16 -5

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

+9 -3
ファイルの表示
@@ -105,7 +105,12 @@ unsafe partial class GraphicsDevice
/// <param name="device">The current <see cref="GraphicsDevice"/> instance.</param>
/// <param name="deviceHandle">The resulting <see cref="GCHandle"/> used as callback state.</param>
/// <param name="deviceRemovedEvent">The resulting device lost event for the callback.</param>
private static void RegisterDeviceLostCallback(GraphicsDevice device, out GCHandle deviceHandle, out HANDLE deviceRemovedEvent)
/// <param name="deviceRemovedWaitHandle">The resulting device lost wait handle for the callback.</param>
private static void RegisterDeviceLostCallback(
GraphicsDevice device,
out GCHandle deviceHandle,
out HANDLE deviceRemovedEvent,
out HANDLE deviceRemovedWaitHandle)
{
HANDLE eventHandle = Windows.CreateEventW(null, Windows.FALSE, Windows.FALSE, null);
@@ -128,7 +133,8 @@ unsafe partial class GraphicsDevice
dwMilliseconds: Windows.INFINITE,
dwFlags: 0);
deviceRemovedEvent = waitHandle;
deviceRemovedEvent = eventHandle;
deviceRemovedWaitHandle = waitHandle;
}
/// <summary>
@@ -137,7 +143,7 @@ unsafe partial class GraphicsDevice
/// <param name="device">The current <see cref="GraphicsDevice"/> instance.</param>
private static void UnregisterDeviceLostCallback(GraphicsDevice device)
{
_ = Windows.UnregisterWait(device.deviceRemovedEvent);
_ = Windows.UnregisterWait(device.deviceRemovedWaitHandle);
_ = Windows.CloseHandle(device.deviceRemovedEvent);
device.deviceHandle.Free();
+7 -2
ファイルの表示
@@ -93,10 +93,15 @@ public sealed unsafe partial class GraphicsDevice : NativeObject
private GCHandle deviceHandle;
/// <summary>
/// The wait event for the device removed.
/// The event for the device removed callback.
/// </summary>
private HANDLE deviceRemovedEvent;
/// <summary>
/// The wait handle for the device removed callback.
/// </summary>
private HANDLE deviceRemovedWaitHandle;
/// <summary>
/// The reason the device was removed, if any.
/// </summary>
@@ -166,7 +171,7 @@ public sealed unsafe partial class GraphicsDevice : NativeObject
this.deviceRemovedReason = S.S_OK;
RegisterDeviceLostCallback(this, out this.deviceHandle, out this.deviceRemovedEvent);
RegisterDeviceLostCallback(this, out this.deviceHandle, out this.deviceRemovedEvent, out this.deviceRemovedWaitHandle);
}
/// <summary>