From ce240ebce517c73ad4b9a7c32d4452d87b5a82b9 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Thu, 4 Feb 2021 13:54:23 +0100 Subject: [PATCH] Added upload/readback texture 3D types --- .../Resources/ReadBackTexture3D{T}.cs | 36 +++++++++++++++++++ .../Resources/UploadTexture3D{T}.cs | 36 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 src/ComputeSharp.Graphics/Resources/ReadBackTexture3D{T}.cs create mode 100644 src/ComputeSharp.Graphics/Resources/UploadTexture3D{T}.cs diff --git a/src/ComputeSharp.Graphics/Resources/ReadBackTexture3D{T}.cs b/src/ComputeSharp.Graphics/Resources/ReadBackTexture3D{T}.cs new file mode 100644 index 00000000..aeb4a130 --- /dev/null +++ b/src/ComputeSharp.Graphics/Resources/ReadBackTexture3D{T}.cs @@ -0,0 +1,36 @@ +using System.Diagnostics; +using ComputeSharp.Graphics.Resources.Enums; +using ComputeSharp.Resources; +using ComputeSharp.Resources.Debug; + +namespace ComputeSharp +{ + /// + /// A representing a typed 3D texture stored on CPU memory, that can be used to transfer back from the GPU. + /// + /// The type of items stored on the texture. + [DebuggerTypeProxy(typeof(TransferTexture3DDebugView<>))] + [DebuggerDisplay("{ToString(),raw}")] + public sealed class ReadBackTexture3D : TransferTexture3D + 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 ReadBackTexture3D(GraphicsDevice device, int width, int height, int depth, AllocationMode allocationMode) + : base(device, width, height, depth, ResourceType.ReadBack, allocationMode) + { + } + + /// + public override string ToString() + { + return $"ComputeSharp.ReadBackTexture3D<{typeof(T)}>[{Width}, {Height}, {Depth}]"; + } + } +} diff --git a/src/ComputeSharp.Graphics/Resources/UploadTexture3D{T}.cs b/src/ComputeSharp.Graphics/Resources/UploadTexture3D{T}.cs new file mode 100644 index 00000000..eacc0862 --- /dev/null +++ b/src/ComputeSharp.Graphics/Resources/UploadTexture3D{T}.cs @@ -0,0 +1,36 @@ +using System.Diagnostics; +using ComputeSharp.Graphics.Resources.Enums; +using ComputeSharp.Resources; +using ComputeSharp.Resources.Debug; + +namespace ComputeSharp +{ + /// + /// A representing a typed 3D texture stored on CPU memory, that can be used to transfer data to the GPU. + /// + /// The type of items stored on the texture. + [DebuggerTypeProxy(typeof(TransferTexture3DDebugView<>))] + [DebuggerDisplay("{ToString(),raw}")] + public sealed class UploadTexture3D : TransferTexture3D + 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 UploadTexture3D(GraphicsDevice device, int width, int height, int depth, AllocationMode allocationMode) + : base(device, width, height, depth, ResourceType.Upload, allocationMode) + { + } + + /// + public override string ToString() + { + return $"ComputeSharp.UploadTexture3D<{typeof(T)}>[{Width}, {Height}, {Depth}]"; + } + } +}