Renamed Buffer2<T> type
このコミットが含まれているのは:
1 親
d75e84c618
コミット
acf2aa9fce
5ファイル変更
+23
-23
検索条件に一致するファイルはありません
+8
-8
@@ -11,15 +11,15 @@ namespace ComputeSharp.Graphics.Buffers
|
||||
/// A <see langword="class"/> representing a typed buffer stored on GPU memory
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the buffer</typeparam>
|
||||
public sealed class Buffer2<T> : GraphicsResource where T : unmanaged
|
||||
public sealed class Buffer<T> : GraphicsResource where T : unmanaged
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Buffer2{T}"/> instance with the specified parameters
|
||||
/// 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="heapType">The heap type for the current buffer</param>
|
||||
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<T>();
|
||||
@@ -120,7 +120,7 @@ namespace ComputeSharp.Graphics.Buffers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of the current <see cref="Buffer2{T}"/> instance and returns an array
|
||||
/// Reads the contents of the current <see cref="Buffer{T}"/> instance and returns an array
|
||||
/// </summary>
|
||||
/// <returns>A <typeparamref name="T"/> array with the contents of the current buffer</returns>
|
||||
[Pure]
|
||||
@@ -133,7 +133,7 @@ namespace ComputeSharp.Graphics.Buffers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of the current <see cref="Buffer2{T}"/> instance and writes them into a target <see cref="Span{T}"/>
|
||||
/// 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)
|
||||
@@ -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<T> readbackBaffer = new Buffer2<T>(GraphicsDevice, Size, HeapType.Readback);
|
||||
using Buffer<T> readbackBaffer = new Buffer<T>(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
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the contents of a given <see cref="Span{T}"/> to the current <see cref="Buffer2{T}"/> instance
|
||||
/// Writes the contents of a given <see cref="Span{T}"/> to the current <see cref="Buffer{T}"/> instance
|
||||
/// </summary>
|
||||
/// <param name="span">The input <see cref="Span{T}"/> to read data from</param>
|
||||
public void SetData(Span<T> 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<T> uploadBuffer = new Buffer2<T>(GraphicsDevice, Size, HeapType.Upload);
|
||||
using Buffer<T> uploadBuffer = new Buffer<T>(GraphicsDevice, Size, HeapType.Upload);
|
||||
using CommandList copyCommandList = new CommandList(GraphicsDevice, CommandListType.Copy);
|
||||
|
||||
uploadBuffer.SetData(span);
|
||||
@@ -16,12 +16,12 @@ namespace ComputeSharp.Graphics.Buffers
|
||||
/// <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 read write <see cref="Buffer2{T}"/> instance of size <paramref name="size"/></returns>
|
||||
/// <returns>A zeroed read write <see cref="Buffer{T}"/> instance of size <paramref name="size"/></returns>
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Buffer2<T> AllocateReadWriteBuffer<T>(this GraphicsDevice device, int size) where T : unmanaged
|
||||
public static Buffer<T> AllocateReadWriteBuffer<T>(this GraphicsDevice device, int size) where T : unmanaged
|
||||
{
|
||||
return new Buffer2<T>(device, size, HeapType.Default);
|
||||
return new Buffer<T>(device, size, HeapType.Default);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -30,12 +30,12 @@ namespace ComputeSharp.Graphics.Buffers
|
||||
/// <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="span">The input <see cref="Span{T}"/> with the data to copy on the allocated buffer</param>
|
||||
/// <returns>A read write <see cref="Buffer2{T}"/> instance with the contents of the input <see cref="Span{T}"/></returns>
|
||||
/// <returns>A read write <see cref="Buffer{T}"/> instance with the contents of the input <see cref="Span{T}"/></returns>
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Buffer2<T> AllocateReadWriteBuffer<T>(this GraphicsDevice device, Span<T> span) where T : unmanaged
|
||||
public static Buffer<T> AllocateReadWriteBuffer<T>(this GraphicsDevice device, Span<T> span) where T : unmanaged
|
||||
{
|
||||
Buffer2<T> buffer = new Buffer2<T>(device, span.Length, HeapType.Default);
|
||||
Buffer<T> buffer = new Buffer<T>(device, span.Length, HeapType.Default);
|
||||
buffer.SetData(span);
|
||||
|
||||
return buffer;
|
||||
@@ -47,12 +47,12 @@ namespace ComputeSharp.Graphics.Buffers
|
||||
/// <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="span">The input <see cref="Span{T}"/> with the data to copy on the allocated buffer</param>
|
||||
/// <returns>A constant <see cref="Buffer2{T}"/> instance with the contents of the input <see cref="Span{T}"/></returns>
|
||||
/// <returns>A constant <see cref="Buffer{T}"/> instance with the contents of the input <see cref="Span{T}"/></returns>
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Buffer2<T> AllocateConstantBuffer<T>(this GraphicsDevice device, Span<T> span) where T : unmanaged
|
||||
public static Buffer<T> AllocateConstantBuffer<T>(this GraphicsDevice device, Span<T> span) where T : unmanaged
|
||||
{
|
||||
Buffer2<T> buffer = new Buffer2<T>(device, span.Length, HeapType.Upload);
|
||||
Buffer<T> buffer = new Buffer<T>(device, span.Length, HeapType.Upload);
|
||||
buffer.SetData(span);
|
||||
|
||||
return buffer;
|
||||
|
||||
@@ -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"
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
@@ -54,13 +54,13 @@ namespace ComputeSharp.Shaders.Mappings
|
||||
type == typeof(Matrix4x4);
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether or not the input type is a <see cref="Buffer2{T}"/> value
|
||||
/// Checks whether or not the input type is a <see cref="Buffer{T}"/> value
|
||||
/// </summary>
|
||||
/// <param name="type">The input <see cref="Type"/> instance to check</param>
|
||||
/// <returns>A <see langword="bool"/> indicating whether the input <see cref="Type"/> is in fact a <see cref="Buffer2{T}"/> instance</returns>
|
||||
/// <returns>A <see langword="bool"/> indicating whether the input <see cref="Type"/> is in fact a <see cref="Buffer{T}"/> instance</returns>
|
||||
[Pure]
|
||||
public static bool IsBufferType(Type type) => type.IsGenericType &&
|
||||
type.GetGenericTypeDefinition() == typeof(Buffer2<>);
|
||||
type.GetGenericTypeDefinition() == typeof(Buffer<>);
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether or not a given <see cref="Type"/> is an HLSL known type
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace ComputeSharp.Shaders
|
||||
|
||||
// Read write buffer
|
||||
if (HlslKnownTypes.IsBufferType(fieldType) &&
|
||||
(HeapType)fieldType.GetProperty(nameof(Buffer2<byte>.HeapType)).GetValue(fieldValue) == HeapType.Default)
|
||||
(HeapType)fieldType.GetProperty(nameof(Buffer<byte>.HeapType)).GetValue(fieldValue) == HeapType.Default)
|
||||
{
|
||||
// Root parameter for a read write buffer
|
||||
DescriptorRange range = new DescriptorRange(DescriptorRangeType.UnorderedAccessView, 1, readWriteBuffersCount);
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace DirectX12ComputeShaderSample
|
||||
array[i] = i + 1;
|
||||
}
|
||||
|
||||
using Buffer2<float> gpuBuffer = Gpu.Default.AllocateReadWriteBuffer(array.AsSpan());
|
||||
using Buffer<float> gpuBuffer = Gpu.Default.AllocateReadWriteBuffer(array.AsSpan());
|
||||
|
||||
// Shader body
|
||||
Action<ThreadIds> action = id =>
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする