diff --git a/src/ComputeSharp/Graphics/Extensions/Interop/ID3D12ResourceExtensions.cs b/src/ComputeSharp/Graphics/Extensions/Interop/ID3D12ResourceExtensions.cs
index 3d46e96e..fdca3723 100644
--- a/src/ComputeSharp/Graphics/Extensions/Interop/ID3D12ResourceExtensions.cs
+++ b/src/ComputeSharp/Graphics/Extensions/Interop/ID3D12ResourceExtensions.cs
@@ -17,6 +17,7 @@ internal static unsafe class ID3D12ResourceExtensions
///
/// The target to map.
/// A instance representing the mapped resource.
+ /// Thrown when the mapping operation fails.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ID3D12ResourceMap Map(this ref ID3D12Resource d3D12Resource)
{
@@ -32,7 +33,6 @@ internal static unsafe class ID3D12ResourceExtensions
///
/// The target to map.
/// A pointer to the mapped area for .
- /// Thrown when the mapping operation fails.
/// Only use this method to unmap resources that were mapped with .
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Unmap(this ref ID3D12Resource d3D12Resource)
@@ -43,9 +43,8 @@ internal static unsafe class ID3D12ResourceExtensions
///
/// Assigns a name to a given .
///
- /// The target to map.
+ /// The target to set the name for.
/// The wrapper object to get the name from.
- /// Thrown when the mapping operation fails.
[Conditional("DEBUG")]
public static void SetName(this ref ID3D12Resource d3D12Resource, object wrapper)
{
diff --git a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Enumerator.cs b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Enumerator.cs
index d28e9b75..795cc5d2 100644
--- a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Enumerator.cs
+++ b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Enumerator.cs
@@ -105,8 +105,6 @@ internal static partial class DeviceHelper
{
this.isInitialized = true;
- EnsureDeviceRemovedExtendedDataConfiguration();
-
fixed (IDXGIFactory6** dxgiFactory6 = this.dxgiFactory6)
{
CreateDXGIFactory6(dxgiFactory6);
diff --git a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Factory.cs b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Factory.cs
index dacfc5ff..95b02175 100644
--- a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Factory.cs
+++ b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Factory.cs
@@ -1,12 +1,8 @@
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;
///
@@ -22,54 +18,6 @@ internal static partial class DeviceHelper
///
private static readonly Dictionary> D3D12InfoQueueMap = new();
- ///
- /// Indicates whether or not DRED is enabled (see ).
- ///
- private static volatile bool IsDeviceRemovedExtendedDataConfigurationEnabled;
-
- ///
- /// Ensures the DRED settings are enabled, if not already. If DRED is not configured, this method does nothing.
- ///
- [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 d3D12DeviceRemovedExtendedDataSettings = default;
-
- DirectX.D3D12GetDebugInterface(
- riid: Windows.__uuidof(),
- 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();
- }
- }
-
///
/// Retrieves a instance for an object.
///
diff --git a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.IDXGIFactory6.cs b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.IDXGIFactory6.cs
index f8b28b9e..c85dcb01 100644
--- a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.IDXGIFactory6.cs
+++ b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.IDXGIFactory6.cs
@@ -33,13 +33,18 @@ internal static partial class DeviceHelper
/// The resulting instance.
internal static unsafe void CreateDXGIFactory6(IDXGIFactory6** dxgiFactory6)
{
- using ComPtr dxgiFactory4 = default;
-
if (Configuration.IsDebugOutputEnabled)
{
EnableDebugMode();
}
+ if (Configuration.IsDeviceRemovedExtendedDataEnabled)
+ {
+ EnableDeviceRemovedExtendedDataConfiguration();
+ }
+
+ using ComPtr dxgiFactory4 = default;
+
DirectX.CreateDXGIFactory2(IDXGIFactoryCreationFlags, Windows.__uuidof(), dxgiFactory4.GetVoidAddressOf()).Assert();
HRESULT result = dxgiFactory4.CopyTo(dxgiFactory6);
@@ -80,6 +85,22 @@ internal static partial class DeviceHelper
}
}
+ ///
+ /// Enables the DRED settings are enabled (see ).
+ ///
+ private static unsafe void EnableDeviceRemovedExtendedDataConfiguration()
+ {
+ using ComPtr d3D12DeviceRemovedExtendedDataSettings = default;
+
+ DirectX.D3D12GetDebugInterface(
+ riid: Windows.__uuidof(),
+ 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);
+ }
+
///
/// A custom fallback implementation to use on systems with no support for it.
///
diff --git a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.cs b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.cs
index bc5d79b3..d31e3065 100644
--- a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.cs
+++ b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.cs
@@ -81,8 +81,6 @@ internal static partial class DeviceHelper
/// Whether a default device was found with the requested feature level.
private static unsafe bool TryGetDefaultDevice(ID3D12Device** d3D12Device, IDXGIAdapter** dxgiAdapter, DXGI_ADAPTER_DESC1* dxgiDescription1)
{
- EnsureDeviceRemovedExtendedDataConfiguration();
-
using ComPtr dxgiFactory6 = default;
CreateDXGIFactory6(dxgiFactory6.GetAddressOf());
@@ -175,8 +173,6 @@ internal static partial class DeviceHelper
/// Whether a warp device was created successfully.
private static unsafe bool TryGetWarpDevice(ID3D12Device** d3D12Device, IDXGIAdapter** dxgiAdapter, DXGI_ADAPTER_DESC1* dxgiDescription1)
{
- EnsureDeviceRemovedExtendedDataConfiguration();
-
using ComPtr dxgiFactory6 = default;
CreateDXGIFactory6(dxgiFactory6.GetAddressOf());