Minor code tweaks
このコミットが含まれているのは:
1 親
333b04b9de
コミット
488e8095a1
3ファイル変更
+16
-18
検索条件に一致するファイルはありません
@@ -45,11 +45,10 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
|
||||
/// <summary>
|
||||
/// Maps the current resource to a specified subresource
|
||||
/// </summary>
|
||||
/// <param name="subresource">The index of the target subresource to map</param>
|
||||
/// <returns>An <see cref="IntPtr"/> for the newly mapped resource</returns>
|
||||
internal IntPtr Map(int subresource)
|
||||
internal IntPtr Map()
|
||||
{
|
||||
IntPtr mappedResource = NativeResource?.Map(subresource) ?? throw new InvalidOperationException("Missing resource");
|
||||
IntPtr mappedResource = NativeResource?.Map(0) ?? throw new InvalidOperationException("Missing resource");
|
||||
MappedResource = mappedResource;
|
||||
return mappedResource;
|
||||
}
|
||||
@@ -57,10 +56,9 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
|
||||
/// <summary>
|
||||
/// Unmaps a subresource specified by a given index
|
||||
/// </summary>
|
||||
/// <param name="subresource">The index of the subresource to unmap</param>
|
||||
internal void Unmap(int subresource)
|
||||
internal void Unmap()
|
||||
{
|
||||
NativeResource?.Unmap(subresource);
|
||||
NativeResource?.Unmap(0);
|
||||
MappedResource = IntPtr.Zero;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,9 +30,9 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
|
||||
copyCommandList.CopyBufferRegion(this, offset * ElementSizeInBytes, transferBuffer, 0, count * ElementSizeInBytes);
|
||||
copyCommandList.Flush();
|
||||
|
||||
transferBuffer.Map(0);
|
||||
transferBuffer.Map();
|
||||
MemoryHelper.Copy(transferBuffer.MappedResource, 0, span, 0, count);
|
||||
transferBuffer.Unmap(0);
|
||||
transferBuffer.Unmap();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
@@ -40,9 +40,9 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
|
||||
{
|
||||
using Buffer<T> transferBuffer = new Buffer<T>(GraphicsDevice, count, count * ElementSizeInBytes, BufferType.Transfer);
|
||||
|
||||
transferBuffer.Map(0);
|
||||
transferBuffer.Map();
|
||||
MemoryHelper.Copy(span, 0, transferBuffer.MappedResource, 0, count);
|
||||
transferBuffer.Unmap(0);
|
||||
transferBuffer.Unmap();
|
||||
|
||||
using CommandList copyCommandList = new CommandList(GraphicsDevice, CommandListType.Copy);
|
||||
|
||||
|
||||
@@ -52,9 +52,9 @@ namespace ComputeSharp
|
||||
Span<byte> temporarySpan = temporaryArray.AsSpan(0, count * PaddedElementSizeInBytes);
|
||||
|
||||
// Copy the padded data to the temporary array
|
||||
Map(0);
|
||||
Map();
|
||||
MemoryHelper.Copy(MappedResource, offset * PaddedElementSizeInBytes, temporarySpan, 0, count * PaddedElementSizeInBytes);
|
||||
Unmap(0);
|
||||
Unmap();
|
||||
|
||||
ref byte tin = ref temporarySpan.GetPinnableReference();
|
||||
ref T tout = ref span.GetPinnableReference();
|
||||
@@ -71,9 +71,9 @@ namespace ComputeSharp
|
||||
else
|
||||
{
|
||||
// Directly copy the data back if there is no padding
|
||||
Map(0);
|
||||
Map();
|
||||
MemoryHelper.Copy(MappedResource, offset, span, 0, count);
|
||||
Unmap(0);
|
||||
Unmap();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,18 +96,18 @@ namespace ComputeSharp
|
||||
}
|
||||
|
||||
// Copy the padded data to the GPU
|
||||
Map(0);
|
||||
Map();
|
||||
MemoryHelper.Copy(temporarySpan, 0, MappedResource, offset * PaddedElementSizeInBytes, count * PaddedElementSizeInBytes);
|
||||
Unmap(0);
|
||||
Unmap();
|
||||
|
||||
ArrayPool<byte>.Shared.Return(temporaryArray);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Directly copy the input span if there is no padding
|
||||
Map(0);
|
||||
Map();
|
||||
MemoryHelper.Copy(span, 0, MappedResource, offset, count);
|
||||
Unmap(0);
|
||||
Unmap();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする