More code tweaks, improved XML docs
このコミットが含まれているのは:
1 親
b32a8ae9e2
コミット
a6ad87200b
4ファイル変更
+24
-21
検索条件に一致するファイルはありません
@@ -44,7 +44,7 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
|
||||
/// <inheritdoc/>
|
||||
public override unsafe void SetData(ReadOnlySpan<T> span, int offset, int count)
|
||||
{
|
||||
using Buffer<T> transferBuffer = new Buffer<T>(GraphicsDevice, count, count * ElementSizeInBytes, BufferType.Transfer);
|
||||
using Buffer<T> transferBuffer = new Buffer<T>(GraphicsDevice, count, count * ElementSizeInBytes, BufferType.Upload);
|
||||
|
||||
using (MappedResource resource = transferBuffer.MapResource())
|
||||
{
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace ComputeSharp.Graphics.Buffers
|
||||
BufferType.ReadOnly => (D3D12_HEAP_TYPE_DEFAULT, D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_COMMON),
|
||||
BufferType.ReadWrite => (D3D12_HEAP_TYPE_DEFAULT, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COMMON),
|
||||
BufferType.ReadBack => (D3D12_HEAP_TYPE_READBACK, D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_COPY_DEST),
|
||||
BufferType.Transfer => (D3D12_HEAP_TYPE_UPLOAD, D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_GENERIC_READ),
|
||||
BufferType.Upload => (D3D12_HEAP_TYPE_UPLOAD, D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_GENERIC_READ),
|
||||
_ => throw null!
|
||||
};
|
||||
|
||||
|
||||
@@ -29,6 +29,13 @@ namespace ComputeSharp
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a single <typeparamref name="T"/> value from the current constant buffer
|
||||
/// </summary>
|
||||
/// <param name="i">The index of the value to get</param>
|
||||
/// <remarks>This API can only be used from a compute shader, and will always throw if used anywhere else</remarks>
|
||||
public T this[int i] => throw new InvalidExecutionContextException($"{nameof(ConstantBuffer<T>)}<T>[int]");
|
||||
|
||||
/// <summary>
|
||||
/// Gets the right padded size for <typeparamref name="T"/> elements to store in the current instance
|
||||
/// </summary>
|
||||
@@ -36,18 +43,9 @@ namespace ComputeSharp
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static int GetPaddedSize()
|
||||
{
|
||||
int size = Unsafe.SizeOf<T>();
|
||||
|
||||
return (size + 15) & ~15;
|
||||
return (Unsafe.SizeOf<T>() + 15) & ~15;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a single <typeparamref name="T"/> value from the current constant buffer
|
||||
/// </summary>
|
||||
/// <param name="i">The index of the value to get</param>
|
||||
/// <remarks>This API can only be used from a compute shader, and will always throw if used anywhere else</remarks>
|
||||
public T this[int i] => throw new InvalidExecutionContextException($"{nameof(ConstantBuffer<T>)}<T>[int]");
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override unsafe void GetData(Span<T> span, int offset, int count)
|
||||
{
|
||||
@@ -56,7 +54,7 @@ namespace ComputeSharp
|
||||
if (IsPaddingPresent)
|
||||
{
|
||||
ref T spanRef = ref MemoryMarshal.GetReference(span);
|
||||
ref byte resourceRef = ref Unsafe.AsRef<byte>((void*)resource.Pointer);
|
||||
ref byte resourceRef = ref Unsafe.AsRef<byte>(resource.Pointer);
|
||||
|
||||
// Move to the initial ref
|
||||
resourceRef = ref Unsafe.Add(ref resourceRef, offset * GetPaddedSize());
|
||||
@@ -79,7 +77,7 @@ namespace ComputeSharp
|
||||
if (IsPaddingPresent)
|
||||
{
|
||||
ref T spanRef = ref MemoryMarshal.GetReference(span);
|
||||
ref byte resourceRef = ref Unsafe.AsRef<byte>((void*)resource.Pointer);
|
||||
ref byte resourceRef = ref Unsafe.AsRef<byte>(resource.Pointer);
|
||||
|
||||
// Move to the initial offset
|
||||
resourceRef = ref Unsafe.Add(ref resourceRef, offset * GetPaddedSize());
|
||||
|
||||
@@ -1,33 +1,38 @@
|
||||
namespace ComputeSharp.Graphics.Buffers.Enums
|
||||
{
|
||||
/// <summary>
|
||||
/// An <see langword="enum"/> that indicates the type of a given HLSL buffer
|
||||
/// An <see langword="enum"/> that indicates the type of a given HLSL buffer.
|
||||
/// </summary>
|
||||
internal enum BufferType
|
||||
{
|
||||
/// <summary>
|
||||
/// A constant buffer, with items aligned to 16 bytes, used for individual values or very small arrays, mapped to <see cref="Vortice.DirectX.Direct3D12.HeapType.Upload"/>
|
||||
/// A constant buffer, with items aligned to 16 bytes, used for individual values or very small arrays.
|
||||
/// This is mapped to a <see langword="cbuffer"/> in <see cref="TerraFX.Interop.D3D12_HEAP_TYPE.D3D12_HEAP_TYPE_UPLOAD"/>.
|
||||
/// </summary>
|
||||
Constant,
|
||||
|
||||
/// <summary>
|
||||
/// A readonly buffer, that can store arbitrary arrays of values, mapped to <see cref="Vortice.DirectX.Direct3D12.HeapType.Default"/>
|
||||
/// A readonly buffer, that can store arbitrary arrays of values and can only be read from by the GPU.
|
||||
/// This is mapped to a <see langword="StructuredBuffer<T>"/> in <see cref="TerraFX.Interop.D3D12_HEAP_TYPE.D3D12_HEAP_TYPE_DEFAULT"/>.
|
||||
/// </summary>
|
||||
ReadOnly,
|
||||
|
||||
/// <summary>
|
||||
/// A read write buffer, that can store arbitrary arrays with both read and write access, mapped to <see cref="Vortice.DirectX.Direct3D12.HeapType.Default"/>
|
||||
/// A read write buffer, that can store arbitrary arrays with both read and write access for the GPU.
|
||||
/// This is mapped to a <see langword="RWStructuredBuffer<T>"/> in <see cref="TerraFX.Interop.D3D12_HEAP_TYPE.D3D12_HEAP_TYPE_DEFAULT"/>.
|
||||
/// </summary>
|
||||
ReadWrite,
|
||||
|
||||
/// <summary>
|
||||
/// A readback buffer, used as temporary buffer to read data back from buffers in the default heap, mapped to <see cref="Vortice.DirectX.Direct3D12.HeapType.Readback"/>
|
||||
/// A readback buffer, used as temporary buffer to read data back from <see cref="ReadOnly"/> and <see cref="ReadWrite"/> buffers.
|
||||
/// This has no mapping in HLSL, and is allocated in <see cref="TerraFX.Interop.D3D12_HEAP_TYPE.D3D12_HEAP_TYPE_READBACK"/>.
|
||||
/// </summary>
|
||||
ReadBack,
|
||||
|
||||
/// <summary>
|
||||
/// A transfer buffer, used as a temporary buffer to set data to buffers in the default heap, mapped to <see cref="Vortice.DirectX.Direct3D12.HeapType.Upload"/>
|
||||
/// A transfer buffer, used as a temporary buffer to set data to <see cref="ReadOnly"/> and <see cref="ReadWrite"/> buffers.
|
||||
/// This has no mapping in HLSL, and is allocated in <see cref="TerraFX.Interop.D3D12_HEAP_TYPE.D3D12_HEAP_TYPE_UPLOAD"/>.
|
||||
/// </summary>
|
||||
Transfer
|
||||
Upload
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする