using System.Diagnostics;
using ComputeSharp.__Internals;
using ComputeSharp.Exceptions;
using ComputeSharp.Graphics.Resources.Enums;
using ComputeSharp.Resources;
using ComputeSharp.Resources.Debug;
using static TerraFX.Interop.D3D12_FORMAT_SUPPORT1;
#pragma warning disable CS0618
namespace ComputeSharp
{
///
/// A representing a typed read write 2D texture stored on GPU memory.
///
/// The type of items stored on the texture.
/// The type of pixels used on the GPU side.
[DebuggerTypeProxy(typeof(Texture2DDebugView<>))]
[DebuggerDisplay("{ToString(),raw}")]
public sealed class ReadWriteTexture2D : Texture2D, IReadWriteTexture2D
where T : unmanaged, IUnorm
where TPixel : 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.
/// The allocation mode to use for the new resource.
internal ReadWriteTexture2D(GraphicsDevice device, int width, int height, AllocationMode allocationMode)
: base(device, width, height, ResourceType.ReadWrite, allocationMode, D3D12_FORMAT_SUPPORT1_TEXTURE2D | D3D12_FORMAT_SUPPORT1_TYPED_UNORDERED_ACCESS_VIEW)
{
}
///
public ref TPixel this[int x, int y] => throw new InvalidExecutionContextException($"{nameof(ReadWriteTexture2D)}[int,int]");
///
public ref TPixel this[Int2 xy] => throw new InvalidExecutionContextException($"{nameof(ReadWriteTexture2D)}[Int2]");
///
public override string ToString()
{
return $"ComputeSharp.ReadWriteTexture2D<{typeof(T)},{typeof(TPixel)}>[{Width}, {Height}]";
}
}
}