Code refactoring, removed cross dependencies in some buffer classes

このコミットが含まれているのは:
Sergio Pedri committed 2019-08-15 16:04:15 +02:00
1 親 673633a48d
コミット 7f8c205330
3ファイル変更
+13 -16

検索条件に一致するファイルはありません

@@ -53,7 +53,7 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
/// <inheritdoc/>
public override void SetData(HlslBuffer<T> buffer)
{
if (buffer is ConstantBuffer<T> readOnlyBuffer && !readOnlyBuffer.IsPaddingPresent)
if (!buffer.IsPaddingPresent)
{
// Directly copy the input buffer
using CommandList copyCommandList = new CommandList(GraphicsDevice, CommandListType.Copy);
@@ -26,6 +26,7 @@ namespace ComputeSharp.Graphics.Buffers
SizeInBytes = sizeInBytes; // Not necessarily a multiple of the element size, as there could be padding
ElementSizeInBytes = Unsafe.SizeOf<T>();
BufferType = bufferType;
PaddedElementSizeInBytes = sizeInBytes / size;
// Determine the right heap type and flags
(HeapType heapType, ResourceFlags flags, ResourceStates states) = bufferType switch
@@ -67,6 +68,16 @@ namespace ComputeSharp.Graphics.Buffers
/// </summary>
protected int ElementSizeInBytes { get; }
/// <summary>
/// Gets the size in bytes of the current buffer
/// </summary>
internal int PaddedElementSizeInBytes { get; }
/// <summary>
/// Gets whether or not there is some padding between elements in the current buffer
/// </summary>
internal bool IsPaddingPresent => PaddedElementSizeInBytes > ElementSizeInBytes;
/// <summary>
/// Gets the buffer type for the current <see cref="Buffer{T}"/> instance
/// </summary>
+1 -15
ファイルの表示
@@ -20,21 +20,7 @@ namespace ComputeSharp.Graphics.Buffers
/// </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>
internal ConstantBuffer(GraphicsDevice device, int size) : base(device, size, size * (Unsafe.SizeOf<T>() / 16 + 1) * 16, BufferType.Constant)
{
PaddedElementSizeInBytes = SizeInBytes / Size;
IsPaddingPresent = PaddedElementSizeInBytes > ElementSizeInBytes;
}
/// <summary>
/// Gets the size in bytes of the current buffer
/// </summary>
internal int PaddedElementSizeInBytes { get; }
/// <summary>
/// Gets whether or not there is some padding between elements in the current buffer
/// </summary>
internal bool IsPaddingPresent { get; }
internal ConstantBuffer(GraphicsDevice device, int size) : base(device, size, size * (Unsafe.SizeOf<T>() / 16 + 1) * 16, BufferType.Constant) { }
/// <summary>
/// Gets a single <typeparamref name="T"/> value from the current constant buffer