Minor code refactoring and bug fixes
このコミットが含まれているのは:
1 親
26d8b83747
コミット
6629e94f0a
4ファイル変更
+9
-11
検索条件に一致するファイルはありません
@@ -8,7 +8,7 @@ using ComputeSharp.Interop;
|
||||
using Microsoft.Toolkit.Diagnostics;
|
||||
using TerraFX.Interop;
|
||||
|
||||
namespace ComputeSharp
|
||||
namespace ComputeSharp.Resources
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see langword="class"/> representing a typed buffer stored on CPU memory, that can be used to transfer data to/from the GPU.
|
||||
@@ -22,11 +22,6 @@ namespace ComputeSharp
|
||||
/// </summary>
|
||||
private ComPtr<ID3D12Resource> d3D12Resource;
|
||||
|
||||
/// <summary>
|
||||
/// The size in bytes of the current buffer (this value is never negative).
|
||||
/// </summary>
|
||||
private readonly nint sizeInBytes;
|
||||
|
||||
/// <summary>
|
||||
/// The pointer to the start of the mapped buffer data.
|
||||
/// </summary>
|
||||
@@ -49,8 +44,9 @@ namespace ComputeSharp
|
||||
GraphicsDevice = device;
|
||||
Length = length;
|
||||
|
||||
this.sizeInBytes = checked((nint)(length * (uint)sizeof(T)));
|
||||
this.d3D12Resource = device.D3D12Device->CreateCommittedResource(resourceType, allocationMode, (ulong)this.sizeInBytes, device.IsCacheCoherentUMA);
|
||||
ulong sizeInBytes = (uint)length * (uint)sizeof(T);
|
||||
|
||||
this.d3D12Resource = device.D3D12Device->CreateCommittedResource(resourceType, allocationMode, sizeInBytes, device.IsCacheCoherentUMA);
|
||||
this.mappedData = (T*)this.d3D12Resource.Get()->Map().Pointer;
|
||||
}
|
||||
|
||||
@@ -147,11 +143,11 @@ namespace ComputeSharp
|
||||
/// <inheritdoc/>
|
||||
public override MemoryHandle Pin(int elementIndex = 0)
|
||||
{
|
||||
Guard.IsInRange(elementIndex, 0, this.buffer.Length, nameof(elementIndex));
|
||||
Guard.IsEqualTo(elementIndex, 0, nameof(elementIndex));
|
||||
|
||||
this.buffer.ThrowIfDisposed();
|
||||
|
||||
return new(this.buffer.mappedData + elementIndex);
|
||||
return new(this.buffer.mappedData);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -167,7 +167,7 @@ namespace ComputeSharp.Resources
|
||||
/// <inheritdoc/>
|
||||
public override Span<T> GetSpan()
|
||||
{
|
||||
return new(this.texture.mappedData, this.texture.Height * this.texture.rowPitch);
|
||||
return new(this.texture.mappedData, this.texture.Width * (this.texture.Width + this.texture.rowPitch));
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Diagnostics;
|
||||
using ComputeSharp.Graphics.Resources.Enums;
|
||||
using ComputeSharp.Resources;
|
||||
using ComputeSharp.Resources.Views;
|
||||
|
||||
namespace ComputeSharp
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Diagnostics;
|
||||
using ComputeSharp.Graphics.Resources.Enums;
|
||||
using ComputeSharp.Resources;
|
||||
using ComputeSharp.Resources.Views;
|
||||
|
||||
namespace ComputeSharp
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする