Add configuration switch to enable DRED

Using "COMPUTESHARP_ENABLE_DEVICE_REMOVED_EXTENDED_DATA"
このコミットが含まれているのは:
Sergio Pedri committed 2022-06-19 02:57:58 +02:00
1 親 1d19f5f4cd
コミット 16ccc67bd9
7ファイル変更
+146

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

+2
ファイルの表示
@@ -105,6 +105,8 @@ internal static partial class DeviceHelper
{
this.isInitialized = true;
EnsureDeviceRemovedExtendedDataConfiguration();
fixed (IDXGIFactory6** dxgiFactory6 = this.dxgiFactory6)
{
CreateDXGIFactory6(dxgiFactory6);
+52
ファイルの表示
@@ -1,8 +1,12 @@
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using ComputeSharp.Core.Extensions;
using ComputeSharp.Graphics.Extensions;
using TerraFX.Interop.DirectX;
using TerraFX.Interop.Windows;
#pragma warning disable CA1416
namespace ComputeSharp.Graphics.Helpers;
/// <inheritdoc/>
@@ -18,6 +22,54 @@ internal static partial class DeviceHelper
/// </summary>
private static readonly Dictionary<Luid, ComPtr<ID3D12InfoQueue>> D3D12InfoQueueMap = new();
/// <summary>
/// Indicates whether or not DRED is enabled (see <see href="https://devblogs.microsoft.com/directx/dred/"/>).
/// </summary>
private static volatile bool IsDeviceRemovedExtendedDataConfigurationEnabled;
/// <summary>
/// Ensures the DRED settings are enabled, if not already. If DRED is not configured, this method does nothing.
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static unsafe void EnsureDeviceRemovedExtendedDataConfiguration()
{
// Enables DRED, if not enabled already
[MethodImpl(MethodImplOptions.NoInlining)]
static void EnableDeviceRemovedExtendedDataConfigurationIfNeeded()
{
if (IsDeviceRemovedExtendedDataConfigurationEnabled)
{
return;
}
lock (DevicesCache)
{
if (IsDeviceRemovedExtendedDataConfigurationEnabled)
{
return;
}
using ComPtr<ID3D12DeviceRemovedExtendedDataSettings> d3D12DeviceRemovedExtendedDataSettings = default;
DirectX.D3D12GetDebugInterface(
riid: Windows.__uuidof<ID3D12DeviceRemovedExtendedDataSettings>(),
ppvDebug: d3D12DeviceRemovedExtendedDataSettings.GetVoidAddressOf()).Assert();
// Enable the auto-breadcrumbs and page faults reporting
d3D12DeviceRemovedExtendedDataSettings.Get()->SetAutoBreadcrumbsEnablement(D3D12_DRED_ENABLEMENT.D3D12_DRED_ENABLEMENT_FORCED_ON);
d3D12DeviceRemovedExtendedDataSettings.Get()->SetPageFaultEnablement(D3D12_DRED_ENABLEMENT.D3D12_DRED_ENABLEMENT_FORCED_ON);
IsDeviceRemovedExtendedDataConfigurationEnabled = true;
}
}
// If the app context switch is set, ensure the DRED setting is enabled
if (Configuration.IsDeviceRemovedExtendedDataEnabled)
{
EnableDeviceRemovedExtendedDataConfigurationIfNeeded();
}
}
/// <summary>
/// Retrieves a <see cref="GraphicsDevice"/> instance for an <see cref="ID3D12Device"/> object.
/// </summary>
+4
ファイルの表示
@@ -81,6 +81,8 @@ internal static partial class DeviceHelper
/// <returns>Whether a default device was found with the requested feature level.</returns>
private static unsafe bool TryGetDefaultDevice(ID3D12Device** d3D12Device, IDXGIAdapter** dxgiAdapter, DXGI_ADAPTER_DESC1* dxgiDescription1)
{
EnsureDeviceRemovedExtendedDataConfiguration();
using ComPtr<IDXGIFactory6> dxgiFactory6 = default;
CreateDXGIFactory6(dxgiFactory6.GetAddressOf());
@@ -173,6 +175,8 @@ internal static partial class DeviceHelper
/// <returns>Whether a warp device was created successfully.</returns>
private static unsafe bool TryGetWarpDevice(ID3D12Device** d3D12Device, IDXGIAdapter** dxgiAdapter, DXGI_ADAPTER_DESC1* dxgiDescription1)
{
EnsureDeviceRemovedExtendedDataConfiguration();
using ComPtr<IDXGIFactory6> dxgiFactory6 = default;
CreateDXGIFactory6(dxgiFactory6.GetAddressOf());
+10
ファイルの表示
@@ -13,11 +13,21 @@ internal static class Configuration
/// </summary>
private const string EnableDebugOutput = "COMPUTESHARP_ENABLE_DEBUG_OUTPUT";
/// <summary>
/// The configuration property name for <see cref="IsDeviceRemovedExtendedDataEnabled"/>.
/// </summary>
private const string EnableDeviceRemovedExtendedDataInfo = "COMPUTESHARP_ENABLE_DEVICE_REMOVED_EXTENDED_DATA";
/// <summary>
/// Indicates whether or not the debug output is enabled.
/// </summary>
public static readonly bool IsDebugOutputEnabled = GetConfigurationValue(EnableDebugOutput);
/// <summary>
/// Indicates whether or not the debug output is enabled.
/// </summary>
public static readonly bool IsDeviceRemovedExtendedDataEnabled = GetConfigurationValue(EnableDeviceRemovedExtendedDataInfo);
/// <summary>
/// Gets a configuration value for a specified property.
/// </summary>
+14
ファイルの表示
@@ -0,0 +1,14 @@
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
// Ported from d3d12.h in Microsoft.Direct3D.D3D12 v1.600.10
// Original source is Copyright © Microsoft. Licensed under the MIT license
namespace TerraFX.Interop.DirectX
{
internal enum D3D12_DRED_ENABLEMENT
{
D3D12_DRED_ENABLEMENT_SYSTEM_CONTROLLED = 0,
D3D12_DRED_ENABLEMENT_FORCED_OFF = 1,
D3D12_DRED_ENABLEMENT_FORCED_ON = 2,
}
}
@@ -0,0 +1,62 @@
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
// Ported from d3d12.h in Microsoft.Direct3D.D3D12 v1.600.10
// Original source is Copyright © Microsoft. Licensed under the MIT license
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using TerraFX.Interop.Windows;
namespace TerraFX.Interop.DirectX
{
[Guid("82BC481C-6B9B-4030-AEDB-7EE3D1DF1E63")]
[NativeTypeName("struct ID3D12DeviceRemovedExtendedDataSettings : IUnknown")]
[NativeInheritance("IUnknown")]
internal unsafe partial struct ID3D12DeviceRemovedExtendedDataSettings
{
public void** lpVtbl;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[VtblIndex(0)]
public HRESULT QueryInterface([NativeTypeName("const IID &")] Guid* riid, void** ppvObject)
{
return ((delegate* unmanaged[Stdcall]<ID3D12DeviceRemovedExtendedDataSettings*, Guid*, void**, int>)(lpVtbl[0]))((ID3D12DeviceRemovedExtendedDataSettings*)Unsafe.AsPointer(ref this), riid, ppvObject);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[VtblIndex(1)]
public uint AddRef()
{
return ((delegate* unmanaged[Stdcall]<ID3D12DeviceRemovedExtendedDataSettings*, uint>)(lpVtbl[1]))((ID3D12DeviceRemovedExtendedDataSettings*)Unsafe.AsPointer(ref this));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[VtblIndex(2)]
public uint Release()
{
return ((delegate* unmanaged[Stdcall]<ID3D12DeviceRemovedExtendedDataSettings*, uint>)(lpVtbl[2]))((ID3D12DeviceRemovedExtendedDataSettings*)Unsafe.AsPointer(ref this));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[VtblIndex(3)]
public void SetAutoBreadcrumbsEnablement(D3D12_DRED_ENABLEMENT Enablement)
{
((delegate* unmanaged[Stdcall]<ID3D12DeviceRemovedExtendedDataSettings*, D3D12_DRED_ENABLEMENT, void>)(lpVtbl[3]))((ID3D12DeviceRemovedExtendedDataSettings*)Unsafe.AsPointer(ref this), Enablement);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[VtblIndex(4)]
public void SetPageFaultEnablement(D3D12_DRED_ENABLEMENT Enablement)
{
((delegate* unmanaged[Stdcall]<ID3D12DeviceRemovedExtendedDataSettings*, D3D12_DRED_ENABLEMENT, void>)(lpVtbl[4]))((ID3D12DeviceRemovedExtendedDataSettings*)Unsafe.AsPointer(ref this), Enablement);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[VtblIndex(5)]
public void SetWatsonDumpEnablement(D3D12_DRED_ENABLEMENT Enablement)
{
((delegate* unmanaged[Stdcall]<ID3D12DeviceRemovedExtendedDataSettings*, D3D12_DRED_ENABLEMENT, void>)(lpVtbl[5]))((ID3D12DeviceRemovedExtendedDataSettings*)Unsafe.AsPointer(ref this), Enablement);
}
}
}
+2
ファイルの表示
@@ -98,6 +98,7 @@
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\d3d12\D3D12_DESCRIPTOR_RANGE1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\d3d12\D3D12_DESCRIPTOR_RANGE_FLAGS.cs" />
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\d3d12\D3D12_DESCRIPTOR_RANGE_TYPE.cs" />
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\d3d12\D3D12_DRED_ENABLEMENT.cs" />
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\d3d12\D3D12_FEATURE.cs" />
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\d3d12\D3D12_FEATURE_DATA_ARCHITECTURE.cs" />
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\d3d12\D3D12_FEATURE_DATA_ARCHITECTURE1.cs" />
@@ -188,6 +189,7 @@
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\d3d12\ID3D12CommandQueue.cs" />
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\d3d12\ID3D12DescriptorHeap.cs" />
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\d3d12\ID3D12Device.cs" />
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\d3d12\ID3D12DeviceRemovedExtendedDataSettings.cs" />
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\d3d12\ID3D12Fence.cs" />
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\d3d12\ID3D12GraphicsCommandList.cs" />
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\d3d12\ID3D12Heap.cs" />