From d6d5c4bcc9ee711a6f84ed5e231dae1f3f082a28 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 23 Nov 2020 12:59:43 +0100 Subject: [PATCH] Renamed Buffer.Size to Length --- .../HlslBokehBlurProcessor{TPixel}.cs | 8 +++--- .../HlslGaussianBlurProcessor{TPixel}.cs | 6 ++--- .../Buffers/Abstract/Buffer{T}.cs | 26 +++++++++---------- .../Buffers/Abstract/StructuredBuffer{T}.cs | 6 ++--- .../Buffers/ConstantBuffer{T}.cs | 8 +++--- .../Buffers/ReadOnlyBuffer{T}.cs | 8 +++--- .../Buffers/ReadWriteBuffer{T}.cs | 8 +++--- .../Extensions/GraphicsDeviceExtensions.cs | 22 ++++++++-------- 8 files changed, 46 insertions(+), 46 deletions(-) diff --git a/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs b/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs index b400ecce..7e46ecb5 100644 --- a/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs +++ b/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs @@ -262,8 +262,8 @@ namespace ComputeSharp.BokehBlur.Processors using IMemoryOwner source4 = GetExposedVector4Buffer(memory); using ReadOnlyBuffer sourceBuffer = Gpu.Default.AllocateReadOnlyBuffer(source4.Memory.Span); - using ReadWriteBuffer processingBuffer = Gpu.Default.AllocateReadWriteBuffer(sourceBuffer.Size); - using ReadWriteBuffer firstPassBuffer = Gpu.Default.AllocateReadWriteBuffer(sourceBuffer.Size * 2); + using ReadWriteBuffer processingBuffer = Gpu.Default.AllocateReadWriteBuffer(sourceBuffer.Length); + using ReadWriteBuffer firstPassBuffer = Gpu.Default.AllocateReadWriteBuffer(sourceBuffer.Length * 2); using ReadOnlyBuffer kernelBuffer = Gpu.Default.AllocateReadOnlyBuffer(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, diff --git a/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs b/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs index 1cd556b2..056b56ee 100644 --- a/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs +++ b/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs @@ -97,7 +97,7 @@ namespace ComputeSharp.BokehBlur.Processors PixelOperations.Instance.ToVector4(Configuration, spanTPixel, spanVector4); using ReadWriteBuffer sourceBuffer = Gpu.Default.AllocateReadWriteBuffer(spanVector4); - using ReadWriteBuffer firstPassBuffer = Gpu.Default.AllocateReadWriteBuffer(sourceBuffer.Size); + using ReadWriteBuffer firstPassBuffer = Gpu.Default.AllocateReadWriteBuffer(sourceBuffer.Length); using ReadOnlyBuffer 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 diff --git a/src/ComputeSharp.Graphics/Buffers/Abstract/Buffer{T}.cs b/src/ComputeSharp.Graphics/Buffers/Abstract/Buffer{T}.cs index 15f34a53..971a0114 100644 --- a/src/ComputeSharp.Graphics/Buffers/Abstract/Buffer{T}.cs +++ b/src/ComputeSharp.Graphics/Buffers/Abstract/Buffer{T}.cs @@ -39,16 +39,16 @@ namespace ComputeSharp.Graphics.Buffers.Abstract /// Creates a new instance with the specified parameters. /// /// The associated with the current instance. - /// The number of items to store in the current buffer. + /// The number of items to store in the current buffer. /// The size in bytes for the current buffer. /// The buffer type for the current buffer. - 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; } /// - /// Gets the size of the current buffer, as in the number of values it contains. + /// Gets the length of the current buffer. /// - public int Size { get; } + public int Length { get; } /// /// Gets the size in bytes of each 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(); + get => SizeInBytes > Length * Unsafe.SizeOf(); } /// @@ -98,7 +98,7 @@ namespace ComputeSharp.Graphics.Buffers.Abstract /// /// A array with the contents of the current buffer. [Pure] - public T[] GetData() => GetData(0, Size); + public T[] GetData() => GetData(0, Length); /// /// Reads the contents of the current instance in a given range and returns an array. @@ -120,7 +120,7 @@ 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, Size); + public void GetData(Span span) => GetData(span, 0, Length); /// /// Reads the contents of the specified range from the current instance and writes them into a target . @@ -148,7 +148,7 @@ namespace ComputeSharp.Graphics.Buffers.Abstract /// Writes the contents of a given to the current instance. /// /// The input to read data from. - public void SetData(ReadOnlySpan span) => SetData(span, 0, Size); + public void SetData(ReadOnlySpan span) => SetData(span, 0, Length); /// /// Writes the contents of a given to a specified area of the current instance. @@ -170,11 +170,11 @@ namespace ComputeSharp.Graphics.Buffers.Abstract /// The input to read data from. protected void SetDataWithCpuBuffer(Buffer buffer) { - T[] array = ArrayPool.Shared.Rent(buffer.Size); + T[] array = ArrayPool.Shared.Rent(buffer.Length); try { - Span span = array.AsSpan(0, buffer.Size); + Span 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); diff --git a/src/ComputeSharp.Graphics/Buffers/Abstract/StructuredBuffer{T}.cs b/src/ComputeSharp.Graphics/Buffers/Abstract/StructuredBuffer{T}.cs index 7d26a995..631da7e9 100644 --- a/src/ComputeSharp.Graphics/Buffers/Abstract/StructuredBuffer{T}.cs +++ b/src/ComputeSharp.Graphics/Buffers/Abstract/StructuredBuffer{T}.cs @@ -21,10 +21,10 @@ namespace ComputeSharp.Graphics.Buffers.Abstract /// Creates a new instance with the specified parameters /// /// The associated with the current instance - /// The number of items to store in the current buffer + /// The number of items to store in the current buffer /// The buffer type for the current buffer - internal StructuredBuffer(GraphicsDevice device, int size, BufferType bufferType) - : base(device, size, size * Unsafe.SizeOf(), bufferType) + internal StructuredBuffer(GraphicsDevice device, int length, BufferType bufferType) + : base(device, length, length * Unsafe.SizeOf(), bufferType) { } diff --git a/src/ComputeSharp.Graphics/Buffers/ConstantBuffer{T}.cs b/src/ComputeSharp.Graphics/Buffers/ConstantBuffer{T}.cs index 53250263..c4aa162e 100644 --- a/src/ComputeSharp.Graphics/Buffers/ConstantBuffer{T}.cs +++ b/src/ComputeSharp.Graphics/Buffers/ConstantBuffer{T}.cs @@ -29,9 +29,9 @@ namespace ComputeSharp /// Creates a new instance with the specified parameters /// /// The associated with the current instance - /// The number of items to store in the current buffer - internal ConstantBuffer(GraphicsDevice device, int size) - : base(device, size, size * GetPaddedSize(), BufferType.Constant) + /// The number of items to store in the current buffer + internal ConstantBuffer(GraphicsDevice device, int length) + : base(device, length, length * GetPaddedSize(), BufferType.Constant) { } @@ -115,7 +115,7 @@ namespace ComputeSharp /// public override string ToString() { - return $"ComputeSharp.ConstantBuffer<{typeof(T)}>[{Size}]"; + return $"ComputeSharp.ConstantBuffer<{typeof(T)}>[{Length}]"; } } } diff --git a/src/ComputeSharp.Graphics/Buffers/ReadOnlyBuffer{T}.cs b/src/ComputeSharp.Graphics/Buffers/ReadOnlyBuffer{T}.cs index e52fb41e..3e98cdfe 100644 --- a/src/ComputeSharp.Graphics/Buffers/ReadOnlyBuffer{T}.cs +++ b/src/ComputeSharp.Graphics/Buffers/ReadOnlyBuffer{T}.cs @@ -20,9 +20,9 @@ namespace ComputeSharp /// Creates a new instance with the specified parameters /// /// The associated with the current instance - /// The number of items to store in the current buffer - internal ReadOnlyBuffer(GraphicsDevice device, int size) - : base(device, size, BufferType.ReadOnly) + /// The number of items to store in the current buffer + internal ReadOnlyBuffer(GraphicsDevice device, int length) + : base(device, length, BufferType.ReadOnly) { } @@ -36,7 +36,7 @@ namespace ComputeSharp /// public override string ToString() { - return $"ComputeSharp.ReadOnlyBuffer<{typeof(T)}>[{Size}]"; + return $"ComputeSharp.ReadOnlyBuffer<{typeof(T)}>[{Length}]"; } } } diff --git a/src/ComputeSharp.Graphics/Buffers/ReadWriteBuffer{T}.cs b/src/ComputeSharp.Graphics/Buffers/ReadWriteBuffer{T}.cs index 805b0516..f297311e 100644 --- a/src/ComputeSharp.Graphics/Buffers/ReadWriteBuffer{T}.cs +++ b/src/ComputeSharp.Graphics/Buffers/ReadWriteBuffer{T}.cs @@ -20,9 +20,9 @@ namespace ComputeSharp /// Creates a new instance with the specified parameters /// /// The associated with the current instance - /// The number of items to store in the current buffer - internal ReadWriteBuffer(GraphicsDevice device, int size) - : base(device, size, BufferType.ReadWrite) + /// The number of items to store in the current buffer + internal ReadWriteBuffer(GraphicsDevice device, int length) + : base(device, length, BufferType.ReadWrite) { } @@ -36,7 +36,7 @@ namespace ComputeSharp /// public override string ToString() { - return $"ComputeSharp.ReadWriteBuffer<{typeof(T)}>[{Size}]"; + return $"ComputeSharp.ReadWriteBuffer<{typeof(T)}>[{Length}]"; } } } diff --git a/src/ComputeSharp/Extensions/GraphicsDeviceExtensions.cs b/src/ComputeSharp/Extensions/GraphicsDeviceExtensions.cs index d202f181..749e127a 100644 --- a/src/ComputeSharp/Extensions/GraphicsDeviceExtensions.cs +++ b/src/ComputeSharp/Extensions/GraphicsDeviceExtensions.cs @@ -54,7 +54,7 @@ namespace ComputeSharp public static ConstantBuffer AllocateConstantBuffer(this GraphicsDevice device, Buffer buffer) where T : unmanaged { - ConstantBuffer constantBuffer = new(device, buffer.Size); + ConstantBuffer constantBuffer = new(device, buffer.Length); constantBuffer.SetData(buffer); @@ -66,13 +66,13 @@ namespace ComputeSharp /// /// The type of items to store in the buffer. /// The instance to use to allocate the buffer. - /// The size of the buffer to allocate. - /// A zeroed instance of size . + /// The length of the buffer to allocate. + /// A zeroed instance of size . [Pure] - public static ReadOnlyBuffer AllocateReadOnlyBuffer(this GraphicsDevice device, int size) + public static ReadOnlyBuffer AllocateReadOnlyBuffer(this GraphicsDevice device, int length) where T : unmanaged { - return new(device, size); + return new(device, length); } /// @@ -118,7 +118,7 @@ namespace ComputeSharp public static ReadOnlyBuffer AllocateReadOnlyBuffer(this GraphicsDevice device, Buffer buffer) where T : unmanaged { - ReadOnlyBuffer readWriteBuffer = new(device, buffer.Size); + ReadOnlyBuffer readWriteBuffer = new(device, buffer.Length); readWriteBuffer.SetData(buffer); @@ -130,13 +130,13 @@ namespace ComputeSharp /// /// The type of items to store in the buffer. /// The instance to use to allocate the buffer. - /// The size of the buffer to allocate. - /// A zeroed instance of size . + /// The length of the buffer to allocate. + /// A zeroed instance of size . [Pure] - public static ReadWriteBuffer AllocateReadWriteBuffer(this GraphicsDevice device, int size) + public static ReadWriteBuffer AllocateReadWriteBuffer(this GraphicsDevice device, int length) where T : unmanaged { - return new(device, size); + return new(device, length); } /// @@ -182,7 +182,7 @@ namespace ComputeSharp public static ReadWriteBuffer AllocateReadWriteBuffer(this GraphicsDevice device, Buffer buffer) where T : unmanaged { - ReadWriteBuffer readWriteBuffer = new(device, buffer.Size); + ReadWriteBuffer readWriteBuffer = new(device, buffer.Length); readWriteBuffer.SetData(buffer);