diff --git a/src/ComputeSharp.Graphics/Buffers/ReadOnlyTexture3D{T}.cs b/src/ComputeSharp.Graphics/Buffers/ReadOnlyTexture3D{T}.cs index 560ad224..11ee7869 100644 --- a/src/ComputeSharp.Graphics/Buffers/ReadOnlyTexture3D{T}.cs +++ b/src/ComputeSharp.Graphics/Buffers/ReadOnlyTexture3D{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 3D texture stored on GPU memory. /// /// The type of items stored on the texture. + [DebuggerTypeProxy(typeof(BufferDebugView3D<>))] [DebuggerDisplay("{ToString(),raw}")] public sealed class ReadOnlyTexture3D : Texture3D where T : unmanaged diff --git a/src/ComputeSharp.Graphics/Buffers/ReadWriteTexture3D{T}.cs b/src/ComputeSharp.Graphics/Buffers/ReadWriteTexture3D{T}.cs index 9e5e950d..b4a341d3 100644 --- a/src/ComputeSharp.Graphics/Buffers/ReadWriteTexture3D{T}.cs +++ b/src/ComputeSharp.Graphics/Buffers/ReadWriteTexture3D{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 3D texture stored on GPU memory. /// /// The type of items stored on the texture. + [DebuggerTypeProxy(typeof(BufferDebugView3D<>))] [DebuggerDisplay("{ToString(),raw}")] public sealed class ReadWriteTexture3D : Texture3D where T : unmanaged @@ -36,7 +38,7 @@ namespace ComputeSharp /// public override string ToString() { - return $"ComputeSharp.ReadOnlyTexture3D<{typeof(T)}>[{Width}, {Height}, {Depth}]"; + return $"ComputeSharp.ReadWriteTexture3D<{typeof(T)}>[{Width}, {Height}, {Depth}]"; } } } diff --git a/src/ComputeSharp.Graphics/Buffers/Views/BufferDebugView2D{T}.cs b/src/ComputeSharp.Graphics/Buffers/Views/BufferDebugView2D{T}.cs index 720d46df..6acf3c20 100644 --- a/src/ComputeSharp.Graphics/Buffers/Views/BufferDebugView2D{T}.cs +++ b/src/ComputeSharp.Graphics/Buffers/Views/BufferDebugView2D{T}.cs @@ -20,7 +20,7 @@ namespace ComputeSharp.Graphics.Buffers.Views { var items = new T[texture.Height, texture.Width]; - texture.GetData(ref items[0, 0], items.Length, 0, 0, texture.Height, texture.Width); + texture.GetData(ref items[0, 0], items.Length, 0, 0, texture.Width, texture.Height); Items = items; } diff --git a/src/ComputeSharp.Graphics/Buffers/Views/BufferDebugView3D{T}.cs b/src/ComputeSharp.Graphics/Buffers/Views/BufferDebugView3D{T}.cs new file mode 100644 index 00000000..24e2a4a5 --- /dev/null +++ b/src/ComputeSharp.Graphics/Buffers/Views/BufferDebugView3D{T}.cs @@ -0,0 +1,35 @@ +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 BufferDebugView3D + where T : unmanaged + { + /// + /// Initializes a new instance of the class with the specified parameters. + /// + /// The input instance with the items to display. + public BufferDebugView3D(Texture3D? texture) + { + if (texture is not null) + { + var items = new T[texture.Depth, texture.Height, texture.Width]; + + texture.GetData(ref items[0, 0, 0], items.Length, 0, 0, 0, texture.Width, texture.Height, texture.Depth); + + Items = items; + } + } + + /// + /// Gets the items to display for the current instance. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Collapsed)] + public T[,,]? Items { get; } + } +}