More code refactoring
このコミットが含まれているのは:
1 親
9edbdcfdc3
コミット
8abf928b45
3ファイル変更
+15
-16
検索条件に一致するファイルはありません
@@ -46,16 +46,10 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
|
||||
public abstract void SetData(Span<T> span);
|
||||
|
||||
/// <summary>
|
||||
/// Writes the contents of a given <see cref="ReadOnlyBuffer{T}"/> to the current <see cref="HlslBuffer{T}"/> instance
|
||||
/// Writes the contents of a given <see cref="HlslBuffer{T}"/> to the current <see cref="HlslBuffer{T}"/> instance
|
||||
/// </summary>
|
||||
/// <param name="buffer">The input <see cref="ReadOnlyBuffer{T}"/> to read data from</param>
|
||||
public virtual void SetData(ReadOnlyBuffer<T> buffer) => SetDataWithCpuBuffer(buffer);
|
||||
|
||||
/// <summary>
|
||||
/// Writes the contents of a given <see cref="ReadWriteBuffer{T}"/> to the current <see cref="HlslBuffer{T}"/> instance
|
||||
/// </summary>
|
||||
/// <param name="buffer">The input <see cref="ReadWriteBuffer{T}"/> to read data from</param>
|
||||
public virtual void SetData(ReadWriteBuffer<T> buffer) => SetDataWithCpuBuffer(buffer);
|
||||
/// <param name="buffer">The input <see cref="HlslBuffer{T}"/> to read data from</param>
|
||||
public abstract void SetData(HlslBuffer<T> buffer);
|
||||
|
||||
/// <summary>
|
||||
/// Writes the contents of a given <see cref="HlslBuffer{T}"/> to the current <see cref="HlslBuffer{T}"/> instance, using a temporary CPU buffer
|
||||
|
||||
@@ -111,12 +111,17 @@ namespace ComputeSharp.Graphics.Buffers
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetData(ReadOnlyBuffer<T> buffer)
|
||||
public override void SetData(HlslBuffer<T> buffer)
|
||||
{
|
||||
using CommandList copyCommandList = new CommandList(GraphicsDevice, CommandListType.Copy);
|
||||
if (buffer is ReadOnlyBuffer<T> readOnlyBuffer)
|
||||
{
|
||||
// Directly copy the input buffer, if possible
|
||||
using CommandList copyCommandList = new CommandList(GraphicsDevice, CommandListType.Copy);
|
||||
|
||||
copyCommandList.CopyBufferRegion(buffer, 0, this, 0, SizeInBytes);
|
||||
copyCommandList.Flush(true);
|
||||
copyCommandList.CopyBufferRegion(buffer, 0, this, 0, SizeInBytes);
|
||||
copyCommandList.Flush(true);
|
||||
}
|
||||
else SetDataWithCpuBuffer(buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -61,10 +61,9 @@ namespace ComputeSharp.Graphics.Buffers
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetData(ReadOnlyBuffer<T> buffer)
|
||||
public override void SetData(HlslBuffer<T> buffer)
|
||||
{
|
||||
if (buffer.IsPaddingPresent) SetDataWithCpuBuffer(buffer);
|
||||
else
|
||||
if (buffer is ReadOnlyBuffer<T> readOnlyBuffer && !readOnlyBuffer.IsPaddingPresent)
|
||||
{
|
||||
// Directly copy the input buffer
|
||||
using CommandList copyCommandList = new CommandList(GraphicsDevice, CommandListType.Copy);
|
||||
@@ -72,6 +71,7 @@ namespace ComputeSharp.Graphics.Buffers
|
||||
copyCommandList.CopyBufferRegion(buffer, 0, this, 0, SizeInBytes);
|
||||
copyCommandList.Flush(true);
|
||||
}
|
||||
else SetDataWithCpuBuffer(buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする