diff --git a/src/ComputeSharp.Graphics/Buffers/Abstract/Buffer{T}.cs b/src/ComputeSharp.Graphics/Buffers/Abstract/Buffer{T}.cs
index bec1c62b..8be43323 100644
--- a/src/ComputeSharp.Graphics/Buffers/Abstract/Buffer{T}.cs
+++ b/src/ComputeSharp.Graphics/Buffers/Abstract/Buffer{T}.cs
@@ -39,8 +39,8 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
/// The associated with the current instance.
/// The number of items to store in the current buffer.
/// The size in bytes of each buffer item (including padding, if any).
- /// The buffer type for the current buffer.
- private protected Buffer(GraphicsDevice device, int length, uint elementSizeInBytes, BufferType bufferType)
+ /// The resource type for the current buffer.
+ private protected Buffer(GraphicsDevice device, int length, uint elementSizeInBytes, ResourceType resourceType)
{
device.ThrowIfDisposed();
@@ -50,19 +50,19 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
GraphicsDevice = device;
Length = length;
- this.d3D12Resource = device.D3D12Device->CreateCommittedResource(bufferType, (ulong)SizeInBytes);
+ this.d3D12Resource = device.D3D12Device->CreateCommittedResource(resourceType, (ulong)SizeInBytes);
device.AllocateShaderResourceViewDescriptorHandles(out D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandle, out D3D12GpuDescriptorHandle);
- switch (bufferType)
+ switch (resourceType)
{
- case BufferType.Constant:
+ case ResourceType.Constant:
device.D3D12Device->CreateConstantBufferView(this.d3D12Resource, SizeInBytes, d3D12CpuDescriptorHandle);
break;
- case BufferType.ReadOnly:
+ case ResourceType.ReadOnly:
device.D3D12Device->CreateShaderResourceView(this.d3D12Resource, (uint)length, elementSizeInBytes, d3D12CpuDescriptorHandle);
break;
- case BufferType.ReadWrite:
+ case ResourceType.ReadWrite:
device.D3D12Device->CreateUnorderedAccessView(this.d3D12Resource, (uint)length, elementSizeInBytes, d3D12CpuDescriptorHandle);
break;
}
diff --git a/src/ComputeSharp.Graphics/Buffers/Abstract/StructuredBuffer{T}.cs b/src/ComputeSharp.Graphics/Buffers/Abstract/StructuredBuffer{T}.cs
index 9f8b01f5..3c89e089 100644
--- a/src/ComputeSharp.Graphics/Buffers/Abstract/StructuredBuffer{T}.cs
+++ b/src/ComputeSharp.Graphics/Buffers/Abstract/StructuredBuffer{T}.cs
@@ -23,9 +23,9 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
///
/// The associated with the current instance.
/// The number of items to store in the current buffer.
- /// The buffer type for the current buffer.
- private protected StructuredBuffer(GraphicsDevice device, int length, BufferType bufferType)
- : base(device, length, (uint)Unsafe.SizeOf(), bufferType)
+ /// The buffer type for the current buffer.
+ private protected StructuredBuffer(GraphicsDevice device, int length, ResourceType resourceType)
+ : base(device, length, (uint)Unsafe.SizeOf(), resourceType)
{
}
@@ -43,7 +43,7 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
byteOffset = (nint)offset * ElementSizeInBytes,
byteSize = (nint)destination.Length * ElementSizeInBytes;
- using ComPtr d3D12Resource = GraphicsDevice.D3D12Device->CreateCommittedResource(BufferType.ReadBack, (ulong)byteSize);
+ using ComPtr d3D12Resource = GraphicsDevice.D3D12Device->CreateCommittedResource(ResourceType.ReadBack, (ulong)byteSize);
using (CommandList copyCommandList = new(GraphicsDevice, D3D12_COMMAND_LIST_TYPE_COPY))
{
@@ -70,7 +70,7 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
byteOffset = (nint)offset * ElementSizeInBytes,
byteSize = (nint)source.Length * ElementSizeInBytes;
- using ComPtr d3D12Resource = GraphicsDevice.D3D12Device->CreateCommittedResource(BufferType.Upload, (ulong)byteSize);
+ using ComPtr d3D12Resource = GraphicsDevice.D3D12Device->CreateCommittedResource(ResourceType.Upload, (ulong)byteSize);
using (ID3D12ResourceMap resource = d3D12Resource.Get()->Map())
{
diff --git a/src/ComputeSharp.Graphics/Buffers/Abstract/Texture2D{T}.cs b/src/ComputeSharp.Graphics/Buffers/Abstract/Texture2D{T}.cs
index 3c4ebe2b..ebd10fa5 100644
--- a/src/ComputeSharp.Graphics/Buffers/Abstract/Texture2D{T}.cs
+++ b/src/ComputeSharp.Graphics/Buffers/Abstract/Texture2D{T}.cs
@@ -34,8 +34,8 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
/// The associated with the current instance.
/// The height of the texture.
/// The width of the texture.
- /// The texture type for the current texture.
- private protected Texture2D(GraphicsDevice device, int width, int height, TextureType textureType)
+ /// The resource type for the current texture.
+ private protected Texture2D(GraphicsDevice device, int width, int height, ResourceType resourceType)
{
device.ThrowIfDisposed();
@@ -46,16 +46,16 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
Width = width;
Height = height;
- this.d3D12Resource = device.D3D12Device->CreateCommittedResource(textureType, DXGIFormatHelper.GetForType(), (uint)width, (uint)height);
+ this.d3D12Resource = device.D3D12Device->CreateCommittedResource(resourceType, DXGIFormatHelper.GetForType(), (uint)width, (uint)height);
device.AllocateShaderResourceViewDescriptorHandles(out D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandle, out D3D12GpuDescriptorHandle);
- switch (textureType)
+ switch (resourceType)
{
- case TextureType.ReadOnly:
+ case ResourceType.ReadOnly:
device.D3D12Device->CreateShaderResourceView(this.d3D12Resource, DXGIFormatHelper.GetForType(), d3D12CpuDescriptorHandle);
break;
- case TextureType.ReadWrite:
+ case ResourceType.ReadWrite:
device.D3D12Device->CreateUnorderedAccessView(this.d3D12Resource, DXGIFormatHelper.GetForType(), d3D12CpuDescriptorHandle);
break;
}
diff --git a/src/ComputeSharp.Graphics/Buffers/ConstantBuffer{T}.cs b/src/ComputeSharp.Graphics/Buffers/ConstantBuffer{T}.cs
index 0fc6a98c..2811f136 100644
--- a/src/ComputeSharp.Graphics/Buffers/ConstantBuffer{T}.cs
+++ b/src/ComputeSharp.Graphics/Buffers/ConstantBuffer{T}.cs
@@ -32,7 +32,7 @@ namespace ComputeSharp
/// The associated with the current instance.
/// The number of items to store in the current buffer.
internal ConstantBuffer(GraphicsDevice device, int length)
- : base(device, length, (uint)GetPaddedSize(), BufferType.Constant)
+ : base(device, length, (uint)GetPaddedSize(), ResourceType.Constant)
{
}
diff --git a/src/ComputeSharp.Graphics/Buffers/Enums/BufferType.cs b/src/ComputeSharp.Graphics/Buffers/Enums/BufferType.cs
deleted file mode 100644
index e2df47aa..00000000
--- a/src/ComputeSharp.Graphics/Buffers/Enums/BufferType.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-namespace ComputeSharp.Graphics.Buffers.Enums
-{
- ///
- /// An that indicates the type of a given HLSL buffer.
- ///
- internal enum BufferType
- {
- ///
- /// A constant buffer, with items aligned to 16 bytes, used for individual values or very small arrays.
- /// This is mapped to a in .
- ///
- Constant,
-
- ///
- /// A readonly buffer, that can store arbitrary arrays of values and can only be read from by the GPU.
- /// This is mapped to a in .
- ///
- ReadOnly,
-
- ///
- /// A read write buffer, that can store arbitrary arrays with both read and write access for the GPU.
- /// This is mapped to a in .
- ///
- ReadWrite,
-
- ///
- /// A readback buffer, used as temporary buffer to read data back from and buffers.
- /// This has no mapping in HLSL, and is allocated in .
- ///
- ReadBack,
-
- ///
- /// A transfer buffer, used as a temporary buffer to set data to and buffers.
- /// This has no mapping in HLSL, and is allocated in .
- ///
- Upload
- }
-}
diff --git a/src/ComputeSharp.Graphics/Buffers/Enums/ResourceType.cs b/src/ComputeSharp.Graphics/Buffers/Enums/ResourceType.cs
new file mode 100644
index 00000000..8ddddb8d
--- /dev/null
+++ b/src/ComputeSharp.Graphics/Buffers/Enums/ResourceType.cs
@@ -0,0 +1,43 @@
+namespace ComputeSharp.Graphics.Buffers.Enums
+{
+ ///
+ /// An that indicates the type of a given HLSL resource.
+ ///
+ internal enum ResourceType
+ {
+ ///
+ /// A constant resource, with items aligned to 16 bytes, used for individual values or very small arrays.
+ /// This is only supported for buffers and is mapped to a .
+ /// Resources of this type are located in .
+ ///
+ Constant,
+
+ ///
+ /// A readonly resource, that can store arbitrary arrays of values and can only be read from by the GPU.
+ /// This is mapped to either or .
+ /// Resources of this type are located in .
+ ///
+ ReadOnly,
+
+ ///
+ /// A read write resource, that can store arbitrary arrays with both read and write access for the GPU.
+ /// This is mapped to either or .
+ /// Resources of this type are located in .
+ ///
+ ReadWrite,
+
+ ///
+ /// A readback resource, used temporarily to read data back from and resources.
+ /// This has no direct mapping to a type in HLSL, as it's only used for copy operations.
+ /// Resources of this type are located in .
+ ///
+ ReadBack,
+
+ ///
+ /// A transfer resource, used temporarily to set data to and resources.
+ /// This has no direct mapping to a type in HLSL, as it's only used for copy operations (like ).
+ /// Resources of this type are located in .
+ ///
+ Upload
+ }
+}
diff --git a/src/ComputeSharp.Graphics/Buffers/Enums/TextureType.cs b/src/ComputeSharp.Graphics/Buffers/Enums/TextureType.cs
deleted file mode 100644
index c6a79432..00000000
--- a/src/ComputeSharp.Graphics/Buffers/Enums/TextureType.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-namespace ComputeSharp.Graphics.Buffers.Enums
-{
- ///
- /// An that indicates the type of a given HLSL texture.
- ///
- internal enum TextureType
- {
- ///
- /// A readonly texture, that can store arbitrary arrays of supported values and can only be read from by the GPU.
- /// This is mapped to a in .
- ///
- ReadOnly,
-
- ///
- /// A read write buffer, that can store arbitrary arrays with both read and write access for the GPU.
- /// This is mapped to a in .
- ///
- ReadWrite
- }
-}
diff --git a/src/ComputeSharp.Graphics/Buffers/ReadOnlyBuffer{T}.cs b/src/ComputeSharp.Graphics/Buffers/ReadOnlyBuffer{T}.cs
index 6488154a..296df86e 100644
--- a/src/ComputeSharp.Graphics/Buffers/ReadOnlyBuffer{T}.cs
+++ b/src/ComputeSharp.Graphics/Buffers/ReadOnlyBuffer{T}.cs
@@ -22,7 +22,7 @@ namespace ComputeSharp
/// The associated with the current instance.
/// The number of items to store in the current buffer.
internal ReadOnlyBuffer(GraphicsDevice device, int length)
- : base(device, length, BufferType.ReadOnly)
+ : base(device, length, ResourceType.ReadOnly)
{
}
diff --git a/src/ComputeSharp.Graphics/Buffers/ReadOnlyTexture2D{T}.cs b/src/ComputeSharp.Graphics/Buffers/ReadOnlyTexture2D{T}.cs
index 9b78dac7..417e4d9b 100644
--- a/src/ComputeSharp.Graphics/Buffers/ReadOnlyTexture2D{T}.cs
+++ b/src/ComputeSharp.Graphics/Buffers/ReadOnlyTexture2D{T}.cs
@@ -21,7 +21,7 @@ namespace ComputeSharp
/// The width of the texture.
/// The height of the texture.
internal ReadOnlyTexture2D(GraphicsDevice device, int width, int height)
- : base(device, width, height, TextureType.ReadOnly)
+ : base(device, width, height, ResourceType.ReadOnly)
{
}
diff --git a/src/ComputeSharp.Graphics/Buffers/ReadWriteBuffer{T}.cs b/src/ComputeSharp.Graphics/Buffers/ReadWriteBuffer{T}.cs
index 7761da25..a2f2c0c2 100644
--- a/src/ComputeSharp.Graphics/Buffers/ReadWriteBuffer{T}.cs
+++ b/src/ComputeSharp.Graphics/Buffers/ReadWriteBuffer{T}.cs
@@ -22,7 +22,7 @@ namespace ComputeSharp
/// The associated with the current instance.
/// The number of items to store in the current buffer.
internal ReadWriteBuffer(GraphicsDevice device, int length)
- : base(device, length, BufferType.ReadWrite)
+ : base(device, length, ResourceType.ReadWrite)
{
}
diff --git a/src/ComputeSharp.Graphics/Buffers/ReadWriteTexture2D{T}.cs b/src/ComputeSharp.Graphics/Buffers/ReadWriteTexture2D{T}.cs
index 0557fdba..29e39764 100644
--- a/src/ComputeSharp.Graphics/Buffers/ReadWriteTexture2D{T}.cs
+++ b/src/ComputeSharp.Graphics/Buffers/ReadWriteTexture2D{T}.cs
@@ -21,7 +21,7 @@ namespace ComputeSharp
/// The width of the texture.
/// The height of the texture.
internal ReadWriteTexture2D(GraphicsDevice device, int width, int height)
- : base(device, width, height, TextureType.ReadWrite)
+ : base(device, width, height, ResourceType.ReadWrite)
{
}
diff --git a/src/ComputeSharp.Graphics/Extensions/ID3D12DeviceExtensions.cs b/src/ComputeSharp.Graphics/Extensions/ID3D12DeviceExtensions.cs
index 5928347e..44d53a35 100644
--- a/src/ComputeSharp.Graphics/Extensions/ID3D12DeviceExtensions.cs
+++ b/src/ComputeSharp.Graphics/Extensions/ID3D12DeviceExtensions.cs
@@ -99,23 +99,23 @@ namespace ComputeSharp.Graphics.Extensions
/// Creates a committed resource for a given buffer type.
///
/// The instance in use.
- /// The buffer type currently in use.
+ /// The resource type currently in use.
/// The size in bytes of the current buffer.
/// An reference for the current buffer.
public static ComPtr CreateCommittedResource(
this ref ID3D12Device d3D12Device,
- BufferType bufferType,
+ ResourceType resourceType,
ulong sizeInBytes)
{
(D3D12_HEAP_TYPE d3D12HeapType,
D3D12_RESOURCE_FLAGS d3D12ResourceFlags,
- D3D12_RESOURCE_STATES d3D12ResourceStates) = bufferType switch
+ D3D12_RESOURCE_STATES d3D12ResourceStates) = resourceType switch
{
- BufferType.Constant => (D3D12_HEAP_TYPE_UPLOAD, D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_GENERIC_READ),
- BufferType.ReadOnly => (D3D12_HEAP_TYPE_DEFAULT, D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_COMMON),
- BufferType.ReadWrite => (D3D12_HEAP_TYPE_DEFAULT, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COMMON),
- BufferType.ReadBack => (D3D12_HEAP_TYPE_READBACK, D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_COPY_DEST),
- BufferType.Upload => (D3D12_HEAP_TYPE_UPLOAD, D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_GENERIC_READ),
+ ResourceType.Constant => (D3D12_HEAP_TYPE_UPLOAD, D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_GENERIC_READ),
+ ResourceType.ReadOnly => (D3D12_HEAP_TYPE_DEFAULT, D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_COMMON),
+ ResourceType.ReadWrite => (D3D12_HEAP_TYPE_DEFAULT, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COMMON),
+ ResourceType.ReadBack => (D3D12_HEAP_TYPE_READBACK, D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_COPY_DEST),
+ ResourceType.Upload => (D3D12_HEAP_TYPE_UPLOAD, D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_GENERIC_READ),
_ => ThrowHelper.ThrowArgumentException<(D3D12_HEAP_TYPE, D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>()
};
@@ -145,22 +145,22 @@ namespace ComputeSharp.Graphics.Extensions
/// Creates a committed resource for a given 2D texture type.
///
/// The instance in use.
- /// The texture type currently in use.
+ /// The resource type currently in use.
/// The value to use.
/// The width of the texture resource.
/// The height of the texture resource.
/// An reference for the current texture.
public static ComPtr CreateCommittedResource(
this ref ID3D12Device d3D12Device,
- TextureType textureType,
+ ResourceType resourceType,
DXGI_FORMAT dxgiFormat,
uint width,
uint height)
{
- D3D12_RESOURCE_FLAGS d3D12ResourceFlags = textureType switch
+ D3D12_RESOURCE_FLAGS d3D12ResourceFlags = resourceType switch
{
- TextureType.ReadOnly => D3D12_RESOURCE_FLAG_NONE,
- TextureType.ReadWrite => D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS,
+ ResourceType.ReadOnly => D3D12_RESOURCE_FLAG_NONE,
+ ResourceType.ReadWrite => D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS,
_ => ThrowHelper.ThrowArgumentException()
};