Added initial Texture2D<T> base type
このコミットが含まれているのは:
1 親
5fdf6d4c5c
コミット
4c8fadac6f
5ファイル変更
+121
-16
検索条件に一致するファイルはありません
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Text;
|
||||
using ComputeSharp.Core.Interop;
|
||||
using ComputeSharp.Graphics;
|
||||
using ComputeSharp.Graphics.Buffers.Abstract;
|
||||
|
||||
@@ -23,19 +24,22 @@ namespace ComputeSharp.Exceptions
|
||||
/// <summary>
|
||||
/// Creates 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>
|
||||
/// <param name="resource">The input <see cref="NativeObject"/> that was used.</param>
|
||||
/// <param name="sourceDevice">The source <see cref="GraphicsDevice"/> instance tied to <paramref name="resource"/>.</param>
|
||||
/// <param name="destinationDevice">The target <see cref="GraphicsDevice"/> instance that was used.</param>
|
||||
/// <returns>A new <see cref="GraphicsDeviceMismatchException"/> instance with a formatted error message.</returns>
|
||||
/// <remarks>
|
||||
/// This method only takes a <see cref="NativeObject"/> instance and the associated <see cref="GraphicsDevice"/> instance as
|
||||
/// <see cref="object.GetType"/> will still be available, but without the unnecessary generic type specializations for the method.
|
||||
/// </remarks>
|
||||
[Pure]
|
||||
private static GraphicsDeviceMismatchException Create<T>(Buffer<T> buffer, GraphicsDevice device)
|
||||
where T : unmanaged
|
||||
private static GraphicsDeviceMismatchException Create(NativeObject resource, GraphicsDevice sourceDevice, GraphicsDevice destinationDevice)
|
||||
{
|
||||
StringBuilder builder = new(512);
|
||||
|
||||
builder.AppendLine("Invalid pairing of graphics devices used to run a compute shader and allocate memory buffers.");
|
||||
builder.AppendLine($"The target device to run the compute shader is \"{device}\".");
|
||||
builder.AppendLine($"The buffer of type {buffer.GetType()} was allocated on device \"{buffer.GraphicsDevice}\".");
|
||||
builder.AppendLine($"The target device to run the compute shader is \"{destinationDevice}\".");
|
||||
builder.AppendLine($"The buffer of type {resource.GetType()} was allocated on device \"{sourceDevice}\".");
|
||||
builder.Append("Make sure to always allocate buffers on the same device used to actually run the code that accesses them.");
|
||||
builder.ToString();
|
||||
|
||||
@@ -52,7 +56,20 @@ namespace ComputeSharp.Exceptions
|
||||
internal static void Throw<T>(Buffer<T> buffer, GraphicsDevice device)
|
||||
where T : unmanaged
|
||||
{
|
||||
throw Create(buffer, device);
|
||||
throw Create(buffer, buffer.GraphicsDevice, device);
|
||||
}
|
||||
|
||||
/// <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="Texture2D{T}"/> that was used.</param>
|
||||
/// <param name="device">The target <see cref="GraphicsDevice"/> instance that was used.</param>
|
||||
[Pure]
|
||||
internal static void Throw<T>(Texture2D<T> texture, GraphicsDevice device)
|
||||
where T : unmanaged
|
||||
{
|
||||
throw Create(texture, texture.GraphicsDevice, device);
|
||||
}
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする