Added custom exception on shader compiler error
このコミットが含まれているのは:
1 親
494a5f4719
コミット
9143b5f704
2ファイル変更
+34
-3
検索条件に一致するファイルはありません
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Text;
|
||||
|
||||
namespace ComputeSharp.Exceptions
|
||||
{
|
||||
/// <summary>
|
||||
/// A custom <see cref="GraphicsDeviceMismatchException"/> that indicates when mismatched devices are being used
|
||||
/// </summary>
|
||||
public sealed class HlslCompilationException : Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="GraphicsDeviceMismatchException"/> instance
|
||||
/// </summary>
|
||||
/// <param name="error">The error message produced by the Dxc compiler</param>
|
||||
internal HlslCompilationException(string error) : base(GetExceptionMessage(error)) { }
|
||||
|
||||
// Gets a proper exception message for a given compilation error
|
||||
[Pure]
|
||||
private static string GetExceptionMessage(string error)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.Append("The Dxc compiler encountered an error while trying to compile the shader.");
|
||||
builder.AppendLine("Make sure to only be using supported features by checking the README file in the ComputeSharp repository: https://github.com/Sergio0694/ComputeSharp.");
|
||||
builder.AppendLine("If you're sure that your C# shader code is valid, please open an issue an include a working repro and the following error message:");
|
||||
builder.AppendLine(error.TrimEnd());
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Diagnostics.Contracts;
|
||||
using ComputeSharp.Exceptions;
|
||||
using Vortice.Direct3D12;
|
||||
using Vortice.Dxc;
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace ComputeSharp.Shaders.Translation
|
||||
|
||||
// Compile error
|
||||
string resultText = Dxc.GetStringFromBlob(Library, result.GetErrors());
|
||||
throw new Exception(resultText);
|
||||
throw new HlslCompilationException(resultText);
|
||||
}
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする