diff --git a/src/ComputeSharp/Graphics/Extensions/ReadBackTexture3DExtensions.cs b/src/ComputeSharp/Graphics/Extensions/ReadBackTexture3DExtensions.cs new file mode 100644 index 00000000..80024868 --- /dev/null +++ b/src/ComputeSharp/Graphics/Extensions/ReadBackTexture3DExtensions.cs @@ -0,0 +1,60 @@ +using ComputeSharp.Resources; + +namespace ComputeSharp; + +/// +/// A that contains extension methods for the type. +/// +public static class ReadBackTexture3DExtensions +{ + /// + /// Reads the contents of a instance and writes them into a target instance. + /// + /// The type of items stored on the texture. + /// The target instance to write data to. + /// The input instance to read data from. + public static void CopyFrom(this ReadBackTexture3D destination, Texture3D source) + where T : unmanaged + { + source.CopyTo(destination, 0, 0, 0, 0, 0, 0, source.Width, source.Height, source.Depth); + } + + /// + /// Reads the contents of a instance and writes them into a target instance. + /// + /// The type of items stored on the texture. + /// The target instance to write data to. + /// The input instance to read data from. + /// The horizontal offset in the source texture. + /// The vertical offset in the source texture. + /// The depthwise offset in the source texture. + /// The width of the memory area to copy. + /// The height of the memory area to copy. + /// The depth of the memory area to copy. + public static void CopyFrom(this ReadBackTexture3D destination, Texture3D source, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int width, int height, int depth) + where T : unmanaged + { + source.CopyTo(destination, sourceOffsetX, sourceOffsetY, sourceOffsetZ, 0, 0, 0, width, height, depth); + } + + /// + /// Reads the contents of a instance and writes them into a target instance. + /// + /// The type of items stored on the texture. + /// The target instance to write data to. + /// The input instance to read data from. + /// The horizontal offset in the source texture. + /// The vertical offset in the source texture. + /// The depthwise offset in the source texture. + /// The horizontal offset in the destination texture. + /// The vertical offset in the destination texture. + /// The depthwise offset in the destination texture. + /// The width of the memory area to copy. + /// The height of the memory area to copy. + /// The depth of the memory area to copy. + public static void CopyFrom(this ReadBackTexture3D destination, Texture3D source, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth) + where T : unmanaged + { + source.CopyTo(destination, sourceOffsetX, sourceOffsetY, sourceOffsetZ, destinationOffsetX, destinationOffsetY, destinationOffsetZ, width, height, depth); + } +} diff --git a/src/ComputeSharp/Graphics/Extensions/Texture3DExtensions.cs b/src/ComputeSharp/Graphics/Extensions/Texture3DExtensions.cs index 23d56dda..c0622aeb 100644 --- a/src/ComputeSharp/Graphics/Extensions/Texture3DExtensions.cs +++ b/src/ComputeSharp/Graphics/Extensions/Texture3DExtensions.cs @@ -180,6 +180,27 @@ public static class Texture3DExtensions source.CopyTo(destination, sourceOffsetX, sourceOffsetY, sourceOffsetZ, 0, 0, 0, width, height, depth); } + /// + /// Reads the contents of a instance and writes them into a target instance. + /// + /// The type of items stored on the texture. + /// The input instance to read data from. + /// The target instance to write data to. + /// The horizontal offset in the source texture. + /// The vertical offset in the source texture. + /// The depthwise offset in the source texture. + /// The horizontal offset in the destination texture. + /// The vertical offset in the destination texture. + /// The depthwise offset in the destination texture. + /// The width of the memory area to copy. + /// The height of the memory area to copy. + /// The depth of the memory area to copy. + public static void CopyTo(this Texture3D source, ReadBackTexture3D destination, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth) + where T : unmanaged + { + source.CopyTo(destination, sourceOffsetX, sourceOffsetY, sourceOffsetZ, destinationOffsetX, destinationOffsetY, destinationOffsetZ, width, height, depth); + } + /// /// Writes the contents of a given array to the current instance. /// @@ -329,4 +350,55 @@ public static class Texture3DExtensions { destination.CopyFrom(ref MemoryMarshal.GetReference(source), source.Length, destinationOffsetX, destinationOffsetY, destinationOffsetZ, width, height, depth); } + + /// + /// Reads the contents of an instance and writes them into a target instance. + /// + /// The type of items stored on the texture. + /// The target instance to write data to. + /// The input instance to read data from. + public static void CopyFrom(this Texture3D destination, UploadTexture3D source) + where T : unmanaged + { + destination.CopyFrom(source, 0, 0, 0, 0, 0, 0, source.Width, source.Height, source.Depth); + } + + /// + /// Reads the contents of an instance and writes them into a target instance. + /// + /// The type of items stored on the texture. + /// The target instance to write data to. + /// The input instance to read data from. + /// The horizontal offset in the source texture. + /// The vertical offset in the source texture. + /// The depthwise offset in the source texture. + /// The width of the memory area to copy. + /// The height of the memory area to copy. + /// The depth of the memory area to copy. + public static void CopyFrom(this Texture3D destination, UploadTexture3D source, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int width, int height, int depth) + where T : unmanaged + { + destination.CopyFrom(source, sourceOffsetX, sourceOffsetY, sourceOffsetZ, 0, 0, 0, width, height, depth); + } + + /// + /// Reads the contents of an instance and writes them into a target instance. + /// + /// The type of items stored on the texture. + /// The target instance to write data to. + /// The input instance to read data from. + /// The horizontal offset in the source texture. + /// The vertical offset in the source texture. + /// The depthwise offset in the source texture. + /// The horizontal offset in the destination texture. + /// The vertical offset in the destination texture. + /// The depthwise offset in the destination texture. + /// The width of the memory area to copy. + /// The height of the memory area to copy. + /// The depth of the memory area to copy. + public static void CopyFrom(this Texture3D destination, UploadTexture3D source, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth) + where T : unmanaged + { + destination.CopyFrom(source, sourceOffsetX, sourceOffsetY, sourceOffsetZ, destinationOffsetX, destinationOffsetY, destinationOffsetZ, width, height, depth); + } } diff --git a/src/ComputeSharp/Graphics/Extensions/UploadTexture3DExtensions.cs b/src/ComputeSharp/Graphics/Extensions/UploadTexture3DExtensions.cs index 6bd980f8..52778dbc 100644 --- a/src/ComputeSharp/Graphics/Extensions/UploadTexture3DExtensions.cs +++ b/src/ComputeSharp/Graphics/Extensions/UploadTexture3DExtensions.cs @@ -11,29 +11,50 @@ public static class UploadTexture3DExtensions /// Reads the contents of a instance and writes them into a target instance. /// /// The type of items stored on the texture. - /// The input instance to read data from. + /// The input instance to read data from. /// The target instance to write data to. - public static void CopyTo(this UploadTexture3D texture, Texture3D destination) + public static void CopyTo(this UploadTexture3D source, Texture3D destination) where T : unmanaged { - destination.CopyFrom(texture, 0, 0, 0, 0, 0, 0, texture.Width, texture.Height, texture.Depth); + destination.CopyFrom(source, 0, 0, 0, 0, 0, 0, source.Width, source.Height, source.Depth); } /// /// Reads the contents of a instance and writes them into a target instance. /// /// The type of items stored on the texture. - /// The input instance to read data from. + /// The input instance to read data from. /// The target instance to write data to. - /// The horizontal offset in the source texture. - /// The vertical offset in the source texture. - /// The depthwise offset in the source texture. + /// The horizontal offset in the source texture. + /// The vertical offset in the source texture. + /// The depthwise offset in the source texture. /// The width of the memory area to copy. /// The height of the memory area to copy. /// The depth of the memory area to copy. - public static void CopyTo(this UploadTexture3D texture, Texture3D destination, int x, int y, int z, int width, int height, int depth) + public static void CopyTo(this UploadTexture3D source, Texture3D destination, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int width, int height, int depth) where T : unmanaged { - destination.CopyFrom(texture, x, y, z, 0, 0, 0, width, height, depth); + destination.CopyFrom(source, sourceOffsetX, sourceOffsetY, sourceOffsetZ, 0, 0, 0, width, height, depth); + } + + /// + /// Reads the contents of a instance and writes them into a target instance. + /// + /// The type of items stored on the texture. + /// The input instance to read data from. + /// The target instance to write data to. + /// The horizontal offset in the source texture. + /// The vertical offset in the source texture. + /// The depthwise offset in the source texture. + /// The horizontal offset in the destination texture. + /// The vertical offset in the destination texture. + /// The depthwise offset in the destination texture. + /// The width of the memory area to copy. + /// The height of the memory area to copy. + /// The depth of the memory area to copy. + public static void CopyTo(this UploadTexture3D source, Texture3D destination, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth) + where T : unmanaged + { + destination.CopyFrom(source, sourceOffsetX, sourceOffsetY, sourceOffsetZ, destinationOffsetX, destinationOffsetY, destinationOffsetZ, width, height, depth); } }