Renamed Buffer<T>.Size to Length

このコミットが含まれているのは:
Sergio Pedri committed 2020-11-23 12:59:43 +01:00
1 親 052bf969c7
コミット d6d5c4bcc9
8ファイル変更
+46 -46

検索条件に一致するファイルはありません

+4 -4
ファイルの表示
@@ -262,8 +262,8 @@ namespace ComputeSharp.BokehBlur.Processors
using IMemoryOwner<Vector4> source4 = GetExposedVector4Buffer(memory);
using ReadOnlyBuffer<Vector4> sourceBuffer = Gpu.Default.AllocateReadOnlyBuffer(source4.Memory.Span);
using ReadWriteBuffer<Vector4> processingBuffer = Gpu.Default.AllocateReadWriteBuffer<Vector4>(sourceBuffer.Size);
using ReadWriteBuffer<Vector4> firstPassBuffer = Gpu.Default.AllocateReadWriteBuffer<Vector4>(sourceBuffer.Size * 2);
using ReadWriteBuffer<Vector4> processingBuffer = Gpu.Default.AllocateReadWriteBuffer<Vector4>(sourceBuffer.Length);
using ReadWriteBuffer<Vector4> firstPassBuffer = Gpu.Default.AllocateReadWriteBuffer<Vector4>(sourceBuffer.Length * 2);
using ReadOnlyBuffer<Vector2> kernelBuffer = Gpu.Default.AllocateReadOnlyBuffer<Vector2>(KernelSize);
ref Vector4 param0 = ref KernelParameters[0]; // Avoid bounds check to access the kernel parameters
@@ -306,7 +306,7 @@ namespace ComputeSharp.BokehBlur.Processors
width = width,
maxY = height - 1,
maxX = width - 1,
kernelLength = kernel.Size,
kernelLength = kernel.Length,
source = source,
target = target,
kernel = kernel
@@ -376,7 +376,7 @@ namespace ComputeSharp.BokehBlur.Processors
width = width,
maxY = height - 1,
maxX = width - 1,
kernelLength = kernel.Size,
kernelLength = kernel.Length,
z = z,
w = w,
source = source,
+3 -3
ファイルの表示
@@ -97,7 +97,7 @@ namespace ComputeSharp.BokehBlur.Processors
PixelOperations<TPixel>.Instance.ToVector4(Configuration, spanTPixel, spanVector4);
using ReadWriteBuffer<Vector4> sourceBuffer = Gpu.Default.AllocateReadWriteBuffer(spanVector4);
using ReadWriteBuffer<Vector4> firstPassBuffer = Gpu.Default.AllocateReadWriteBuffer<Vector4>(sourceBuffer.Size);
using ReadWriteBuffer<Vector4> firstPassBuffer = Gpu.Default.AllocateReadWriteBuffer<Vector4>(sourceBuffer.Length);
using ReadOnlyBuffer<float> kernelBuffer = Gpu.Default.AllocateReadOnlyBuffer(Kernel);
ApplyVerticalConvolution(sourceBuffer, firstPassBuffer, kernelBuffer);
@@ -129,7 +129,7 @@ namespace ComputeSharp.BokehBlur.Processors
width = width,
maxY = height - 1,
maxX = width - 1,
kernelLength = kernel.Size,
kernelLength = kernel.Length,
source = source,
target = target,
kernel = kernel
@@ -191,7 +191,7 @@ namespace ComputeSharp.BokehBlur.Processors
width = width,
maxY = height - 1,
maxX = width - 1,
kernelLength = kernel.Size,
kernelLength = kernel.Length,
source = source,
target = target,
kernel = kernel
+13 -13
ファイルの表示
@@ -39,16 +39,16 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
/// Creates a new <see cref="Buffer{T}"/> instance with the specified parameters.
/// </summary>
/// <param name="device">The <see cref="GraphicsDevice"/> associated with the current instance.</param>
/// <param name="size">The number of items to store in the current buffer.</param>
/// <param name="length">The number of items to store in the current buffer.</param>
/// <param name="sizeInBytes">The size in bytes for the current buffer.</param>
/// <param name="bufferType">The buffer type for the current buffer.</param>
internal Buffer(GraphicsDevice device, int size, int sizeInBytes, BufferType bufferType)
internal Buffer(GraphicsDevice device, int length, int sizeInBytes, BufferType bufferType)
{
this.d3D12Resource = device.D3D12Device->CreateCommittedResource(bufferType, sizeInBytes);
SizeInBytes = sizeInBytes;
GraphicsDevice = device;
Size = size;
Length = length;
GraphicsDevice.AllocateShaderResourceViewDescriptorHandles(out D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandle, out D3D12GpuDescriptorHandle);
@@ -66,9 +66,9 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
public GraphicsDevice GraphicsDevice { get; }
/// <summary>
/// Gets the size of the current buffer, as in the number of <typeparamref name="T"/> values it contains.
/// Gets the length of the current buffer.
/// </summary>
public int Size { get; }
public int Length { get; }
/// <summary>
/// Gets the size in bytes of each <typeparamref name="T"/> value contained in the buffer.
@@ -85,7 +85,7 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
internal bool IsPaddingPresent
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => SizeInBytes > Size * Unsafe.SizeOf<T>();
get => SizeInBytes > Length * Unsafe.SizeOf<T>();
}
/// <summary>
@@ -98,7 +98,7 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
/// </summary>
/// <returns>A <typeparamref name="T"/> array with the contents of the current buffer.</returns>
[Pure]
public T[] GetData() => GetData(0, Size);
public T[] GetData() => GetData(0, Length);
/// <summary>
/// Reads the contents of the current <see cref="Buffer{T}"/> instance in a given range and returns an array.
@@ -120,7 +120,7 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
/// Reads the contents of the current <see cref="Buffer{T}"/> instance and writes them into a target <see cref="Span{T}"/>.
/// </summary>
/// <param name="span">The input <see cref="Span{T}"/> to write data to.</param>
public void GetData(Span<T> span) => GetData(span, 0, Size);
public void GetData(Span<T> span) => GetData(span, 0, Length);
/// <summary>
/// Reads the contents of the specified range from the current <see cref="Buffer{T}"/> instance and writes them into a target <see cref="Span{T}"/>.
@@ -148,7 +148,7 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
/// Writes the contents of a given <see cref="ReadOnlySpan{T}"/> to the current <see cref="Buffer{T}"/> instance.
/// </summary>
/// <param name="span">The input <see cref="ReadOnlySpan{T}"/> to read data from.</param>
public void SetData(ReadOnlySpan<T> span) => SetData(span, 0, Size);
public void SetData(ReadOnlySpan<T> span) => SetData(span, 0, Length);
/// <summary>
/// Writes the contents of a given <see cref="ReadOnlySpan{T}"/> to a specified area of the current <see cref="Buffer{T}"/> instance.
@@ -170,11 +170,11 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
/// <param name="buffer">The input <see cref="Buffer{T}"/> to read data from.</param>
protected void SetDataWithCpuBuffer(Buffer<T> buffer)
{
T[] array = ArrayPool<T>.Shared.Rent(buffer.Size);
T[] array = ArrayPool<T>.Shared.Rent(buffer.Length);
try
{
Span<T> span = array.AsSpan(0, buffer.Size);
Span<T> span = array.AsSpan(0, buffer.Length);
buffer.GetData(span);
@@ -210,7 +210,7 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
D3D12_SHADER_RESOURCE_VIEW_DESC d3D12ShaderResourceViewDescription = default;
d3D12ShaderResourceViewDescription.ViewDimension = D3D12_SRV_DIMENSION_BUFFER;
d3D12ShaderResourceViewDescription.Shader4ComponentMapping = FX.D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
d3D12ShaderResourceViewDescription.Buffer.NumElements = (uint)Size;
d3D12ShaderResourceViewDescription.Buffer.NumElements = (uint)Length;
d3D12ShaderResourceViewDescription.Buffer.StructureByteStride = (uint)ElementSizeInBytes;
GraphicsDevice.D3D12Device->CreateShaderResourceView(D3D12Resource, &d3D12ShaderResourceViewDescription, d3D12CpuDescriptorHandle);
@@ -224,7 +224,7 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
{
D3D12_UNORDERED_ACCESS_VIEW_DESC d3D12UnorderedAccessViewDescription = default;
d3D12UnorderedAccessViewDescription.ViewDimension = D3D12_UAV_DIMENSION_BUFFER;
d3D12UnorderedAccessViewDescription.Buffer.NumElements = (uint)Size;
d3D12UnorderedAccessViewDescription.Buffer.NumElements = (uint)Length;
d3D12UnorderedAccessViewDescription.Buffer.StructureByteStride = (uint)ElementSizeInBytes;
GraphicsDevice.D3D12Device->CreateUnorderedAccessView(D3D12Resource, null, &d3D12UnorderedAccessViewDescription, d3D12CpuDescriptorHandle);
+3 -3
ファイルの表示
@@ -21,10 +21,10 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
/// Creates a new <see cref="StructuredBuffer{T}"/> instance with the specified parameters
/// </summary>
/// <param name="device">The <see cref="GraphicsDevice"/> associated with the current instance</param>
/// <param name="size">The number of items to store in the current buffer</param>
/// <param name="length">The number of items to store in the current buffer</param>
/// <param name="bufferType">The buffer type for the current buffer</param>
internal StructuredBuffer(GraphicsDevice device, int size, BufferType bufferType)
: base(device, size, size * Unsafe.SizeOf<T>(), bufferType)
internal StructuredBuffer(GraphicsDevice device, int length, BufferType bufferType)
: base(device, length, length * Unsafe.SizeOf<T>(), bufferType)
{
}
+4 -4
ファイルの表示
@@ -29,9 +29,9 @@ namespace ComputeSharp
/// Creates a new <see cref="ConstantBuffer{T}"/> instance with the specified parameters
/// </summary>
/// <param name="device">The <see cref="GraphicsDevice"/> associated with the current instance</param>
/// <param name="size">The number of items to store in the current buffer</param>
internal ConstantBuffer(GraphicsDevice device, int size)
: base(device, size, size * GetPaddedSize(), BufferType.Constant)
/// <param name="length">The number of items to store in the current buffer</param>
internal ConstantBuffer(GraphicsDevice device, int length)
: base(device, length, length * GetPaddedSize(), BufferType.Constant)
{
}
@@ -115,7 +115,7 @@ namespace ComputeSharp
/// <inheritdoc/>
public override string ToString()
{
return $"ComputeSharp.ConstantBuffer<{typeof(T)}>[{Size}]";
return $"ComputeSharp.ConstantBuffer<{typeof(T)}>[{Length}]";
}
}
}
+4 -4
ファイルの表示
@@ -20,9 +20,9 @@ namespace ComputeSharp
/// Creates a new <see cref="ReadOnlyBuffer{T}"/> instance with the specified parameters
/// </summary>
/// <param name="device">The <see cref="GraphicsDevice"/> associated with the current instance</param>
/// <param name="size">The number of items to store in the current buffer</param>
internal ReadOnlyBuffer(GraphicsDevice device, int size)
: base(device, size, BufferType.ReadOnly)
/// <param name="length">The number of items to store in the current buffer</param>
internal ReadOnlyBuffer(GraphicsDevice device, int length)
: base(device, length, BufferType.ReadOnly)
{
}
@@ -36,7 +36,7 @@ namespace ComputeSharp
/// <inheritdoc/>
public override string ToString()
{
return $"ComputeSharp.ReadOnlyBuffer<{typeof(T)}>[{Size}]";
return $"ComputeSharp.ReadOnlyBuffer<{typeof(T)}>[{Length}]";
}
}
}
+4 -4
ファイルの表示
@@ -20,9 +20,9 @@ namespace ComputeSharp
/// Creates a new <see cref="ReadWriteBuffer{T}"/> instance with the specified parameters
/// </summary>
/// <param name="device">The <see cref="GraphicsDevice"/> associated with the current instance</param>
/// <param name="size">The number of items to store in the current buffer</param>
internal ReadWriteBuffer(GraphicsDevice device, int size)
: base(device, size, BufferType.ReadWrite)
/// <param name="length">The number of items to store in the current buffer</param>
internal ReadWriteBuffer(GraphicsDevice device, int length)
: base(device, length, BufferType.ReadWrite)
{
}
@@ -36,7 +36,7 @@ namespace ComputeSharp
/// <inheritdoc/>
public override string ToString()
{
return $"ComputeSharp.ReadWriteBuffer<{typeof(T)}>[{Size}]";
return $"ComputeSharp.ReadWriteBuffer<{typeof(T)}>[{Length}]";
}
}
}
+11 -11
ファイルの表示
@@ -54,7 +54,7 @@ namespace ComputeSharp
public static ConstantBuffer<T> AllocateConstantBuffer<T>(this GraphicsDevice device, Buffer<T> buffer)
where T : unmanaged
{
ConstantBuffer<T> constantBuffer = new(device, buffer.Size);
ConstantBuffer<T> constantBuffer = new(device, buffer.Length);
constantBuffer.SetData(buffer);
@@ -66,13 +66,13 @@ namespace ComputeSharp
/// </summary>
/// <typeparam name="T">The type of items to store in the buffer.</typeparam>
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the buffer.</param>
/// <param name="size">The size of the buffer to allocate.</param>
/// <returns>A zeroed <see cref="ReadOnlyBuffer{T}"/> instance of size <paramref name="size"/>.</returns>
/// <param name="length">The length of the buffer to allocate.</param>
/// <returns>A zeroed <see cref="ReadOnlyBuffer{T}"/> instance of size <paramref name="length"/>.</returns>
[Pure]
public static ReadOnlyBuffer<T> AllocateReadOnlyBuffer<T>(this GraphicsDevice device, int size)
public static ReadOnlyBuffer<T> AllocateReadOnlyBuffer<T>(this GraphicsDevice device, int length)
where T : unmanaged
{
return new(device, size);
return new(device, length);
}
/// <summary>
@@ -118,7 +118,7 @@ namespace ComputeSharp
public static ReadOnlyBuffer<T> AllocateReadOnlyBuffer<T>(this GraphicsDevice device, Buffer<T> buffer)
where T : unmanaged
{
ReadOnlyBuffer<T> readWriteBuffer = new(device, buffer.Size);
ReadOnlyBuffer<T> readWriteBuffer = new(device, buffer.Length);
readWriteBuffer.SetData(buffer);
@@ -130,13 +130,13 @@ namespace ComputeSharp
/// </summary>
/// <typeparam name="T">The type of items to store in the buffer.</typeparam>
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the buffer.</param>
/// <param name="size">The size of the buffer to allocate.</param>
/// <returns>A zeroed <see cref="ReadWriteBuffer{T}"/> instance of size <paramref name="size"/>.</returns>
/// <param name="length">The length of the buffer to allocate.</param>
/// <returns>A zeroed <see cref="ReadWriteBuffer{T}"/> instance of size <paramref name="length"/>.</returns>
[Pure]
public static ReadWriteBuffer<T> AllocateReadWriteBuffer<T>(this GraphicsDevice device, int size)
public static ReadWriteBuffer<T> AllocateReadWriteBuffer<T>(this GraphicsDevice device, int length)
where T : unmanaged
{
return new(device, size);
return new(device, length);
}
/// <summary>
@@ -182,7 +182,7 @@ namespace ComputeSharp
public static ReadWriteBuffer<T> AllocateReadWriteBuffer<T>(this GraphicsDevice device, Buffer<T> buffer)
where T : unmanaged
{
ReadWriteBuffer<T> readWriteBuffer = new(device, buffer.Size);
ReadWriteBuffer<T> readWriteBuffer = new(device, buffer.Length);
readWriteBuffer.SetData(buffer);