diff --git a/src/ComputeSharp.Graphics/Buffers/Abstract/HlslStructuredBuffer{T}.cs b/src/ComputeSharp.Graphics/Buffers/Abstract/HlslStructuredBuffer{T}.cs
index 32d1772c..9bea7b84 100644
--- a/src/ComputeSharp.Graphics/Buffers/Abstract/HlslStructuredBuffer{T}.cs
+++ b/src/ComputeSharp.Graphics/Buffers/Abstract/HlslStructuredBuffer{T}.cs
@@ -44,7 +44,7 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
///
public override unsafe void SetData(ReadOnlySpan span, int offset, int count)
{
- using Buffer transferBuffer = new Buffer(GraphicsDevice, count, count * ElementSizeInBytes, BufferType.Transfer);
+ using Buffer transferBuffer = new Buffer(GraphicsDevice, count, count * ElementSizeInBytes, BufferType.Upload);
using (MappedResource resource = transferBuffer.MapResource())
{
diff --git a/src/ComputeSharp.Graphics/Buffers/Buffer{T}.cs b/src/ComputeSharp.Graphics/Buffers/Buffer{T}.cs
index 237a75f4..263a9c8b 100644
--- a/src/ComputeSharp.Graphics/Buffers/Buffer{T}.cs
+++ b/src/ComputeSharp.Graphics/Buffers/Buffer{T}.cs
@@ -105,7 +105,7 @@ namespace ComputeSharp.Graphics.Buffers
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.Transfer => (D3D12_HEAP_TYPE_UPLOAD, D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_GENERIC_READ),
+ BufferType.Upload => (D3D12_HEAP_TYPE_UPLOAD, D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_GENERIC_READ),
_ => throw null!
};
diff --git a/src/ComputeSharp.Graphics/Buffers/ConstantBuffer{T}.cs b/src/ComputeSharp.Graphics/Buffers/ConstantBuffer{T}.cs
index 6de580b6..ba43b15f 100644
--- a/src/ComputeSharp.Graphics/Buffers/ConstantBuffer{T}.cs
+++ b/src/ComputeSharp.Graphics/Buffers/ConstantBuffer{T}.cs
@@ -29,6 +29,13 @@ namespace ComputeSharp
{
}
+ ///
+ /// Gets a single value from the current constant buffer
+ ///
+ /// The index of the value to get
+ /// This API can only be used from a compute shader, and will always throw if used anywhere else
+ public T this[int i] => throw new InvalidExecutionContextException($"{nameof(ConstantBuffer)}[int]");
+
///
/// Gets the right padded size for elements to store in the current instance
///
@@ -36,18 +43,9 @@ namespace ComputeSharp
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static int GetPaddedSize()
{
- int size = Unsafe.SizeOf();
-
- return (size + 15) & ~15;
+ return (Unsafe.SizeOf() + 15) & ~15;
}
- ///
- /// Gets a single value from the current constant buffer
- ///
- /// The index of the value to get
- /// This API can only be used from a compute shader, and will always throw if used anywhere else
- public T this[int i] => throw new InvalidExecutionContextException($"{nameof(ConstantBuffer)}[int]");
-
///
public override unsafe void GetData(Span span, int offset, int count)
{
@@ -56,7 +54,7 @@ namespace ComputeSharp
if (IsPaddingPresent)
{
ref T spanRef = ref MemoryMarshal.GetReference(span);
- ref byte resourceRef = ref Unsafe.AsRef((void*)resource.Pointer);
+ ref byte resourceRef = ref Unsafe.AsRef(resource.Pointer);
// Move to the initial ref
resourceRef = ref Unsafe.Add(ref resourceRef, offset * GetPaddedSize());
@@ -79,7 +77,7 @@ namespace ComputeSharp
if (IsPaddingPresent)
{
ref T spanRef = ref MemoryMarshal.GetReference(span);
- ref byte resourceRef = ref Unsafe.AsRef((void*)resource.Pointer);
+ ref byte resourceRef = ref Unsafe.AsRef(resource.Pointer);
// Move to the initial offset
resourceRef = ref Unsafe.Add(ref resourceRef, offset * GetPaddedSize());
diff --git a/src/ComputeSharp.Graphics/Buffers/Enums/BufferType.cs b/src/ComputeSharp.Graphics/Buffers/Enums/BufferType.cs
index 8c7bbd63..e2df47aa 100644
--- a/src/ComputeSharp.Graphics/Buffers/Enums/BufferType.cs
+++ b/src/ComputeSharp.Graphics/Buffers/Enums/BufferType.cs
@@ -1,33 +1,38 @@
namespace ComputeSharp.Graphics.Buffers.Enums
{
///
- /// An that indicates the type of a given HLSL buffer
+ /// 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, mapped to
+ /// 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, mapped to
+ /// 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, mapped to
+ /// 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 buffers in the default heap, mapped to
+ /// 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 buffers in the default heap, mapped to
+ /// A transfer buffer, used as a temporary buffer to set data to and buffers.
+ /// This has no mapping in HLSL, and is allocated in .
///
- Transfer
+ Upload
}
}