Added TransferBuffer<T> debug info

このコミットが含まれているのは:
Sergio Pedri committed 2021-01-31 20:24:12 +01:00
1 親 9e728efca5
コミット 8b9c0bf53b
3ファイル変更
+59 -4

検索条件に一致するファイルはありません

+12 -2
ファイルの表示
@@ -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 <see langword="class"/> representing a typed buffer stored on CPU memory, that can be used to transfer back from the GPU.
/// </summary>
/// <typeparam name="T">The type of items stored on the buffer.</typeparam>
[DebuggerTypeProxy(typeof(TransferBufferDebugView<>))]
[DebuggerDisplay("{ToString(),raw}")]
public sealed class ReadBackBuffer<T> : TransferBuffer<T>
where T : unmanaged
{
@@ -15,9 +19,15 @@ namespace ComputeSharp
/// <param name="device">The <see cref="GraphicsDevice"/> associated with the current instance.</param>
/// <param name="length">The number of items to store in the current buffer.</param>
/// <param name="allocationMode">The allocation mode to use for the new resource.</param>
public ReadBackBuffer(GraphicsDevice device, int length, AllocationMode allocationMode)
internal ReadBackBuffer(GraphicsDevice device, int length, AllocationMode allocationMode)
: base(device, length, ResourceType.ReadBack, allocationMode)
{
}
/// <inheritdoc/>
public override string ToString()
{
return $"ComputeSharp.ReadBackBuffer<{typeof(T)}>[{Length}]";
}
}
}
+12 -2
ファイルの表示
@@ -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 <see langword="class"/> representing a typed buffer stored on CPU memory, that can be used to transfer data to the GPU.
/// </summary>
/// <typeparam name="T">The type of items stored on the buffer.</typeparam>
[DebuggerTypeProxy(typeof(TransferBufferDebugView<>))]
[DebuggerDisplay("{ToString(),raw}")]
public sealed class UploadBuffer<T> : TransferBuffer<T>
where T : unmanaged
{
@@ -15,9 +19,15 @@ namespace ComputeSharp
/// <param name="device">The <see cref="GraphicsDevice"/> associated with the current instance.</param>
/// <param name="length">The number of items to store in the current buffer.</param>
/// <param name="allocationMode">The allocation mode to use for the new resource.</param>
public UploadBuffer(GraphicsDevice device, int length, AllocationMode allocationMode)
internal UploadBuffer(GraphicsDevice device, int length, AllocationMode allocationMode)
: base(device, length, ResourceType.Upload, allocationMode)
{
}
/// <inheritdoc/>
public override string ToString()
{
return $"ComputeSharp.UploadBuffer<{typeof(T)}>[{Length}]";
}
}
}
+35
ファイルの表示
@@ -0,0 +1,35 @@
using System;
using System.Diagnostics;
namespace ComputeSharp.Resources.Views
{
/// <summary>
/// A debug proxy used to display items in a <see cref="TransferBuffer{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items to display.</typeparam>
internal sealed class TransferBufferDebugView<T>
where T : unmanaged
{
/// <summary>
/// Initializes a new instance of the <see cref="TransferBufferDebugView{T}"/> class with the specified parameters.
/// </summary>
/// <param name="buffer">The input <see cref="TransferBuffer{T}"/> instance with the items to display.</param>
public TransferBufferDebugView(TransferBuffer<T>? buffer)
{
if (buffer is not null)
{
var items = GC.AllocateUninitializedArray<T>(buffer.Length);
buffer.Span.CopyTo(items);
Items = items;
}
}
/// <summary>
/// Gets the items to display for the current instance.
/// </summary>
[DebuggerBrowsable(DebuggerBrowsableState.Collapsed)]
public T[]? Items { get; }
}
}