Added prototype for ID3D12InfoQueue

このコミットが含まれているのは:
Sergio Pedri committed 2021-02-14 22:26:03 +01:00
1 親 cf5fa57bfe
コミット 35ffb4ed43
3ファイル変更
+86 -10

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

+3
ファイルの表示
@@ -1,6 +1,7 @@
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using ComputeSharp.Graphics.Helpers;
using Microsoft.Toolkit.Diagnostics;
using HRESULT = System.Int32;
@@ -22,6 +23,8 @@ namespace ComputeSharp.Core.Extensions
{
if (result < 0)
{
DeviceDebugHelper.FlushMessages();
ThrowHelper.ThrowWin32Exception(result);
}
}
+82 -2
ファイルの表示
@@ -1,15 +1,86 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Text;
using ComputeSharp.Core.Extensions;
using TerraFX.Interop;
namespace ComputeSharp.Graphics.Helpers
{
internal static class DeviceDebugHelper
{
public static unsafe void FlushMessages()
{
int j = 0;
foreach (var pair in DeviceHelper.D3D12InfoQueueMap)
{
var device = DeviceHelper.DevicesCache[pair.Key];
var queue = pair.Value;
ulong messages = queue.Get()->GetNumStoredMessages();
if (messages > 0)
{
var builder = new StringBuilder();
builder.AppendLine("====================[ID3D12InfoQueue]====================");
builder.AppendLine($"[ID3D12InfoQueue messages for device #{j}");
builder.AppendLine($"[LUID]: {device.Luid}");
builder.AppendLine($"[NAME]: {device.Name}");
builder.AppendLine($"[DEDICATED MEMORY]: {device.DedicatedMemorySize}");
builder.AppendLine($"[IS HARDWARE]: {device.IsHardwareAccelerated}");
builder.AppendLine($"[IS UMA]: {device.IsCacheCoherentUMA}");
builder.AppendLine($"[COMPUTE UNITS]: {device.ComputeUnits}");
builder.AppendLine($"[WAVE SIZE]: {device.WavefrontSize}");
builder.Append("=========================================================");
for (ulong i = 0; i < messages; i++)
{
nuint length;
queue.Get()->GetMessage(i, null, &length);
D3D12_MESSAGE* message = (D3D12_MESSAGE*)Marshal.AllocHGlobal((nint)length);
queue.Get()->GetMessage(i, message, &length);
builder.AppendLine();
builder.AppendLine($"[D3D12 DEBUG MESSAGE #{i}]");
builder.AppendLine($"[CATEGORY]: {Enum.GetName(message->Category)}");
builder.AppendLine($"[SEVERITY]: {Enum.GetName(message->Severity)}");
builder.AppendLine($"[ID]: {Enum.GetName(message->ID)}");
builder.AppendLine($"[INFO]: \"{new string(message->pDescription)}\"");
builder.Append("=========================================================");
Marshal.FreeHGlobal((IntPtr)message);
}
string text = builder.ToString();
Console.WriteLine(text);
if (Debugger.IsAttached)
{
Debug.WriteLine(text);
}
queue.Get()->ClearStoredMessages();
}
j++;
}
}
}
/// <inheritdoc/>
internal static partial class DeviceHelper
{
/// <summary>
/// The local cache of <see cref="GraphicsDevice"/> instances that are currently usable.
/// </summary>
private static readonly Dictionary<Luid, GraphicsDevice> DevicesCache = new();
internal static readonly Dictionary<Luid, GraphicsDevice> DevicesCache = new();
internal static readonly Dictionary<Luid, ComPtr<ID3D12InfoQueue>> D3D12InfoQueueMap = new();
/// <summary>
/// Retrieves a <see cref="GraphicsDevice"/> instance for an <see cref="ID3D12Device"/> object.
@@ -28,6 +99,12 @@ namespace ComputeSharp.Graphics.Helpers
device = new GraphicsDevice(d3D12Device, dxgiDescription1);
DevicesCache.Add(luid, device);
ComPtr<ID3D12InfoQueue> d3D12InfoQueue = default;
int res = d3D12Device.Get()->QueryInterface(Windows.__uuidof<ID3D12InfoQueue>(), d3D12InfoQueue.GetVoidAddressOf());
D3D12InfoQueueMap.Add(luid, d3D12InfoQueue);
}
return device;
@@ -43,6 +120,9 @@ namespace ComputeSharp.Graphics.Helpers
lock (DevicesCache)
{
DevicesCache.Remove(device.Luid);
D3D12InfoQueueMap.Remove(device.Luid, out var queue);
queue.Dispose();
}
}
}
+1 -8
ファイルの表示
@@ -1,5 +1,4 @@
using System;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using ComputeSharp.Core.Extensions;
using Microsoft.Toolkit.Diagnostics;
@@ -139,17 +138,11 @@ namespace ComputeSharp.Graphics.Helpers
/// <summary>
/// The creation flags for <see cref="IDXGIFactory"/> instances.
/// </summary>
private const uint IDXGIFactoryCreationFlags =
#if DEBUG
FX.DXGI_CREATE_FACTORY_DEBUG;
#else
0;
#endif
private const uint IDXGIFactoryCreationFlags = FX.DXGI_CREATE_FACTORY_DEBUG;
/// <summary>
/// Enables the debug layer for DirectX APIs.
/// </summary>
[Conditional("DEBUG")]
private static unsafe void EnableDebugMode()
{
using ComPtr<ID3D12Debug> d3D12Debug = default;