Added [ReadOnly|ReadWrite]Texture2D<T> types

このコミットが含まれているのは:
Sergio Pedri committed 2020-12-02 20:26:21 +01:00
1 親 705b47c0ee
コミット 030d787958
3ファイル変更
+83 -1

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

+1 -1
ファイルの表示
@@ -27,7 +27,7 @@ namespace ComputeSharp
}
/// <summary>
/// Gets a single <typeparamref name="T"/> value from the current read write buffer.
/// Gets a single <typeparamref name="T"/> value from the current readonly buffer.
/// </summary>
/// <param name="i">The index 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>
+41
ファイルの表示
@@ -0,0 +1,41 @@
using System.Diagnostics;
using ComputeSharp.Exceptions;
using ComputeSharp.Graphics;
using ComputeSharp.Graphics.Buffers.Abstract;
using ComputeSharp.Graphics.Buffers.Enums;
namespace ComputeSharp
{
/// <summary>
/// A <see langword="class"/> representing a typed readonly 2D texture stored on GPU memory.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
[DebuggerDisplay("{ToString(),raw}")]
public sealed class ReadOnlyTexture2D<T> : Texture2D<T>
where T : unmanaged
{
/// <summary>
/// Creates a new <see cref="ReadOnlyTexture2D{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="height">The height of the texture.</param>
internal ReadOnlyTexture2D(GraphicsDevice device, int width, int height)
: base(device, width, height, TextureType.ReadOnly)
{
}
/// <summary>
/// Gets a single <typeparamref name="T"/> value from the current readonly texture.
/// </summary>
/// <param name="xy">The coordinates 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 T this[UInt2 xy] => throw new InvalidExecutionContextException($"{nameof(ReadOnlyTexture2D<T>)}<T>[UInt2]");
/// <inheritdoc/>
public override string ToString()
{
return $"ComputeSharp.ReadOnlyTexture2D<{typeof(T)}>[{Width}, {Height}]";
}
}
}
+41
ファイルの表示
@@ -0,0 +1,41 @@
using System.Diagnostics;
using ComputeSharp.Exceptions;
using ComputeSharp.Graphics;
using ComputeSharp.Graphics.Buffers.Abstract;
using ComputeSharp.Graphics.Buffers.Enums;
namespace ComputeSharp
{
/// <summary>
/// A <see langword="class"/> representing a typed read write 2D texture stored on GPU memory.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
[DebuggerDisplay("{ToString(),raw}")]
public sealed class ReadWriteTexture2D<T> : Texture2D<T>
where T : unmanaged
{
/// <summary>
/// Creates a new <see cref="ReadWriteTexture2D{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="height">The height of the texture.</param>
internal ReadWriteTexture2D(GraphicsDevice device, int width, int height)
: base(device, width, height, TextureType.ReadWrite)
{
}
/// <summary>
/// Gets or sets a single <typeparamref name="T"/> value from the current readonly texture.
/// </summary>
/// <param name="xy">The coordinates 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[UInt2 xy] => throw new InvalidExecutionContextException($"{nameof(ReadOnlyTexture2D<T>)}<T>[UInt2]");
/// <inheritdoc/>
public override string ToString()
{
return $"ComputeSharp.ReadWriteTexture2D<{typeof(T)}>[{Width}, {Height}]";
}
}
}