Remove HRESULTExtensions from D3D12 generator
このコミットが含まれているのは:
1 親
3fe4491f63
コミット
f0d1172c45
3ファイル変更
+20
-53
検索条件に一致するファイルはありません
@@ -8,7 +8,6 @@
|
||||
<ItemGroup>
|
||||
|
||||
<!-- ComputeSharp.Core APIs -->
|
||||
<Compile Include="..\ComputeSharp.Core\Attributes\AutoConstructorAttribute.cs" Link="ComputeSharp.Core\Attributes\AutoConstructorAttribute.cs" />
|
||||
<Compile Include="..\ComputeSharp.Core\Exceptions\InvalidExecutionContextException.cs" Link="ComputeSharp.Core\Exceptions\InvalidExecutionContextException.cs" />
|
||||
<Compile Include="..\ComputeSharp.Core\Intrinsics\Attributes\HlslIntrinsicNameAttribute.cs" Link="ComputeSharp.Core\Intrinsics\Attributes\HlslIntrinsicNameAttribute.cs" />
|
||||
<Compile Include="..\ComputeSharp.Core\Intrinsics\Hlsl.Casts.g.cs" Link="ComputeSharp.Core\Intrinsics\Hlsl.Casts.g.cs" />
|
||||
@@ -67,7 +66,6 @@
|
||||
<Compile Include="..\ComputeSharp\Core\Helpers\AlignmentHelper.cs" Link="ComputeSharp\Core\Helpers\AlignmentHelper.cs" />
|
||||
<Compile Include="..\ComputeSharp\Core\Interfaces\IComputeShader.cs" Link="ComputeSharp\Core\Interfaces\IComputeShader.cs" />
|
||||
<Compile Include="..\ComputeSharp\Core\Interfaces\IComputeShader{TPixel}.cs" Link="ComputeSharp\Core\Interfaces\IComputeShader{TPixel}.cs" />
|
||||
<Compile Include="..\ComputeSharp\Graphics\Extensions\Interop\ComPtrExtensions.cs" Link="ComputeSharp\Graphics\Extensions\Interop\ComPtrExtensions.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
-35
@@ -1,35 +0,0 @@
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using TerraFX.Interop.Windows;
|
||||
|
||||
namespace ComputeSharp.Core.Extensions;
|
||||
|
||||
/// <summary>
|
||||
/// Helper methods to efficiently throw exceptions.
|
||||
/// </summary>
|
||||
[DebuggerStepThrough]
|
||||
internal static class HRESULTExtensions
|
||||
{
|
||||
/// <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>
|
||||
public static void Assert(this HRESULT result)
|
||||
{
|
||||
Assert((int)result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a <see cref="Win32Exception"/> if <paramref name="result"/> represents an error.
|
||||
/// </summary>
|
||||
/// <param name="result">The input <see cref="int"/> to check.</param>
|
||||
/// <exception cref="Win32Exception">Thrown if <paramref name="result"/> represents an error.</exception>
|
||||
public static void Assert(this int result)
|
||||
{
|
||||
if (result < 0)
|
||||
{
|
||||
throw new Win32Exception(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using ComputeSharp.Core.Extensions;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
|
||||
@@ -44,21 +44,21 @@ internal sealed unsafe class DxcShaderCompiler
|
||||
using ComPtr<IDxcLibrary> dxcLibrary = default;
|
||||
using ComPtr<IDxcIncludeHandler> dxcIncludeHandler = default;
|
||||
|
||||
DirectX.DxcCreateInstance(
|
||||
Marshal.ThrowExceptionForHR(DirectX.DxcCreateInstance(
|
||||
(Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in CLSID.CLSID_DxcCompiler)),
|
||||
Windows.__uuidof<IDxcCompiler>(),
|
||||
(void**)dxcCompiler.GetAddressOf()).Assert();
|
||||
(void**)dxcCompiler.GetAddressOf()));
|
||||
|
||||
DirectX.DxcCreateInstance(
|
||||
Marshal.ThrowExceptionForHR(DirectX.DxcCreateInstance(
|
||||
(Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in CLSID.CLSID_DxcLibrary)),
|
||||
Windows.__uuidof<IDxcLibrary>(),
|
||||
(void**)dxcLibrary.GetAddressOf()).Assert();
|
||||
(void**)dxcLibrary.GetAddressOf()));
|
||||
|
||||
dxcLibrary.Get()->CreateIncludeHandler(dxcIncludeHandler.GetAddressOf()).Assert();
|
||||
Marshal.ThrowExceptionForHR(dxcLibrary.Get()->CreateIncludeHandler(dxcIncludeHandler.GetAddressOf()));
|
||||
|
||||
this.dxcCompiler = dxcCompiler.Move();
|
||||
this.dxcLibrary = dxcLibrary.Move();
|
||||
this.dxcIncludeHandler = dxcIncludeHandler.Move();
|
||||
this.dxcCompiler = new ComPtr<IDxcCompiler>(dxcCompiler.Get());
|
||||
this.dxcLibrary = new ComPtr<IDxcLibrary>(dxcLibrary.Get());
|
||||
this.dxcIncludeHandler = new ComPtr<IDxcIncludeHandler>(dxcIncludeHandler.Get());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -90,11 +90,13 @@ internal sealed unsafe class DxcShaderCompiler
|
||||
// Get the encoded blob from the source code
|
||||
fixed (char* p = source)
|
||||
{
|
||||
this.dxcLibrary.Get()->CreateBlobWithEncodingOnHeapCopy(
|
||||
int hresult = this.dxcLibrary.Get()->CreateBlobWithEncodingOnHeapCopy(
|
||||
p,
|
||||
(uint)source.Length * 2,
|
||||
1200,
|
||||
dxcBlobEncoding.GetAddressOf()).Assert();
|
||||
dxcBlobEncoding.GetAddressOf());
|
||||
|
||||
Marshal.ThrowExceptionForHR(hresult);
|
||||
}
|
||||
|
||||
token.ThrowIfCancellationRequested();
|
||||
@@ -109,7 +111,7 @@ internal sealed unsafe class DxcShaderCompiler
|
||||
{
|
||||
char** arguments = stackalloc char*[3] { optimization, rowMajor, warningsAsErrors };
|
||||
|
||||
this.dxcCompiler.Get()->Compile(
|
||||
int hresult = this.dxcCompiler.Get()->Compile(
|
||||
(IDxcBlob*)dxcBlobEncoding.Get(),
|
||||
(ushort*)shaderName,
|
||||
(ushort*)entryPoint,
|
||||
@@ -119,21 +121,23 @@ internal sealed unsafe class DxcShaderCompiler
|
||||
null,
|
||||
0,
|
||||
this.dxcIncludeHandler.Get(),
|
||||
dxcOperationResult.GetAddressOf()).Assert();
|
||||
dxcOperationResult.GetAddressOf());
|
||||
|
||||
Marshal.ThrowExceptionForHR(hresult);
|
||||
}
|
||||
|
||||
token.ThrowIfCancellationRequested();
|
||||
|
||||
HRESULT status;
|
||||
|
||||
dxcOperationResult.Get()->GetStatus(&status).Assert();
|
||||
Marshal.ThrowExceptionForHR(dxcOperationResult.Get()->GetStatus(&status));
|
||||
|
||||
// The compilation was successful, so we can extract the shader bytecode
|
||||
if (status == 0)
|
||||
{
|
||||
using ComPtr<IDxcBlob> dxcBlobBytecode = default;
|
||||
|
||||
dxcOperationResult.Get()->GetResult(dxcBlobBytecode.GetAddressOf()).Assert();
|
||||
Marshal.ThrowExceptionForHR(dxcOperationResult.Get()->GetResult(dxcBlobBytecode.GetAddressOf()));
|
||||
|
||||
byte* buffer = (byte*)dxcBlobBytecode.Get()->GetBufferPointer();
|
||||
int length = checked((int)dxcBlobBytecode.Get()->GetBufferSize());
|
||||
@@ -154,7 +158,7 @@ internal sealed unsafe class DxcShaderCompiler
|
||||
{
|
||||
using ComPtr<IDxcBlobEncoding> dxcBlobEncodingError = default;
|
||||
|
||||
dxcOperationResult->GetErrorBuffer(dxcBlobEncodingError.GetAddressOf()).Assert();
|
||||
Marshal.ThrowExceptionForHR(dxcOperationResult->GetErrorBuffer(dxcBlobEncodingError.GetAddressOf()));
|
||||
|
||||
string message = new((sbyte*)dxcBlobEncodingError.Get()->GetBufferPointer());
|
||||
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする