diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1InputDescription.cs b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1InputDescription.cs
index 0a403fd8..9a563844 100644
--- a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1InputDescription.cs
+++ b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1InputDescription.cs
@@ -12,21 +12,6 @@ namespace ComputeSharp.D2D1.Interop;
[StructLayout(LayoutKind.Sequential)]
public readonly struct D2D1InputDescription
{
- ///
- /// The index of the resource the description belongs to.
- ///
- private readonly int index;
-
- ///
- /// The type of filter to apply to the input texture.
- ///
- private readonly D2D1Filter filter;
-
- ///
- /// The mip level to retrieve from the upstream transform, if specified.
- ///
- private readonly int levelOfDetailCount;
-
///
/// Creates a new instance with the specified parameters.
///
@@ -34,26 +19,22 @@ public readonly struct D2D1InputDescription
/// The type of filter to apply to the input texture.
public D2D1InputDescription(int index, D2D1Filter filter)
{
- this.index = index;
- this.filter = filter;
+ Index = index;
+ Filter = filter;
}
///
/// Gets the index of the resource the description belongs to.
///
- public int Index => this.index;
+ public int Index { get; }
///
/// Gets the type of filter to apply to the input texture.
///
- public D2D1Filter Filter => this.filter;
+ public D2D1Filter Filter { get; }
///
/// Gets the mip level to retrieve from the upstream transform, if specified.
///
- public int LevelOfDetailCount
- {
- get => this.levelOfDetailCount;
- init => this.levelOfDetailCount = value;
- }
+ public int LevelOfDetailCount { get; init; }
}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1ResourceTextureDescription.cs b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1ResourceTextureDescription.cs
index ce924f0a..93977ca7 100644
--- a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1ResourceTextureDescription.cs
+++ b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1ResourceTextureDescription.cs
@@ -8,17 +8,6 @@ namespace ComputeSharp.D2D1.Interop;
[StructLayout(LayoutKind.Sequential)]
public readonly struct D2D1ResourceTextureDescription
{
- ///
- /// The index of the resource texture the description belongs to.
- ///
- /// See notes in for why explicit fields are used here.
- private readonly int index;
-
- ///
- /// The number of dimensions of the resource texture the description belongs to.
- ///
- private readonly int dimensions;
-
///
/// Creates a new instance with the specified parameters.
///
@@ -26,17 +15,17 @@ public readonly struct D2D1ResourceTextureDescription
/// The number of dimensions of the resource texture the description belongs to.
public D2D1ResourceTextureDescription(int index, int dimensions)
{
- this.index = index;
- this.dimensions = dimensions;
+ Index = index;
+ Dimensions = dimensions;
}
///
/// Gets the index of the resource texture the description belongs to.
///
- public int Index => this.index;
+ public int Index { get; }
///
/// Gets the rank of the resource texture the description belongs to.
///
- public int Dimensions => this.dimensions;
+ public int Dimensions { get; }
}
\ No newline at end of file
diff --git a/src/ComputeSharp/Core/Interfaces/__Internals/IDispatchMetadataLoader.cs b/src/ComputeSharp/Core/Interfaces/__Internals/IDispatchMetadataLoader.cs
index 0e455379..0ae91753 100644
--- a/src/ComputeSharp/Core/Interfaces/__Internals/IDispatchMetadataLoader.cs
+++ b/src/ComputeSharp/Core/Interfaces/__Internals/IDispatchMetadataLoader.cs
@@ -16,5 +16,5 @@ public interface IDispatchMetadataLoader
/// The serialized metadata for the current shader.
/// The sequence of resource descriptors for the current shader.
/// The resulting opaque metadata handle.
- void LoadMetadataHandle(ReadOnlySpan serializedMetadata, ReadOnlySpan resourceDescriptors, out IntPtr result);
+ void LoadMetadataHandle(ReadOnlySpan serializedMetadata, ReadOnlySpan resourceDescriptors, out IntPtr result);
}
\ No newline at end of file
diff --git a/src/ComputeSharp/Graphics/Interop/ResourceDescriptorRange.cs b/src/ComputeSharp/Graphics/Interop/ResourceDescriptorRange.cs
new file mode 100644
index 00000000..ed5dc8dc
--- /dev/null
+++ b/src/ComputeSharp/Graphics/Interop/ResourceDescriptorRange.cs
@@ -0,0 +1,38 @@
+using System.Runtime.InteropServices;
+
+namespace ComputeSharp.Interop;
+
+///
+/// A type containing info on a descriptor for a given D3D12 shader resource range.
+///
+///
+/// This type exposes a subset of values from
+/// D3D12_DESCRIPTOR_RANGE1.
+///
+[StructLayout(LayoutKind.Sequential)]
+public readonly struct ResourceDescriptorRange
+{
+ ///
+ /// Creates a new instance with the specified parameters.
+ ///
+ /// The type of the descriptor range.
+ /// The shader register in the range.
+ public ResourceDescriptorRange(ResourceDescriptorRangeType type, uint register)
+ {
+ Type = type;
+ Register = register;
+ }
+
+ ///
+ /// Gets the type of the descriptor range.
+ ///
+ public ResourceDescriptorRangeType Type { get; }
+
+ ///
+ /// Gets the shader register in the range.
+ ///
+ ///
+ /// For example, for shader-resource views (SRVs), 3 maps to register(t3) in HLSL.
+ ///
+ public uint Register { get; }
+}
\ No newline at end of file
diff --git a/src/ComputeSharp/Graphics/Interop/ResourceDescriptorRangeType.cs b/src/ComputeSharp/Graphics/Interop/ResourceDescriptorRangeType.cs
new file mode 100644
index 00000000..9e6640bc
--- /dev/null
+++ b/src/ComputeSharp/Graphics/Interop/ResourceDescriptorRangeType.cs
@@ -0,0 +1,28 @@
+using static TerraFX.Interop.DirectX.D3D12_DESCRIPTOR_RANGE_TYPE;
+
+namespace ComputeSharp.Interop;
+
+///
+/// A type containing info on a descriptor type for a given D3D12 shader resource range.
+///
+///
+/// This type exposes the available values in
+/// D3D12_DESCRIPTOR_RANGE_TYPE.
+///
+public enum ResourceDescriptorRangeType
+{
+ ///
+ /// Specifies a range of SRVs.
+ ///
+ ShaderResourceView = D3D12_DESCRIPTOR_RANGE_TYPE_SRV,
+
+ ///
+ /// Specifies a range of unordered-access views (UAVs).
+ ///
+ UnorderedAccessView = D3D12_DESCRIPTOR_RANGE_TYPE_UAV,
+
+ ///
+ /// Specifies a range of constant-buffer views (CBVs).
+ ///
+ ConstantBufferView = D3D12_DESCRIPTOR_RANGE_TYPE_CBV
+}
\ No newline at end of file
diff --git a/src/ComputeSharp/Graphics/Resources/Interop/__Internals/ResourceDescriptor.cs b/src/ComputeSharp/Graphics/Resources/Interop/__Internals/ResourceDescriptor.cs
deleted file mode 100644
index 803ef761..00000000
--- a/src/ComputeSharp/Graphics/Resources/Interop/__Internals/ResourceDescriptor.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using System;
-using System.ComponentModel;
-using TerraFX.Interop.DirectX;
-using static TerraFX.Interop.DirectX.D3D12_DESCRIPTOR_RANGE_FLAGS;
-
-#pragma warning disable IDE0052, IDE1006, CS0414
-
-namespace ComputeSharp.__Internals;
-
-///
-/// An opaque type describing a captured resource to be used in a shader.
-///
-[EditorBrowsable(EditorBrowsableState.Never)]
-[Obsolete("This type is not intended to be used directly by user code")]
-public struct ResourceDescriptor
-{
- ///
- private D3D12_DESCRIPTOR_RANGE_TYPE RangeType;
-
- ///
- private uint NumDescriptors;
-
- ///
- private uint BaseShaderRegister;
-
- ///
- private uint RegisterSpace;
-
- ///
- private D3D12_DESCRIPTOR_RANGE_FLAGS Flags;
-
- ///
- private uint OffsetInDescriptorsFromTableStart;
-
- ///
- /// Initializes a new instance.
- ///
- /// The type of resource to create the descriptor for.
- /// The offset in the resource from the start of the shader mapping.
- /// The resulting instance.
- public static void Create(int type, uint offset, out ResourceDescriptor descriptor)
- {
- descriptor.RangeType = (D3D12_DESCRIPTOR_RANGE_TYPE)type;
- descriptor.NumDescriptors = 1;
- descriptor.BaseShaderRegister = offset;
- descriptor.RegisterSpace = 0;
- descriptor.Flags = D3D12_DESCRIPTOR_RANGE_FLAG_NONE;
- descriptor.OffsetInDescriptorsFromTableStart = D3D12.D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND;
- }
-}
\ No newline at end of file
diff --git a/src/ComputeSharp/Shaders/Dispatching/ShaderDispatchMetadataLoader.cs b/src/ComputeSharp/Shaders/Dispatching/ShaderDispatchMetadataLoader.cs
index eb92cd8a..c43be70d 100644
--- a/src/ComputeSharp/Shaders/Dispatching/ShaderDispatchMetadataLoader.cs
+++ b/src/ComputeSharp/Shaders/Dispatching/ShaderDispatchMetadataLoader.cs
@@ -31,7 +31,7 @@ internal readonly unsafe struct ShaderDispatchMetadataLoader : IDispatchMetadata
}
///
- public unsafe void LoadMetadataHandle(ReadOnlySpan serializedMetadata, ReadOnlySpan resourceDescriptors, out IntPtr result)
+ public unsafe void LoadMetadataHandle(ReadOnlySpan serializedMetadata, ReadOnlySpan resourceDescriptors, out IntPtr result)
{
default(ArgumentException).ThrowIf(serializedMetadata.Length != 5, nameof(serializedMetadata));
@@ -39,7 +39,7 @@ internal readonly unsafe struct ShaderDispatchMetadataLoader : IDispatchMetadata
{
*(ComPtr*)p = this.d3D12Device->CreateRootSignature(
MemoryMarshal.Read(serializedMetadata),
- MemoryMarshal.Cast(resourceDescriptors),
+ MemoryMarshal.Cast(resourceDescriptors),
MemoryMarshal.Read(serializedMetadata.Slice(4)));
}
}