diff --git a/src/ComputeSharp.Graphics/Buffers/Buffer2.cs b/src/ComputeSharp.Graphics/Buffers/Buffer.cs similarity index 90% rename from src/ComputeSharp.Graphics/Buffers/Buffer2.cs rename to src/ComputeSharp.Graphics/Buffers/Buffer.cs index 1a17cf3a..1cbc6ad9 100644 --- a/src/ComputeSharp.Graphics/Buffers/Buffer2.cs +++ b/src/ComputeSharp.Graphics/Buffers/Buffer.cs @@ -11,15 +11,15 @@ namespace ComputeSharp.Graphics.Buffers /// A representing a typed buffer stored on GPU memory /// /// The type of items stored on the buffer - public sealed class Buffer2 : GraphicsResource where T : unmanaged + public sealed class Buffer : GraphicsResource where T : unmanaged { /// - /// Creates a new instance with the specified parameters + /// 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 heap type for the current buffer - internal Buffer2(GraphicsDevice device, int size, HeapType heapType) : base(device) + internal Buffer(GraphicsDevice device, int size, HeapType heapType) : base(device) { Size = size; ElementSizeInBytes = Unsafe.SizeOf(); @@ -120,7 +120,7 @@ namespace ComputeSharp.Graphics.Buffers } /// - /// Reads the contents of the current instance and returns an array + /// Reads the contents of the current instance and returns an array /// /// A array with the contents of the current buffer [Pure] @@ -133,7 +133,7 @@ namespace ComputeSharp.Graphics.Buffers } /// - /// Reads the contents of the current instance and writes them into a target + /// Reads the contents of the current instance and writes them into a target /// /// The input to write data to public void GetData(Span span) @@ -141,7 +141,7 @@ namespace ComputeSharp.Graphics.Buffers // Create a temporary readback buffer if the current buffer type is read write (can't be read from directly) if (HeapType == HeapType.Default) { - using Buffer2 readbackBaffer = new Buffer2(GraphicsDevice, Size, HeapType.Readback); + using Buffer readbackBaffer = new Buffer(GraphicsDevice, Size, HeapType.Readback); using CommandList copyCommandList = new CommandList(GraphicsDevice, CommandListType.Copy); copyCommandList.CopyBufferRegion(this, 0, readbackBaffer, 0, SizeInBytes); @@ -159,7 +159,7 @@ namespace ComputeSharp.Graphics.Buffers } /// - /// Writes the contents of a given to the current instance + /// Writes the contents of a given to the current instance /// /// The input to read data from public void SetData(Span span) @@ -167,7 +167,7 @@ namespace ComputeSharp.Graphics.Buffers // Create a temporary upload buffer if the current buffer type is read write (can't be written to directly) if (HeapType == HeapType.Default) { - using Buffer2 uploadBuffer = new Buffer2(GraphicsDevice, Size, HeapType.Upload); + using Buffer uploadBuffer = new Buffer(GraphicsDevice, Size, HeapType.Upload); using CommandList copyCommandList = new CommandList(GraphicsDevice, CommandListType.Copy); uploadBuffer.SetData(span); diff --git a/src/ComputeSharp.Graphics/Buffers/BufferExtensions.cs b/src/ComputeSharp.Graphics/Buffers/BufferExtensions.cs index 318698bb..e424961e 100644 --- a/src/ComputeSharp.Graphics/Buffers/BufferExtensions.cs +++ b/src/ComputeSharp.Graphics/Buffers/BufferExtensions.cs @@ -16,12 +16,12 @@ namespace ComputeSharp.Graphics.Buffers /// 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 read write instance of size + /// A zeroed read write instance of size [Pure] [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Buffer2 AllocateReadWriteBuffer(this GraphicsDevice device, int size) where T : unmanaged + public static Buffer AllocateReadWriteBuffer(this GraphicsDevice device, int size) where T : unmanaged { - return new Buffer2(device, size, HeapType.Default); + return new Buffer(device, size, HeapType.Default); } /// @@ -30,12 +30,12 @@ namespace ComputeSharp.Graphics.Buffers /// The type of items to store in the buffer /// The instance to use to allocate the buffer /// The input with the data to copy on the allocated buffer - /// A read write instance with the contents of the input + /// A read write instance with the contents of the input [Pure] [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Buffer2 AllocateReadWriteBuffer(this GraphicsDevice device, Span span) where T : unmanaged + public static Buffer AllocateReadWriteBuffer(this GraphicsDevice device, Span span) where T : unmanaged { - Buffer2 buffer = new Buffer2(device, span.Length, HeapType.Default); + Buffer buffer = new Buffer(device, span.Length, HeapType.Default); buffer.SetData(span); return buffer; @@ -47,12 +47,12 @@ namespace ComputeSharp.Graphics.Buffers /// The type of items to store in the buffer /// The instance to use to allocate the buffer /// The input with the data to copy on the allocated buffer - /// A constant instance with the contents of the input + /// A constant instance with the contents of the input [Pure] [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Buffer2 AllocateConstantBuffer(this GraphicsDevice device, Span span) where T : unmanaged + public static Buffer AllocateConstantBuffer(this GraphicsDevice device, Span span) where T : unmanaged { - Buffer2 buffer = new Buffer2(device, span.Length, HeapType.Upload); + Buffer buffer = new Buffer(device, span.Length, HeapType.Upload); buffer.SetData(span); return buffer; diff --git a/src/ComputeSharp.Shaders/Mappings/HlslKnownTypes.cs b/src/ComputeSharp.Shaders/Mappings/HlslKnownTypes.cs index 17eeb5ba..e1847415 100644 --- a/src/ComputeSharp.Shaders/Mappings/HlslKnownTypes.cs +++ b/src/ComputeSharp.Shaders/Mappings/HlslKnownTypes.cs @@ -27,7 +27,7 @@ namespace ComputeSharp.Shaders.Mappings [typeof(Vector4).FullName] = "float4", [typeof(Matrix4x4).FullName] = "float4x4", [typeof(ThreadIds).FullName] = "uint3", - [typeof(Buffer2<>).FullName] = "RWBuffer" + [typeof(Buffer<>).FullName] = "RWBuffer" }; /// @@ -54,13 +54,13 @@ namespace ComputeSharp.Shaders.Mappings type == typeof(Matrix4x4); /// - /// Checks whether or not the input type is a value + /// Checks whether or not the input type is a value /// /// The input instance to check - /// A indicating whether the input is in fact a instance + /// A indicating whether the input is in fact a instance [Pure] public static bool IsBufferType(Type type) => type.IsGenericType && - type.GetGenericTypeDefinition() == typeof(Buffer2<>); + type.GetGenericTypeDefinition() == typeof(Buffer<>); /// /// Checks whether or not a given is an HLSL known type diff --git a/src/ComputeSharp.Shaders/ShaderLoader.cs b/src/ComputeSharp.Shaders/ShaderLoader.cs index 05d6d235..a0f362db 100644 --- a/src/ComputeSharp.Shaders/ShaderLoader.cs +++ b/src/ComputeSharp.Shaders/ShaderLoader.cs @@ -117,7 +117,7 @@ namespace ComputeSharp.Shaders // Read write buffer if (HlslKnownTypes.IsBufferType(fieldType) && - (HeapType)fieldType.GetProperty(nameof(Buffer2.HeapType)).GetValue(fieldValue) == HeapType.Default) + (HeapType)fieldType.GetProperty(nameof(Buffer.HeapType)).GetValue(fieldValue) == HeapType.Default) { // Root parameter for a read write buffer DescriptorRange range = new DescriptorRange(DescriptorRangeType.UnorderedAccessView, 1, readWriteBuffersCount); diff --git a/src/DirectX12ComputeShaderSample/Program.cs b/src/DirectX12ComputeShaderSample/Program.cs index 347d721b..78958d04 100644 --- a/src/DirectX12ComputeShaderSample/Program.cs +++ b/src/DirectX12ComputeShaderSample/Program.cs @@ -18,7 +18,7 @@ namespace DirectX12ComputeShaderSample array[i] = i + 1; } - using Buffer2 gpuBuffer = Gpu.Default.AllocateReadWriteBuffer(array.AsSpan()); + using Buffer gpuBuffer = Gpu.Default.AllocateReadWriteBuffer(array.AsSpan()); // Shader body Action action = id =>