Add double feature support in TransferBuffer<T> ctor
このコミットが含まれているのは:
1 親
ca17662bfb
コミット
a441ce5e6f
4ファイル変更
+16
検索条件に一致するファイルはありません
@@ -1075,6 +1075,7 @@ partial class GraphicsDeviceExtensions
|
||||
/// <param name="length">The length of the buffer to allocate.</param>
|
||||
/// <param name="allocationMode">The allocation mode to use for the new resource.</param>
|
||||
/// <returns>A <see cref="ReadOnlyBuffer{T}"/> instance of size <paramref name="length"/>.</returns>
|
||||
[RequiresUnreferencedCode("This method reads type info of all fields of the resource element type (recursively).")]
|
||||
public static UploadBuffer<T> AllocateUploadBuffer<T>(this GraphicsDevice device, int length, AllocationMode allocationMode = AllocationMode.Default)
|
||||
where T : unmanaged
|
||||
{
|
||||
@@ -1126,6 +1127,7 @@ partial class GraphicsDeviceExtensions
|
||||
/// <param name="length">The length of the buffer to allocate.</param>
|
||||
/// <param name="allocationMode">The allocation mode to use for the new resource.</param>
|
||||
/// <returns>A <see cref="ReadBackBuffer{T}"/> instance of size <paramref name="length"/>.</returns>
|
||||
[RequiresUnreferencedCode("This method reads type info of all fields of the resource element type (recursively).")]
|
||||
public static ReadBackBuffer<T> AllocateReadBackBuffer<T>(this GraphicsDevice device, int length, AllocationMode allocationMode = AllocationMode.Default)
|
||||
where T : unmanaged
|
||||
{
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
using ComputeSharp.Interop;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
using static TerraFX.Interop.DirectX.D3D12_FEATURE;
|
||||
using ResourceType = ComputeSharp.Graphics.Resources.Enums.ResourceType;
|
||||
|
||||
namespace ComputeSharp.Resources;
|
||||
@@ -42,6 +45,7 @@ public abstract unsafe class TransferBuffer<T> : NativeObject, IGraphicsResource
|
||||
/// <param name="length">The number of items to store in the current buffer.</param>
|
||||
/// <param name="resourceType">The resource type for the current buffer.</param>
|
||||
/// <param name="allocationMode">The allocation mode to use for the new resource.</param>
|
||||
[RequiresUnreferencedCode("This method reads type info of all fields of the resource element type (recursively).")]
|
||||
private protected TransferBuffer(GraphicsDevice device, int length, ResourceType resourceType, AllocationMode allocationMode)
|
||||
{
|
||||
// The maximum length is set such that the aligned buffer size can't exceed uint.MaxValue
|
||||
@@ -51,6 +55,12 @@ public abstract unsafe class TransferBuffer<T> : NativeObject, IGraphicsResource
|
||||
|
||||
device.ThrowIfDeviceLost();
|
||||
|
||||
if (TypeInfo<T>.IsDoubleOrContainsDoubles &&
|
||||
device.D3D12Device->CheckFeatureSupport<D3D12_FEATURE_DATA_D3D12_OPTIONS>(D3D12_FEATURE_D3D12_OPTIONS).DoublePrecisionFloatShaderOps == 0)
|
||||
{
|
||||
UnsupportedDoubleOperationException.Throw<T>();
|
||||
}
|
||||
|
||||
GraphicsDevice = device;
|
||||
Length = length;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using ComputeSharp.Graphics.Resources.Enums;
|
||||
using ComputeSharp.Resources;
|
||||
using ComputeSharp.Resources.Debug;
|
||||
@@ -20,6 +21,7 @@ public sealed class ReadBackBuffer<T> : TransferBuffer<T>
|
||||
/// <param name="device">The <see cref="GraphicsDevice"/> associated with the current instance.</param>
|
||||
/// <param name="length">The number of items to store in the current buffer.</param>
|
||||
/// <param name="allocationMode">The allocation mode to use for the new resource.</param>
|
||||
[RequiresUnreferencedCode("This method reads type info of all fields of the resource element type (recursively).")]
|
||||
internal ReadBackBuffer(GraphicsDevice device, int length, AllocationMode allocationMode)
|
||||
: base(device, length, ResourceType.ReadBack, allocationMode)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using ComputeSharp.Graphics.Resources.Enums;
|
||||
using ComputeSharp.Resources;
|
||||
using ComputeSharp.Resources.Debug;
|
||||
@@ -20,6 +21,7 @@ public sealed class UploadBuffer<T> : TransferBuffer<T>
|
||||
/// <param name="device">The <see cref="GraphicsDevice"/> associated with the current instance.</param>
|
||||
/// <param name="length">The number of items to store in the current buffer.</param>
|
||||
/// <param name="allocationMode">The allocation mode to use for the new resource.</param>
|
||||
[RequiresUnreferencedCode("This method reads type info of all fields of the resource element type (recursively).")]
|
||||
internal UploadBuffer(GraphicsDevice device, int length, AllocationMode allocationMode)
|
||||
: base(device, length, ResourceType.Upload, allocationMode)
|
||||
{
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする