Removed Vortice.Windows references and files
このコミットが含まれているのは:
1 親
b67af4aaa1
コミット
4811769ebc
46ファイル変更
+1124
-3358
検索条件に一致するファイルはありません
@@ -1,89 +1,85 @@
|
||||
using System;
|
||||
using ComputeSharp.Core.Interop;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Vortice.Direct3D12;
|
||||
using TerraFX.Interop;
|
||||
|
||||
namespace ComputeSharp.Graphics.Buffers.Abstract
|
||||
{
|
||||
/// <summary>
|
||||
/// An abstract <see langword="class"/> that represents a graphics resource object
|
||||
/// An abstract <see langword="class"/> that represents a graphics resource object.
|
||||
/// </summary>
|
||||
public abstract class GraphicsResource : IDisposable
|
||||
public abstract unsafe class GraphicsResource : NativeObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="GraphicsResource"/> instance with the specified parameters
|
||||
/// The <see cref="ID3D12Resource"/> instance currently mapped.
|
||||
/// </summary>
|
||||
/// <param name="device">The <see cref="GraphicsDevice"/> associated with the current instance</param>
|
||||
protected GraphicsResource(GraphicsDevice device)
|
||||
protected internal readonly ID3D12Resource* D3D12Resource;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="GraphicsResource"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="device">The <see cref="GraphicsDevice"/> associated with the current instance.</param>
|
||||
protected GraphicsResource(GraphicsDevice device, ID3D12Resource* d3d12resource)
|
||||
{
|
||||
D3D12Resource = d3d12resource;
|
||||
|
||||
GraphicsDevice = device;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="GraphicsDevice"/> associated with the current instance
|
||||
/// Gets the <see cref="GraphicsDevice"/> associated with the current instance.
|
||||
/// </summary>
|
||||
public GraphicsDevice GraphicsDevice { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="ID3D12Resource"/> object currently mapped
|
||||
/// Maps the current resource to a specified subresource.
|
||||
/// </summary>
|
||||
protected internal ID3D12Resource? NativeResource { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="CpuDescriptorHandle"/> instance for the current resource
|
||||
/// </summary>
|
||||
protected internal CpuDescriptorHandle? NativeCpuDescriptorHandle { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="GpuDescriptorHandle"/> instance for the current resource
|
||||
/// </summary>
|
||||
protected internal GpuDescriptorHandle? NativeGpuDescriptorHandle { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Maps the current resource to a specified subresource
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="MappedResource"/> instance representing the mapped resource</returns>
|
||||
/// <returns>A <see cref="MappedResource"/> instance representing the mapped resource.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal MappedResource MapResource()
|
||||
{
|
||||
var resource = NativeResource ?? throw new InvalidOperationException("Missing resource");
|
||||
|
||||
return new MappedResource(resource);
|
||||
return new MappedResource(D3D12Resource);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public virtual void Dispose() => NativeResource?.Dispose();
|
||||
protected override void OnDispose()
|
||||
{
|
||||
D3D12Resource->Release();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A type representing a mapped memory resource
|
||||
/// A type representing a mapped memory resource.
|
||||
/// </summary>
|
||||
internal readonly ref struct MappedResource
|
||||
{
|
||||
/// <summary>
|
||||
/// The target <see cref="ID3D12Resource"/> to map
|
||||
/// The target <see cref="ID3D12Resource"/> to map.
|
||||
/// </summary>
|
||||
private readonly ID3D12Resource Resource;
|
||||
private readonly ID3D12Resource* d3D12Resource;
|
||||
|
||||
/// <summary>
|
||||
/// The pointer to the mapped resource
|
||||
/// The pointer to the mapped resource.
|
||||
/// </summary>
|
||||
public readonly IntPtr Pointer;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="MappedResource"/> instance for a given <see cref="ID3D12Resource"/> value
|
||||
/// Creates a new <see cref="MappedResource"/> instance for a given <see cref="ID3D12Resource"/> value.
|
||||
/// </summary>
|
||||
/// <param name="resource">The input <see cref="ID3D12Resource"/> instance to map</param>
|
||||
/// <param name="resource">The input <see cref="ID3D12Resource"/> instance to map.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public MappedResource(ID3D12Resource resource)
|
||||
public MappedResource(ID3D12Resource* d3d12resource)
|
||||
{
|
||||
Resource = resource;
|
||||
Pointer = resource.Map(0);
|
||||
d3D12Resource = d3d12resource;
|
||||
|
||||
Pointer = d3d12resource->Map();
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IDisposable.Dispose"/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Dispose()
|
||||
{
|
||||
Resource.Unmap(0);
|
||||
d3D12Resource->Unmap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
using ComputeSharp.Core.Interop;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using TerraFX.Interop;
|
||||
|
||||
namespace ComputeSharp.Graphics.Buffers.Abstract
|
||||
{
|
||||
/// <summary>
|
||||
/// An abstract <see langword="class"/> that represents a graphics resource object.
|
||||
/// </summary>
|
||||
public abstract unsafe class GraphicsResource2 : NativeObject
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="ID3D12Resource"/> instance currently mapped.
|
||||
/// </summary>
|
||||
protected internal readonly ID3D12Resource* D3D12Resource;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="GraphicsResource"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="device">The <see cref="GraphicsDevice"/> associated with the current instance.</param>
|
||||
protected GraphicsResource2(GraphicsDevice2 device, ID3D12Resource* d3d12resource)
|
||||
{
|
||||
D3D12Resource = d3d12resource;
|
||||
|
||||
GraphicsDevice = device;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="GraphicsDevice"/> associated with the current instance.
|
||||
/// </summary>
|
||||
public GraphicsDevice2 GraphicsDevice { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Maps the current resource to a specified subresource.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="MappedResource"/> instance representing the mapped resource.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal MappedResource MapResource()
|
||||
{
|
||||
return new MappedResource(D3D12Resource);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void OnDispose()
|
||||
{
|
||||
D3D12Resource->Release();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A type representing a mapped memory resource.
|
||||
/// </summary>
|
||||
internal readonly ref struct MappedResource
|
||||
{
|
||||
/// <summary>
|
||||
/// The target <see cref="ID3D12Resource"/> to map.
|
||||
/// </summary>
|
||||
private readonly ID3D12Resource* d3D12Resource;
|
||||
|
||||
/// <summary>
|
||||
/// The pointer to the mapped resource.
|
||||
/// </summary>
|
||||
public readonly IntPtr Pointer;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="MappedResource"/> instance for a given <see cref="ID3D12Resource"/> value.
|
||||
/// </summary>
|
||||
/// <param name="resource">The input <see cref="ID3D12Resource"/> instance to map.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public MappedResource(ID3D12Resource* d3d12resource)
|
||||
{
|
||||
d3D12Resource = d3d12resource;
|
||||
|
||||
Pointer = d3d12resource->Map();
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IDisposable.Dispose"/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Dispose()
|
||||
{
|
||||
d3D12Resource->Unmap();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Diagnostics.Contracts;
|
||||
using ComputeSharp.Graphics.Buffers.Enums;
|
||||
|
||||
namespace ComputeSharp.Graphics.Buffers.Abstract
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see langword="class"/> representing a typed buffer stored on GPU memory, that can be used from an HLSL shader
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the buffer</typeparam>
|
||||
public abstract class HlslBuffer2<T> : Buffer2<T> where T : unmanaged
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="HlslBuffer2{T}"/> instance with the specified parameters
|
||||
/// </summary>
|
||||
/// <param name="device">The <see cref="GraphicsDevice2"/> associated with the current instance</param>
|
||||
/// <param name="size">The number of items to store in the current buffer</param>
|
||||
/// <param name="sizeInBytes">The size in bytes for the current buffer</param>
|
||||
/// <param name="bufferType">The buffer type for the current buffer</param>
|
||||
private protected HlslBuffer2(GraphicsDevice2 device, int size, int sizeInBytes, BufferType bufferType)
|
||||
: base(device, size, sizeInBytes, bufferType)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of the current <see cref="HlslBuffer2{T}"/> instance and returns an array
|
||||
/// </summary>
|
||||
/// <returns>A <typeparamref name="T"/> array with the contents of the current buffer</returns>
|
||||
[Pure]
|
||||
public T[] GetData() => GetData(0, Size);
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of the current <see cref="HlslBuffer2{T}"/> instance in a given range and returns an array
|
||||
/// </summary>
|
||||
/// <param name="offset">The offset to start reading data from</param>
|
||||
/// <param name="count">The number of items to read</param>
|
||||
/// <returns>A <typeparamref name="T"/> array with the contents of the specified range from the current buffer</returns>
|
||||
[Pure]
|
||||
public T[] GetData(int offset, int count)
|
||||
{
|
||||
T[] data = new T[count];
|
||||
GetData(data, offset, count);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of the current <see cref="HlslBuffer2{T}"/> instance and writes them into a target <see cref="Span{T}"/>
|
||||
/// </summary>
|
||||
/// <param name="span">The input <see cref="Span{T}"/> to write data to</param>
|
||||
public void GetData(Span<T> span) => GetData(span, 0, Size);
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of the specified range from the current <see cref="HlslBuffer2{T}"/> instance and writes them into a target <see cref="Span{T}"/>
|
||||
/// </summary>
|
||||
/// <param name="span">The input <see cref="Span{T}"/> to write data to</param>
|
||||
/// <param name="offset">The offset to start reading data from</param>
|
||||
/// <param name="count">The number of items to read</param>
|
||||
public abstract void GetData(Span<T> span, int offset, int count);
|
||||
|
||||
/// <summary>
|
||||
/// Writes the contents of a given <typeparamref name="T"/> array to the current <see cref="HlslBuffer2{T}"/> instance
|
||||
/// </summary>
|
||||
/// <param name="array">The input <typeparamref name="T"/> array to read data from</param>
|
||||
public void SetData(T[] array) => SetData(array.AsSpan());
|
||||
|
||||
/// <summary>
|
||||
/// Writes the contents of a given <typeparamref name="T"/> array to a specified area of the current <see cref="HlslBuffer2{T}"/> instance
|
||||
/// </summary>
|
||||
/// <param name="array">The input <typeparamref name="T"/> array to read data from</param>
|
||||
/// <param name="offset">The offset to start writing data to</param>
|
||||
/// <param name="count">The number of items to write</param>
|
||||
public void SetData(T[] array, int offset, int count) => SetData(array.AsSpan(), offset, count);
|
||||
|
||||
/// <summary>
|
||||
/// Writes the contents of a given <see cref="ReadOnlySpan{T}"/> to the current <see cref="HlslBuffer2{T}"/> instance
|
||||
/// </summary>
|
||||
/// <param name="span">The input <see cref="ReadOnlySpan{T}"/> to read data from</param>
|
||||
public void SetData(ReadOnlySpan<T> span) => SetData(span, 0, Size);
|
||||
|
||||
/// <summary>
|
||||
/// Writes the contents of a given <see cref="ReadOnlySpan{T}"/> to a specified area of the current <see cref="HlslBuffer2{T}"/> instance
|
||||
/// </summary>
|
||||
/// <param name="span">The input <see cref="ReadOnlySpan{T}"/> to read data from</param>
|
||||
/// <param name="offset">The offset to start writing data to</param>
|
||||
/// <param name="count">The number of items to write</param>
|
||||
public abstract void SetData(ReadOnlySpan<T> span, int offset, int count);
|
||||
|
||||
/// <summary>
|
||||
/// Writes the contents of a given <see cref="HlslBuffer2{T}"/> to the current <see cref="HlslBuffer2{T}"/> instance
|
||||
/// </summary>
|
||||
/// <param name="buffer">The input <see cref="HlslBuffer2{T}"/> to read data from</param>
|
||||
public abstract void SetData(HlslBuffer2<T> buffer);
|
||||
|
||||
/// <summary>
|
||||
/// Writes the contents of a given <see cref="HlslBuffer2{T}"/> to the current <see cref="HlslBuffer2{T}"/> instance, using a temporary CPU buffer
|
||||
/// </summary>
|
||||
/// <param name="buffer">The input <see cref="HlslBuffer2{T}"/> to read data from</param>
|
||||
protected void SetDataWithCpuBuffer(HlslBuffer2<T> buffer)
|
||||
{
|
||||
// Create a temporary array
|
||||
T[] array = ArrayPool<T>.Shared.Rent(buffer.Size);
|
||||
Span<T> span = array.AsSpan(0, buffer.Size);
|
||||
|
||||
// Get the unpadded data from the read write buffer
|
||||
buffer.GetData(span);
|
||||
|
||||
// Set the data, adding the padding if needed
|
||||
SetData(span);
|
||||
|
||||
ArrayPool<T>.Shared.Return(array);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,10 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
|
||||
/// <param name="size">The number of items to store in the current buffer</param>
|
||||
/// <param name="sizeInBytes">The size in bytes for the current buffer</param>
|
||||
/// <param name="bufferType">The buffer type for the current buffer</param>
|
||||
private protected HlslBuffer(GraphicsDevice device, int size, int sizeInBytes, BufferType bufferType) : base(device, size, sizeInBytes, bufferType) { }
|
||||
private protected HlslBuffer(GraphicsDevice device, int size, int sizeInBytes, BufferType bufferType)
|
||||
: base(device, size, sizeInBytes, bufferType)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of the current <see cref="HlslBuffer{T}"/> instance and returns an array
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.Graphics.Buffers.Enums;
|
||||
using ComputeSharp.Graphics.Commands;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
using static TerraFX.Interop.D3D12_COMMAND_LIST_TYPE;
|
||||
|
||||
namespace ComputeSharp.Graphics.Buffers.Abstract
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see langword="class"/> representing a typed structured buffer stored on GPU memory
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the buffer</typeparam>
|
||||
public abstract class HlslStructuredBuffer2<T> : HlslBuffer2<T>
|
||||
where T : unmanaged
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="HlslStructuredBuffer2{T}"/> instance with the specified parameters
|
||||
/// </summary>
|
||||
/// <param name="device">The <see cref="GraphicsDevice2"/> associated with the current instance</param>
|
||||
/// <param name="size">The number of items to store in the current buffer</param>
|
||||
/// <param name="bufferType">The buffer type for the current buffer</param>
|
||||
internal HlslStructuredBuffer2(GraphicsDevice2 device, int size, BufferType bufferType)
|
||||
: base(device, size, size * Unsafe.SizeOf<T>(), bufferType)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override unsafe void GetData(Span<T> span, int offset, int count)
|
||||
{
|
||||
using Buffer2<T> transferBuffer = new Buffer2<T>(GraphicsDevice, count, count * ElementSizeInBytes, BufferType.ReadBack);
|
||||
|
||||
using (CommandList2 copyCommandList = new CommandList2(GraphicsDevice, D3D12_COMMAND_LIST_TYPE_COPY))
|
||||
{
|
||||
copyCommandList.CopyBufferRegion(D3D12Resource, offset * ElementSizeInBytes, transferBuffer.D3D12Resource, 0, count * ElementSizeInBytes);
|
||||
copyCommandList.ExecuteAndWaitForCompletion();
|
||||
}
|
||||
|
||||
using MappedResource resource = transferBuffer.MapResource();
|
||||
|
||||
MemoryHelper.Copy(resource.Pointer, 0, span, 0, count);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override unsafe void SetData(ReadOnlySpan<T> span, int offset, int count)
|
||||
{
|
||||
using Buffer2<T> transferBuffer = new Buffer2<T>(GraphicsDevice, count, count * ElementSizeInBytes, BufferType.Transfer);
|
||||
|
||||
using (MappedResource resource = transferBuffer.MapResource())
|
||||
{
|
||||
MemoryHelper.Copy(span, resource.Pointer, 0, count);
|
||||
}
|
||||
|
||||
using CommandList2 copyCommandList = new CommandList2(GraphicsDevice, D3D12_COMMAND_LIST_TYPE_COPY);
|
||||
|
||||
copyCommandList.CopyBufferRegion(transferBuffer.D3D12Resource, 0, D3D12Resource, offset * ElementSizeInBytes, count * ElementSizeInBytes);
|
||||
copyCommandList.ExecuteAndWaitForCompletion();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override unsafe void SetData(HlslBuffer2<T> buffer)
|
||||
{
|
||||
if (!buffer.IsPaddingPresent)
|
||||
{
|
||||
// Directly copy the input buffer
|
||||
using CommandList2 copyCommandList = new CommandList2(GraphicsDevice, D3D12_COMMAND_LIST_TYPE_COPY);
|
||||
|
||||
copyCommandList.CopyBufferRegion(buffer.D3D12Resource, 0, D3D12Resource, 0, SizeInBytes);
|
||||
copyCommandList.ExecuteAndWaitForCompletion();
|
||||
}
|
||||
else SetDataWithCpuBuffer(buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.Graphics.Buffers.Enums;
|
||||
using ComputeSharp.Graphics.Commands;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
using Vortice.Direct3D12;
|
||||
using CommandList = ComputeSharp.Graphics.Commands.CommandList;
|
||||
using static TerraFX.Interop.D3D12_COMMAND_LIST_TYPE;
|
||||
|
||||
namespace ComputeSharp.Graphics.Buffers.Abstract
|
||||
{
|
||||
@@ -20,16 +20,19 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
|
||||
/// <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>
|
||||
/// <param name="bufferType">The buffer type for the current buffer</param>
|
||||
internal HlslStructuredBuffer(GraphicsDevice device, int size, BufferType bufferType) : base(device, size, size * Unsafe.SizeOf<T>(), bufferType) { }
|
||||
internal HlslStructuredBuffer(GraphicsDevice device, int size, BufferType bufferType)
|
||||
: base(device, size, size * Unsafe.SizeOf<T>(), bufferType)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void GetData(Span<T> span, int offset, int count)
|
||||
public override unsafe void GetData(Span<T> span, int offset, int count)
|
||||
{
|
||||
using Buffer<T> transferBuffer = new Buffer<T>(GraphicsDevice, count, count * ElementSizeInBytes, BufferType.ReadBack);
|
||||
|
||||
using (CommandList copyCommandList = new CommandList(GraphicsDevice, CommandListType.Copy))
|
||||
using (CommandList copyCommandList = new CommandList(GraphicsDevice, D3D12_COMMAND_LIST_TYPE_COPY))
|
||||
{
|
||||
copyCommandList.CopyBufferRegion(this, offset * ElementSizeInBytes, transferBuffer, 0, count * ElementSizeInBytes);
|
||||
copyCommandList.CopyBufferRegion(D3D12Resource, offset * ElementSizeInBytes, transferBuffer.D3D12Resource, 0, count * ElementSizeInBytes);
|
||||
copyCommandList.ExecuteAndWaitForCompletion();
|
||||
}
|
||||
|
||||
@@ -39,7 +42,7 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetData(ReadOnlySpan<T> span, int offset, int count)
|
||||
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);
|
||||
|
||||
@@ -48,21 +51,21 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
|
||||
MemoryHelper.Copy(span, resource.Pointer, 0, count);
|
||||
}
|
||||
|
||||
using CommandList copyCommandList = new CommandList(GraphicsDevice, CommandListType.Copy);
|
||||
using CommandList copyCommandList = new CommandList(GraphicsDevice, D3D12_COMMAND_LIST_TYPE_COPY);
|
||||
|
||||
copyCommandList.CopyBufferRegion(transferBuffer, 0, this, offset * ElementSizeInBytes, count * ElementSizeInBytes);
|
||||
copyCommandList.CopyBufferRegion(transferBuffer.D3D12Resource, 0, D3D12Resource, offset * ElementSizeInBytes, count * ElementSizeInBytes);
|
||||
copyCommandList.ExecuteAndWaitForCompletion();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetData(HlslBuffer<T> buffer)
|
||||
public override unsafe void SetData(HlslBuffer<T> buffer)
|
||||
{
|
||||
if (!buffer.IsPaddingPresent)
|
||||
{
|
||||
// Directly copy the input buffer
|
||||
using CommandList copyCommandList = new CommandList(GraphicsDevice, CommandListType.Copy);
|
||||
using CommandList copyCommandList = new CommandList(GraphicsDevice, D3D12_COMMAND_LIST_TYPE_COPY);
|
||||
|
||||
copyCommandList.CopyBufferRegion(buffer, 0, this, 0, SizeInBytes);
|
||||
copyCommandList.CopyBufferRegion(buffer.D3D12Resource, 0, D3D12Resource, 0, SizeInBytes);
|
||||
copyCommandList.ExecuteAndWaitForCompletion();
|
||||
}
|
||||
else SetDataWithCpuBuffer(buffer);
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする