From 70a8b095b09ccccf1e46b4752871d18b660e0c7a Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Thu, 3 Dec 2020 15:50:47 +0100 Subject: [PATCH] Added BufferDebugView2D type --- .../Buffers/ReadOnlyTexture2D{T}.cs | 2 ++ .../Buffers/ReadWriteTexture2D{T}.cs | 2 ++ .../Buffers/Views/BufferDebugView2D{T}.cs | 28 +++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 src/ComputeSharp.Graphics/Buffers/Views/BufferDebugView2D{T}.cs diff --git a/src/ComputeSharp.Graphics/Buffers/ReadOnlyTexture2D{T}.cs b/src/ComputeSharp.Graphics/Buffers/ReadOnlyTexture2D{T}.cs index 417e4d9b..2c7c9130 100644 --- a/src/ComputeSharp.Graphics/Buffers/ReadOnlyTexture2D{T}.cs +++ b/src/ComputeSharp.Graphics/Buffers/ReadOnlyTexture2D{T}.cs @@ -3,6 +3,7 @@ using ComputeSharp.Exceptions; using ComputeSharp.Graphics; using ComputeSharp.Graphics.Buffers.Abstract; using ComputeSharp.Graphics.Buffers.Enums; +using ComputeSharp.Graphics.Buffers.Views; namespace ComputeSharp { @@ -10,6 +11,7 @@ namespace ComputeSharp /// A representing a typed readonly 2D texture stored on GPU memory. /// /// The type of items stored on the texture. + [DebuggerTypeProxy(typeof(BufferDebugView2D<>))] [DebuggerDisplay("{ToString(),raw}")] public sealed class ReadOnlyTexture2D : Texture2D where T : unmanaged diff --git a/src/ComputeSharp.Graphics/Buffers/ReadWriteTexture2D{T}.cs b/src/ComputeSharp.Graphics/Buffers/ReadWriteTexture2D{T}.cs index 29e39764..779bba67 100644 --- a/src/ComputeSharp.Graphics/Buffers/ReadWriteTexture2D{T}.cs +++ b/src/ComputeSharp.Graphics/Buffers/ReadWriteTexture2D{T}.cs @@ -3,6 +3,7 @@ using ComputeSharp.Exceptions; using ComputeSharp.Graphics; using ComputeSharp.Graphics.Buffers.Abstract; using ComputeSharp.Graphics.Buffers.Enums; +using ComputeSharp.Graphics.Buffers.Views; namespace ComputeSharp { @@ -10,6 +11,7 @@ namespace ComputeSharp /// A representing a typed read write 2D texture stored on GPU memory. /// /// The type of items stored on the texture. + [DebuggerTypeProxy(typeof(BufferDebugView2D<>))] [DebuggerDisplay("{ToString(),raw}")] public sealed class ReadWriteTexture2D : Texture2D where T : unmanaged diff --git a/src/ComputeSharp.Graphics/Buffers/Views/BufferDebugView2D{T}.cs b/src/ComputeSharp.Graphics/Buffers/Views/BufferDebugView2D{T}.cs new file mode 100644 index 00000000..c3061ea1 --- /dev/null +++ b/src/ComputeSharp.Graphics/Buffers/Views/BufferDebugView2D{T}.cs @@ -0,0 +1,28 @@ +using System.Diagnostics; +using ComputeSharp.Graphics.Buffers.Abstract; + +namespace ComputeSharp.Graphics.Buffers.Views +{ + /// + /// A debug proxy used to display items in a instance. + /// + /// The type of items to display. + internal sealed class BufferDebugView2D + where T : unmanaged + { + /// + /// Initializes a new instance of the class with the specified parameters. + /// + /// The input instance with the items to display. + public BufferDebugView2D(Texture2D? texture) + { + Items = texture?.GetData(); + } + + /// + /// Gets the items to display for the current instance. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Collapsed)] + public T[,]? Items { get; } + } +}