Code style improvements
このコミットが含まれているのは:
1 親
145fc5817e
コミット
3c050dbad4
8ファイル変更
+68
-159
検索条件に一致するファイルはありません
@@ -55,9 +55,7 @@ namespace ComputeSharp.Graphics.Commands
|
||||
{
|
||||
if (this.d3d12CommandAllocatorQueue.TryDequeue(out *&d3D12CommandAllocator))
|
||||
{
|
||||
int result = d3D12CommandAllocator.Get()->Reset();
|
||||
|
||||
ThrowHelper.ThrowIfFailed(result);
|
||||
d3D12CommandAllocator.Get()->Reset().Assert();
|
||||
|
||||
return d3D12CommandAllocator.Move();
|
||||
}
|
||||
|
||||
@@ -35,12 +35,10 @@ namespace ComputeSharp.Graphics.Extensions
|
||||
d3d12CommandQueueDesc.NodeMask = 0;
|
||||
Guid d3d12CommandQueueDescGuid = FX.IID_ID3D12CommandQueue;
|
||||
|
||||
int result = d3d12device.CreateCommandQueue(
|
||||
d3d12device.CreateCommandQueue(
|
||||
&d3d12CommandQueueDesc,
|
||||
&d3d12CommandQueueDescGuid,
|
||||
d3D12CommandQueue.GetVoidAddressOf());
|
||||
|
||||
ThrowHelper.ThrowIfFailed(result);
|
||||
d3D12CommandQueue.GetVoidAddressOf()).Assert();
|
||||
|
||||
return d3D12CommandQueue.Move();
|
||||
}
|
||||
@@ -57,13 +55,11 @@ namespace ComputeSharp.Graphics.Extensions
|
||||
|
||||
Guid d3D12FenceGuid = FX.IID_ID3D12Fence;
|
||||
|
||||
int result = d3d12device.CreateFence(
|
||||
d3d12device.CreateFence(
|
||||
0,
|
||||
D3D12_FENCE_FLAG_NONE,
|
||||
&d3D12FenceGuid,
|
||||
d3d12Fence.GetVoidAddressOf());
|
||||
|
||||
ThrowHelper.ThrowIfFailed(result);
|
||||
d3d12Fence.GetVoidAddressOf()).Assert();
|
||||
|
||||
return d3d12Fence.Move();
|
||||
}
|
||||
@@ -86,12 +82,10 @@ namespace ComputeSharp.Graphics.Extensions
|
||||
d3d12DescriptorHeapDesc.NodeMask = 0;
|
||||
Guid d3d12DescriptorHeapDescGuid = FX.IID_ID3D12DescriptorHeap;
|
||||
|
||||
int result = d3d12device.CreateDescriptorHeap(
|
||||
d3d12device.CreateDescriptorHeap(
|
||||
&d3d12DescriptorHeapDesc,
|
||||
&d3d12DescriptorHeapDescGuid,
|
||||
d3d12DescriptorHeap.GetVoidAddressOf());
|
||||
|
||||
ThrowHelper.ThrowIfFailed(result);
|
||||
d3d12DescriptorHeap.GetVoidAddressOf()).Assert();
|
||||
|
||||
return d3d12DescriptorHeap.Move();
|
||||
}
|
||||
@@ -121,16 +115,14 @@ namespace ComputeSharp.Graphics.Extensions
|
||||
D3D12_RESOURCE_DESC d3D12ResourceDescription = D3D12_RESOURCE_DESC.Buffer(width, d3D12ResourceFlags);
|
||||
Guid d3D12ResourceGuid = FX.IID_ID3D12Resource;
|
||||
|
||||
int result = d3d12device.CreateCommittedResource(
|
||||
d3d12device.CreateCommittedResource(
|
||||
&d3D12HeapProperties,
|
||||
D3D12_HEAP_FLAGS.D3D12_HEAP_FLAG_NONE,
|
||||
&d3D12ResourceDescription,
|
||||
d3D12ResourceStates,
|
||||
null,
|
||||
&d3D12ResourceGuid,
|
||||
d3D12Resource.GetVoidAddressOf());
|
||||
|
||||
ThrowHelper.ThrowIfFailed(result);
|
||||
d3D12Resource.GetVoidAddressOf()).Assert();
|
||||
|
||||
return d3D12Resource.Move();
|
||||
}
|
||||
@@ -150,12 +142,10 @@ namespace ComputeSharp.Graphics.Extensions
|
||||
|
||||
Guid d3D12CommandAllocatorGuid = FX.IID_ID3D12CommandAllocator;
|
||||
|
||||
int result = d3d12device.CreateCommandAllocator(
|
||||
d3d12device.CreateCommandAllocator(
|
||||
d3d12CommandListType,
|
||||
&d3D12CommandAllocatorGuid,
|
||||
d3D12CommandAllocator.GetVoidAddressOf());
|
||||
|
||||
ThrowHelper.ThrowIfFailed(result);
|
||||
d3D12CommandAllocator.GetVoidAddressOf()).Assert();
|
||||
|
||||
return d3D12CommandAllocator.Move();
|
||||
}
|
||||
@@ -176,15 +166,13 @@ namespace ComputeSharp.Graphics.Extensions
|
||||
|
||||
Guid d3D12GraphicsCommandListGuid = FX.IID_ID3D12GraphicsCommandList;
|
||||
|
||||
int result = d3d12device.CreateCommandList(
|
||||
d3d12device.CreateCommandList(
|
||||
0,
|
||||
d3d12CommandListType,
|
||||
d3D12CommandAllocator,
|
||||
null,
|
||||
&d3D12GraphicsCommandListGuid,
|
||||
d3d12GraphicsCommandList.GetVoidAddressOf());
|
||||
|
||||
ThrowHelper.ThrowIfFailed(result);
|
||||
d3d12GraphicsCommandList.GetVoidAddressOf()).Assert();
|
||||
|
||||
return d3d12GraphicsCommandList.Move();
|
||||
}
|
||||
@@ -202,9 +190,7 @@ namespace ComputeSharp.Graphics.Extensions
|
||||
{
|
||||
TFeature feature;
|
||||
|
||||
int result = d3d12device.CheckFeatureSupport(d3d12feature, &feature, (uint)sizeof(TFeature));
|
||||
|
||||
ThrowHelper.ThrowIfFailed(result);
|
||||
d3d12device.CheckFeatureSupport(d3d12feature, &feature, (uint)sizeof(TFeature)).Assert();
|
||||
|
||||
return feature;
|
||||
}
|
||||
|
||||
@@ -19,9 +19,7 @@ namespace ComputeSharp.Graphics.Extensions
|
||||
{
|
||||
IntPtr ptr;
|
||||
|
||||
int result = d3d12resource.Map(0, null, (void**)&ptr);
|
||||
|
||||
ThrowHelper.ThrowIfFailed(result);
|
||||
d3d12resource.Map(0, null, (void**)&ptr).Assert();
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
@@ -178,16 +178,12 @@ namespace ComputeSharp.Graphics
|
||||
// Execute the command list and signal to the target fence
|
||||
d3D12CommandQueue->ExecuteCommandLists(1, commandList.GetD3D12CommandListAddressOf());
|
||||
|
||||
int result = d3D12CommandQueue->Signal(d3D12Fence, d3D12FenceValue);
|
||||
|
||||
ThrowHelper.ThrowIfFailed(result);
|
||||
d3D12CommandQueue->Signal(d3D12Fence, d3D12FenceValue).Assert();
|
||||
|
||||
// If the fence value hasn't been reached, wait until the operation completes
|
||||
if (d3D12FenceValue > d3D12Fence->GetCompletedValue())
|
||||
{
|
||||
result = d3D12Fence->SetEventOnCompletion(d3D12FenceValue, default);
|
||||
|
||||
ThrowHelper.ThrowIfFailed(result);
|
||||
d3D12Fence->SetEventOnCompletion(d3D12FenceValue, default).Assert();
|
||||
}
|
||||
|
||||
// Enqueue the command allocator pool so that it can be reused later
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using TerraFX.Interop;
|
||||
|
||||
namespace ComputeSharp.Graphics.Helpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper methods to efficiently throw exceptions.
|
||||
/// </summary>
|
||||
[DebuggerStepThrough]
|
||||
internal static class ThrowHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Throws a <see cref="Win32Exception"/> if <paramref name="result"/> represents an error.
|
||||
/// </summary>
|
||||
/// <param name="result">The input <see cref="HRESULT"/> to check.</param>
|
||||
/// <exception cref="Win32Exception">Thrown if <paramref name="result"/> represents an error.</exception>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void ThrowIfFailed(int result)
|
||||
{
|
||||
if (result < 0)
|
||||
{
|
||||
static void Throw(int result) => throw new Win32Exception(result);
|
||||
|
||||
Throw(result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a <see cref="Win32Exception"/> if <paramref name="result"/> represents an error.
|
||||
/// </summary>
|
||||
/// <param name="result">The input <see cref="HRESULT"/> to check.</param>
|
||||
/// <param name="d3d3blobError">A <see cref="ID3DBlob"/> pointer representing an error message.</param>
|
||||
/// <exception cref="Win32Exception">Thrown if <paramref name="result"/> represents an error.</exception>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe void ThrowIfFailed(int result, ID3DBlob* d3d3blobError)
|
||||
{
|
||||
if (result < 0)
|
||||
{
|
||||
// Gets an exception with an optional message with more info.
|
||||
// The input buffer transfers ownership and is disposed on return.
|
||||
static Win32Exception GetException(int result, ID3DBlob* d3d3blobError)
|
||||
{
|
||||
if (d3d3blobError is null) return new Win32Exception(result);
|
||||
|
||||
char* p = (char*)d3d3blobError->GetBufferPointer();
|
||||
int length = checked((int)unchecked(d3d3blobError->GetBufferSize() / sizeof(char)));
|
||||
string message = new(p, 0, length);
|
||||
|
||||
d3d3blobError->Release();
|
||||
|
||||
return new Win32Exception(result, message);
|
||||
}
|
||||
|
||||
static void Throw(int result, ID3DBlob* d3d3blobError) => throw GetException(result, d3d3blobError);
|
||||
|
||||
Throw(result, d3d3blobError);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a <see cref="Win32Exception"/> if <paramref name="result"/> represents an error.
|
||||
/// </summary>
|
||||
/// <param name="result">The input <see cref="HRESULT"/> to check.</param>
|
||||
/// <param name="d3d3blobError">A <see cref="IDxcBlob"/> pointer representing an error message.</param>
|
||||
/// <exception cref="Win32Exception">Thrown if <paramref name="result"/> represents an error.</exception>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe void ThrowIfFailed(int result, IDxcBlob* d3d3blobError)
|
||||
{
|
||||
ThrowIfFailed(result, (ID3DBlob*)d3d3blobError);
|
||||
}
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする