Added validation for some DirectX calls

このコミットが含まれているのは:
Sergio Pedri committed 2020-08-27 14:01:56 +02:00
1 親 1223deffb5
コミット f759e8b495
3ファイル変更
+33 -3

検索条件に一致するファイルはありません

+10 -1
ファイルの表示
@@ -1,8 +1,10 @@
using System;
using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using ComputeSharp.Graphics.Buffers.Abstract;
using ComputeSharp.Graphics.Buffers.Enums;
using SharpGen.Runtime;
using Vortice.Direct3D12;
namespace ComputeSharp.Graphics.Buffers
@@ -41,7 +43,14 @@ namespace ComputeSharp.Graphics.Buffers
// Create the native resource
ResourceDescription description = ResourceDescription.Buffer(sizeInBytes, flags);
NativeResource = GraphicsDevice.NativeDevice.CreateCommittedResource(new HeapProperties(heapType), HeapFlags.None, description, states);
Result result = GraphicsDevice.NativeDevice.CreateCommittedResource(new HeapProperties(heapType), HeapFlags.None, description, states, out ID3D12Resource? resource);
if (result.Failure)
{
throw new COMException("Failed to create the committed resource", result.Code);
}
NativeResource = resource!;
// Create the resource handles, if needed
(NativeCpuDescriptorHandle, NativeGpuDescriptorHandle) = bufferType switch
+12 -1
ファイルの表示
@@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
using ComputeSharp.Graphics.Commands.Abstract;
using SharpGen.Runtime;
using Vortice.Direct3D12;
namespace ComputeSharp.Graphics.Commands
@@ -40,6 +42,7 @@ namespace ComputeSharp.Graphics.Commands
{
lock (CommandAllocatorQueue)
{
// Reuse an existing command allocator, if one is present in the queue
if (CommandAllocatorQueue.Count > 0)
{
(ID3D12CommandAllocator commandAllocator, long fenceValue) = CommandAllocatorQueue.Peek();
@@ -61,7 +64,15 @@ namespace ComputeSharp.Graphics.Commands
}
}
return GraphicsDevice.NativeDevice.CreateCommandAllocator(CommandListType);
// Create a new command allocator
Result result = GraphicsDevice.NativeDevice.CreateCommandAllocator(CommandListType, out ID3D12CommandAllocator? nativeCommandAllocator);
if (result.Failure)
{
throw new COMException("Failed to create the command allocator", result.Code);
}
return nativeCommandAllocator!;
}
}
+11 -1
ファイルの表示
@@ -1,7 +1,9 @@
using System;
using System.Runtime.InteropServices;
using ComputeSharp.Exceptions;
using ComputeSharp.Graphics.Buffers.Abstract;
using ComputeSharp.Graphics.Commands.Abstract;
using SharpGen.Runtime;
using Vortice.Direct3D12;
namespace ComputeSharp.Graphics.Commands
@@ -21,7 +23,15 @@ namespace ComputeSharp.Graphics.Commands
CommandListType.Direct => GraphicsDevice.DirectAllocatorPool.GetCommandAllocator(),
_ => throw new NotSupportedException($"Unsupported command list type with value {CommandListType}")
};
NativeCommandList = GraphicsDevice.NativeDevice.CreateCommandList(0, CommandListType, CommandAllocator, null);
Result result = GraphicsDevice.NativeDevice.CreateCommandList(0, commandListType, CommandAllocator, null, out ID3D12GraphicsCommandList? nativeCommandList);
if (result.Failure)
{
throw new COMException("Failed to create the commands list", result.Code);
}
NativeCommandList = nativeCommandList!;
// Set the heap descriptor if the command list is not for copy operations
if (CommandListType != CommandListType.Copy)