diff --git a/src/ComputeSharp.Graphics/Buffers/Extensions/BufferExtensions.cs b/src/ComputeSharp.Graphics/Buffers/Extensions/BufferExtensions.cs
index 2f3c0ae3..708bdb95 100644
--- a/src/ComputeSharp.Graphics/Buffers/Extensions/BufferExtensions.cs
+++ b/src/ComputeSharp.Graphics/Buffers/Extensions/BufferExtensions.cs
@@ -98,12 +98,12 @@ namespace ComputeSharp
/// The type of items to store in the buffer
/// The instance to use to allocate the buffer
/// The input array with the data to copy on the allocated buffer
- /// A constant instance with the contents of the input array
+ /// A constant instance with the contents of the input array
[Pure]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static ReadOnlyBuffer AllocateReadOnlyBuffer(this GraphicsDevice device, T[] array) where T : unmanaged
+ public static ConstantBuffer AllocateConstantBuffer(this GraphicsDevice device, T[] array) where T : unmanaged
{
- return device.AllocateReadOnlyBuffer(array.AsSpan());
+ return device.AllocateConstantBuffer(array.AsSpan());
}
///
@@ -112,15 +112,15 @@ namespace ComputeSharp
/// The type of items to store in the buffer
/// The instance to use to allocate the buffer
/// The input 2D array with the data to copy on the allocated buffer
- /// A constant instance with the contents of the input 2D array
+ /// A constant instance with the contents of the input 2D array
[Pure]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static unsafe ReadOnlyBuffer AllocateReadOnlyBuffer(this GraphicsDevice device, T[,] array) where T : unmanaged
+ public static unsafe ConstantBuffer AllocateConstantBuffer(this GraphicsDevice device, T[,] array) where T : unmanaged
{
fixed (T* p = array)
{
Span span = new Span(p, array.Length);
- return device.AllocateReadOnlyBuffer(span);
+ return device.AllocateConstantBuffer(span);
}
}
@@ -130,12 +130,12 @@ namespace ComputeSharp
/// 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 ReadOnlyBuffer AllocateReadOnlyBuffer(this GraphicsDevice device, Span span) where T : unmanaged
+ public static ConstantBuffer AllocateConstantBuffer(this GraphicsDevice device, Span span) where T : unmanaged
{
- ReadOnlyBuffer buffer = new ReadOnlyBuffer(device, span.Length);
+ ConstantBuffer buffer = new ConstantBuffer(device, span.Length);
buffer.SetData(span);
return buffer;
@@ -147,15 +147,15 @@ namespace ComputeSharp
/// 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 ReadOnlyBuffer AllocateReadOnlyBuffer(this GraphicsDevice device, HlslBuffer buffer) where T : unmanaged
+ public static ConstantBuffer AllocateConstantBuffer(this GraphicsDevice device, HlslBuffer buffer) where T : unmanaged
{
- ReadOnlyBuffer readOnlyBuffer = new ReadOnlyBuffer(device, buffer.Size);
- readOnlyBuffer.SetData(buffer);
+ ConstantBuffer constantBuffer = new ConstantBuffer(device, buffer.Size);
+ constantBuffer.SetData(buffer);
- return readOnlyBuffer;
+ return constantBuffer;
}
}
}
diff --git a/src/ComputeSharp.Graphics/Buffers/Extensions/GraphicsResourceExtensions.cs b/src/ComputeSharp.Graphics/Buffers/Extensions/GraphicsResourceExtensions.cs
index 2f1d952e..aba80fb4 100644
--- a/src/ComputeSharp.Graphics/Buffers/Extensions/GraphicsResourceExtensions.cs
+++ b/src/ComputeSharp.Graphics/Buffers/Extensions/GraphicsResourceExtensions.cs
@@ -23,7 +23,7 @@ namespace ComputeSharp.Graphics.Buffers.Extensions
///
/// The instance to use to allocate the buffer
/// The input to copy to the allocated buffer
- /// A constant instance (as a ) with the input data
+ /// A constant instance (as a ) with the input data
[Pure]
public static GraphicsResource AllocateReadOnlyBufferFromReflectedSingleValue(this GraphicsDevice device, object data)
{
@@ -31,7 +31,7 @@ namespace ComputeSharp.Graphics.Buffers.Extensions
if (!TypeMapping.TryGetValue(dataType, out var info))
{
// Get the generic buffer constructor
- Type bufferType = typeof(ReadOnlyBuffer<>).MakeGenericType(dataType);
+ Type bufferType = typeof(ConstantBuffer<>).MakeGenericType(dataType);
info.Constructor = bufferType.GetConstructors(BindingFlags.Instance | BindingFlags.NonPublic).First();
// Create the reusable array
diff --git a/src/ComputeSharp.Graphics/Buffers/ReadOnlyBuffer{T}.cs b/src/ComputeSharp.Graphics/Buffers/ReadOnlyBuffer{T}.cs
index 89ebb6dd..a91e4aaf 100644
--- a/src/ComputeSharp.Graphics/Buffers/ReadOnlyBuffer{T}.cs
+++ b/src/ComputeSharp.Graphics/Buffers/ReadOnlyBuffer{T}.cs
@@ -12,14 +12,14 @@ namespace ComputeSharp.Graphics.Buffers
/// A representing a typed read write buffer stored on GPU memory
///
/// The type of items stored on the buffer
- public sealed class ReadOnlyBuffer : HlslBuffer where T : unmanaged
+ public sealed class ConstantBuffer : HlslBuffer 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
- internal ReadOnlyBuffer(GraphicsDevice device, int size) : base(device, size, size * (Unsafe.SizeOf() / 16 + 1) * 16, HeapType.Upload)
+ internal ConstantBuffer(GraphicsDevice device, int size) : base(device, size, size * (Unsafe.SizeOf() / 16 + 1) * 16, HeapType.Upload)
{
PaddedElementSizeInBytes = SizeInBytes / Size;
IsPaddingPresent = PaddedElementSizeInBytes > ElementSizeInBytes;
@@ -114,7 +114,7 @@ namespace ComputeSharp.Graphics.Buffers
///
public override void SetData(HlslBuffer buffer)
{
- if (buffer is ReadOnlyBuffer)
+ if (buffer is ConstantBuffer)
{
// Directly copy the input buffer, if possible
using CommandList copyCommandList = new CommandList(GraphicsDevice, CommandListType.Copy);
diff --git a/src/ComputeSharp.Graphics/Buffers/ReadWriteBuffer{T}.cs b/src/ComputeSharp.Graphics/Buffers/ReadWriteBuffer{T}.cs
index cd7c9158..fb62c357 100644
--- a/src/ComputeSharp.Graphics/Buffers/ReadWriteBuffer{T}.cs
+++ b/src/ComputeSharp.Graphics/Buffers/ReadWriteBuffer{T}.cs
@@ -63,7 +63,7 @@ namespace ComputeSharp.Graphics.Buffers
///
public override void SetData(HlslBuffer buffer)
{
- if (buffer is ReadOnlyBuffer readOnlyBuffer && !readOnlyBuffer.IsPaddingPresent)
+ if (buffer is ConstantBuffer readOnlyBuffer && !readOnlyBuffer.IsPaddingPresent)
{
// Directly copy the input buffer
using CommandList copyCommandList = new CommandList(GraphicsDevice, CommandListType.Copy);
diff --git a/src/ComputeSharp.Shaders/Mappings/HlslKnownTypes.cs b/src/ComputeSharp.Shaders/Mappings/HlslKnownTypes.cs
index 0a6e5e36..471f2667 100644
--- a/src/ComputeSharp.Shaders/Mappings/HlslKnownTypes.cs
+++ b/src/ComputeSharp.Shaders/Mappings/HlslKnownTypes.cs
@@ -63,13 +63,13 @@ namespace ComputeSharp.Shaders.Mappings
type.GetGenericTypeDefinition() == typeof(ReadWriteBuffer<>);
///
- /// 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 IsReadOnlyBufferType(Type type) => type.IsGenericType &&
- type.GetGenericTypeDefinition() == typeof(ReadOnlyBuffer<>);
+ public static bool IsConstantBufferType(Type type) => type.IsGenericType &&
+ type.GetGenericTypeDefinition() == typeof(ConstantBuffer<>);
///
/// Checks whether or not a given is an HLSL known type
diff --git a/src/ComputeSharp.Shaders/Translation/ShaderLoader.cs b/src/ComputeSharp.Shaders/Translation/ShaderLoader.cs
index ee380182..404dc19d 100644
--- a/src/ComputeSharp.Shaders/Translation/ShaderLoader.cs
+++ b/src/ComputeSharp.Shaders/Translation/ShaderLoader.cs
@@ -136,9 +136,9 @@ namespace ComputeSharp.Shaders.Translation
string typeName = HlslKnownTypes.GetMappedName(fieldType);
processedFieldInfo = new ReadWriteBufferFieldInfo(typeName, fieldName, readWriteBuffersCount++);
}
- else if (HlslKnownTypes.IsReadOnlyBufferType(fieldType))
+ else if (HlslKnownTypes.IsConstantBufferType(fieldType))
{
- // Read only buffer
+ // Constant buffer
DescriptorRange range = new DescriptorRange(DescriptorRangeType.ConstantBufferView, 1, readOnlyBuffersCount);
descriptorRanges.Add(range);
@@ -150,7 +150,7 @@ namespace ComputeSharp.Shaders.Translation
}
else if (HlslKnownTypes.IsKnownScalarType(fieldType))
{
- // Read only buffer
+ // Constant buffer
DescriptorRange range = new DescriptorRange(DescriptorRangeType.ConstantBufferView, 1, readOnlyBuffersCount);
descriptorRanges.Add(range);
diff --git a/tests/ComputeSharp.NetCore.Tests.Internals/BufferTests.cs b/tests/ComputeSharp.NetCore.Tests.Internals/BufferTests.cs
index ea37b67f..6ae06b93 100644
--- a/tests/ComputeSharp.NetCore.Tests.Internals/BufferTests.cs
+++ b/tests/ComputeSharp.NetCore.Tests.Internals/BufferTests.cs
@@ -14,7 +14,7 @@ namespace ComputeSharp.NetCore.Tests.Internals
{
object value = 77;
- using ReadOnlyBuffer buffer = (ReadOnlyBuffer)Gpu.Default.AllocateReadOnlyBufferFromReflectedSingleValue(value);
+ using ConstantBuffer buffer = (ConstantBuffer)Gpu.Default.AllocateReadOnlyBufferFromReflectedSingleValue(value);
int[] result = buffer.GetData();
Assert.IsTrue(result.Length == 1);
@@ -26,7 +26,7 @@ namespace ComputeSharp.NetCore.Tests.Internals
{
object value = 3.14f;
- using ReadOnlyBuffer buffer = (ReadOnlyBuffer)Gpu.Default.AllocateReadOnlyBufferFromReflectedSingleValue(value);
+ using ConstantBuffer buffer = (ConstantBuffer)Gpu.Default.AllocateReadOnlyBufferFromReflectedSingleValue(value);
float[] result = buffer.GetData();
Assert.IsTrue(result.Length == 1);
diff --git a/tests/ComputeSharp.NetCore.Tests/BufferTests.cs b/tests/ComputeSharp.NetCore.Tests/BufferTests.cs
index 5040ea07..54553917 100644
--- a/tests/ComputeSharp.NetCore.Tests/BufferTests.cs
+++ b/tests/ComputeSharp.NetCore.Tests/BufferTests.cs
@@ -26,7 +26,7 @@ namespace ComputeSharp.NetCore.Tests
{
float[] array = Enumerable.Range(0, 4096).Select(i => (float)i).ToArray();
- using ReadOnlyBuffer buffer = Gpu.Default.AllocateReadOnlyBuffer(array);
+ using ConstantBuffer buffer = Gpu.Default.AllocateConstantBuffer(array);
float[] result = buffer.GetData();
Assert.IsTrue(array.AsSpan().ContentEquals(result));
@@ -52,7 +52,7 @@ namespace ComputeSharp.NetCore.Tests
{
float[] array = Enumerable.Range(0, 4096).Select(i => (float)i).ToArray();
- using ReadOnlyBuffer sourceBuffer = Gpu.Default.AllocateReadOnlyBuffer(array);
+ using ConstantBuffer sourceBuffer = Gpu.Default.AllocateConstantBuffer(array);
using ReadWriteBuffer destinationBuffer = Gpu.Default.AllocateReadWriteBuffer(sourceBuffer);
float[] sourceResult = sourceBuffer.GetData();
@@ -68,7 +68,7 @@ namespace ComputeSharp.NetCore.Tests
float[] array = Enumerable.Range(0, 4096).Select(i => (float)i).ToArray();
using ReadWriteBuffer sourceBuffer = Gpu.Default.AllocateReadWriteBuffer(array);
- using ReadOnlyBuffer destinationBuffer = Gpu.Default.AllocateReadOnlyBuffer(sourceBuffer);
+ using ConstantBuffer destinationBuffer = Gpu.Default.AllocateConstantBuffer(sourceBuffer);
float[] sourceResult = sourceBuffer.GetData();
float[] destinationResult = destinationBuffer.GetData();
@@ -82,8 +82,8 @@ namespace ComputeSharp.NetCore.Tests
{
float[] array = Enumerable.Range(0, 4096).Select(i => (float)i).ToArray();
- using ReadOnlyBuffer sourceBuffer = Gpu.Default.AllocateReadOnlyBuffer(array);
- using ReadOnlyBuffer destinationBuffer = Gpu.Default.AllocateReadOnlyBuffer(sourceBuffer);
+ using ConstantBuffer sourceBuffer = Gpu.Default.AllocateConstantBuffer(array);
+ using ConstantBuffer destinationBuffer = Gpu.Default.AllocateConstantBuffer(sourceBuffer);
float[] sourceResult = sourceBuffer.GetData();
float[] destinationResult = destinationBuffer.GetData();
diff --git a/tests/ComputeSharp.NetCore.Tests/ShaderClosureTests.cs b/tests/ComputeSharp.NetCore.Tests/ShaderClosureTests.cs
index abda8eb8..9a23fcd5 100644
--- a/tests/ComputeSharp.NetCore.Tests/ShaderClosureTests.cs
+++ b/tests/ComputeSharp.NetCore.Tests/ShaderClosureTests.cs
@@ -85,7 +85,7 @@ namespace ComputeSharp.NetCore.Tests
{
float[] source = Enumerable.Range(0, 100).Select(i => (float)i).ToArray();
- using ReadOnlyBuffer input = Gpu.Default.AllocateReadOnlyBuffer(source);
+ using ConstantBuffer input = Gpu.Default.AllocateConstantBuffer(source);
using ReadWriteBuffer buffer = Gpu.Default.AllocateReadWriteBuffer(source.Length);
Action action = id => buffer[id.X] = input[id.X];