Add Read[Only|Write]Texture1D<T> types

このコミットが含まれているのは:
Sergio Pedri committed 2022-08-31 02:14:02 +02:00
1 親 61d85829cb
コミット 3e8d751b28
3ファイル変更
+117

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

+33
ファイルの表示
@@ -0,0 +1,33 @@
using System.Diagnostics;
namespace ComputeSharp.Resources.Debug;
/// <summary>
/// A debug proxy used to display items in a <see cref="Texture1D{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items to display.</typeparam>
internal sealed class Texture1DDebugView<T>
where T : unmanaged
{
/// <summary>
/// Initializes a new instance of the <see cref="Texture1DDebugView{T}"/> class with the specified parameters.
/// </summary>
/// <param name="texture">The input <see cref="Texture1D{T}"/> instance with the items to display.</param>
public Texture1DDebugView(Texture1D<T>? texture)
{
if (texture is not null)
{
T[] items = new T[texture.Width];
texture.CopyTo(ref items[0], items.Length, 0, texture.Width);
Items = items;
}
}
/// <summary>
/// Gets the items to display for the current instance.
/// </summary>
[DebuggerBrowsable(DebuggerBrowsableState.Collapsed)]
public T[]? Items { get; }
}
+42
ファイルの表示
@@ -0,0 +1,42 @@
using System.Diagnostics;
using ComputeSharp.Exceptions;
using ComputeSharp.Graphics.Resources.Enums;
using ComputeSharp.Resources;
using ComputeSharp.Resources.Debug;
using static TerraFX.Interop.DirectX.D3D12_FORMAT_SUPPORT1;
namespace ComputeSharp;
/// <summary>
/// A <see langword="class"/> representing a typed readonly 1D texture stored on GPU memory.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
[DebuggerTypeProxy(typeof(Texture1DDebugView<>))]
[DebuggerDisplay("{ToString(),raw}")]
public sealed class ReadOnlyTexture1D<T> : Texture1D<T>
where T : unmanaged
{
/// <summary>
/// Creates a new <see cref="ReadOnlyTexture1D{T}"/> instance with the specified parameters.
/// </summary>
/// <param name="device">The <see cref="GraphicsDevice"/> associated with the current instance.</param>
/// <param name="width">The width of the texture.</param>
/// <param name="allocationMode">The allocation mode to use for the new resource.</param>
internal ReadOnlyTexture1D(GraphicsDevice device, int width, AllocationMode allocationMode)
: base(device, width, ResourceType.ReadOnly, allocationMode, D3D12_FORMAT_SUPPORT1_TEXTURE1D)
{
}
/// <summary>
/// Gets a single <typeparamref name="T"/> value from the current readonly texture.
/// </summary>
/// <param name="x">The horizontal offset of the value to get.</param>
/// <remarks>This API can only be used from a compute shader, and will always throw if used anywhere else.</remarks>
public ref readonly T this[int x] => throw new InvalidExecutionContextException($"{typeof(ReadOnlyTexture1D<T>)}[{typeof(int)}]");
/// <inheritdoc/>
public override string ToString()
{
return $"ComputeSharp.ReadOnlyTexture1D<{typeof(T)}>[{Width}]";
}
}
+42
ファイルの表示
@@ -0,0 +1,42 @@
using System.Diagnostics;
using ComputeSharp.Exceptions;
using ComputeSharp.Graphics.Resources.Enums;
using ComputeSharp.Resources;
using ComputeSharp.Resources.Debug;
using static TerraFX.Interop.DirectX.D3D12_FORMAT_SUPPORT1;
namespace ComputeSharp;
/// <summary>
/// A <see langword="class"/> representing a typed read write 1D texture stored on GPU memory.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
[DebuggerTypeProxy(typeof(Texture1DDebugView<>))]
[DebuggerDisplay("{ToString(),raw}")]
public sealed partial class ReadWriteTexture1D<T> : Texture1D<T>
where T : unmanaged
{
/// <summary>
/// Creates a new <see cref="ReadWriteTexture1D{T}"/> instance with the specified parameters.
/// </summary>
/// <param name="device">The <see cref="GraphicsDevice"/> associated with the current instance.</param>
/// <param name="width">The width of the texture.</param>
/// <param name="allocationMode">The allocation mode to use for the new resource.</param>
internal ReadWriteTexture1D(GraphicsDevice device, int width, AllocationMode allocationMode)
: base(device, width, ResourceType.ReadWrite, allocationMode, D3D12_FORMAT_SUPPORT1_TEXTURE1D | D3D12_FORMAT_SUPPORT1_TYPED_UNORDERED_ACCESS_VIEW)
{
}
/// <summary>
/// Gets a single <typeparamref name="T"/> value from the current writeable texture.
/// </summary>
/// <param name="x">The horizontal offset of the value to get.</param>
/// <remarks>This API can only be used from a compute shader, and will always throw if used anywhere else.</remarks>
public ref T this[int x] => throw new InvalidExecutionContextException($"{typeof(ReadWriteTexture1D<T>)}[{typeof(int)}]");
/// <inheritdoc/>
public override string ToString()
{
return $"ComputeSharp.ReadWriteTexture1D<{typeof(T)}>[{Width}]";
}
}