diff --git a/src/ComputeSharp.Graphics/Extensions/ID3D12DeviceExtensions.cs b/src/ComputeSharp.Graphics/Extensions/ID3D12DeviceExtensions.cs
index 5e3d17f6..8a6f278c 100644
--- a/src/ComputeSharp.Graphics/Extensions/ID3D12DeviceExtensions.cs
+++ b/src/ComputeSharp.Graphics/Extensions/ID3D12DeviceExtensions.cs
@@ -9,6 +9,7 @@ using static TerraFX.Interop.D3D12_COMMAND_QUEUE_PRIORITY;
using static TerraFX.Interop.D3D12_CPU_PAGE_PROPERTY;
using static TerraFX.Interop.D3D12_DESCRIPTOR_HEAP_FLAGS;
using static TerraFX.Interop.D3D12_DESCRIPTOR_HEAP_TYPE;
+using static TerraFX.Interop.D3D12_FEATURE;
using static TerraFX.Interop.D3D12_FENCE_FLAGS;
using static TerraFX.Interop.D3D12_MEMORY_POOL;
using static TerraFX.Interop.D3D12_HEAP_FLAGS;
@@ -448,5 +449,23 @@ namespace ComputeSharp.Graphics.Extensions
return feature;
}
+
+ ///
+ /// Checks whether or not a given DXGI format is supported for the specified resource type.
+ ///
+ /// The target to use to check features for.
+ /// The type to check support for.
+ /// The resource type to check support for.
+ /// Whether or not the input device supports the requested format for the specified resource type.
+ [Pure]
+ public static unsafe bool IsDxgiFormatSupported(this ref ID3D12Device d3D12Device, DXGI_FORMAT dxgiFormat, D3D12_FORMAT_SUPPORT1 d3D12FormatSupport1)
+ {
+ D3D12_FEATURE_DATA_FORMAT_SUPPORT d3D12FeatureDataFormatSupport = default;
+ d3D12FeatureDataFormatSupport.Format = dxgiFormat;
+
+ d3D12Device.CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT, &d3D12FeatureDataFormatSupport, (uint)sizeof(D3D12_FEATURE_DATA_FORMAT_SUPPORT)).Assert();
+
+ return (d3D12FeatureDataFormatSupport.Support1 & d3D12FormatSupport1) != 0;
+ }
}
}
diff --git a/src/ComputeSharp.Graphics/GraphicsDevice.cs b/src/ComputeSharp.Graphics/GraphicsDevice.cs
index a5e18802..92503ee7 100644
--- a/src/ComputeSharp.Graphics/GraphicsDevice.cs
+++ b/src/ComputeSharp.Graphics/GraphicsDevice.cs
@@ -1,4 +1,5 @@
using System.Diagnostics;
+using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;
using ComputeSharp.Core.Extensions;
using ComputeSharp.Graphics.Commands;
@@ -10,6 +11,7 @@ using Microsoft.Toolkit.Diagnostics;
using TerraFX.Interop;
using static TerraFX.Interop.D3D12_COMMAND_LIST_TYPE;
using static TerraFX.Interop.D3D12_FEATURE;
+using static TerraFX.Interop.D3D12_FORMAT_SUPPORT1;
namespace ComputeSharp.Graphics
{
@@ -126,6 +128,36 @@ namespace ComputeSharp.Graphics
///
internal ID3D12Device* D3D12Device => this.d3D12Device;
+ ///
+ /// Checks whether the current device supports the creation of
+ /// resources for a specified type .
+ ///
+ /// The type of values to check support for.
+ /// Whether instances can be created by the current device.
+ [Pure]
+ public bool IsTexture2DSupportedForType()
+ where T : unmanaged
+ {
+ ThrowIfDisposed();
+
+ return this.d3D12Device.Get()->IsDxgiFormatSupported(DXGIFormatHelper.GetForType(), D3D12_FORMAT_SUPPORT1_TEXTURE2D);
+ }
+
+ ///
+ /// Checks whether the current device supports the creation of
+ /// resources for a specified type .
+ ///
+ /// The type of values to check support for.
+ /// Whether instances can be created by the current device.
+ [Pure]
+ public bool IsTexture3DSupportedForType()
+ where T : unmanaged
+ {
+ ThrowIfDisposed();
+
+ return this.d3D12Device.Get()->IsDxgiFormatSupported(DXGIFormatHelper.GetForType(), D3D12_FORMAT_SUPPORT1_TEXTURE3D);
+ }
+
///
internal void RentShaderResourceViewDescriptorHandles(
out D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandle,