Improve debug output when a device is removed
このコミットが含まれているのは:
1 親
1fa665fe88
コミット
878f6da329
1ファイル変更
+24
-23
@@ -4,6 +4,7 @@ using System.Text;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
using static TerraFX.Interop.DirectX.D3D12_MESSAGE_ID;
|
||||
using static TerraFX.Interop.DirectX.D3D12_MESSAGE_SEVERITY;
|
||||
#if NET6_0_OR_GREATER
|
||||
using Enum = System.Enum;
|
||||
@@ -58,6 +59,29 @@ internal static partial class DeviceHelper
|
||||
builder.AppendLine($"[Category]: {Enum.GetName(message->Category)}");
|
||||
builder.AppendLine($"[Severity]: {Enum.GetName(message->Severity)}");
|
||||
builder.AppendLine($"[ID]: {Enum.GetName(message->ID)}");
|
||||
|
||||
// Special handling for device removal messages
|
||||
if (message->ID is D3D12_MESSAGE_ID_DEVICE_REMOVAL_PROCESS_AT_FAULT or D3D12_MESSAGE_ID_DEVICE_REMOVAL_PROCESS_POSSIBLY_AT_FAULT or D3D12_MESSAGE_ID_DEVICE_REMOVAL_PROCESS_NOT_AT_FAULT)
|
||||
{
|
||||
HRESULT result = device.D3D12Device->GetDeviceRemovedReason();
|
||||
|
||||
// If the device removal reason is available, also include that in the output message
|
||||
if (result != S.S_OK)
|
||||
{
|
||||
string deviceRemovalReason = (int)result switch
|
||||
{
|
||||
DXGI.DXGI_ERROR_DEVICE_HUNG => nameof(DXGI.DXGI_ERROR_DEVICE_HUNG),
|
||||
DXGI.DXGI_ERROR_DEVICE_REMOVED => nameof(DXGI.DXGI_ERROR_DEVICE_REMOVED),
|
||||
DXGI.DXGI_ERROR_DEVICE_RESET => nameof(DXGI.DXGI_ERROR_DEVICE_RESET),
|
||||
DXGI.DXGI_ERROR_DRIVER_INTERNAL_ERROR => nameof(DXGI.DXGI_ERROR_DRIVER_INTERNAL_ERROR),
|
||||
DXGI.DXGI_ERROR_INVALID_CALL => nameof(DXGI.DXGI_ERROR_INVALID_CALL),
|
||||
_ => ThrowHelper.ThrowArgumentOutOfRangeException<string>("Invalid GetDeviceRemovedReason HRESULT.")
|
||||
};
|
||||
|
||||
builder.AppendLine($"[Reason]: {deviceRemovalReason}");
|
||||
}
|
||||
}
|
||||
|
||||
builder.Append($"[Description]: \"{new string(message->pDescription)}\"");
|
||||
}
|
||||
finally
|
||||
@@ -74,29 +98,6 @@ internal static partial class DeviceHelper
|
||||
}
|
||||
|
||||
queue->ClearStoredMessages();
|
||||
|
||||
HRESULT result = device.D3D12Device->GetDeviceRemovedReason();
|
||||
|
||||
if (result != S.S_OK)
|
||||
{
|
||||
string message = (int)result switch
|
||||
{
|
||||
DXGI.DXGI_ERROR_DEVICE_HUNG => nameof(DXGI.DXGI_ERROR_DEVICE_HUNG),
|
||||
DXGI.DXGI_ERROR_DEVICE_REMOVED => nameof(DXGI.DXGI_ERROR_DEVICE_REMOVED),
|
||||
DXGI.DXGI_ERROR_DEVICE_RESET => nameof(DXGI.DXGI_ERROR_DEVICE_RESET),
|
||||
DXGI.DXGI_ERROR_DRIVER_INTERNAL_ERROR => nameof(DXGI.DXGI_ERROR_DRIVER_INTERNAL_ERROR),
|
||||
DXGI.DXGI_ERROR_INVALID_CALL => nameof(DXGI.DXGI_ERROR_INVALID_CALL),
|
||||
_ => ThrowHelper.ThrowArgumentOutOfRangeException<string>("Invalid GetDeviceRemovedReason HRESULT.")
|
||||
};
|
||||
|
||||
builder.Clear();
|
||||
builder.AppendLine($"[D3D12 device \"{device}\" removed (HW: {device.IsHardwareAccelerated}, UMA: {device.IsCacheCoherentUMA})]");
|
||||
builder.AppendLine($"[Reason]: {message}");
|
||||
|
||||
hasErrorsOrWarnings = true;
|
||||
|
||||
Trace.WriteLine(builder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする