From 453eec3366b6aae8422ca8e90657c23efa37c6dd Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Fri, 12 Nov 2021 14:18:18 +0100 Subject: [PATCH] Rename parameters in Texture3D copy APIs --- .../Extensions/Texture3DExtensions.cs | 186 +++++++++--------- .../Resources/Abstract/Texture3D{T}.cs | 152 +++++++------- 2 files changed, 169 insertions(+), 169 deletions(-) diff --git a/src/ComputeSharp/Graphics/Extensions/Texture3DExtensions.cs b/src/ComputeSharp/Graphics/Extensions/Texture3DExtensions.cs index 436b1be1..23d56dda 100644 --- a/src/ComputeSharp/Graphics/Extensions/Texture3DExtensions.cs +++ b/src/ComputeSharp/Graphics/Extensions/Texture3DExtensions.cs @@ -15,7 +15,7 @@ public static class Texture3DExtensions /// Reads the contents of the current instance and returns an array. /// /// The type of items stored on the texture. - /// The input instance to read data from. + /// The input instance to read data from. /// A array with the contents of the current buffer. /// /// The returned array will be using the same memory layout as the texture, that is, each 2D plane @@ -23,12 +23,12 @@ public static class Texture3DExtensions /// the depth dimension. This means that the resulting 3D array will have a size of [D, H, W]. /// [Pure] - public static T[,,] ToArray(this Texture3D texture) + public static T[,,] ToArray(this Texture3D source) where T : unmanaged { - T[,,] data = new T[texture.Depth, texture.Height, texture.Width]; + T[,,] data = new T[source.Depth, source.Height, source.Width]; - texture.CopyTo(data); + source.CopyTo(data); return data; } @@ -37,247 +37,247 @@ public static class Texture3DExtensions /// Reads the contents of the current instance and writes them into a target array. /// /// The type of items stored on the texture. - /// The input instance to read data from. + /// The input instance to read data from. /// The input array to write data to. /// /// The input 3D array needs to have each 2D plane stacked on the depth axis. That is, the expected /// layout of the input array has to be of shape [depth, height, width]. /// - public static void CopyTo(this Texture3D texture, T[,,] destination) + public static void CopyTo(this Texture3D source, T[,,] destination) where T : unmanaged { - Guard.IsEqualTo(destination.GetLength(0), texture.Depth, nameof(destination)); - Guard.IsEqualTo(destination.GetLength(1), texture.Height, nameof(destination)); - Guard.IsEqualTo(destination.GetLength(2), texture.Width, nameof(destination)); + Guard.IsEqualTo(destination.GetLength(0), source.Depth, nameof(destination)); + Guard.IsEqualTo(destination.GetLength(1), source.Height, nameof(destination)); + Guard.IsEqualTo(destination.GetLength(2), source.Width, nameof(destination)); - texture.CopyTo(ref destination[0, 0, 0], destination.Length, 0, 0, 0, texture.Width, texture.Height, texture.Depth); + source.CopyTo(ref destination[0, 0, 0], destination.Length, 0, 0, 0, source.Width, source.Height, source.Depth); } /// /// Reads the contents of the specified range from the current instance and writes them into a target array. /// /// The type of items stored on the texture. - /// The input instance to read data from. + /// The input instance to read data from. /// The input array to write data to. - /// The starting offset within to write data to. - public static void CopyTo(this Texture3D texture, T[] destination, int offset) + /// The starting offset within to write data to. + public static void CopyTo(this Texture3D source, T[] destination, int destinationOffset) where T : unmanaged { - texture.CopyTo(destination.AsSpan(offset), 0, 0, 0, texture.Width, texture.Height, texture.Depth); + source.CopyTo(destination.AsSpan(destinationOffset), 0, 0, 0, source.Width, source.Height, source.Depth); } /// /// Reads the contents of the specified range from the current instance and writes them into a target array. /// /// The type of items stored on the texture. - /// The input instance to read data from. + /// The input instance to read data from. /// The input array to write data to. - /// The starting offset within to write data to. + /// The starting offset within to write data to. /// The horizontal range of items to copy. /// The vertical range of items to copy. /// The depthwise range of items to copy. - public static void CopyTo(this Texture3D texture, T[] destination, int offset, Range x, Range y, Range z) + public static void CopyTo(this Texture3D source, T[] destination, int destinationOffset, Range x, Range y, Range z) where T : unmanaged { - texture.CopyTo(destination.AsSpan(offset), x, y, z); + source.CopyTo(destination.AsSpan(destinationOffset), x, y, z); } /// /// Reads the contents of the specified range from the current instance and writes them into a target array. /// /// The type of items stored on the texture. - /// The input instance to read data from. + /// The input instance to read data from. /// The input array to write data to. - /// The starting offset within 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 starting offset within to write data to. /// 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 texture, T[] destination, int offset, int x, int y, int z, int width, int height, int depth) + public static void CopyTo(this Texture3D source, T[] destination, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int destinationOffset, int width, int height, int depth) where T : unmanaged { - texture.CopyTo(destination.AsSpan(offset), x, y, z, width, height, depth); + source.CopyTo(destination.AsSpan(destinationOffset), sourceOffsetX, sourceOffsetY, sourceOffsetZ, width, height, depth); } /// /// Reads the contents of the specified range from the current instance and writes them into a target . /// /// The type of items stored on the texture. - /// The input instance to read data from. + /// The input instance to read data from. /// The input to write data to. - public static void CopyTo(this Texture3D texture, Span destination) + public static void CopyTo(this Texture3D source, Span destination) where T : unmanaged { - texture.CopyTo(destination, 0, 0, 0, texture.Width, texture.Height, texture.Depth); + source.CopyTo(destination, 0, 0, 0, source.Width, source.Height, source.Depth); } /// /// Reads the contents of the specified range from the current instance and writes them into a target . /// /// The type of items stored on the texture. - /// The input instance to read data from. + /// The input instance to read data from. /// The input to write data to. /// The horizontal range in the source texture. /// The vertical range in the source texture. /// The depthwise range in the source texture. - public static void CopyTo(this Texture3D texture, Span destination, Range x, Range y, Range z) + public static void CopyTo(this Texture3D source, Span destination, Range x, Range y, Range z) where T : unmanaged { - var (offsetX, width) = x.GetOffsetAndLength(texture.Width); - var (offsetY, height) = y.GetOffsetAndLength(texture.Height); - var (offsetZ, depth) = z.GetOffsetAndLength(texture.Depth); + var (offsetX, width) = x.GetOffsetAndLength(source.Width); + var (offsetY, height) = y.GetOffsetAndLength(source.Height); + var (offsetZ, depth) = z.GetOffsetAndLength(source.Depth); - texture.CopyTo(destination, offsetX, offsetY, offsetZ, width, height, depth); + source.CopyTo(destination, offsetX, offsetY, offsetZ, width, height, depth); } /// /// Reads the contents of the specified range from the current instance and writes them into a target . /// /// The type of items stored on the texture. - /// The input instance to read data from. + /// The input instance to read data from. /// The input 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 Texture3D texture, Span destination, int x, int y, int z, int width, int height, int depth) + public static void CopyTo(this Texture3D source, Span destination, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int width, int height, int depth) where T : unmanaged { - texture.CopyTo(ref MemoryMarshal.GetReference(destination), destination.Length, x, y, z, width, height, depth); + source.CopyTo(ref MemoryMarshal.GetReference(destination), destination.Length, sourceOffsetX, sourceOffsetY, sourceOffsetZ, 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 input instance to read data from. /// The target instance to write data to. - public static void CopyTo(this Texture3D texture, ReadBackTexture3D destination) + public static void CopyTo(this Texture3D source, ReadBackTexture3D destination) where T : unmanaged { - texture.CopyTo(destination, 0, 0, 0, 0, 0, 0, texture.Width, texture.Height, texture.Depth); + 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 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 Texture3D texture, ReadBackTexture3D destination, int x, int y, int z, int width, int height, int depth) + public static void CopyTo(this Texture3D source, ReadBackTexture3D destination, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int width, int height, int depth) where T : unmanaged { - texture.CopyTo(destination, 0, 0, 0, x, y, z, width, height, depth); + source.CopyTo(destination, sourceOffsetX, sourceOffsetY, sourceOffsetZ, 0, 0, 0, width, height, depth); } /// /// Writes the contents of a given array to the current instance. /// /// The type of items stored on the texture. - /// The target instance to write data to. + /// The target instance to write data to. /// The input array to read data from. /// /// The source 3D array needs to have each 2D plane stacked on the depth axis. That is, the expected /// layout of the input array has to be of shape [depth, height, width]. /// - public static void CopyFrom(this Texture3D texture, T[,,] source) + public static void CopyFrom(this Texture3D destination, T[,,] source) where T : unmanaged { - Guard.IsEqualTo(source.GetLength(0), texture.Depth, nameof(source)); - Guard.IsEqualTo(source.GetLength(1), texture.Height, nameof(source)); - Guard.IsEqualTo(source.GetLength(2), texture.Width, nameof(source)); + Guard.IsEqualTo(source.GetLength(0), destination.Depth, nameof(source)); + Guard.IsEqualTo(source.GetLength(1), destination.Height, nameof(source)); + Guard.IsEqualTo(source.GetLength(2), destination.Width, nameof(source)); - texture.CopyFrom(ref source[0, 0, 0], source.Length, 0, 0, 0, texture.Width, texture.Height, texture.Depth); + destination.CopyFrom(ref source[0, 0, 0], source.Length, 0, 0, 0, destination.Width, destination.Height, destination.Depth); } /// /// Writes the contents of a given array to the current instance. /// /// The type of items stored on the texture. - /// The target instance to write data to. + /// The target instance to write data to. /// The input array to read data from. - public static void CopyFrom(this Texture3D texture, T[] source) + public static void CopyFrom(this Texture3D destination, T[] source) where T : unmanaged { - texture.CopyFrom(source.AsSpan(), 0, 0, 0, texture.Width, texture.Height, texture.Depth); + destination.CopyFrom(source.AsSpan(), 0, 0, 0, destination.Width, destination.Height, destination.Depth); } /// /// Writes the contents of a given array to a specified area of the current instance. /// /// The type of items stored on the texture. - /// The target instance to write data to. + /// The target instance to write data to. /// The input array to read data from. /// The horizontal range of items to write. /// The vertical range of items to write. /// The depthwise range of items to write. - public static void CopyFrom(this Texture3D texture, T[] source, Range x, Range y, Range z) + public static void CopyFrom(this Texture3D destination, T[] source, Range x, Range y, Range z) where T : unmanaged { - texture.CopyFrom(source.AsSpan(), x, y, z); + destination.CopyFrom(source.AsSpan(), x, y, z); } /// /// Writes the contents of a given array to a specified area of the current instance. /// /// The type of items stored on the texture. - /// The target instance to write data to. + /// The target instance to write data to. /// The input array to read data from. - /// The horizontal offset in the destination texture. - /// The vertical offset in the destination texture. - /// The depthwise offset in the destination 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 write to. /// The height of the memory area to write to. /// The depth of the memory area to write to. - public static void CopyFrom(this Texture3D texture, T[] source, int x, int y, int z, int width, int height, int depth) + public static void CopyFrom(this Texture3D destination, T[] source, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth) where T : unmanaged { - texture.CopyFrom(source.AsSpan(), x, y, z, width, height, depth); + destination.CopyFrom(source.AsSpan(), destinationOffsetX, destinationOffsetY, destinationOffsetZ, width, height, depth); } /// /// Writes the contents of a given array to a specified area of the current instance. /// /// The type of items stored on the texture. - /// The target instance to write data to. + /// The target instance to write data to. /// The input array to read data from. - /// The starting offset within to read data from. + /// The starting offset within to read data from. /// The horizontal range of items to write. /// The vertical range of items to write. /// The depthwise range of items to write. - public static void CopyFrom(this Texture3D texture, T[] source, int offset, Range x, Range y, Range z) + public static void CopyFrom(this Texture3D destination, T[] source, int sourceOffset, Range x, Range y, Range z) where T : unmanaged { - texture.CopyFrom(source.AsSpan(offset), x, y, z); + destination.CopyFrom(source.AsSpan(sourceOffset), x, y, z); } /// /// Writes the contents of a given array to a specified area of the current instance. /// /// The type of items stored on the texture. - /// The target instance to write data to. + /// The target instance to write data to. /// The input array to read data from. - /// The starting offset within to read data from. - /// The horizontal offset in the destination texture. - /// The vertical offset in the destination texture. - /// The depthwise offset in the destination texture. + /// The starting offset within to read data from. + /// 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 write to. /// The height of the memory area to write to. /// The depth of the memory area to write to. - public static void CopyFrom(this Texture3D texture, T[] source, int offset, int x, int y, int z, int width, int height, int depth) + public static void CopyFrom(this Texture3D destination, T[] source, int sourceOffset, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth) where T : unmanaged { - texture.CopyFrom(source.AsSpan(offset), x, y, z, width, height, depth); + destination.CopyFrom(source.AsSpan(sourceOffset), destinationOffsetX, destinationOffsetY, destinationOffsetZ, width, height, depth); } /// @@ -285,48 +285,48 @@ public static class Texture3DExtensions /// The input data will be written to the start of the texture, and all input items will be copied. /// /// The type of items stored on the texture. - /// The target instance to write data to. + /// The target instance to write data to. /// The input to read data from. - public static void CopyFrom(this Texture3D texture, ReadOnlySpan source) + public static void CopyFrom(this Texture3D destination, ReadOnlySpan source) where T : unmanaged { - texture.CopyFrom(source, 0, 0, 0, texture.Width, texture.Height, texture.Depth); + destination.CopyFrom(source, 0, 0, 0, destination.Width, destination.Height, destination.Depth); } /// /// Writes the contents of a given to a specified area of the current instance. /// /// The type of items stored on the texture. - /// The target instance to write data to. + /// The target instance to write data to. /// The input to read data from. /// The horizontal range of items to write. /// The vertical range of items to write. /// The depthwise range of items to write. - public static void CopyFrom(this Texture3D texture, ReadOnlySpan source, Range x, Range y, Range z) + public static void CopyFrom(this Texture3D destination, ReadOnlySpan source, Range x, Range y, Range z) where T : unmanaged { - var (offsetX, width) = x.GetOffsetAndLength(texture.Width); - var (offsetY, height) = y.GetOffsetAndLength(texture.Height); - var (offsetZ, depth) = z.GetOffsetAndLength(texture.Depth); + var (offsetX, width) = x.GetOffsetAndLength(destination.Width); + var (offsetY, height) = y.GetOffsetAndLength(destination.Height); + var (offsetZ, depth) = z.GetOffsetAndLength(destination.Depth); - texture.CopyFrom(source, offsetX, offsetY, offsetZ, width, height, depth); + destination.CopyFrom(source, offsetX, offsetY, offsetZ, width, height, depth); } /// /// Writes the contents of a given to a specified area of the current instance. /// /// The type of items stored on the texture. - /// The target instance to write data to. + /// The target instance to write data to. /// The input to read data from. - /// The horizontal offset in the destination texture. - /// The vertical offset in the destination texture. - /// The depthwise offseet in the destination texture. + /// The horizontal offset in the destination texture. + /// The vertical offset in the destination texture. + /// The depthwise offseet in the destination texture. /// The width of the memory area to write to. /// The height of the memory area to write to. /// The depth of the memory area to write to. - public static void CopyFrom(this Texture3D texture, ReadOnlySpan source, int x, int y, int z, int width, int height, int depth) + public static void CopyFrom(this Texture3D destination, ReadOnlySpan source, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth) where T : unmanaged { - texture.CopyFrom(ref MemoryMarshal.GetReference(source), source.Length, x, y, z, width, height, depth); + destination.CopyFrom(ref MemoryMarshal.GetReference(source), source.Length, destinationOffsetX, destinationOffsetY, destinationOffsetZ, width, height, depth); } } diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/Texture3D{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/Texture3D{T}.cs index 263a15a1..6e569b89 100644 --- a/src/ComputeSharp/Graphics/Resources/Abstract/Texture3D{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/Abstract/Texture3D{T}.cs @@ -156,27 +156,27 @@ public unsafe abstract class Texture3D : NativeObject, GraphicsResourceHelper /// /// The target memory area to write data to. /// The size of the memory area 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. - internal void CopyTo(ref T destination, int size, int x, int y, int z, int width, int height, int depth) + internal void CopyTo(ref T destination, int size, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int width, int height, int depth) { GraphicsDevice.ThrowIfDisposed(); ThrowIfDisposed(); - Guard.IsInRange(x, 0, Width, nameof(x)); - Guard.IsInRange(y, 0, Height, nameof(y)); - Guard.IsInRange(z, 0, Depth, nameof(z)); + Guard.IsInRange(sourceOffsetX, 0, Width, nameof(sourceOffsetX)); + Guard.IsInRange(sourceOffsetY, 0, Height, nameof(sourceOffsetY)); + Guard.IsInRange(sourceOffsetZ, 0, Depth, nameof(sourceOffsetZ)); Guard.IsBetweenOrEqualTo(width, 1, Width, nameof(width)); Guard.IsBetweenOrEqualTo(height, 1, Height, nameof(height)); Guard.IsBetweenOrEqualTo(depth, 1, Depth, nameof(depth)); - Guard.IsLessThanOrEqualTo(x + width, Width, nameof(x)); - Guard.IsLessThanOrEqualTo(y + height, Height, nameof(y)); - Guard.IsLessThanOrEqualTo(z + depth, Depth, nameof(z)); + Guard.IsLessThanOrEqualTo(sourceOffsetX + width, Width, nameof(sourceOffsetX)); + Guard.IsLessThanOrEqualTo(sourceOffsetY + height, Height, nameof(sourceOffsetY)); + Guard.IsLessThanOrEqualTo(sourceOffsetZ + depth, Depth, nameof(sourceOffsetZ)); Guard.IsGreaterThanOrEqualTo(size, (nint)width * height * depth, nameof(size)); GraphicsDevice.D3D12Device->GetCopyableFootprint( @@ -210,9 +210,9 @@ public unsafe abstract class Texture3D : NativeObject, GraphicsResourceHelper destinationY: 0, destinationZ: 0, d3D12ResourceSource: D3D12Resource, - sourceX: (uint)x, - sourceY: (uint)y, - sourceZ: (ushort)z, + sourceX: (uint)sourceOffsetX, + sourceY: (uint)sourceOffsetY, + sourceZ: (ushort)sourceOffsetZ, (uint)width, (uint)height, (ushort)depth); @@ -244,16 +244,16 @@ public unsafe abstract class Texture3D : NativeObject, GraphicsResourceHelper /// Reads the contents of the specified range from the current instance and writes them into a instance. /// /// The target instance to write data to. - /// The horizontal offset within . - /// The vertical offset within . - /// The depthwise offset within . - /// 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 horizontal offset within . + /// The vertical offset within . + /// The depthwise offset within . /// The width of the memory area to copy. /// The height of the memory area to copy. /// The depth of the memory area to copy. - internal void CopyTo(ReadBackTexture3D destination, int destinationX, int destinationY, int destinationZ, int sourceX, int sourceY, int sourceZ, int width, int height, int depth) + internal void CopyTo(ReadBackTexture3D destination, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth) { GraphicsDevice.ThrowIfDisposed(); @@ -262,24 +262,24 @@ public unsafe abstract class Texture3D : NativeObject, GraphicsResourceHelper destination.ThrowIfDeviceMismatch(GraphicsDevice); destination.ThrowIfDisposed(); - Guard.IsInRange(destinationX, 0, destination.Width, nameof(destinationX)); - Guard.IsInRange(destinationY, 0, destination.Height, nameof(destinationY)); - Guard.IsInRange(destinationZ, 0, destination.Depth, nameof(destinationZ)); - Guard.IsInRange(sourceX, 0, Width, nameof(sourceX)); - Guard.IsInRange(sourceY, 0, Height, nameof(sourceY)); - Guard.IsInRange(sourceZ, 0, Depth, nameof(sourceZ)); + Guard.IsInRange(sourceOffsetX, 0, Width, nameof(sourceOffsetX)); + Guard.IsInRange(sourceOffsetY, 0, Height, nameof(sourceOffsetY)); + Guard.IsInRange(sourceOffsetZ, 0, Depth, nameof(sourceOffsetZ)); + Guard.IsInRange(destinationOffsetX, 0, destination.Width, nameof(destinationOffsetX)); + Guard.IsInRange(destinationOffsetY, 0, destination.Height, nameof(destinationOffsetY)); + Guard.IsInRange(destinationOffsetZ, 0, destination.Depth, nameof(destinationOffsetZ)); Guard.IsBetweenOrEqualTo(width, 1, Width, nameof(width)); Guard.IsBetweenOrEqualTo(height, 1, Height, nameof(height)); Guard.IsBetweenOrEqualTo(depth, 1, Depth, nameof(depth)); Guard.IsBetweenOrEqualTo(width, 1, destination.Width, nameof(width)); Guard.IsBetweenOrEqualTo(height, 1, destination.Height, nameof(height)); Guard.IsBetweenOrEqualTo(depth, 1, destination.Depth, nameof(depth)); - Guard.IsBetweenOrEqualTo(destinationX + width, 1, destination.Width, nameof(destinationX)); - Guard.IsBetweenOrEqualTo(destinationY + height, 1, destination.Height, nameof(destinationY)); - Guard.IsBetweenOrEqualTo(destinationZ + depth, 1, destination.Depth, nameof(destinationZ)); - Guard.IsLessThanOrEqualTo(sourceX + width, Width, nameof(sourceX)); - Guard.IsLessThanOrEqualTo(sourceY + height, Height, nameof(sourceY)); - Guard.IsLessThanOrEqualTo(sourceZ + depth, Depth, nameof(sourceZ)); + Guard.IsBetweenOrEqualTo(destinationOffsetX + width, 1, destination.Width, nameof(destinationOffsetX)); + Guard.IsBetweenOrEqualTo(destinationOffsetY + height, 1, destination.Height, nameof(destinationOffsetY)); + Guard.IsBetweenOrEqualTo(destinationOffsetZ + depth, 1, destination.Depth, nameof(destinationOffsetZ)); + Guard.IsLessThanOrEqualTo(sourceOffsetX + width, Width, nameof(sourceOffsetX)); + Guard.IsLessThanOrEqualTo(sourceOffsetY + height, Height, nameof(sourceOffsetY)); + Guard.IsLessThanOrEqualTo(sourceOffsetZ + depth, Depth, nameof(sourceOffsetZ)); using CommandList copyCommandList = new(GraphicsDevice, this.d3D12CommandListType); @@ -293,13 +293,13 @@ public unsafe abstract class Texture3D : NativeObject, GraphicsResourceHelper copyCommandList.D3D12GraphicsCommandList->CopyTextureRegion( d3D12ResourceDestination: destination.D3D12Resource, d3D12PlacedSubresourceFootprintDestination, - (uint)destinationX, - (uint)destinationY, - (ushort)destinationZ, + (uint)destinationOffsetX, + (uint)destinationOffsetY, + (ushort)destinationOffsetZ, d3D12ResourceSource: D3D12Resource, - (uint)sourceX, - (uint)sourceY, - (ushort)sourceZ, + (uint)sourceOffsetX, + (uint)sourceOffsetY, + (ushort)sourceOffsetZ, (uint)width, (uint)height, (ushort)depth); @@ -318,27 +318,27 @@ public unsafe abstract class Texture3D : NativeObject, GraphicsResourceHelper /// /// The input memory area to read data from. /// The size of the memory area to read data from. - /// The horizontal offset in the destination texture. - /// The vertical offset in the destination texture. - /// The depthwise offset in the destination 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 write to. /// The height of the memory area to write to. /// The depth of the memory area to write to. - internal void CopyFrom(ref T source, int size, int x, int y, int z, int width, int height, int depth) + internal void CopyFrom(ref T source, int size, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth) { GraphicsDevice.ThrowIfDisposed(); ThrowIfDisposed(); - Guard.IsInRange(x, 0, Width, nameof(x)); - Guard.IsInRange(y, 0, Height, nameof(y)); - Guard.IsInRange(z, 0, Depth, nameof(z)); + Guard.IsInRange(destinationOffsetX, 0, Width, nameof(destinationOffsetX)); + Guard.IsInRange(destinationOffsetY, 0, Height, nameof(destinationOffsetY)); + Guard.IsInRange(destinationOffsetZ, 0, Depth, nameof(destinationOffsetZ)); Guard.IsBetweenOrEqualTo(width, 1, Width, nameof(width)); Guard.IsBetweenOrEqualTo(height, 1, Height, nameof(height)); Guard.IsBetweenOrEqualTo(depth, 1, Depth, nameof(depth)); - Guard.IsLessThanOrEqualTo(x + width, Width, nameof(x)); - Guard.IsLessThanOrEqualTo(y + height, Height, nameof(y)); - Guard.IsLessThanOrEqualTo(z + depth, Depth, nameof(z)); + Guard.IsLessThanOrEqualTo(destinationOffsetX + width, Width, nameof(destinationOffsetX)); + Guard.IsLessThanOrEqualTo(destinationOffsetY + height, Height, nameof(destinationOffsetY)); + Guard.IsLessThanOrEqualTo(destinationOffsetZ + depth, Depth, nameof(destinationOffsetZ)); Guard.IsGreaterThanOrEqualTo(size, (nint)width * height * depth, nameof(size)); GraphicsDevice.D3D12Device->GetCopyableFootprint( @@ -380,9 +380,9 @@ public unsafe abstract class Texture3D : NativeObject, GraphicsResourceHelper copyCommandList.D3D12GraphicsCommandList->CopyTextureRegion( d3D12ResourceDestination: D3D12Resource, - destinationX: (uint)x, - destinationY: (uint)y, - destinationZ: (ushort)z, + destinationX: (uint)destinationOffsetX, + destinationY: (uint)destinationOffsetY, + destinationZ: (ushort)destinationOffsetZ, d3D12ResourceSource: d3D12Resource.Get(), &d3D12PlacedSubresourceFootprintSource, sourceX: 0, @@ -404,16 +404,16 @@ public unsafe abstract class Texture3D : NativeObject, GraphicsResourceHelper /// Writes the contents of a given instance to a specified area of the current instance. /// /// The input instance to read data from. - /// The horizontal offset within . - /// The vertical offset within . - /// The depthwise offset within . - /// The horizontal offset in the destination texture. - /// The vertical offset in the destination texture. - /// The depthwise offset in the destination texture. + /// The horizontal offset within . + /// The vertical offset within . + /// The depthwise offset within . + /// 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 write to. /// The height of the memory area to write to. /// The depth of the memory area to write to. - internal void CopyFrom(UploadTexture3D source, int sourceX, int sourceY, int sourceZ, int destinationX, int destinationY, int destinationZ, int width, int height, int depth) + internal void CopyFrom(UploadTexture3D source, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth) { GraphicsDevice.ThrowIfDisposed(); @@ -422,24 +422,24 @@ public unsafe abstract class Texture3D : NativeObject, GraphicsResourceHelper source.ThrowIfDeviceMismatch(GraphicsDevice); source.ThrowIfDisposed(); - Guard.IsInRange(sourceX, 0, source.Width, nameof(sourceX)); - Guard.IsInRange(sourceY, 0, source.Height, nameof(sourceY)); - Guard.IsInRange(sourceZ, 0, source.Depth, nameof(sourceZ)); - Guard.IsInRange(destinationX, 0, Width, nameof(destinationX)); - Guard.IsInRange(destinationY, 0, Height, nameof(destinationY)); - Guard.IsInRange(destinationZ, 0, Depth, nameof(destinationZ)); + Guard.IsInRange(sourceOffsetX, 0, source.Width, nameof(sourceOffsetX)); + Guard.IsInRange(sourceOffsetY, 0, source.Height, nameof(sourceOffsetY)); + Guard.IsInRange(sourceOffsetZ, 0, source.Depth, nameof(sourceOffsetZ)); + Guard.IsInRange(destinationOffsetX, 0, Width, nameof(destinationOffsetX)); + Guard.IsInRange(destinationOffsetY, 0, Height, nameof(destinationOffsetY)); + Guard.IsInRange(destinationOffsetZ, 0, Depth, nameof(destinationOffsetZ)); Guard.IsBetweenOrEqualTo(width, 1, Width, nameof(width)); Guard.IsBetweenOrEqualTo(height, 1, Height, nameof(height)); Guard.IsBetweenOrEqualTo(depth, 1, Depth, nameof(depth)); Guard.IsBetweenOrEqualTo(width, 1, source.Width, nameof(width)); Guard.IsBetweenOrEqualTo(height, 1, source.Height, nameof(height)); Guard.IsBetweenOrEqualTo(depth, 1, source.Depth, nameof(depth)); - Guard.IsLessThanOrEqualTo(sourceX + width, source.Width, nameof(sourceX)); - Guard.IsLessThanOrEqualTo(sourceY + height, source.Height, nameof(sourceY)); - Guard.IsLessThanOrEqualTo(sourceZ + depth, source.Depth, nameof(sourceZ)); - Guard.IsLessThanOrEqualTo(destinationX + width, Width, nameof(destinationX)); - Guard.IsLessThanOrEqualTo(destinationY + height, Height, nameof(destinationY)); - Guard.IsLessThanOrEqualTo(destinationZ + depth, Depth, nameof(destinationZ)); + Guard.IsLessThanOrEqualTo(sourceOffsetX + width, source.Width, nameof(sourceOffsetX)); + Guard.IsLessThanOrEqualTo(sourceOffsetY + height, source.Height, nameof(sourceOffsetY)); + Guard.IsLessThanOrEqualTo(sourceOffsetZ + depth, source.Depth, nameof(sourceOffsetZ)); + Guard.IsLessThanOrEqualTo(destinationOffsetX + width, Width, nameof(destinationOffsetX)); + Guard.IsLessThanOrEqualTo(destinationOffsetY + height, Height, nameof(destinationOffsetY)); + Guard.IsLessThanOrEqualTo(destinationOffsetZ + depth, Depth, nameof(destinationOffsetZ)); using CommandList copyCommandList = new(GraphicsDevice, this.d3D12CommandListType); @@ -452,14 +452,14 @@ public unsafe abstract class Texture3D : NativeObject, GraphicsResourceHelper { copyCommandList.D3D12GraphicsCommandList->CopyTextureRegion( d3D12ResourceDestination: D3D12Resource, - (uint)destinationX, - (uint)destinationY, - (ushort)destinationZ, + (uint)destinationOffsetX, + (uint)destinationOffsetY, + (ushort)destinationOffsetZ, d3D12ResourceSource: source.D3D12Resource, d3D12PlacedSubresourceFootprintSource, - (uint)sourceX, - (uint)sourceY, - (ushort)sourceZ, + (uint)sourceOffsetX, + (uint)sourceOffsetY, + (ushort)sourceOffsetZ, (uint)width, (uint)height, (ushort)depth);