Minor code tweaks

このコミットが含まれているのは:
Sergio Pedri committed 2020-12-01 18:30:15 +01:00
1 親 d1e91d71ab
コミット fcb2b59956
3ファイル変更
+28 -10

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

+1 -3
ファイルの表示
@@ -279,9 +279,7 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
{
if (GraphicsDevice != device)
{
void Throw() => throw GraphicsDeviceMismatchException.Create(this, device);
Throw();
GraphicsDeviceMismatchException.Throw(this, device);
}
}
}
+15 -2
ファイルの表示
@@ -7,7 +7,7 @@ using ComputeSharp.Graphics.Buffers.Abstract;
namespace ComputeSharp.Exceptions
{
/// <summary>
/// A custom <see cref="Exception"/> that indicates when mismatched devices are being used.
/// A custom <see cref="InvalidOperationException"/> that indicates when mismatched devices are being used.
/// </summary>
public sealed class GraphicsDeviceMismatchException : InvalidOperationException
{
@@ -28,7 +28,7 @@ namespace ComputeSharp.Exceptions
/// <param name="device">The target <see cref="GraphicsDevice"/> instance that was used.</param>
/// <returns>A new <see cref="GraphicsDeviceMismatchException"/> instance with a formatted error message.</returns>
[Pure]
public static GraphicsDeviceMismatchException Create<T>(Buffer<T> buffer, GraphicsDevice device)
private static GraphicsDeviceMismatchException Create<T>(Buffer<T> buffer, GraphicsDevice device)
where T : unmanaged
{
StringBuilder builder = new(512);
@@ -41,5 +41,18 @@ namespace ComputeSharp.Exceptions
return new(builder.ToString());
}
/// <summary>
/// Throws a new <see cref="GraphicsDeviceMismatchException"/> instance from the specified parameters.
/// </summary>
/// <typeparam name="T">The type of values in the input buffer.</typeparam>
/// <param name="buffer">The input <see cref="Buffer{T}"/> that was used.</param>
/// <param name="device">The target <see cref="GraphicsDevice"/> instance that was used.</param>
[Pure]
internal static void Throw<T>(Buffer<T> buffer, GraphicsDevice device)
where T : unmanaged
{
throw Create(buffer, device);
}
}
}
+12 -5
ファイルの表示
@@ -5,17 +5,24 @@ using System.Text;
namespace ComputeSharp.Exceptions
{
/// <summary>
/// A custom <see cref="GraphicsDeviceMismatchException"/> that indicates when mismatched devices are being used
/// A custom <see cref="Exception"/> type that indicates when a shader compilation with the DXC compiler has failed.
/// </summary>
public sealed class HlslCompilationException : Exception
{
/// <summary>
/// Creates a new <see cref="GraphicsDeviceMismatchException"/> instance
/// Creates a new <see cref="HlslCompilationException"/> instance
/// </summary>
/// <param name="error">The error message produced by the Dxc compiler</param>
internal HlslCompilationException(string error) : base(GetExceptionMessage(error)) { }
/// <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
/// <summary>
/// Gets a formatted exception message for a given compilation error.
/// </summary>
/// <param name="error">The input compilatin error message from the DXC compiler.</param>
/// <returns>A formatted error message for a new <see cref="HlslCompilationException"/> instance.</returns>
[Pure]
private static string GetExceptionMessage(string error)
{