diff --git a/src/ComputeSharp.Graphics/Resources/Abstract/Texture2D{T}.cs b/src/ComputeSharp.Graphics/Resources/Abstract/Texture2D{T}.cs index 2169427b..ed5d771b 100644 --- a/src/ComputeSharp.Graphics/Resources/Abstract/Texture2D{T}.cs +++ b/src/ComputeSharp.Graphics/Resources/Abstract/Texture2D{T}.cs @@ -361,7 +361,7 @@ namespace ComputeSharp.Resources source.ThrowIfDisposed(); Guard.IsInRange(sourceX, 0, source.Width, nameof(sourceX)); - Guard.IsInRange(sourceY, 0, source.Width, nameof(sourceY)); + Guard.IsInRange(sourceY, 0, source.Height, nameof(sourceY)); Guard.IsInRange(destinationX, 0, Width, nameof(destinationX)); Guard.IsInRange(destinationY, 0, Height, nameof(destinationY)); Guard.IsBetweenOrEqualTo(width, 1, Width, nameof(width)); diff --git a/src/ComputeSharp.Graphics/Resources/Abstract/Texture3D{T}.cs b/src/ComputeSharp.Graphics/Resources/Abstract/Texture3D{T}.cs index 3385bd96..78980eb0 100644 --- a/src/ComputeSharp.Graphics/Resources/Abstract/Texture3D{T}.cs +++ b/src/ComputeSharp.Graphics/Resources/Abstract/Texture3D{T}.cs @@ -377,13 +377,16 @@ namespace ComputeSharp.Resources /// 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 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 x, int y, int z, int width, int height, int depth) + internal void CopyFrom(UploadTexture3D source, int sourceX, int sourceY, int sourceZ, int destinationX, int destinationY, int destinationZ, int width, int height, int depth) { GraphicsDevice.ThrowIfDisposed(); @@ -392,18 +395,24 @@ namespace ComputeSharp.Resources source.ThrowIfDeviceMismatch(GraphicsDevice); source.ThrowIfDisposed(); - Guard.IsInRange(x, 0, Width, nameof(x)); - Guard.IsInRange(y, 0, Height, nameof(y)); - Guard.IsInRange(z, 0, Depth, nameof(z)); + 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.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(x + width, Width, nameof(x)); - Guard.IsLessThanOrEqualTo(y + height, Height, nameof(y)); - Guard.IsLessThanOrEqualTo(z + depth, Depth, nameof(z)); + 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)); using CommandList copyCommandList = new(GraphicsDevice, this.d3D12CommandListType); @@ -416,14 +425,14 @@ namespace ComputeSharp.Resources { copyCommandList.D3D12GraphicsCommandList->CopyTextureRegion( d3D12ResourceDestination: D3D12Resource, - destinationX: (uint)x, - destinationY: (uint)y, - destinationZ: (ushort)z, + (uint)destinationX, + (uint)destinationY, + (ushort)destinationZ, d3D12ResourceSource: source.D3D12Resource, d3D12PlacedSubresourceFootprintSource, - sourceX: 0, - sourceY: 0, - sourceZ: 0, + (uint)sourceX, + (uint)sourceY, + (ushort)sourceZ, (uint)width, (uint)height, (ushort)depth); diff --git a/src/ComputeSharp.Graphics/Resources/Abstract/TransferTexture3D{T}.cs b/src/ComputeSharp.Graphics/Resources/Abstract/TransferTexture3D{T}.cs index 746d6ad2..c16364a5 100644 --- a/src/ComputeSharp.Graphics/Resources/Abstract/TransferTexture3D{T}.cs +++ b/src/ComputeSharp.Graphics/Resources/Abstract/TransferTexture3D{T}.cs @@ -69,7 +69,7 @@ namespace ComputeSharp.Resources out _, out ulong totalSizeInBytes); - using ComPtr d3D12Resource = GraphicsDevice.D3D12Device->CreateCommittedResource(resourceType, allocationMode, totalSizeInBytes, GraphicsDevice.IsCacheCoherentUMA); + this.d3D12Resource = GraphicsDevice.D3D12Device->CreateCommittedResource(resourceType, allocationMode, totalSizeInBytes, GraphicsDevice.IsCacheCoherentUMA); this.mappedData = (T*)this.d3D12Resource.Get()->Map().Pointer; } diff --git a/src/ComputeSharp/Extensions/Resources/UploadTexture3DExtensions.cs b/src/ComputeSharp/Extensions/Resources/UploadTexture3DExtensions.cs index ad8bf455..d5e42e85 100644 --- a/src/ComputeSharp/Extensions/Resources/UploadTexture3DExtensions.cs +++ b/src/ComputeSharp/Extensions/Resources/UploadTexture3DExtensions.cs @@ -16,7 +16,7 @@ namespace ComputeSharp public static void CopyTo(this UploadTexture3D texture, Texture3D destination) where T : unmanaged { - destination.CopyFrom(texture, 0, 0, 0, texture.Width, texture.Height, texture.Depth); + destination.CopyFrom(texture, 0, 0, 0, 0, 0, 0, texture.Width, texture.Height, texture.Depth); } /// @@ -34,7 +34,7 @@ namespace ComputeSharp public static void CopyTo(this UploadTexture3D texture, Texture3D destination, int x, int y, int z, int width, int height, int depth) where T : unmanaged { - destination.CopyFrom(texture, x, y, z, width, height, depth); + destination.CopyFrom(texture, x, y, z, 0, 0, 0, width, height, depth); } } }