diff --git a/src/ComputeSharp/Graphics/Extensions/Interop/ID3D12GraphicsCommandListExtensions.cs b/src/ComputeSharp/Graphics/Extensions/Interop/ID3D12GraphicsCommandListExtensions.cs
index 0027ade5..25f7a512 100644
--- a/src/ComputeSharp/Graphics/Extensions/Interop/ID3D12GraphicsCommandListExtensions.cs
+++ b/src/ComputeSharp/Graphics/Extensions/Interop/ID3D12GraphicsCommandListExtensions.cs
@@ -45,7 +45,9 @@ internal static unsafe class ID3D12GraphicsCommandListExtensions
D3D12_BOX d3D12Box;
D3D12_BOX* pD3D12Box;
- if (sourceX == 0 && sourceY == 0 && sourceZ == 0 &&
+ if (sourceX == 0 &&
+ sourceY == 0 &&
+ sourceZ == 0 &&
width == d3D12ResourceDescriptionSource.Width &&
height == d3D12ResourceDescriptionSource.Height &&
depth == d3D12ResourceDescriptionSource.Depth)
@@ -103,7 +105,9 @@ internal static unsafe class ID3D12GraphicsCommandListExtensions
D3D12_BOX d3D12Box;
D3D12_BOX* pD3D12Box;
- if (sourceX == 0 && sourceY == 0 && sourceZ == 0 &&
+ if (sourceX == 0 &&
+ sourceY == 0 &&
+ sourceZ == 0 &&
width == d3D12PlacedSubresourceFootprintSource->Footprint.Width &&
height == d3D12PlacedSubresourceFootprintSource->Footprint.Height &&
depth == d3D12PlacedSubresourceFootprintSource->Footprint.Depth)
@@ -125,6 +129,65 @@ internal static unsafe class ID3D12GraphicsCommandListExtensions
pD3D12Box);
}
+ ///
+ /// Copies a texture memory region from one texture to another.
+ ///
+ /// The instance in use.
+ /// The destination (a buffer) to write to.
+ /// The horizontal offset in the destination buffer.
+ /// The vertical offset in the destination buffer.
+ /// The depthwise offset in the destination buffer.
+ /// The source (a texture) to read 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 read from.
+ /// The height of the memory area to read from.
+ /// The depth of the memory area to read from.
+ public static void CopyTextureRegion(
+ this ref ID3D12GraphicsCommandList d3D12GraphicsCommandList,
+ ID3D12Resource* d3D12ResourceDestination,
+ uint destinationX,
+ uint destinationY,
+ ushort destinationZ,
+ ID3D12Resource* d3D12ResourceSource,
+ uint sourceX,
+ uint sourceY,
+ ushort sourceZ,
+ uint width,
+ uint height,
+ ushort depth)
+ {
+ D3D12_RESOURCE_DESC d3D12ResourceDescriptionSource = d3D12ResourceSource->GetDesc();
+ D3D12_TEXTURE_COPY_LOCATION d3D12TextureCopyLocationDestination = new(d3D12ResourceDestination, 0);
+ D3D12_TEXTURE_COPY_LOCATION d3D12TextureCopyLocationSource = new(d3D12ResourceSource, 0);
+ D3D12_BOX d3D12Box;
+ D3D12_BOX* pD3D12Box;
+
+ if (sourceX == 0 &&
+ sourceY == 0 &&
+ sourceZ == 0 &&
+ width == d3D12ResourceDescriptionSource.Width &&
+ height == d3D12ResourceDescriptionSource.Height &&
+ depth == d3D12ResourceDescriptionSource.Depth)
+ {
+ pD3D12Box = null;
+ }
+ else
+ {
+ d3D12Box = new D3D12_BOX((int)sourceX, (int)sourceY, sourceZ, (int)(sourceX + width), (int)(sourceY + height), sourceZ + depth);
+ pD3D12Box = &d3D12Box;
+ }
+
+ d3D12GraphicsCommandList.CopyTextureRegion(
+ &d3D12TextureCopyLocationDestination,
+ destinationX,
+ destinationY,
+ destinationZ,
+ &d3D12TextureCopyLocationSource,
+ pD3D12Box);
+ }
+
///
/// Creates a resource barrier to transition a resource to a specific state.
///
diff --git a/src/ComputeSharp/Graphics/Extensions/Texture2DExtensions.cs b/src/ComputeSharp/Graphics/Extensions/Texture2DExtensions.cs
index db24237f..d0a12488 100644
--- a/src/ComputeSharp/Graphics/Extensions/Texture2DExtensions.cs
+++ b/src/ComputeSharp/Graphics/Extensions/Texture2DExtensions.cs
@@ -177,6 +177,52 @@ public static class Texture2DExtensions
source.CopyTo(ref MemoryMarshal.GetReference(destination), destination.Length, sourceOffsetX, sourceOffsetY, width, height);
}
+ ///
+ /// 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.
+ public static void CopyTo(this Texture2D source, Texture2D destination)
+ where T : unmanaged
+ {
+ source.CopyTo(destination, 0, 0, 0, 0, source.Width, source.Height);
+ }
+
+ ///
+ /// 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 width of the memory area to copy.
+ /// The height of the memory area to copy.
+ public static void CopyTo(this Texture2D source, Texture2D destination, int sourceOffsetX, int sourceOffsetY, int width, int height)
+ where T : unmanaged
+ {
+ source.CopyTo(destination, sourceOffsetX, sourceOffsetY, 0, 0, width, height);
+ }
+
+ ///
+ /// 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 horizontal offset in the destination texture.
+ /// The vertical offset in the destination texture.
+ /// The width of the memory area to copy.
+ /// The height of the memory area to copy.
+ public static void CopyTo(this Texture2D source, Texture2D destination, int sourceOffsetX, int sourceOffsetY, int destinationOffsetX, int destinationOffsetY, int width, int height)
+ where T : unmanaged
+ {
+ source.CopyTo(destination, sourceOffsetX, sourceOffsetY, destinationOffsetX, destinationOffsetY, width, height);
+ }
+
///
/// Reads the contents of a instance and writes them into a target instance.
///
@@ -358,6 +404,52 @@ public static class Texture2DExtensions
destination.CopyFrom(ref MemoryMarshal.GetReference(source), source.Length, destinationOffsetX, destinationOffsetY, width, height);
}
+ ///
+ /// 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 Texture2D destination, Texture2D source)
+ where T : unmanaged
+ {
+ destination.CopyFrom(source, 0, 0, 0, 0, source.Width, source.Height);
+ }
+
+ ///
+ /// 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 width of the memory area to copy.
+ /// The height of the memory area to copy.
+ public static void CopyFrom(this Texture2D destination, Texture2D source, int sourceOffsetX, int sourceOffsetY, int width, int height)
+ where T : unmanaged
+ {
+ source.CopyTo(destination, sourceOffsetX, sourceOffsetY, 0, 0, width, height);
+ }
+
+ ///
+ /// 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 horizontal offset in the destination texture.
+ /// The vertical offset in the destination texture.
+ /// The width of the memory area to copy.
+ /// The height of the memory area to copy.
+ public static void CopyFrom(this Texture2D destination, Texture2D source, int sourceOffsetX, int sourceOffsetY, int destinationOffsetX, int destinationOffsetY, int width, int height)
+ where T : unmanaged
+ {
+ source.CopyTo(destination, sourceOffsetX, sourceOffsetY, destinationOffsetX, destinationOffsetY, width, height);
+ }
+
///
/// Reads the contents of an instance and writes them into a target instance.
///
@@ -367,7 +459,7 @@ public static class Texture2DExtensions
public static void CopyFrom(this Texture2D destination, UploadTexture2D source)
where T : unmanaged
{
- destination.CopyFrom(source, 0, 0, 0, 0, source.Width, source.Height);
+ source.CopyTo(destination, 0, 0, 0, 0, source.Width, source.Height);
}
///
diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/Texture2D{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/Texture2D{T}.cs
index b83a618c..4c2f723e 100644
--- a/src/ComputeSharp/Graphics/Resources/Abstract/Texture2D{T}.cs
+++ b/src/ComputeSharp/Graphics/Resources/Abstract/Texture2D{T}.cs
@@ -223,6 +223,74 @@ public unsafe abstract class Texture2D : NativeObject, GraphicsResourceHelper
}
}
+ ///
+ /// Reads the contents of the specified range from the current instance and writes them into a target instance.
+ ///
+ /// The target instance to write data to.
+ /// The horizontal offset within .
+ /// The vertical offset within .
+ /// The horizontal offset in the source texture.
+ /// The vertical offset in the source texture.
+ /// The width of the memory area to copy.
+ /// The height of the memory area to copy.
+ internal void CopyTo(Texture2D destination, int sourceOffsetX, int sourceOffsetY, int destinationOffsetX, int destinationOffsetY, int width, int height)
+ {
+ GraphicsDevice.ThrowIfDisposed();
+
+ ThrowIfDisposed();
+
+ destination.ThrowIfDeviceMismatch(GraphicsDevice);
+ destination.ThrowIfDisposed();
+
+ Guard.IsInRange(sourceOffsetX, 0, Width, nameof(sourceOffsetX));
+ Guard.IsInRange(sourceOffsetY, 0, Height, nameof(sourceOffsetY));
+ Guard.IsInRange(destinationOffsetX, 0, destination.Width, nameof(destinationOffsetX));
+ Guard.IsInRange(destinationOffsetY, 0, destination.Height, nameof(destinationOffsetY));
+ Guard.IsBetweenOrEqualTo(width, 1, Width, nameof(width));
+ Guard.IsBetweenOrEqualTo(height, 1, Height, nameof(height));
+ Guard.IsBetweenOrEqualTo(width, 1, destination.Width, nameof(width));
+ Guard.IsBetweenOrEqualTo(height, 1, destination.Height, nameof(height));
+ Guard.IsBetweenOrEqualTo(destinationOffsetX + width, 1, destination.Width, nameof(destinationOffsetX));
+ Guard.IsBetweenOrEqualTo(destinationOffsetY + height, 1, destination.Height, nameof(destinationOffsetY));
+ Guard.IsLessThanOrEqualTo(sourceOffsetX + width, Width, nameof(sourceOffsetX));
+ Guard.IsLessThanOrEqualTo(sourceOffsetY + height, Height, nameof(sourceOffsetY));
+
+ D3D12_COMMAND_LIST_TYPE d3D12CommandListType =
+ this.d3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE ||
+ destination.d3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE
+ ? D3D12_COMMAND_LIST_TYPE_COMPUTE
+ : D3D12_COMMAND_LIST_TYPE_COPY;
+
+ using CommandList copyCommandList = new(GraphicsDevice, d3D12CommandListType);
+
+ if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
+ {
+ copyCommandList.D3D12GraphicsCommandList->ResourceBarrier(D3D12Resource, this.d3D12ResourceState, D3D12_RESOURCE_STATE_COPY_SOURCE);
+ copyCommandList.D3D12GraphicsCommandList->ResourceBarrier(destination.D3D12Resource, destination.d3D12ResourceState, D3D12_RESOURCE_STATE_COPY_DEST);
+ }
+
+ copyCommandList.D3D12GraphicsCommandList->CopyTextureRegion(
+ d3D12ResourceDestination: destination.D3D12Resource,
+ (uint)destinationOffsetX,
+ (uint)destinationOffsetY,
+ destinationZ: 0,
+ d3D12ResourceSource: D3D12Resource,
+ (uint)sourceOffsetX,
+ (uint)sourceOffsetY,
+ sourceZ: 0,
+ (uint)width,
+ (uint)height,
+ 1);
+
+ if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
+ {
+ copyCommandList.D3D12GraphicsCommandList->ResourceBarrier(D3D12Resource, D3D12_RESOURCE_STATE_COPY_SOURCE, this.d3D12ResourceState);
+ copyCommandList.D3D12GraphicsCommandList->ResourceBarrier(destination.D3D12Resource, D3D12_RESOURCE_STATE_COPY_DEST, destination.d3D12ResourceState);
+ }
+
+ copyCommandList.ExecuteAndWaitForCompletion();
+ }
+
///
/// Reads the contents of the specified range from the current instance and writes them into a target instance.
///
diff --git a/tests/ComputeSharp.Tests/Texture2DTests.cs b/tests/ComputeSharp.Tests/Texture2DTests.cs
index a89f3ce4..04c018aa 100644
--- a/tests/ComputeSharp.Tests/Texture2DTests.cs
+++ b/tests/ComputeSharp.Tests/Texture2DTests.cs
@@ -165,6 +165,228 @@ public partial class Texture2DTests
texture.CopyTo(result, x, y, width, height);
}
+ [CombinatorialTestMethod]
+ [AllDevices]
+ [Resource(typeof(ReadOnlyTexture2D<>))]
+ [Resource(typeof(ReadWriteTexture2D<>))]
+ [AdditionalResource(typeof(ReadOnlyTexture2D<>))]
+ [AdditionalResource(typeof(ReadWriteTexture2D<>))]
+ [Data(1024, 1024, 1024, 1024, 0, 0, 0, 0, 1024, 1024)]
+ [Data(1024, 1024, 1024, 1024, 127, 256, 0, 0, 512, 480)]
+ [Data(1024, 1024, 1024, 1024, 0, 0, 127, 256, 512, 480)]
+ [Data(1024, 1024, 1024, 1024, 122, 329, 127, 256, 512, 480)]
+ [Data(512, 480, 1024, 768, 122, 29, 127, 256, 256, 320)]
+ [Data(512, 480, 256, 256, 122, 120, 0, 0, 256, 256)]
+ [Data(512, 512, 1024, 1024, 0, 0, 0, 0, 512, 512)]
+ [Data(512, 512, 1024, 1024, 0, 0, 512, 0, 512, 512)]
+ [Data(512, 512, 1024, 1024, 0, 0, 0, 512, 512, 512)]
+ [Data(512, 512, 1024, 1024, 0, 0, 512, 512, 512, 512)]
+ [Data(512, 512, 1024, 1024, 0, 0, 256, 256, 512, 512)]
+ public void CopyTo_TextureToVoid_Ok(
+ Device device,
+ Type sourceType,
+ Type destinationType,
+ int sourceWidth,
+ int sourceHeight,
+ int destinationWidth,
+ int destinationHeight,
+ int sourceOffsetX,
+ int sourceOffsetY,
+ int destinationOffsetX,
+ int destinationOffsetY,
+ int copyWidth,
+ int copyHeight)
+ {
+ float[] array = Enumerable.Range(0, sourceHeight * sourceWidth).Select(static i => (float)i).ToArray();
+
+ using Texture2D source = device.Get().AllocateTexture2D(sourceType, array, sourceWidth, sourceHeight);
+ using Texture2D destination = device.Get().AllocateTexture2D(destinationType, destinationWidth, destinationHeight, AllocationMode.Clear);
+
+ source.CopyTo(destination, sourceOffsetX, sourceOffsetY, destinationOffsetX, destinationOffsetY, copyWidth, copyHeight);
+
+ ReadOnlySpan2D expected = new(array, sourceHeight, sourceWidth);
+ ReadOnlySpan2D result = destination.ToArray();
+
+ for (int i = 0; i < destinationHeight; i++)
+ {
+ for (int j = 0; j < destinationWidth; j++)
+ {
+ if (i >= destinationOffsetY &&
+ i < destinationOffsetY + copyHeight &&
+ j >= destinationOffsetX &&
+ j < destinationOffsetX + copyWidth)
+ {
+ int sourceY = i - destinationOffsetY + sourceOffsetY;
+ int sourceX = j - destinationOffsetX + sourceOffsetX;
+
+ Assert.AreEqual(expected[sourceY, sourceX], result[i, j]);
+ }
+ else
+ {
+ Assert.AreEqual(0, result[i, j]);
+ }
+ }
+ }
+ }
+
+ [CombinatorialTestMethod]
+ [AllDevices]
+ [Resource(typeof(ReadOnlyTexture2D<>))]
+ [Resource(typeof(ReadWriteTexture2D<>))]
+ [AdditionalResource(typeof(ReadOnlyTexture2D<>))]
+ [AdditionalResource(typeof(ReadWriteTexture2D<>))]
+ [Data(1024, 1024, 1024, 1024, 0, 0, 0, 0, 2055, 1024)]
+ [Data(1024, 1024, 1024, 1024, 0, 0, 0, 0, 1024, 3920)]
+ [Data(1024, 1024, 1024, 1024, 0, 0, 0, 0, -1, 1024)]
+ [Data(1024, 1024, 1024, 1024, 0, 0, 0, 0, 512, -2)]
+ [Data(1024, 1024, 1024, 1024, 0, 0, 0, 0, 512, int.MaxValue)]
+ [Data(512, 512, 1024, 1024, 0, 0, 0, 0, 768, 768)]
+ [Data(512, 512, 1024, 1024, 0, 0, 0, 0, 256, 768)]
+ [Data(512, 512, 1024, 1024, 0, 0, 0, 0, 620, 256)]
+ [Data(1024, 1024, 512, 512, 0, 0, 0, 0, 768, 768)]
+ [Data(1024, 1024, 512, 512, 0, 0, 0, 0, 256, 768)]
+ [Data(1024, 1024, 512, 512, 0, 0, 0, 0, 620, 256)]
+ [Data(512, 512, 512, 512, 450, 0, 0, 0, 128, 128)]
+ [Data(512, 512, 512, 512, 0, 450, 0, 0, 128, 128)]
+ [Data(512, 512, 512, 512, 0, 0, 450, 0, 128, 128)]
+ [Data(512, 512, 512, 512, 0, 0, 0, 450, 128, 128)]
+ [Data(512, 512, 512, 512, -1, 0, 0, 0, 128, 128)]
+ [Data(512, 512, 512, 512, 0, -1, 0, 0, 128, 128)]
+ [Data(512, 512, 512, 512, 0, 0, -1, 0, 128, 128)]
+ [Data(512, 512, 512, 512, 0, 0, 0, -1, 128, 128)]
+ [ExpectedException(typeof(ArgumentOutOfRangeException))]
+ public void CopyTo_TextureToVoid_Fail(
+ Device device,
+ Type sourceType,
+ Type destinationType,
+ int sourceWidth,
+ int sourceHeight,
+ int destinationWidth,
+ int destinationHeight,
+ int sourceOffsetX,
+ int sourceOffsetY,
+ int destinationOffsetX,
+ int destinationOffsetY,
+ int copyWidth,
+ int copyHeight)
+ {
+ using Texture2D source = device.Get().AllocateTexture2D(sourceType, sourceWidth, sourceHeight);
+ using Texture2D destination = device.Get().AllocateTexture2D(destinationType, destinationWidth, destinationHeight, AllocationMode.Clear);
+
+ source.CopyTo(destination, sourceOffsetX, sourceOffsetY, destinationOffsetX, destinationOffsetY, copyWidth, copyHeight);
+ }
+
+ [CombinatorialTestMethod]
+ [AllDevices]
+ [Resource(typeof(ReadOnlyTexture2D<>))]
+ [Resource(typeof(ReadWriteTexture2D<>))]
+ [AdditionalResource(typeof(ReadOnlyTexture2D<>))]
+ [AdditionalResource(typeof(ReadWriteTexture2D<>))]
+ [Data(1024, 1024, 1024, 1024, 0, 0, 0, 0, 1024, 1024)]
+ [Data(1024, 1024, 1024, 1024, 127, 256, 0, 0, 512, 480)]
+ [Data(1024, 1024, 1024, 1024, 0, 0, 127, 256, 512, 480)]
+ [Data(1024, 1024, 1024, 1024, 122, 329, 127, 256, 512, 480)]
+ [Data(512, 480, 1024, 768, 122, 29, 127, 256, 256, 320)]
+ [Data(512, 480, 256, 256, 122, 120, 0, 0, 256, 256)]
+ [Data(512, 512, 1024, 1024, 0, 0, 0, 0, 512, 512)]
+ [Data(512, 512, 1024, 1024, 0, 0, 512, 0, 512, 512)]
+ [Data(512, 512, 1024, 1024, 0, 0, 0, 512, 512, 512)]
+ [Data(512, 512, 1024, 1024, 0, 0, 512, 512, 512, 512)]
+ [Data(512, 512, 1024, 1024, 0, 0, 256, 256, 512, 512)]
+ public void CopyFrom_TextureToVoid_Ok(
+ Device device,
+ Type sourceType,
+ Type destinationType,
+ int sourceWidth,
+ int sourceHeight,
+ int destinationWidth,
+ int destinationHeight,
+ int sourceOffsetX,
+ int sourceOffsetY,
+ int destinationOffsetX,
+ int destinationOffsetY,
+ int copyWidth,
+ int copyHeight)
+ {
+ float[] array = Enumerable.Range(0, sourceHeight * sourceWidth).Select(static i => (float)i).ToArray();
+
+ using Texture2D source = device.Get().AllocateTexture2D(sourceType, array, sourceWidth, sourceHeight);
+ using Texture2D destination = device.Get().AllocateTexture2D(destinationType, destinationWidth, destinationHeight, AllocationMode.Clear);
+
+ destination.CopyFrom(source, sourceOffsetX, sourceOffsetY, destinationOffsetX, destinationOffsetY, copyWidth, copyHeight);
+
+ ReadOnlySpan2D expected = new(array, sourceHeight, sourceWidth);
+ ReadOnlySpan2D result = destination.ToArray();
+
+ for (int i = 0; i < destinationHeight; i++)
+ {
+ for (int j = 0; j < destinationWidth; j++)
+ {
+ if (i >= destinationOffsetY &&
+ i < destinationOffsetY + copyHeight &&
+ j >= destinationOffsetX &&
+ j < destinationOffsetX + copyWidth)
+ {
+ int sourceY = i - destinationOffsetY + sourceOffsetY;
+ int sourceX = j - destinationOffsetX + sourceOffsetX;
+
+ Assert.AreEqual(expected[sourceY, sourceX], result[i, j]);
+ }
+ else
+ {
+ Assert.AreEqual(0, result[i, j]);
+ }
+ }
+ }
+ }
+
+ [CombinatorialTestMethod]
+ [AllDevices]
+ [Resource(typeof(ReadOnlyTexture2D<>))]
+ [Resource(typeof(ReadWriteTexture2D<>))]
+ [AdditionalResource(typeof(ReadOnlyTexture2D<>))]
+ [AdditionalResource(typeof(ReadWriteTexture2D<>))]
+ [Data(1024, 1024, 1024, 1024, 0, 0, 0, 0, 2055, 1024)]
+ [Data(1024, 1024, 1024, 1024, 0, 0, 0, 0, 1024, 3920)]
+ [Data(1024, 1024, 1024, 1024, 0, 0, 0, 0, -1, 1024)]
+ [Data(1024, 1024, 1024, 1024, 0, 0, 0, 0, 512, -2)]
+ [Data(1024, 1024, 1024, 1024, 0, 0, 0, 0, 512, int.MaxValue)]
+ [Data(512, 512, 1024, 1024, 0, 0, 0, 0, 768, 768)]
+ [Data(512, 512, 1024, 1024, 0, 0, 0, 0, 256, 768)]
+ [Data(512, 512, 1024, 1024, 0, 0, 0, 0, 620, 256)]
+ [Data(1024, 1024, 512, 512, 0, 0, 0, 0, 768, 768)]
+ [Data(1024, 1024, 512, 512, 0, 0, 0, 0, 256, 768)]
+ [Data(1024, 1024, 512, 512, 0, 0, 0, 0, 620, 256)]
+ [Data(512, 512, 512, 512, 450, 0, 0, 0, 128, 128)]
+ [Data(512, 512, 512, 512, 0, 450, 0, 0, 128, 128)]
+ [Data(512, 512, 512, 512, 0, 0, 450, 0, 128, 128)]
+ [Data(512, 512, 512, 512, 0, 0, 0, 450, 128, 128)]
+ [Data(512, 512, 512, 512, -1, 0, 0, 0, 128, 128)]
+ [Data(512, 512, 512, 512, 0, -1, 0, 0, 128, 128)]
+ [Data(512, 512, 512, 512, 0, 0, -1, 0, 128, 128)]
+ [Data(512, 512, 512, 512, 0, 0, 0, -1, 128, 128)]
+ [ExpectedException(typeof(ArgumentOutOfRangeException))]
+ public void CopyFrom_TextureToVoid_Fail(
+ Device device,
+ Type sourceType,
+ Type destinationType,
+ int sourceWidth,
+ int sourceHeight,
+ int destinationWidth,
+ int destinationHeight,
+ int sourceOffsetX,
+ int sourceOffsetY,
+ int destinationOffsetX,
+ int destinationOffsetY,
+ int copyWidth,
+ int copyHeight)
+ {
+ using Texture2D source = device.Get().AllocateTexture2D(sourceType, sourceWidth, sourceHeight);
+ using Texture2D destination = device.Get().AllocateTexture2D(destinationType, destinationWidth, destinationHeight, AllocationMode.Clear);
+
+ destination.CopyFrom(source, sourceOffsetX, sourceOffsetY, destinationOffsetX, destinationOffsetY, copyWidth, copyHeight);
+ }
+
[CombinatorialTestMethod]
[AllDevices]
public void Dispatch_ReadOnlyTexture2D(Device device)