using System.Diagnostics;
using ComputeSharp.Exceptions;
using ComputeSharp.Graphics.Resources.Enums;
using ComputeSharp.Resources;
using ComputeSharp.Resources.Views;
using static TerraFX.Interop.D3D12_FORMAT_SUPPORT1;
namespace ComputeSharp
{
///
/// A representing a typed readonly 3D texture stored on GPU memory.
///
/// The type of items stored on the texture.
[DebuggerTypeProxy(typeof(Texture3DDebugView<>))]
[DebuggerDisplay("{ToString(),raw}")]
public sealed class ReadOnlyTexture3D : Texture3D
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.
/// The depth of the texture.
/// The allocation mode to use for the new resource.
internal ReadOnlyTexture3D(GraphicsDevice device, int width, int height, int depth, AllocationMode allocationMode)
: base(device, width, height, depth, ResourceType.ReadOnly, allocationMode, D3D12_FORMAT_SUPPORT1_TEXTURE3D)
{
}
///
/// Gets a single value from the current readonly texture.
///
/// The horizontal offset of the value to get.
/// The vertical offset of the value to get.
/// The depthwise offset of the value to get.
/// This API can only be used from a compute shader, and will always throw if used anywhere else.
public T this[int x, int y, int z] => throw new InvalidExecutionContextException($"{nameof(ReadOnlyTexture3D)}[int,int,int]");
///
/// Gets 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 T this[Int3 xyz] => throw new InvalidExecutionContextException($"{nameof(ReadOnlyTexture3D)}[Int3]");
///
public override string ToString()
{
return $"ComputeSharp.ReadOnlyTexture3D<{typeof(T)}>[{Width}, {Height}, {Depth}]";
}
}
}