From be91da6d05ccf761e046e61506bdaba259b6a06f Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 23 Nov 2020 14:01:27 +0100 Subject: [PATCH] Renamed some API parameters --- .../Buffers/Abstract/Buffer{T}.cs | 38 +++++++++---------- .../Buffers/Abstract/StructuredBuffer{T}.cs | 26 ++++++------- .../Buffers/ConstantBuffer{T}.cs | 30 +++++++-------- 3 files changed, 47 insertions(+), 47 deletions(-) diff --git a/src/ComputeSharp.Graphics/Buffers/Abstract/Buffer{T}.cs b/src/ComputeSharp.Graphics/Buffers/Abstract/Buffer{T}.cs index dc48dba0..f3dc3b27 100644 --- a/src/ComputeSharp.Graphics/Buffers/Abstract/Buffer{T}.cs +++ b/src/ComputeSharp.Graphics/Buffers/Abstract/Buffer{T}.cs @@ -124,64 +124,64 @@ namespace ComputeSharp.Graphics.Buffers.Abstract /// /// Reads the contents of the current instance and writes them into a target . /// - /// The input to write data to. - public void GetData(Span span) => GetData(span, 0, Length); + /// The input to write data to. + public void GetData(Span destination) => GetData(destination, 0, Length); /// /// Reads the contents of the specified range from the current instance and writes them into a target . /// - /// The input to write data to. + /// The input to write data to. /// The offset to start reading data from. /// The number of items to read. - public abstract void GetData(Span span, int offset, int count); + public abstract void GetData(Span destination, int offset, int count); /// /// Writes the contents of a given array to the current instance. /// - /// The input array to read data from. - public void SetData(T[] array) => SetData(array.AsSpan()); + /// The input array to read data from. + public void SetData(T[] source) => SetData(source.AsSpan()); /// /// Writes the contents of a given array to a specified area of the current instance. /// - /// The input array to read data from. + /// The input array to read data from. /// The offset to start writing data to. /// The number of items to write. - public void SetData(T[] array, int offset, int count) => SetData(array.AsSpan(), offset, count); + public void SetData(T[] source, int offset, int count) => SetData(source.AsSpan(), offset, count); /// /// Writes the contents of a given to the current instance. /// - /// The input to read data from. - public void SetData(ReadOnlySpan span) => SetData(span, 0, Length); + /// The input to read data from. + public void SetData(ReadOnlySpan source) => SetData(source, 0, Length); /// /// Writes the contents of a given to a specified area of the current instance. /// - /// The input to read data from. + /// The input to read data from. /// The offset to start writing data to. /// The number of items to write. - public abstract void SetData(ReadOnlySpan span, int offset, int count); + public abstract void SetData(ReadOnlySpan source, int offset, int count); /// /// Writes the contents of a given to the current instance. /// - /// The input to read data from. - public abstract void SetData(Buffer buffer); + /// The input to read data from. + public abstract void SetData(Buffer source); /// /// Writes the contents of a given to the current instance, using a temporary CPU buffer. /// - /// The input to read data from. - protected void SetDataWithCpuBuffer(Buffer buffer) + /// The input to read data from. + protected void SetDataWithCpuBuffer(Buffer source) { - T[] array = ArrayPool.Shared.Rent(buffer.Length); + T[] array = ArrayPool.Shared.Rent(source.Length); try { - Span span = array.AsSpan(0, buffer.Length); + Span span = array.AsSpan(0, source.Length); - buffer.GetData(span); + source.GetData(span); SetData(span); } diff --git a/src/ComputeSharp.Graphics/Buffers/Abstract/StructuredBuffer{T}.cs b/src/ComputeSharp.Graphics/Buffers/Abstract/StructuredBuffer{T}.cs index f0e6d3ee..86bb4fde 100644 --- a/src/ComputeSharp.Graphics/Buffers/Abstract/StructuredBuffer{T}.cs +++ b/src/ComputeSharp.Graphics/Buffers/Abstract/StructuredBuffer{T}.cs @@ -30,7 +30,7 @@ namespace ComputeSharp.Graphics.Buffers.Abstract } /// - public override unsafe void GetData(Span span, int offset, int count) + public override unsafe void GetData(Span destination, int offset, int count) { GraphicsDevice.ThrowIfDisposed(); @@ -39,7 +39,7 @@ namespace ComputeSharp.Graphics.Buffers.Abstract Guard.IsInRange(offset, 0, Length, nameof(offset)); Guard.IsInRange(count, 0, Length, nameof(count)); Guard.IsLessThanOrEqualTo((uint)offset + count, (uint)Length, nameof(count)); - Guard.IsInRangeFor(count, span, nameof(count)); + Guard.IsInRangeFor(count, destination, nameof(count)); nint byteOffset = (nint)offset * ElementSizeInBytes, @@ -55,11 +55,11 @@ namespace ComputeSharp.Graphics.Buffers.Abstract using ID3D12ResourceMap resource = d3D12Resource.Get()->Map(); - MemoryHelper.Copy(resource.Pointer, 0, span, count); + MemoryHelper.Copy(resource.Pointer, 0, destination, count); } /// - public override unsafe void SetData(ReadOnlySpan span, int offset, int count) + public override unsafe void SetData(ReadOnlySpan source, int offset, int count) { GraphicsDevice.ThrowIfDisposed(); @@ -68,7 +68,7 @@ namespace ComputeSharp.Graphics.Buffers.Abstract Guard.IsInRange(offset, 0, Length, nameof(offset)); Guard.IsInRange(count, 0, Length, nameof(count)); Guard.IsLessThanOrEqualTo((uint)offset + count, (uint)Length, nameof(count)); - Guard.IsInRangeFor(count, span, nameof(count)); + Guard.IsInRangeFor(count, source, nameof(count)); nint byteOffset = (nint)offset * ElementSizeInBytes, @@ -78,7 +78,7 @@ namespace ComputeSharp.Graphics.Buffers.Abstract using (ID3D12ResourceMap resource = d3D12Resource.Get()->Map()) { - MemoryHelper.Copy(span, resource.Pointer, 0, count); + MemoryHelper.Copy(source, resource.Pointer, 0, count); } using CommandList copyCommandList = new(GraphicsDevice, D3D12_COMMAND_LIST_TYPE_COPY); @@ -88,24 +88,24 @@ namespace ComputeSharp.Graphics.Buffers.Abstract } /// - public override unsafe void SetData(Buffer buffer) + public override unsafe void SetData(Buffer source) { GraphicsDevice.ThrowIfDisposed(); - buffer.GraphicsDevice.ThrowIfDisposed(); + source.GraphicsDevice.ThrowIfDisposed(); ThrowIfDisposed(); - buffer.ThrowIfDisposed(); + source.ThrowIfDisposed(); - if (!buffer.IsPaddingPresent && - buffer.GraphicsDevice == GraphicsDevice) + if (!source.IsPaddingPresent && + source.GraphicsDevice == GraphicsDevice) { // Directly copy the input buffer using CommandList copyCommandList = new(GraphicsDevice, D3D12_COMMAND_LIST_TYPE_COPY); - copyCommandList.CopyBufferRegion(buffer.D3D12Resource, 0, D3D12Resource, 0, (ulong)SizeInBytes); + copyCommandList.CopyBufferRegion(source.D3D12Resource, 0, D3D12Resource, 0, (ulong)SizeInBytes); copyCommandList.ExecuteAndWaitForCompletion(); } - else SetDataWithCpuBuffer(buffer); + else SetDataWithCpuBuffer(source); } } } diff --git a/src/ComputeSharp.Graphics/Buffers/ConstantBuffer{T}.cs b/src/ComputeSharp.Graphics/Buffers/ConstantBuffer{T}.cs index f9547c63..4689e75a 100644 --- a/src/ComputeSharp.Graphics/Buffers/ConstantBuffer{T}.cs +++ b/src/ComputeSharp.Graphics/Buffers/ConstantBuffer{T}.cs @@ -54,7 +54,7 @@ namespace ComputeSharp } /// - public override unsafe void GetData(Span span, int offset, int count) + public override unsafe void GetData(Span destination, int offset, int count) { GraphicsDevice.ThrowIfDisposed(); @@ -63,13 +63,13 @@ namespace ComputeSharp Guard.IsInRange(offset, 0, Length, nameof(offset)); Guard.IsInRange(count, 0, Length, nameof(count)); Guard.IsLessThanOrEqualTo((uint)offset + count, (uint)Length, nameof(count)); - Guard.IsInRangeFor(count, span, nameof(count)); + Guard.IsInRangeFor(count, destination, nameof(count)); using ID3D12ResourceMap resource = D3D12Resource->Map(); if (IsPaddingPresent) { - ref T spanRef = ref MemoryMarshal.GetReference(span); + ref T spanRef = ref MemoryMarshal.GetReference(destination); ref byte resourceRef = ref Unsafe.AsRef(resource.Pointer); // Move to the initial ref @@ -82,11 +82,11 @@ namespace ComputeSharp Unsafe.Add(ref spanRef, i) = Unsafe.As(ref targetRef); } } - else MemoryHelper.Copy(resource.Pointer, offset, span, count); + else MemoryHelper.Copy(resource.Pointer, offset, destination, count); } /// - public override unsafe void SetData(ReadOnlySpan span, int offset, int count) + public override unsafe void SetData(ReadOnlySpan source, int offset, int count) { GraphicsDevice.ThrowIfDisposed(); @@ -95,13 +95,13 @@ namespace ComputeSharp Guard.IsInRange(offset, 0, Length, nameof(offset)); Guard.IsInRange(count, 0, Length, nameof(count)); Guard.IsLessThanOrEqualTo((uint)offset + count, (uint)Length, nameof(count)); - Guard.IsInRangeFor(count, span, nameof(count)); + Guard.IsInRangeFor(count, source, nameof(count)); using ID3D12ResourceMap resource = D3D12Resource->Map(); if (IsPaddingPresent) { - ref T spanRef = ref MemoryMarshal.GetReference(span); + ref T spanRef = ref MemoryMarshal.GetReference(source); ref byte resourceRef = ref Unsafe.AsRef(resource.Pointer); // Move to the initial offset @@ -114,28 +114,28 @@ namespace ComputeSharp Unsafe.As(ref targetRef) = Unsafe.Add(ref spanRef, i); } } - else MemoryHelper.Copy(span, resource.Pointer, offset, count); + else MemoryHelper.Copy(source, resource.Pointer, offset, count); } /// - public override unsafe void SetData(Buffer buffer) + public override unsafe void SetData(Buffer source) { GraphicsDevice.ThrowIfDisposed(); - buffer.GraphicsDevice.ThrowIfDisposed(); + source.GraphicsDevice.ThrowIfDisposed(); ThrowIfDisposed(); - buffer.ThrowIfDisposed(); + source.ThrowIfDisposed(); - if (buffer is ConstantBuffer && - buffer.GraphicsDevice == GraphicsDevice) + if (source is ConstantBuffer && + source.GraphicsDevice == GraphicsDevice) { // Directly copy the input buffer, if possible using CommandList copyCommandList = new CommandList(GraphicsDevice, D3D12_COMMAND_LIST_TYPE_COPY); - copyCommandList.CopyBufferRegion(buffer.D3D12Resource, 0, D3D12Resource, 0, (ulong)SizeInBytes); + copyCommandList.CopyBufferRegion(source.D3D12Resource, 0, D3D12Resource, 0, (ulong)SizeInBytes); copyCommandList.ExecuteAndWaitForCompletion(); } - else SetDataWithCpuBuffer(buffer); + else SetDataWithCpuBuffer(source); } ///