diff --git a/src/ComputeSharp.Graphics/Resources/ReadBackBuffer{T}.cs b/src/ComputeSharp.Graphics/Resources/ReadBackBuffer{T}.cs
index cdb231ac..dd8f50a3 100644
--- a/src/ComputeSharp.Graphics/Resources/ReadBackBuffer{T}.cs
+++ b/src/ComputeSharp.Graphics/Resources/ReadBackBuffer{T}.cs
@@ -1,4 +1,6 @@
-using ComputeSharp.Graphics.Resources.Enums;
+using System.Diagnostics;
+using ComputeSharp.Graphics.Resources.Enums;
+using ComputeSharp.Resources.Views;
namespace ComputeSharp
{
@@ -6,6 +8,8 @@ namespace ComputeSharp
/// A representing a typed buffer stored on CPU memory, that can be used to transfer back from the GPU.
///
/// The type of items stored on the buffer.
+ [DebuggerTypeProxy(typeof(TransferBufferDebugView<>))]
+ [DebuggerDisplay("{ToString(),raw}")]
public sealed class ReadBackBuffer : TransferBuffer
where T : unmanaged
{
@@ -15,9 +19,15 @@ namespace ComputeSharp
/// The associated with the current instance.
/// The number of items to store in the current buffer.
/// The allocation mode to use for the new resource.
- public ReadBackBuffer(GraphicsDevice device, int length, AllocationMode allocationMode)
+ internal ReadBackBuffer(GraphicsDevice device, int length, AllocationMode allocationMode)
: base(device, length, ResourceType.ReadBack, allocationMode)
{
}
+
+ ///
+ public override string ToString()
+ {
+ return $"ComputeSharp.ReadBackBuffer<{typeof(T)}>[{Length}]";
+ }
}
}
diff --git a/src/ComputeSharp.Graphics/Resources/UploadBuffer{T}.cs b/src/ComputeSharp.Graphics/Resources/UploadBuffer{T}.cs
index 7ab3c125..b7d155ad 100644
--- a/src/ComputeSharp.Graphics/Resources/UploadBuffer{T}.cs
+++ b/src/ComputeSharp.Graphics/Resources/UploadBuffer{T}.cs
@@ -1,4 +1,6 @@
-using ComputeSharp.Graphics.Resources.Enums;
+using System.Diagnostics;
+using ComputeSharp.Graphics.Resources.Enums;
+using ComputeSharp.Resources.Views;
namespace ComputeSharp
{
@@ -6,6 +8,8 @@ namespace ComputeSharp
/// A representing a typed buffer stored on CPU memory, that can be used to transfer data to the GPU.
///
/// The type of items stored on the buffer.
+ [DebuggerTypeProxy(typeof(TransferBufferDebugView<>))]
+ [DebuggerDisplay("{ToString(),raw}")]
public sealed class UploadBuffer : TransferBuffer
where T : unmanaged
{
@@ -15,9 +19,15 @@ namespace ComputeSharp
/// The associated with the current instance.
/// The number of items to store in the current buffer.
/// The allocation mode to use for the new resource.
- public UploadBuffer(GraphicsDevice device, int length, AllocationMode allocationMode)
+ internal UploadBuffer(GraphicsDevice device, int length, AllocationMode allocationMode)
: base(device, length, ResourceType.Upload, allocationMode)
{
}
+
+ ///
+ public override string ToString()
+ {
+ return $"ComputeSharp.UploadBuffer<{typeof(T)}>[{Length}]";
+ }
}
}
diff --git a/src/ComputeSharp.Graphics/Resources/Views/TransferBufferDebugView{T}.cs b/src/ComputeSharp.Graphics/Resources/Views/TransferBufferDebugView{T}.cs
new file mode 100644
index 00000000..2ef02e18
--- /dev/null
+++ b/src/ComputeSharp.Graphics/Resources/Views/TransferBufferDebugView{T}.cs
@@ -0,0 +1,35 @@
+using System;
+using System.Diagnostics;
+
+namespace ComputeSharp.Resources.Views
+{
+ ///
+ /// A debug proxy used to display items in a instance.
+ ///
+ /// The type of items to display.
+ internal sealed class TransferBufferDebugView
+ where T : unmanaged
+ {
+ ///
+ /// Initializes a new instance of the class with the specified parameters.
+ ///
+ /// The input instance with the items to display.
+ public TransferBufferDebugView(TransferBuffer? buffer)
+ {
+ if (buffer is not null)
+ {
+ var items = GC.AllocateUninitializedArray(buffer.Length);
+
+ buffer.Span.CopyTo(items);
+
+ Items = items;
+ }
+ }
+
+ ///
+ /// Gets the items to display for the current instance.
+ ///
+ [DebuggerBrowsable(DebuggerBrowsableState.Collapsed)]
+ public T[]? Items { get; }
+ }
+}