using System.Diagnostics;
using ComputeSharp.Exceptions;
using ComputeSharp.Graphics;
using ComputeSharp.Graphics.Buffers.Abstract;
using ComputeSharp.Graphics.Buffers.Enums;
using ComputeSharp.Graphics.Buffers.Views;
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
{
///
/// Creates a new instance with the specified parameters.
///
/// The associated with the current instance.
/// The width of the texture.
/// The height of the texture.
internal ReadWriteTexture2D(GraphicsDevice device, int width, int height)
: base(device, width, height, ResourceType.ReadWrite)
{
}
///
/// Gets or sets a single value from the current readonly texture.
///
/// The coordinates of the value to get.
/// This API can only be used from a compute shader, and will always throw if used anywhere else.
public ref T this[UInt2 xy] => throw new InvalidExecutionContextException($"{nameof(ReadOnlyTexture2D)}[UInt2]");
///
public override string ToString()
{
return $"ComputeSharp.ReadWriteTexture2D<{typeof(T)}>[{Width}, {Height}]";
}
}
}