Merge pull request #489 from Sergio0694/dev/drop-toolkit-diagnostics
Switch all packages to internal and shared throw helpers
このコミットが含まれているのは:
96ファイル変更
+1475
-1371
検索条件に一致するファイルはありません
@@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BenchmarkDotNet" Version="0.13.4" />
|
||||
<PackageReference Include="CommunityToolkit.Diagnostics" Version="8.1.0" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.3" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommunityToolkit.Diagnostics" Version="8.1.0" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.3" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
|
||||
namespace ComputeSharp.Sample;
|
||||
|
||||
@@ -19,12 +18,6 @@ internal static class Formatting
|
||||
/// <param name="name">The name of the matrix to print.</param>
|
||||
public static void PrintMatrix(float[] array, int width, int height, string name)
|
||||
{
|
||||
Guard.IsNotNull(array);
|
||||
Guard.IsGreaterThan(width, 0);
|
||||
Guard.IsGreaterThan(height, 0);
|
||||
Guard.IsEqualTo(array.Length, (long)width * height, nameof(array));
|
||||
Guard.IsNotNullOrEmpty(name);
|
||||
|
||||
int pad = 48 - name.Length;
|
||||
string title = $"{new string('=', pad / 2)} {name} {new string('=', (pad + 1) / 2)}";
|
||||
|
||||
|
||||
@@ -26,8 +26,10 @@
|
||||
-->
|
||||
<PropertyGroup Condition="'$(COMPUTESHARP_SWAPCHAIN_CLI_PUBLISH_AOT)' == 'true'">
|
||||
<PublishAot>true</PublishAot>
|
||||
<DebuggerSupport>false</DebuggerSupport>
|
||||
<UseSystemResourceKeys>true</UseSystemResourceKeys>
|
||||
<InvariantGlobalization>true</InvariantGlobalization>
|
||||
<IlcFoldIdenticalMethodBodies>true</IlcFoldIdenticalMethodBodies>
|
||||
<IlcGenerateStackTraceData>false</IlcGenerateStackTraceData>
|
||||
<IlcDisableReflection>true</IlcDisableReflection>
|
||||
<IlcOptimizationPreference>Speed</IlcOptimizationPreference>
|
||||
|
||||
@@ -160,6 +160,9 @@
|
||||
</ApplicationDefinition>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommunityToolkit.Diagnostics">
|
||||
<Version>8.1.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="CommunityToolkit.Mvvm">
|
||||
<Version>8.1.0</Version>
|
||||
</PackageReference>
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.2.230118.102" />
|
||||
<PackageReference Include="CommunityToolkit.Diagnostics" Version="8.1.0" />
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.1.0" />
|
||||
<PackageReference Include="CommunityToolkit.WinUI.UI.Controls.Core" Version="7.1.2" />
|
||||
<PackageReference Include="CommunityToolkit.WinUI.UI.Media" Version="7.1.2" />
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace System;
|
||||
|
||||
/// <summary>
|
||||
/// Throw helper extensions for <see cref="ArgumentException"/>.
|
||||
/// </summary>
|
||||
internal static class ArgumentExceptionExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ArgumentException"/> for a given parameter name.
|
||||
/// </summary>
|
||||
/// <param name="_">Dummy value to invoke the extension upon (always pass <see langword="null"/>.</param>
|
||||
/// <param name="parameterName">The name of the parameter to report in the exception.</param>
|
||||
/// <exception cref="ArgumentException">Thrown with <paramref name="parameterName"/>.</exception>
|
||||
[DoesNotReturn]
|
||||
public static void Throw(this ArgumentException? _, string? parameterName)
|
||||
{
|
||||
throw new ArgumentException(null, parameterName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ArgumentException"/> for a given parameter name and message.
|
||||
/// </summary>
|
||||
/// <param name="_">Dummy value to invoke the extension upon (always pass <see langword="null"/>.</param>
|
||||
/// <param name="parameterName">The name of the parameter to report in the exception.</param>
|
||||
/// <param name="message">The message to include in the exception.</param>
|
||||
/// <exception cref="ArgumentException">Thrown with <paramref name="parameterName"/>.</exception>
|
||||
[DoesNotReturn]
|
||||
public static void Throw(this ArgumentException? _, string? parameterName, string? message)
|
||||
{
|
||||
throw new ArgumentException(message, parameterName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ArgumentException"/> for a given parameter name.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type to let the compiler assume it returns.</typeparam>
|
||||
/// <param name="_">Dummy value to invoke the extension upon (always pass <see langword="null"/>.</param>
|
||||
/// <param name="parameterName">The name of the parameter to report in the exception.</param>
|
||||
/// <returns>This method never returns any values.</returns>
|
||||
/// <exception cref="ArgumentException">Thrown with <paramref name="parameterName"/>.</exception>
|
||||
[DoesNotReturn]
|
||||
public static T Throw<T>(this ArgumentException? _, string? parameterName)
|
||||
{
|
||||
throw new ArgumentException(null, parameterName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ArgumentException"/> if <paramref name="condition"/> is <see langword="true"/>.
|
||||
/// </summary>
|
||||
/// <param name="_">Dummy value to invoke the extension upon (always pass <see langword="null"/>.</param>
|
||||
/// <param name="condition">The condition to decide whether to throw the exception.</param>
|
||||
/// <param name="parameterName">The name of the parameter with which <paramref name="condition"/> corresponds.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void ThrowIf(this ArgumentException? _, [DoesNotReturnIf(true)] bool condition, string? parameterName = null)
|
||||
{
|
||||
if (condition)
|
||||
{
|
||||
Throw(parameterName);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ArgumentException"/> for a given parameter name.
|
||||
/// </summary>
|
||||
/// <param name="parameterName">The name of the parameter to report in the exception.</param>
|
||||
/// <exception cref="ArgumentException">Thrown with <paramref name="parameterName"/>.</exception>
|
||||
[DoesNotReturn]
|
||||
private static void Throw(string? parameterName)
|
||||
{
|
||||
throw new ArgumentException(null, parameterName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace System;
|
||||
|
||||
/// <summary>
|
||||
/// Throw helper extensions for <see cref="ArgumentNullException"/>.
|
||||
/// </summary>
|
||||
internal static class ArgumentNullExceptionExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ArgumentNullException"/> for a given parameter name.
|
||||
/// </summary>
|
||||
/// <param name="_">Dummy value to invoke the extension upon (always pass <see langword="null"/>.</param>
|
||||
/// <param name="parameterName">The name of the parameter to report in the exception.</param>
|
||||
/// <exception cref="ArgumentNullException">Thrown with <paramref name="parameterName"/>.</exception>
|
||||
[DoesNotReturn]
|
||||
public static void Throw(this ArgumentNullException? _, string? parameterName)
|
||||
{
|
||||
throw new ArgumentNullException(parameterName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ArgumentNullException"/> if <paramref name="argument"/> is <see langword="null"/>.
|
||||
/// </summary>
|
||||
/// <param name="_">Dummy value to invoke the extension upon (always pass <see langword="null"/>.</param>
|
||||
/// <param name="argument">The reference type argument to validate as non-<see langword="null"/>.</param>
|
||||
/// <param name="parameterName">The name of the parameter with which <paramref name="argument"/> corresponds.</param>
|
||||
/// <exception cref="ArgumentNullException">Thrown if <paramref name="argument"/> is <see langword="null"/>.</exception>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void ThrowIfNull(this ArgumentNullException? _, [NotNull] object? argument, [CallerArgumentExpression(nameof(argument))] string? parameterName = null)
|
||||
{
|
||||
if (argument is null)
|
||||
{
|
||||
Throw(parameterName);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ArgumentNullException"/> if <paramref name="argument"/> is <see langword="null"/>.
|
||||
/// </summary>
|
||||
/// <param name="_">Dummy value to invoke the extension upon (always pass <see langword="null"/>.</param>
|
||||
/// <param name="argument">The pointer argument to validate as non-<see langword="null"/>.</param>
|
||||
/// <param name="parameterName">The name of the parameter with which <paramref name="argument"/> corresponds.</param>
|
||||
/// <exception cref="ArgumentNullException">Thrown if <paramref name="argument"/> is <see langword="null"/>.</exception>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe void ThrowIfNull(this ArgumentNullException? _, [NotNull] void* argument, [CallerArgumentExpression(nameof(argument))] string? parameterName = null)
|
||||
{
|
||||
if (argument is null)
|
||||
{
|
||||
Throw(parameterName);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Throw(ArgumentNullException?, string?)"/>
|
||||
[DoesNotReturn]
|
||||
private static void Throw(string? parameterName)
|
||||
{
|
||||
throw new ArgumentNullException(parameterName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace System;
|
||||
|
||||
/// <summary>
|
||||
/// Throw helper extensions for <see cref="ArgumentOutOfRangeException"/>.
|
||||
/// </summary>
|
||||
internal static class ArgumentOutOfRangeExceptionExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ArgumentOutOfRangeException"/> if <paramref name="value"/> is not zero.
|
||||
/// </summary>
|
||||
/// <param name="_">Dummy value to invoke the extension upon (always pass <see langword="null"/>.</param>
|
||||
/// <param name="value">The argument to validate as zero.</param>
|
||||
/// <param name="parameterName">The name of the parameter with which <paramref name="value"/> corresponds.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void ThrowIfNotZero(this ArgumentOutOfRangeException? _, int value, [CallerArgumentExpression(nameof(value))] string? parameterName = null)
|
||||
{
|
||||
if (value != 0)
|
||||
{
|
||||
Throw(parameterName, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ArgumentOutOfRangeException"/> if <paramref name="value"/> is negative.
|
||||
/// </summary>
|
||||
/// <param name="_">Dummy value to invoke the extension upon (always pass <see langword="null"/>.</param>
|
||||
/// <param name="value">The argument to validate as non-negative.</param>
|
||||
/// <param name="parameterName">The name of the parameter with which <paramref name="value"/> corresponds.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void ThrowIfNegative(this ArgumentOutOfRangeException? _, int value, [CallerArgumentExpression(nameof(value))] string? parameterName = null)
|
||||
{
|
||||
if (value < 0)
|
||||
{
|
||||
Throw(parameterName, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ArgumentOutOfRangeException"/> if <paramref name="value"/> is negative or zero.
|
||||
/// </summary>
|
||||
/// <param name="_">Dummy value to invoke the extension upon (always pass <see langword="null"/>.</param>
|
||||
/// <param name="value">The argument to validate as non-zero or non-negative.</param>
|
||||
/// <param name="parameterName">The name of the parameter with which <paramref name="value"/> corresponds.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void ThrowIfNegativeOrZero(this ArgumentOutOfRangeException? _, int value, [CallerArgumentExpression(nameof(value))] string? parameterName = null)
|
||||
{
|
||||
if (value <= 0)
|
||||
{
|
||||
Throw(parameterName, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ArgumentOutOfRangeException"/> if <paramref name="value"/> is greater than <paramref name="other"/>.
|
||||
/// </summary>
|
||||
/// <param name="_">Dummy value to invoke the extension upon (always pass <see langword="null"/>.</param>
|
||||
/// <param name="value">The argument to validate as less or equal than <paramref name="other"/>.</param>
|
||||
/// <param name="other">The value to compare with <paramref name="value"/>.</param>
|
||||
/// <param name="parameterName">The name of the parameter with which <paramref name="value"/> corresponds.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void ThrowIfGreaterThan(this ArgumentOutOfRangeException? _, int value, int other, [CallerArgumentExpression(nameof(value))] string? parameterName = null)
|
||||
{
|
||||
if (value > other)
|
||||
{
|
||||
Throw(parameterName, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ArgumentOutOfRangeException"/> if <paramref name="value"/> is less than <paramref name="other"/>.
|
||||
/// </summary>
|
||||
/// <param name="_">Dummy value to invoke the extension upon (always pass <see langword="null"/>.</param>
|
||||
/// <param name="value">The argument to validate as less or equal than <paramref name="other"/>.</param>
|
||||
/// <param name="other">The value to compare with <paramref name="value"/>.</param>
|
||||
/// <param name="parameterName">The name of the parameter with which <paramref name="value"/> corresponds.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void ThrowIfLessThan(this ArgumentOutOfRangeException? _, int value, int other, [CallerArgumentExpression(nameof(value))] string? parameterName = null)
|
||||
{
|
||||
if (value < other)
|
||||
{
|
||||
Throw(parameterName, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ArgumentOutOfRangeException"/> if <paramref name="value"/> is less than <paramref name="other"/>.
|
||||
/// </summary>
|
||||
/// <param name="_">Dummy value to invoke the extension upon (always pass <see langword="null"/>.</param>
|
||||
/// <param name="value">The argument to validate as less or equal than <paramref name="other"/>.</param>
|
||||
/// <param name="other">The value to compare with <paramref name="value"/>.</param>
|
||||
/// <param name="parameterName">The name of the parameter with which <paramref name="value"/> corresponds.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void ThrowIfLessThan(this ArgumentOutOfRangeException? _, long value, long other, [CallerArgumentExpression(nameof(value))] string? parameterName = null)
|
||||
{
|
||||
if (value < other)
|
||||
{
|
||||
Throw(parameterName, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ArgumentOutOfRangeException"/> if <paramref name="value"/> is not in the specified range.
|
||||
/// </summary>
|
||||
/// <param name="_">Dummy value to invoke the extension upon (always pass <see langword="null"/>.</param>
|
||||
/// <param name="value">The argument to validate as non-zero or non-negative.</param>
|
||||
/// <param name="minimum">The inclusive starting value for the range.</param>
|
||||
/// <param name="maximum">The exclusive ending value for the range.</param>
|
||||
/// <param name="parameterName">The name of the parameter with which <paramref name="value"/> corresponds.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void ThrowIfNotInRange(this ArgumentOutOfRangeException? _, int value, int minimum, int maximum, [CallerArgumentExpression(nameof(value))] string? parameterName = null)
|
||||
{
|
||||
if (value < minimum || value >= maximum)
|
||||
{
|
||||
Throw(parameterName, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ArgumentOutOfRangeException"/> if <paramref name="value"/> is not in the specified range.
|
||||
/// </summary>
|
||||
/// <param name="_">Dummy value to invoke the extension upon (always pass <see langword="null"/>.</param>
|
||||
/// <param name="value">The argument to validate as non-zero or non-negative.</param>
|
||||
/// <param name="minimum">The inclusive starting value for the range.</param>
|
||||
/// <param name="maximum">The inclusive ending value for the range.</param>
|
||||
/// <param name="parameterName">The name of the parameter with which <paramref name="value"/> corresponds.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void ThrowIfNotBetweenOrEqual(this ArgumentOutOfRangeException? _, int value, int minimum, int maximum, [CallerArgumentExpression(nameof(value))] string? parameterName = null)
|
||||
{
|
||||
if (value < minimum || value > maximum)
|
||||
{
|
||||
Throw(parameterName, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ArgumentOutOfRangeException"/> if <paramref name="value"/> is not in the specified range.
|
||||
/// </summary>
|
||||
/// <param name="_">Dummy value to invoke the extension upon (always pass <see langword="null"/>.</param>
|
||||
/// <param name="value">The argument to validate as non-zero or non-negative.</param>
|
||||
/// <param name="minimum">The inclusive starting value for the range.</param>
|
||||
/// <param name="maximum">The inclusive ending value for the range.</param>
|
||||
/// <param name="parameterName">The name of the parameter with which <paramref name="value"/> corresponds.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void ThrowIfNotBetweenOrEqual(this ArgumentOutOfRangeException? _, long value, long minimum, long maximum, [CallerArgumentExpression(nameof(value))] string? parameterName = null)
|
||||
{
|
||||
if (value < minimum || value > maximum)
|
||||
{
|
||||
Throw(parameterName, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ArgumentOutOfRangeException"/> for a given parameter name.
|
||||
/// </summary>
|
||||
/// <param name="parameterName">The name of the parameter to report in the exception.</param>
|
||||
/// <param name="value">The invalid value that was used.</param>
|
||||
/// <exception cref="ArgumentOutOfRangeException">Thrown with <paramref name="parameterName"/>.</exception>
|
||||
[DoesNotReturn]
|
||||
private static void Throw(string? parameterName, int value)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(parameterName, value, null);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Throw(string?, int)"/>
|
||||
[DoesNotReturn]
|
||||
private static void Throw(string? parameterName, long value)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(parameterName, value, null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace System;
|
||||
|
||||
/// <summary>
|
||||
/// Throw helper extensions for <see cref="InvalidOperationException"/>.
|
||||
/// </summary>
|
||||
internal static class InvalidOperationExceptionExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Throws an <see cref="InvalidOperationException"/> for a given parameter name.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type to let the compiler assume it returns.</typeparam>
|
||||
/// <param name="_">Dummy value to invoke the extension upon (always pass <see langword="null"/>.</param>
|
||||
/// <returns>This method never returns any values.</returns>
|
||||
/// <exception cref="InvalidOperationException">Thrown with no parameters.</exception>
|
||||
[DoesNotReturn]
|
||||
public static T Throw<T>(this InvalidOperationException? _)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="InvalidOperationException"/> if <paramref name="condition"/> is <see langword="true"/>.
|
||||
/// </summary>
|
||||
/// <param name="_">Dummy value to invoke the extension upon (always pass <see langword="null"/>.</param>
|
||||
/// <param name="condition">The condition to decide whether to throw the exception.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void ThrowIf(this InvalidOperationException? _, [DoesNotReturnIf(true)] bool condition)
|
||||
{
|
||||
if (condition)
|
||||
{
|
||||
Throw();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="InvalidOperationException"/> for a given parameter name.
|
||||
/// </summary>
|
||||
/// <exception cref="InvalidOperationException">Always thrown with no parameters.</exception>
|
||||
[DoesNotReturn]
|
||||
private static void Throw()
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace System;
|
||||
|
||||
/// <summary>
|
||||
/// Throw helper extensions for <see cref="NotSupportedException"/>.
|
||||
/// </summary>
|
||||
internal static class NotSupportedExceptionExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Throws an <see cref="NotSupportedException"/>.
|
||||
/// </summary>
|
||||
/// <param name="_">Dummy value to invoke the extension upon (always pass <see langword="null"/>.</param>
|
||||
/// <exception cref="NotSupportedException">Thrown with no parameters.</exception>
|
||||
[DoesNotReturn]
|
||||
public static void Throw(this NotSupportedException? _)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="NotSupportedException"/> for a given parameter name.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type to let the compiler assume it returns.</typeparam>
|
||||
/// <param name="_">Dummy value to invoke the extension upon (always pass <see langword="null"/>.</param>
|
||||
/// <returns>This method never returns any values.</returns>
|
||||
/// <exception cref="NotSupportedException">Thrown with no parameters.</exception>
|
||||
[DoesNotReturn]
|
||||
public static T Throw<T>(this NotSupportedException? _)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="NotSupportedException"/> if <paramref name="condition"/> is <see langword="true"/>.
|
||||
/// </summary>
|
||||
/// <param name="_">Dummy value to invoke the extension upon (always pass <see langword="null"/>.</param>
|
||||
/// <param name="condition">The condition to decide whether to throw the exception.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void ThrowIf(this NotSupportedException? _, [DoesNotReturnIf(true)] bool condition)
|
||||
{
|
||||
if (condition)
|
||||
{
|
||||
Throw();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="NotSupportedException"/> for a given parameter name.
|
||||
/// </summary>
|
||||
/// <exception cref="NotSupportedException">Always thrown with no parameters.</exception>
|
||||
[DoesNotReturn]
|
||||
private static void Throw()
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace System;
|
||||
|
||||
/// <summary>
|
||||
/// Throw helper extensions for <see cref="ObjectDisposedException"/>.
|
||||
/// </summary>
|
||||
internal static class ObjectDisposedExceptionExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ObjectDisposedException"/> if <paramref name="condition"/> is <see langword="true"/>.
|
||||
/// </summary>
|
||||
/// <param name="_">Dummy value to invoke the extension upon (always pass <see langword="null"/>.</param>
|
||||
/// <param name="condition">The condition indicating whether <paramref name="disposableInstance"/> has been disposed.</param>
|
||||
/// <param name="disposableInstance">The instance that can be signaled as being disposed.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void ThrowIf(this ObjectDisposedException? _, [DoesNotReturnIf(true)] bool condition, object disposableInstance)
|
||||
{
|
||||
if (condition)
|
||||
{
|
||||
Throw(disposableInstance);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ObjectDisposedException"/> if <paramref name="validationObject"/> is <see langword="null"/>.
|
||||
/// </summary>
|
||||
/// <param name="_">Dummy value to invoke the extension upon (always pass <see langword="null"/>.</param>
|
||||
/// <param name="validationObject">The instance to check to determine whether the target instance has been disposed.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void ThrowIfNull(this ObjectDisposedException? _, [NotNull] object? validationObject)
|
||||
{
|
||||
if (validationObject is null)
|
||||
{
|
||||
Throw();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ObjectDisposedException"/>.
|
||||
/// </summary>
|
||||
/// <exception cref="ObjectDisposedException">Thrown with no parameters.</exception>
|
||||
[DoesNotReturn]
|
||||
private static void Throw()
|
||||
{
|
||||
throw new ObjectDisposedException(null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ObjectDisposedException"/> for a given target instance.
|
||||
/// </summary>
|
||||
/// <param name="targetObject">The target instance that was disposed.</param>
|
||||
/// <exception cref="ObjectDisposedException">Thrown for <paramref name="targetObject"/>.</exception>
|
||||
[DoesNotReturn]
|
||||
private static void Throw(object targetObject)
|
||||
{
|
||||
throw new ObjectDisposedException(targetObject.ToString());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace System.ComponentModel;
|
||||
|
||||
/// <summary>
|
||||
/// Throw helper extensions for <see cref="Win32Exception"/>.
|
||||
/// </summary>
|
||||
internal static class Win32ExceptionExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Throws an <see cref="Win32Exception"/> for a given error code.
|
||||
/// </summary>
|
||||
/// <param name="_">Dummy value to invoke the extension upon (always pass <see langword="null"/>.</param>
|
||||
/// <param name="hresult">The error code to report.</param>
|
||||
[DoesNotReturn]
|
||||
public static void Throw(this Win32Exception? _, int hresult)
|
||||
{
|
||||
throw new Win32Exception(hresult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="Win32Exception"/> if <paramref name="condition"/> is <see langword="true"/>.
|
||||
/// </summary>
|
||||
/// <param name="_">Dummy value to invoke the extension upon (always pass <see langword="null"/>.</param>
|
||||
/// <param name="condition">The condition to decide whether to throw the exception.</param>
|
||||
/// <param name="hresult">The error code to report.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void ThrowIf(this Win32Exception? _, [DoesNotReturnIf(true)] bool condition, int hresult)
|
||||
{
|
||||
if (condition)
|
||||
{
|
||||
Throw(hresult);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="Win32Exception"/> if a given error code represents an error.
|
||||
/// </summary>
|
||||
/// <param name="_">Dummy value to invoke the extension upon (always pass <see langword="null"/>.</param>
|
||||
/// <param name="hresult">The error code to check.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void ThrowIfFailed(this Win32Exception? _, int hresult)
|
||||
{
|
||||
if (hresult < 0)
|
||||
{
|
||||
Throw(hresult);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="Win32Exception"/> for a given error code.
|
||||
/// </summary>
|
||||
/// <param name="hresult">The error code to report.</param>
|
||||
/// <exception cref="Win32Exception">Thrown with the given error code.</exception>
|
||||
[DoesNotReturn]
|
||||
private static void Throw(int hresult)
|
||||
{
|
||||
throw new Win32Exception(hresult);
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@
|
||||
<Compile Include="..\ComputeSharp.Core\Intrinsics\Hlsl.cs" Link="ComputeSharp.Core\Intrinsics\Hlsl.cs" />
|
||||
<Compile Include="..\ComputeSharp.Core\Intrinsics\Hlsl.g.cs" Link="ComputeSharp.Core\Intrinsics\Hlsl.g.cs" />
|
||||
<Compile Include="..\ComputeSharp.Core\Intrinsics\Hlsl.Void.g.cs" Link="ComputeSharp.Core\Intrinsics\Hlsl.Void.g.cs" />
|
||||
<Compile Include="..\ComputeSharp.Core\Polyfills\Win32ExceptionExtensions.cs" Link="ComputeSharp.Core\Polyfills\Win32ExceptionExtensions.cs" />
|
||||
<Compile Include="..\ComputeSharp.Core\Primitives\Bool\Bool.cs" Link="ComputeSharp.Core\Primitives\Bool\Bool.cs" />
|
||||
<Compile Include="..\ComputeSharp.Core\Primitives\Bool\Bool2.cs" Link="ComputeSharp.Core\Primitives\Bool\Bool2.cs" />
|
||||
<Compile Include="..\ComputeSharp.Core\Primitives\Bool\Bool3.cs" Link="ComputeSharp.Core\Primitives\Bool\Bool3.cs" />
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.D2D1.Helpers;
|
||||
using Windows.Graphics.Effects;
|
||||
|
||||
namespace ComputeSharp.D2D1.Uwp.Buffers;
|
||||
@@ -103,10 +102,7 @@ internal struct GraphicsEffectSourceBuffer
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get
|
||||
{
|
||||
if ((uint)index >= 16)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentOutOfRangeException(nameof(index), "The index must be in the [0, 15] range.");
|
||||
}
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(index, 0, 16);
|
||||
|
||||
ref SourceReference r0 = ref Unsafe.As<GraphicsEffectSourceBuffer, SourceReference>(ref this);
|
||||
ref SourceReference r1 = ref Unsafe.Add(ref r0, index);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.D2D1.Helpers;
|
||||
using ComputeSharp.D2D1.Interop;
|
||||
|
||||
namespace ComputeSharp.D2D1.Uwp.Buffers;
|
||||
@@ -103,10 +102,7 @@ internal struct ResourceTextureManagerBuffer
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get
|
||||
{
|
||||
if ((uint)index >= 16)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentOutOfRangeException(nameof(index), "The index must be in the [0, 15] range.");
|
||||
}
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(index, 0, 16);
|
||||
|
||||
ref D2D1ResourceTextureManager? r0 = ref Unsafe.As<ResourceTextureManagerBuffer, D2D1ResourceTextureManager?>(ref this);
|
||||
ref D2D1ResourceTextureManager? r1 = ref Unsafe.Add(ref r0, index);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
using ABI.Microsoft.Graphics.Canvas;
|
||||
@@ -69,10 +68,7 @@ unsafe partial class CanvasEffect
|
||||
{
|
||||
lock (this.lockObject)
|
||||
{
|
||||
if (this.isDisposed)
|
||||
{
|
||||
ThrowObjectDisposedException();
|
||||
}
|
||||
default(ObjectDisposedException).ThrowIf(this.isDisposed, this);
|
||||
|
||||
this.canvasImage ??= CreateCanvasImage();
|
||||
|
||||
@@ -99,13 +95,4 @@ unsafe partial class CanvasEffect
|
||||
|
||||
canvasImageUnknown.CopyTo(canvasImageInterop).Assert();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="ObjectDisposedException"/>.
|
||||
/// </summary>
|
||||
[DoesNotReturn]
|
||||
public void ThrowObjectDisposedException()
|
||||
{
|
||||
throw new ObjectDisposedException(ToString(), "The current effect has been disposed and can no longer be used.");
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ComputeSharp.D2D1.Helpers;
|
||||
|
||||
namespace ComputeSharp.D2D1.Uwp.Collections;
|
||||
|
||||
@@ -18,17 +17,11 @@ internal static class FixedCountList<T>
|
||||
/// <param name="index">The initial index within <paramref name="array"/>.</param>
|
||||
public static void CopyTo(IFixedCountList<T> list, T[] array, int index)
|
||||
{
|
||||
if (array is null)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentNullException(nameof(array), "The input array cannot be null.");
|
||||
}
|
||||
default(ArgumentNullException).ThrowIfNull(array);
|
||||
|
||||
Span<T> span = array.AsSpan(index);
|
||||
|
||||
if (list.Indices.Length > span.Length)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentException(nameof(array), "The destination array range is smaller than the number of source items.");
|
||||
}
|
||||
default(ArgumentException).ThrowIf(list.Indices.Length > span.Length, nameof(array));
|
||||
|
||||
foreach (int i in list.Indices)
|
||||
{
|
||||
@@ -44,22 +37,12 @@ internal static class FixedCountList<T>
|
||||
/// <param name="index">The initial index within <paramref name="array"/>.</param>
|
||||
public static void CopyTo(IFixedCountList<T> list, Array array, int index)
|
||||
{
|
||||
if (array is null)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentNullException(nameof(array), "The input array cannot be null.");
|
||||
}
|
||||
|
||||
if ((uint)index >= array.Length)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentOutOfRangeException(nameof(index), "The starting array index is out of range.");
|
||||
}
|
||||
default(ArgumentNullException).ThrowIfNull(array);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(index, 0, array.Length);
|
||||
|
||||
int remainingLength = array.Length - index;
|
||||
|
||||
if (list.Indices.Length > remainingLength)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentException(nameof(array), "The destination array range is smaller than the number of source items.");
|
||||
}
|
||||
default(ArgumentException).ThrowIf(list.Indices.Length > remainingLength, nameof(array));
|
||||
|
||||
foreach (int i in list.Indices)
|
||||
{
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Buffers;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using ComputeSharp.D2D1.Extensions;
|
||||
using ComputeSharp.D2D1.Helpers;
|
||||
using ComputeSharp.D2D1.Interop;
|
||||
using ComputeSharp.D2D1.Shaders.Interop.Effects.ResourceManagers;
|
||||
using ComputeSharp.D2D1.Shaders.Interop.Effects.TransformMappers;
|
||||
@@ -158,9 +157,7 @@ internal static unsafe class ID2D1EffectExtensions
|
||||
}
|
||||
|
||||
// There was no way to retrieve the correct managed wrapper
|
||||
ThrowHelper.ThrowInvalidOperationException("Cannot retrieve a D2D1ResourceTextureManager instance wrapping a native object that was set externally.");
|
||||
|
||||
return null;
|
||||
return default(InvalidOperationException).Throw<D2D1ResourceTextureManager?>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using ABI.Microsoft.Graphics.Canvas;
|
||||
using ComputeSharp.D2D1.Extensions;
|
||||
using ComputeSharp.D2D1.Helpers;
|
||||
using ComputeSharp.D2D1.Interop;
|
||||
using ComputeSharp.D2D1.Interop.Effects;
|
||||
using ComputeSharp.D2D1.Uwp.Extensions;
|
||||
@@ -350,10 +349,7 @@ unsafe partial class PixelShaderEffect<T>
|
||||
if (source is null)
|
||||
{
|
||||
// If the source is null and that is not valid here (eg. when drawing), just throw
|
||||
if ((flags & WIN2D_GET_D2D_IMAGE_FLAGS_ALLOW_NULL_EFFECT_INPUTS) == WIN2D_GET_D2D_IMAGE_FLAGS_NONE)
|
||||
{
|
||||
ThrowHelper.ThrowInvalidOperationException("The effect has one or more sources set to null, and null effect inputs are not valid at this time.");
|
||||
}
|
||||
default(InvalidOperationException).ThrowIf((flags & WIN2D_GET_D2D_IMAGE_FLAGS_ALLOW_NULL_EFFECT_INPUTS) == WIN2D_GET_D2D_IMAGE_FLAGS_NONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using ABI.Microsoft.Graphics.Canvas;
|
||||
using ComputeSharp.D2D1.Extensions;
|
||||
using ComputeSharp.D2D1.Helpers;
|
||||
using ComputeSharp.D2D1.Uwp.Buffers;
|
||||
using ComputeSharp.D2D1.Uwp.Extensions;
|
||||
using ComputeSharp.Interop;
|
||||
@@ -147,10 +146,7 @@ unsafe partial class PixelShaderEffect<T>
|
||||
}
|
||||
|
||||
// If unrealization isn't requested for failures, just throw
|
||||
if ((flags & WIN2D_GET_D2D_IMAGE_FLAGS_UNREALIZE_ON_FAILURE) == WIN2D_GET_D2D_IMAGE_FLAGS_NONE)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentException(nameof(value), "The effect source is not valid (it must implement ICanvasImageInterop).");
|
||||
}
|
||||
default(InvalidOperationException).ThrowIf((flags & WIN2D_GET_D2D_IMAGE_FLAGS_UNREALIZE_ON_FAILURE) == WIN2D_GET_D2D_IMAGE_FLAGS_NONE);
|
||||
|
||||
Unrealize(value, index);
|
||||
|
||||
@@ -184,10 +180,7 @@ unsafe partial class PixelShaderEffect<T>
|
||||
// on that specific source will just fail during the recursive traversal, but that couldn't be checked from here anyway.
|
||||
if (sourceCanvasDeviceType == WIN2D_GET_DEVICE_ASSOCIATION_TYPE_CREATION_DEVICE && !this.canvasDevice.Get()->IsSameInstance(sourceCanvasDevice.Get()))
|
||||
{
|
||||
if ((flags & WIN2D_GET_D2D_IMAGE_FLAGS_UNREALIZE_ON_FAILURE) == WIN2D_GET_D2D_IMAGE_FLAGS_NONE)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentException(nameof(value), "The effect source is realized on a different canvas device.");
|
||||
}
|
||||
default(InvalidOperationException).ThrowIf((flags & WIN2D_GET_D2D_IMAGE_FLAGS_UNREALIZE_ON_FAILURE) == WIN2D_GET_D2D_IMAGE_FLAGS_NONE);
|
||||
|
||||
Unrealize(value, index);
|
||||
|
||||
@@ -220,7 +213,7 @@ unsafe partial class PixelShaderEffect<T>
|
||||
else if ((flags & WIN2D_GET_D2D_IMAGE_FLAGS_ALLOW_NULL_EFFECT_INPUTS) == WIN2D_GET_D2D_IMAGE_FLAGS_NONE)
|
||||
{
|
||||
// If the source is null and this is not explicitly allowed, the invocation is not valid
|
||||
ThrowHelper.ThrowArgumentNullException(nameof(value), "The effect source cannot be null.");
|
||||
default(ArgumentNullException).Throw(nameof(value));
|
||||
}
|
||||
|
||||
// Save the managed wrapper and realized image
|
||||
|
||||
+16
-33
@@ -4,7 +4,6 @@ using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.D2D1.Helpers;
|
||||
using ComputeSharp.D2D1.Interop;
|
||||
using ComputeSharp.D2D1.Shaders.Loaders;
|
||||
using ComputeSharp.D2D1.Uwp.Buffers;
|
||||
@@ -56,18 +55,16 @@ partial class PixelShaderEffect<T>
|
||||
{
|
||||
get
|
||||
{
|
||||
ValidateIndex(index);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(index, 0, 16, nameof(index));
|
||||
default(ArgumentOutOfRangeException).ThrowIf((IndexBitmask & (1 << index)) == 0, nameof(index));
|
||||
|
||||
return Owner.GetResourceTextureManager(index);
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value is null)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentNullException(nameof(value), "Input resource texture managers cannot be null.");
|
||||
}
|
||||
|
||||
ValidateIndex(index);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(index, 0, 16, nameof(index));
|
||||
default(ArgumentOutOfRangeException).ThrowIf((IndexBitmask & (1 << index)) == 0, nameof(index));
|
||||
default(ArgumentNullException).ThrowIfNull(value);
|
||||
|
||||
Owner.SetResourceTextureManager(value, index);
|
||||
}
|
||||
@@ -111,30 +108,30 @@ partial class PixelShaderEffect<T>
|
||||
bool ICollection.IsSynchronized => true;
|
||||
|
||||
/// <inheritdoc/>
|
||||
object ICollection.SyncRoot => throw new NotSupportedException("ICollection.SyncRoot is not supported for ResourceTextureManagerCollection.");
|
||||
object ICollection.SyncRoot => default(NotSupportedException).Throw<object>();
|
||||
|
||||
/// <inheritdoc/>
|
||||
void ICollection<D2D1ResourceTextureManager?>.Add(D2D1ResourceTextureManager? item)
|
||||
{
|
||||
throw new NotSupportedException("ICollection<T>.Add is not supported for ResourceTextureManagerCollection.");
|
||||
default(NotSupportedException).Throw();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
int IList.Add(object value)
|
||||
{
|
||||
throw new NotSupportedException("IList.Add is not supported for ResourceTextureManagerCollection.");
|
||||
return default(NotSupportedException).Throw<int>();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
void ICollection<D2D1ResourceTextureManager?>.Clear()
|
||||
{
|
||||
throw new NotSupportedException("ICollection<T>.Clear is not supported for ResourceTextureManagerCollection.");
|
||||
default(NotSupportedException).Throw();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
void IList.Clear()
|
||||
{
|
||||
throw new NotSupportedException("IList.Clear is not supported for ResourceTextureManagerCollection.");
|
||||
default(NotSupportedException).Throw();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
@@ -188,51 +185,37 @@ partial class PixelShaderEffect<T>
|
||||
/// <inheritdoc/>
|
||||
void IList<D2D1ResourceTextureManager?>.Insert(int index, D2D1ResourceTextureManager? item)
|
||||
{
|
||||
throw new NotSupportedException("IList<T>.Insert is not supported for ResourceTextureManagerCollection.");
|
||||
default(NotSupportedException).Throw();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
void IList.Insert(int index, object value)
|
||||
{
|
||||
throw new NotSupportedException("IList.Insert is not supported for ResourceTextureManagerCollection.");
|
||||
default(NotSupportedException).Throw();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
bool ICollection<D2D1ResourceTextureManager?>.Remove(D2D1ResourceTextureManager? item)
|
||||
{
|
||||
throw new NotSupportedException("ICollection<T>.Remove is not supported for ResourceTextureManagerCollection.");
|
||||
return default(NotSupportedException).Throw<bool>();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
void IList.Remove(object value)
|
||||
{
|
||||
throw new NotSupportedException("IList.Remove is not supported for ResourceTextureManagerCollection.");
|
||||
default(NotSupportedException).Throw();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
void IList<D2D1ResourceTextureManager?>.RemoveAt(int index)
|
||||
{
|
||||
throw new NotSupportedException("IList<T>.RemoveAt is not supported for ResourceTextureManagerCollection.");
|
||||
default(NotSupportedException).Throw();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
void IList.RemoveAt(int index)
|
||||
{
|
||||
throw new NotSupportedException("IList.RemoveAt is not supported for ResourceTextureManagerCollection.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates the input index for <see cref="this[int]"/>.
|
||||
/// </summary>
|
||||
/// <param name="index">The index to validate.</param>
|
||||
/// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="index"/> is out of range.</exception>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static void ValidateIndex(int index)
|
||||
{
|
||||
if ((uint)index >= 16 || (IndexBitmask & (1 << index)) == 0)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentOutOfRangeException(nameof(index), "The input index is not a valid resource texture manager index for the current effect.");
|
||||
}
|
||||
default(NotSupportedException).Throw();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.D2D1.Helpers;
|
||||
using ComputeSharp.D2D1.Interop;
|
||||
using ComputeSharp.D2D1.Uwp.Buffers;
|
||||
using ComputeSharp.D2D1.Uwp.Collections;
|
||||
@@ -50,13 +49,13 @@ partial class PixelShaderEffect<T>
|
||||
{
|
||||
get
|
||||
{
|
||||
ValidateIndex(index);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(index, 0, D2D1PixelShader.GetInputCount<T>(), nameof(index));
|
||||
|
||||
return Owner.GetSource(index);
|
||||
}
|
||||
set
|
||||
{
|
||||
ValidateIndex(index);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(index, 0, D2D1PixelShader.GetInputCount<T>(), nameof(index));
|
||||
|
||||
Owner.SetSource(value, index);
|
||||
}
|
||||
@@ -95,30 +94,30 @@ partial class PixelShaderEffect<T>
|
||||
bool ICollection.IsSynchronized => true;
|
||||
|
||||
/// <inheritdoc/>
|
||||
object ICollection.SyncRoot => throw new NotSupportedException("ICollection.SyncRoot is not supported for SourceCollection.");
|
||||
object ICollection.SyncRoot => default(NotSupportedException).Throw<object>();
|
||||
|
||||
/// <inheritdoc/>
|
||||
void ICollection<IGraphicsEffectSource?>.Add(IGraphicsEffectSource? item)
|
||||
{
|
||||
throw new NotSupportedException("ICollection<T>.Add is not supported for SourceCollection.");
|
||||
default(NotSupportedException).Throw();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
int IList.Add(object value)
|
||||
{
|
||||
throw new NotSupportedException("IList.Add is not supported for SourceCollection.");
|
||||
return default(NotSupportedException).Throw<int>();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
void ICollection<IGraphicsEffectSource?>.Clear()
|
||||
{
|
||||
throw new NotSupportedException("ICollection<T>.Clear is not supported for SourceCollection.");
|
||||
default(NotSupportedException).Throw();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
void IList.Clear()
|
||||
{
|
||||
throw new NotSupportedException("IList.Clear is not supported for SourceCollection.");
|
||||
default(NotSupportedException).Throw();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
@@ -172,51 +171,37 @@ partial class PixelShaderEffect<T>
|
||||
/// <inheritdoc/>
|
||||
void IList<IGraphicsEffectSource?>.Insert(int index, IGraphicsEffectSource? item)
|
||||
{
|
||||
throw new NotSupportedException("IList<T>.Insert is not supported for SourceCollection.");
|
||||
default(NotSupportedException).Throw();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
void IList.Insert(int index, object value)
|
||||
{
|
||||
throw new NotSupportedException("IList.Insert is not supported for SourceCollection.");
|
||||
default(NotSupportedException).Throw();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
bool ICollection<IGraphicsEffectSource?>.Remove(IGraphicsEffectSource? item)
|
||||
{
|
||||
throw new NotSupportedException("ICollection<T>.Remove is not supported for SourceCollection.");
|
||||
return default(NotSupportedException).Throw<bool>();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
void IList.Remove(object value)
|
||||
{
|
||||
throw new NotSupportedException("IList.Remove is not supported for SourceCollection.");
|
||||
default(NotSupportedException).Throw();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
void IList<IGraphicsEffectSource?>.RemoveAt(int index)
|
||||
{
|
||||
throw new NotSupportedException("IList<T>.RemoveAt is not supported for SourceCollection.");
|
||||
default(NotSupportedException).Throw();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
void IList.RemoveAt(int index)
|
||||
{
|
||||
throw new NotSupportedException("IList.RemoveAt is not supported for SourceCollection.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates the input index for <see cref="this[int]"/>.
|
||||
/// </summary>
|
||||
/// <param name="index">The index to validate.</param>
|
||||
/// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="index"/> is out of range.</exception>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static void ValidateIndex(int index)
|
||||
{
|
||||
if ((uint)index >= D2D1PixelShader.GetInputCount<T>())
|
||||
{
|
||||
ThrowHelper.ThrowArgumentOutOfRangeException(nameof(index), "The input index is not a valid source index for the current effect.");
|
||||
}
|
||||
default(NotSupportedException).Throw();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
using TerraFX.Interop.Windows;
|
||||
|
||||
@@ -21,10 +20,7 @@ internal static class HRESULTExtensions
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void Assert(this HRESULT result)
|
||||
{
|
||||
if ((int)result < 0)
|
||||
{
|
||||
ThrowWin32Exception(result);
|
||||
}
|
||||
default(Win32Exception).ThrowIfFailed((int)result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -35,19 +31,6 @@ internal static class HRESULTExtensions
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void Assert(this int result)
|
||||
{
|
||||
if (result < 0)
|
||||
{
|
||||
ThrowWin32Exception(result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a <see cref="Win32Exception"/>.
|
||||
/// </summary>
|
||||
/// <param name="result">The input return code.</param>
|
||||
[DoesNotReturn]
|
||||
private static void ThrowWin32Exception(int result)
|
||||
{
|
||||
throw new Win32Exception(result);
|
||||
default(Win32Exception).ThrowIfFailed(result);
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace ComputeSharp.D2D1.Helpers;
|
||||
|
||||
/// <summary>
|
||||
/// Helper methods to efficiently throw exceptions.
|
||||
/// </summary>
|
||||
internal static class ThrowHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="ArgumentException"/>.
|
||||
/// </summary>
|
||||
/// <param name="name">The argument name.</param>
|
||||
/// <param name="message">The message to include in the exception.</param>
|
||||
/// <exception cref="ArgumentException">Thrown with the specified parameters.</exception>
|
||||
[DoesNotReturn]
|
||||
public static void ThrowArgumentException(string? name, string? message)
|
||||
{
|
||||
throw new ArgumentException(message, name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="ArgumentException"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of expected result.</typeparam>
|
||||
/// <param name="name">The argument name.</param>
|
||||
/// <param name="message">The message to include in the exception.</param>
|
||||
/// <exception cref="ArgumentException">Thrown with the specified parameters.</exception>
|
||||
/// <returns>This method always throws, so it actually never returns a value.</returns>
|
||||
[DoesNotReturn]
|
||||
public static T ThrowArgumentException<T>(string? name, string? message)
|
||||
{
|
||||
throw new ArgumentException(message, name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="ArgumentException"/>.
|
||||
/// </summary>
|
||||
/// <param name="name">The argument name.</param>
|
||||
/// <param name="message">The message to include in the exception.</param>
|
||||
/// <exception cref="ArgumentNullException">Thrown with the specified parameters.</exception>
|
||||
[DoesNotReturn]
|
||||
public static void ThrowArgumentNullException(string? name, string? message)
|
||||
{
|
||||
throw new ArgumentNullException(name, message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="ArgumentOutOfRangeException"/>.
|
||||
/// </summary>
|
||||
/// <param name="name">The argument name.</param>
|
||||
/// <exception cref="ArgumentOutOfRangeException">Thrown with the specified parameter.</exception>
|
||||
[DoesNotReturn]
|
||||
public static void ThrowArgumentOutOfRangeException(string? name)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="ArgumentOutOfRangeException"/>.
|
||||
/// </summary>
|
||||
/// <param name="name">The argument name.</param>
|
||||
/// <param name="message">The message to include in the exception.</param>
|
||||
/// <exception cref="ArgumentOutOfRangeException">Thrown with the specified parameter.</exception>
|
||||
[DoesNotReturn]
|
||||
public static void ThrowArgumentOutOfRangeException(string? name, string? message)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(name, message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="InvalidOperationException"/>.
|
||||
/// </summary>
|
||||
/// <param name="message">The message to include in the exception.</param>
|
||||
/// <exception cref="InvalidOperationException">Thrown with the specified parameter.</exception>
|
||||
[DoesNotReturn]
|
||||
public static void ThrowInvalidOperationException(string? message)
|
||||
{
|
||||
throw new InvalidOperationException(message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a new <see cref="NotSupportedException"/>.
|
||||
/// </summary>
|
||||
/// <param name="message">The message to include in the exception.</param>
|
||||
/// <exception cref="NotSupportedException">Thrown with the specified parameter.</exception>
|
||||
[DoesNotReturn]
|
||||
public static void ThrowNotSupportedException(string? message)
|
||||
{
|
||||
throw new NotSupportedException(message);
|
||||
}
|
||||
}
|
||||
@@ -57,10 +57,7 @@ internal ref struct ArrayPoolBufferWriter<T>
|
||||
{
|
||||
T[]? array = this.array;
|
||||
|
||||
if (array is null)
|
||||
{
|
||||
ArrayPoolBufferWriterHelpers.ThrowObjectDisposedException();
|
||||
}
|
||||
default(ObjectDisposedException).ThrowIfNull(array);
|
||||
|
||||
return array.AsSpan(0, this.index);
|
||||
}
|
||||
@@ -70,28 +67,14 @@ internal ref struct ArrayPoolBufferWriter<T>
|
||||
/// Advances the current writer.
|
||||
/// </summary>
|
||||
/// <param name="count">The amount to advance.</param>
|
||||
/// <remarks>
|
||||
/// <para>Must be called after <see cref="GetSpan"/>.</para>
|
||||
/// <para>This and the methods below are <see langword="readonly"/> to enable mutating extensions.</para>
|
||||
/// </remarks>
|
||||
/// <remarks>Must be called after <see cref="GetSpan"/>.</remarks>
|
||||
internal void Advance(int count)
|
||||
{
|
||||
T[]? array = this.array;
|
||||
|
||||
if (array is null)
|
||||
{
|
||||
ArrayPoolBufferWriterHelpers.ThrowObjectDisposedException();
|
||||
}
|
||||
|
||||
if (count < 0)
|
||||
{
|
||||
ArrayPoolBufferWriterHelpers.ThrowArgumentOutOfRangeExceptionForNegativeCount();
|
||||
}
|
||||
|
||||
if (this.index > array.Length - count)
|
||||
{
|
||||
ArrayPoolBufferWriterHelpers.ThrowArgumentExceptionForAdvancedTooFar();
|
||||
}
|
||||
default(ObjectDisposedException).ThrowIfNull(array);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNegative(count);
|
||||
default(ArgumentException).ThrowIf(this.index > array.Length - count);
|
||||
|
||||
this.index += count;
|
||||
}
|
||||
@@ -118,15 +101,8 @@ internal ref struct ArrayPoolBufferWriter<T>
|
||||
{
|
||||
T[]? array = this.array;
|
||||
|
||||
if (array is null)
|
||||
{
|
||||
ArrayPoolBufferWriterHelpers.ThrowObjectDisposedException();
|
||||
}
|
||||
|
||||
if (sizeHint < 0)
|
||||
{
|
||||
ArrayPoolBufferWriterHelpers.ThrowArgumentOutOfRangeExceptionForNegativeSizeHint();
|
||||
}
|
||||
default(ObjectDisposedException).ThrowIfNull(array);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNegative(sizeHint);
|
||||
|
||||
if (sizeHint == 0)
|
||||
{
|
||||
@@ -181,46 +157,4 @@ internal ref struct ArrayPoolBufferWriter<T>
|
||||
|
||||
ArrayPool<T>.Shared.Return(array);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Private helpers for <see cref="ArrayPoolBufferWriter{T}"/>.
|
||||
/// </summary>
|
||||
file static class ArrayPoolBufferWriterHelpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ArgumentOutOfRangeException"/> when the requested count is negative.
|
||||
/// </summary>
|
||||
[DoesNotReturn]
|
||||
public static void ThrowArgumentOutOfRangeExceptionForNegativeCount()
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("count", "The count can't be a negative value.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ArgumentOutOfRangeException"/> when the size hint is negative.
|
||||
/// </summary>
|
||||
[DoesNotReturn]
|
||||
public static void ThrowArgumentOutOfRangeExceptionForNegativeSizeHint()
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("sizeHint", "The size hint can't be a negative value.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ArgumentOutOfRangeException"/> when the requested count is negative.
|
||||
/// </summary>
|
||||
[DoesNotReturn]
|
||||
public static void ThrowArgumentExceptionForAdvancedTooFar()
|
||||
{
|
||||
throw new ArgumentException("The buffer writer has advanced too far.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="ObjectDisposedException"/> when the array is <see langword="null"/>.
|
||||
/// </summary>
|
||||
[DoesNotReturn]
|
||||
public static void ThrowObjectDisposedException()
|
||||
{
|
||||
throw new ObjectDisposedException("The current buffer has already been disposed.");
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ using System;
|
||||
using System.Buffers;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using ComputeSharp.D2D1.Helpers;
|
||||
|
||||
namespace ComputeSharp.D2D1.Shaders.Interop.Buffers;
|
||||
|
||||
@@ -40,10 +39,7 @@ internal sealed unsafe class PinnedBufferMemoryManager : MemoryManager<byte>
|
||||
/// <inheritdoc/>
|
||||
public override unsafe MemoryHandle Pin(int elementIndex = 0)
|
||||
{
|
||||
if ((uint)elementIndex >= this.length)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentOutOfRangeException(nameof(elementIndex));
|
||||
}
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(elementIndex, 0, this.length);
|
||||
|
||||
return new(this.buffer + elementIndex);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using ComputeSharp.D2D1.Helpers;
|
||||
|
||||
namespace ComputeSharp.D2D1.Interop;
|
||||
|
||||
@@ -94,31 +93,31 @@ public static class D2D1EffectRegistrationData
|
||||
case LoadingResult.Success:
|
||||
return data;
|
||||
case LoadingResult.EmptyBuffer:
|
||||
ThrowHelper.ThrowArgumentException(nameof(blob), "The input blob is empty.");
|
||||
default(ArgumentException).Throw(nameof(blob), "The input blob is empty.");
|
||||
break;
|
||||
case LoadingResult.BufferTooShort:
|
||||
ThrowHelper.ThrowArgumentException(nameof(blob), "The input blob is too short.");
|
||||
default(ArgumentException).Throw(nameof(blob), "The input blob is too short.");
|
||||
break;
|
||||
case LoadingResult.BufferTooLong:
|
||||
ThrowHelper.ThrowArgumentException(nameof(blob), "The input blob is too long.");
|
||||
default(ArgumentException).Throw(nameof(blob), "The input blob is too long.");
|
||||
break;
|
||||
case LoadingResult.MismatchedBlobVersionId:
|
||||
ThrowHelper.ThrowArgumentException(nameof(blob), "The blob version id from the input blob does not match.");
|
||||
default(ArgumentException).Throw(nameof(blob), "The blob version id from the input blob does not match.");
|
||||
break;
|
||||
case LoadingResult.InvalidNumberOfInputs:
|
||||
ThrowHelper.ThrowArgumentException(nameof(blob), "The input blob has an invalid number of inputs.");
|
||||
default(ArgumentException).Throw(nameof(blob), "The input blob has an invalid number of inputs.");
|
||||
break;
|
||||
case LoadingResult.InvalidPropertyXml:
|
||||
ThrowHelper.ThrowArgumentException(nameof(blob), "The property XML value in the input blob is invalid.");
|
||||
default(ArgumentException).Throw(nameof(blob), "The property XML value in the input blob is invalid.");
|
||||
break;
|
||||
case LoadingResult.InvalidNumberOfBindings:
|
||||
ThrowHelper.ThrowArgumentException(nameof(blob), "The input blob declares an invalid number of bindings.");
|
||||
default(ArgumentException).Throw(nameof(blob), "The input blob declares an invalid number of bindings.");
|
||||
break;
|
||||
case LoadingResult.InvalidBindingPropertyName:
|
||||
ThrowHelper.ThrowArgumentException(nameof(blob), "The input blob has an invalid property name for one of its property bindings.");
|
||||
default(ArgumentException).Throw(nameof(blob), "The input blob has an invalid property name for one of its property bindings.");
|
||||
break;
|
||||
default:
|
||||
ThrowHelper.ThrowArgumentException(nameof(blob), "The input blob failed to be loaded for an unknown reason.");
|
||||
default(ArgumentException).Throw(nameof(blob), "The input blob failed to be loaded for an unknown reason.");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.D2D1.Helpers;
|
||||
using ComputeSharp.D2D1.Shaders.Interop.Buffers;
|
||||
using ComputeSharp.D2D1.Shaders.Loaders;
|
||||
using TerraFX.Interop.DirectX;
|
||||
@@ -132,10 +131,7 @@ public static class D2D1PixelShader
|
||||
public static ReadOnlyMemory<byte> LoadBytecode<T>(D2D1CompileOptions compileOptions)
|
||||
where T : unmanaged, ID2D1PixelShader
|
||||
{
|
||||
if ((compileOptions & D2D1CompileOptions.PackMatrixColumnMajor) != 0)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentException(nameof(compileOptions), "The PackMatrixColumnMajor compile options is not compatible with ComputeSharp.D2D1 shaders.");
|
||||
}
|
||||
default(ArgumentException).ThrowIf((compileOptions & D2D1CompileOptions.PackMatrixColumnMajor) != 0, nameof(compileOptions));
|
||||
|
||||
return LoadOrCompileBytecode<T>(null, compileOptions | D2D1CompileOptions.PackMatrixRowMajor, out _, out _);
|
||||
}
|
||||
@@ -167,10 +163,7 @@ public static class D2D1PixelShader
|
||||
public static ReadOnlyMemory<byte> LoadBytecode<T>(D2D1CompileOptions compileOptions, out D2D1ShaderProfile shaderProfile)
|
||||
where T : unmanaged, ID2D1PixelShader
|
||||
{
|
||||
if ((compileOptions & D2D1CompileOptions.PackMatrixColumnMajor) != 0)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentException(nameof(compileOptions), "The PackMatrixColumnMajor compile options is not compatible with ComputeSharp.D2D1 shaders.");
|
||||
}
|
||||
default(ArgumentException).ThrowIf((compileOptions & D2D1CompileOptions.PackMatrixColumnMajor) != 0, nameof(compileOptions));
|
||||
|
||||
return LoadOrCompileBytecode<T>(null, compileOptions | D2D1CompileOptions.PackMatrixRowMajor, out shaderProfile, out _);
|
||||
}
|
||||
@@ -193,10 +186,7 @@ public static class D2D1PixelShader
|
||||
public static ReadOnlyMemory<byte> LoadBytecode<T>(D2D1ShaderProfile shaderProfile, D2D1CompileOptions compileOptions)
|
||||
where T : unmanaged, ID2D1PixelShader
|
||||
{
|
||||
if ((compileOptions & D2D1CompileOptions.PackMatrixColumnMajor) != 0)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentException(nameof(compileOptions), "The PackMatrixColumnMajor compile options is not compatible with ComputeSharp.D2D1 shaders.");
|
||||
}
|
||||
default(ArgumentException).ThrowIf((compileOptions & D2D1CompileOptions.PackMatrixColumnMajor) != 0, nameof(compileOptions));
|
||||
|
||||
return LoadOrCompileBytecode<T>(shaderProfile, compileOptions | D2D1CompileOptions.PackMatrixRowMajor, out _, out _);
|
||||
}
|
||||
@@ -280,10 +270,7 @@ public static class D2D1PixelShader
|
||||
{
|
||||
Unsafe.SkipInit(out T shader);
|
||||
|
||||
if ((uint)index >= shader.GetInputCount())
|
||||
{
|
||||
ThrowHelper.ThrowArgumentOutOfRangeException(nameof(index), "The input index is outside of range for the target pixel shader type.");
|
||||
}
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(index, 0, (int)shader.GetInputCount());
|
||||
|
||||
return (D2D1PixelShaderInputType)shader.GetInputType((uint)index);
|
||||
}
|
||||
@@ -395,7 +382,7 @@ public static class D2D1PixelShader
|
||||
{
|
||||
if (!TryGetConstantBuffer(in shader, span, out int writtenBytes))
|
||||
{
|
||||
ThrowHelper.ThrowArgumentException(nameof(span), "The destination span is too short.");
|
||||
default(ArgumentException).Throw(nameof(span));
|
||||
}
|
||||
|
||||
return writtenBytes;
|
||||
@@ -433,10 +420,7 @@ public static class D2D1PixelShader
|
||||
public static unsafe void SetConstantBufferForD2D1DrawInfo<T>(void* d2D1DrawInfo, in T shader)
|
||||
where T : unmanaged, ID2D1PixelShader
|
||||
{
|
||||
if (d2D1DrawInfo is null)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentNullException(nameof(d2D1DrawInfo), "The input ID2D1DrawInfo object cannot be null.");
|
||||
}
|
||||
default(ArgumentNullException).ThrowIfNull(d2D1DrawInfo);
|
||||
|
||||
D2D1DrawInfoDispatchDataLoader dataLoader = new((ID2D1DrawInfo*)d2D1DrawInfo);
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.D2D1.Extensions;
|
||||
using ComputeSharp.D2D1.Helpers;
|
||||
using ComputeSharp.D2D1.Interop.Effects;
|
||||
using ComputeSharp.D2D1.Shaders.Interop.Buffers;
|
||||
using ComputeSharp.D2D1.Shaders.Interop.Effects.ResourceManagers;
|
||||
@@ -31,10 +30,7 @@ public static unsafe class D2D1PixelShaderEffect
|
||||
public static void RegisterForD2D1Factory1<T>(void* d2D1Factory1, out Guid effectId)
|
||||
where T : unmanaged, ID2D1PixelShader
|
||||
{
|
||||
if (d2D1Factory1 is null)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentNullException(nameof(d2D1Factory1), "The input ID2D1Factory1 object cannot be null.");
|
||||
}
|
||||
default(ArgumentNullException).ThrowIfNull(d2D1Factory1);
|
||||
|
||||
effectId = default;
|
||||
|
||||
@@ -475,15 +471,8 @@ public static unsafe class D2D1PixelShaderEffect
|
||||
public static void CreateFromD2D1DeviceContext<T>(void* d2D1DeviceContext, void** d2D1Effect)
|
||||
where T : unmanaged, ID2D1PixelShader
|
||||
{
|
||||
if (d2D1DeviceContext is null)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentNullException(nameof(d2D1DeviceContext), "The input ID2D1DeviceContext object cannot be null.");
|
||||
}
|
||||
|
||||
if (d2D1Effect is null)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentNullException(nameof(d2D1Effect), "The pointer to the target ID2D1Effect result cannot be null.");
|
||||
}
|
||||
default(ArgumentNullException).ThrowIfNull(d2D1DeviceContext);
|
||||
default(ArgumentNullException).ThrowIfNull(d2D1Effect);
|
||||
|
||||
fixed (Guid* pGuid = &PixelShaderEffect.For<T>.Instance.Id)
|
||||
{
|
||||
@@ -504,10 +493,7 @@ public static unsafe class D2D1PixelShaderEffect
|
||||
public static void SetConstantBufferForD2D1Effect<T>(void* d2D1Effect, in T shader)
|
||||
where T : unmanaged, ID2D1PixelShader
|
||||
{
|
||||
if (d2D1Effect is null)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentNullException(nameof(d2D1Effect), "The input ID2D1DeviceContext object cannot be null.");
|
||||
}
|
||||
default(ArgumentNullException).ThrowIfNull(d2D1Effect);
|
||||
|
||||
D2D1EffectDispatchDataLoader dataLoader = new((ID2D1Effect*)d2D1Effect);
|
||||
|
||||
@@ -524,15 +510,8 @@ public static unsafe class D2D1PixelShaderEffect
|
||||
/// <remarks>For more info, see <see href="https://docs.microsoft.com/windows/win32/api/d2d1_1/nf-d2d1_1-id2d1properties-setvalue(uint32_d2d1_property_type_constbyte_uint32)"/>.</remarks>
|
||||
public static void SetResourceTextureManagerForD2D1Effect(void* d2D1Effect, void* resourceTextureManager, int resourceTextureIndex)
|
||||
{
|
||||
if (d2D1Effect is null)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentNullException(nameof(d2D1Effect), "The input ID2D1Effect object cannot be null.");
|
||||
}
|
||||
|
||||
if (resourceTextureManager is null)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentNullException(nameof(resourceTextureManager), "The input ID2D1ResourceTextureManager object cannot be null.");
|
||||
}
|
||||
default(ArgumentNullException).ThrowIfNull(d2D1Effect);
|
||||
default(ArgumentNullException).ThrowIfNull(resourceTextureManager);
|
||||
|
||||
((ID2D1Effect*)d2D1Effect)->SetValue(
|
||||
index: D2D1PixelShaderEffectProperty.ResourceTextureManager0 + (uint)resourceTextureIndex,
|
||||
@@ -551,15 +530,8 @@ public static unsafe class D2D1PixelShaderEffect
|
||||
/// <remarks>For more info, see <see href="https://docs.microsoft.com/windows/win32/api/d2d1_1/nf-d2d1_1-id2d1properties-setvalue(uint32_d2d1_property_type_constbyte_uint32)"/>.</remarks>
|
||||
public static void SetResourceTextureManagerForD2D1Effect(void* d2D1Effect, D2D1ResourceTextureManager resourceTextureManager, int resourceTextureIndex)
|
||||
{
|
||||
if (d2D1Effect is null)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentNullException(nameof(d2D1Effect), "The input ID2D1Effect object cannot be null.");
|
||||
}
|
||||
|
||||
if (resourceTextureManager is null)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentNullException(nameof(resourceTextureManager), "The input D2D1ResourceTextureManager object cannot be null.");
|
||||
}
|
||||
default(ArgumentNullException).ThrowIfNull(d2D1Effect);
|
||||
default(ArgumentNullException).ThrowIfNull(resourceTextureManager);
|
||||
|
||||
using ComPtr<ID2D1ResourceTextureManager> resourceTextureManager2 = default;
|
||||
|
||||
@@ -581,15 +553,8 @@ public static unsafe class D2D1PixelShaderEffect
|
||||
/// <remarks>For more info, see <see href="https://docs.microsoft.com/windows/win32/api/d2d1_1/nf-d2d1_1-id2d1properties-setvalue(uint32_d2d1_property_type_constbyte_uint32)"/>.</remarks>
|
||||
public static void SetTransformMapperForD2D1Effect(void* d2D1Effect, void* transformMapper)
|
||||
{
|
||||
if (d2D1Effect is null)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentNullException(nameof(d2D1Effect), "The input ID2D1Effect object cannot be null.");
|
||||
}
|
||||
|
||||
if (transformMapper is null)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentNullException(nameof(transformMapper), "The input ID2D1TransformMapper object cannot be null.");
|
||||
}
|
||||
default(ArgumentNullException).ThrowIfNull(d2D1Effect);
|
||||
default(ArgumentNullException).ThrowIfNull(transformMapper);
|
||||
|
||||
((ID2D1Effect*)d2D1Effect)->SetValue(
|
||||
index: D2D1PixelShaderEffectProperty.TransformMapper,
|
||||
@@ -608,15 +573,8 @@ public static unsafe class D2D1PixelShaderEffect
|
||||
public static void SetTransformMapperForD2D1Effect<T>(void* d2D1Effect, D2D1TransformMapper<T> transformMapper)
|
||||
where T : unmanaged, ID2D1PixelShader
|
||||
{
|
||||
if (d2D1Effect is null)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentNullException(nameof(d2D1Effect), "The input ID2D1Effect object cannot be null.");
|
||||
}
|
||||
|
||||
if (transformMapper is null)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentNullException(nameof(transformMapper), "The input D2D1TransformMapper<T> object cannot be null.");
|
||||
}
|
||||
default(ArgumentNullException).ThrowIfNull(d2D1Effect);
|
||||
default(ArgumentNullException).ThrowIfNull(transformMapper);
|
||||
|
||||
using ComPtr<ID2D1TransformMapper> transformMapper2 = default;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using ComputeSharp.D2D1.Helpers;
|
||||
using ComputeSharp.D2D1.Shaders.Interop.Factories;
|
||||
|
||||
namespace ComputeSharp.D2D1.Interop;
|
||||
@@ -41,10 +41,7 @@ public static class D2D1TransformMapperFactory<T>
|
||||
/// <returns>The resulting <see cref="D2D1TransformMapper{T}"/> instance for an inflate transform.</returns>
|
||||
public static D2D1TransformMapper<T> Inflate(Accessor<int> accessor)
|
||||
{
|
||||
if (accessor is null)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentNullException(nameof(accessor), "The input D2D1TransformMapperFactory<T>.Accessor<int> object cannot be null.");
|
||||
}
|
||||
default(ArgumentNullException).ThrowIfNull(accessor);
|
||||
|
||||
return new D2D1InflateTransformMapper<T>.DynamicAmount { Accessor = accessor };
|
||||
}
|
||||
@@ -56,10 +53,7 @@ public static class D2D1TransformMapperFactory<T>
|
||||
/// <returns>The resulting <see cref="D2D1TransformMapper{T}"/> instance for an inflate transform.</returns>
|
||||
public static D2D1TransformMapper<T> Inflate(Accessor<(int Left, int Top, int Right, int Bottom)> accessor)
|
||||
{
|
||||
if (accessor is null)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentNullException(nameof(accessor), "The input D2D1TransformMapperFactory<T>.Accessor<(int Left, int Top, int Right, int Bottom)> object cannot be null.");
|
||||
}
|
||||
default(ArgumentNullException).ThrowIfNull(accessor);
|
||||
|
||||
return new D2D1InflateTransformMapper<T>.DynamicLeftTopRightBottomAmount { Accessor = accessor };
|
||||
}
|
||||
@@ -81,10 +75,7 @@ public static class D2D1TransformMapperFactory<T>
|
||||
/// <returns>The resulting <see cref="D2D1TransformMapper{T}"/> instance for an affine transform.</returns>
|
||||
public static D2D1TransformMapper<T> Transform(Accessor<Matrix3x2> accessor)
|
||||
{
|
||||
if (accessor is null)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentNullException(nameof(accessor), "The input D2D1TransformMapperFactory<T>.Accessor<Matrix3x2> object cannot be null.");
|
||||
}
|
||||
default(ArgumentNullException).ThrowIfNull(accessor);
|
||||
|
||||
return new D2D1AffineTransformMapper<T>.DynamicMatrix { Accessor = accessor };
|
||||
}
|
||||
|
||||
@@ -95,7 +95,9 @@ internal abstract class D2D1AffineTransformMapper<T> : D2D1TransformMapper<T, Ma
|
||||
{
|
||||
static void Throw()
|
||||
{
|
||||
throw new ArgumentException("The input transform matrix can't be inverted, so it can't be used for a transform mapper.");
|
||||
// The parameter name is "matrix" and it's passed by users from D2D1TransformMapperFactory<T>.Transform.
|
||||
// Additionally, we explicitly don't use a throw helper here to avoid loading the two string literals.
|
||||
throw new ArgumentException("The input transform matrix can't be inverted, so it can't be used for a transform mapper.", "matrix");
|
||||
}
|
||||
|
||||
Throw();
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using ComputeSharp.D2D1.__Internals;
|
||||
using ComputeSharp.D2D1.Extensions;
|
||||
using ComputeSharp.D2D1.Helpers;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
|
||||
@@ -49,16 +48,9 @@ internal unsafe struct D2D1ShaderBytecodeLoader : ID2D1BytecodeLoader
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
unsafe void ID2D1BytecodeLoader.LoadDynamicBytecode(IntPtr handle)
|
||||
{
|
||||
if (this.embeddedBytecodePtr is not null ||
|
||||
this.d3DBlob.Get() is not null)
|
||||
{
|
||||
ThrowHelper.ThrowInvalidOperationException("The shader has already been initialized.");
|
||||
}
|
||||
|
||||
if (handle == IntPtr.Zero)
|
||||
{
|
||||
ThrowHelper.ThrowNotSupportedException("Runtime shader compilation is not supported by the current configuration.");
|
||||
}
|
||||
default(InvalidOperationException).ThrowIf(this.embeddedBytecodePtr is not null);
|
||||
default(InvalidOperationException).ThrowIf(this.d3DBlob.Get() is not null);
|
||||
default(NotSupportedException).ThrowIf(handle == IntPtr.Zero);
|
||||
|
||||
this.d3DBlob = new ComPtr<ID3DBlob>((ID3DBlob*)handle);
|
||||
}
|
||||
@@ -67,11 +59,8 @@ internal unsafe struct D2D1ShaderBytecodeLoader : ID2D1BytecodeLoader
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void ID2D1BytecodeLoader.LoadEmbeddedBytecode(ReadOnlySpan<byte> bytecode)
|
||||
{
|
||||
if (this.embeddedBytecodePtr is not null ||
|
||||
this.d3DBlob.Get() is not null)
|
||||
{
|
||||
ThrowHelper.ThrowInvalidOperationException("The shader has already been initialized.");
|
||||
}
|
||||
default(InvalidOperationException).ThrowIf(this.embeddedBytecodePtr is not null);
|
||||
default(InvalidOperationException).ThrowIf(this.d3DBlob.Get() is not null);
|
||||
|
||||
this.embeddedBytecodePtr = (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(bytecode));
|
||||
this.embeddedBytecodeSize = bytecode.Length;
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using TerraFX.Interop.Windows;
|
||||
|
||||
namespace ComputeSharp.Shaders.Translation;
|
||||
@@ -31,7 +30,7 @@ unsafe partial class ShaderCompiler
|
||||
{
|
||||
Architecture.X64 => "win-x64",
|
||||
Architecture.Arm64 => "win-arm64",
|
||||
_ => ThrowHelper.ThrowNotSupportedException<string>("Invalid process architecture.")
|
||||
_ => default(NotSupportedException).Throw<string>()
|
||||
};
|
||||
|
||||
// Test whether the native libraries are present in the same folder of the executable
|
||||
|
||||
@@ -2,7 +2,6 @@ using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using ComputeSharp.Interop;
|
||||
#if WINDOWS_UWP
|
||||
using ComputeSharp.Uwp.Extensions;
|
||||
@@ -28,7 +27,7 @@ partial class SwapChainManager<TOwner>
|
||||
/// <param name="shaderRunner">The <see cref="IShaderRunner"/> instance to use to render frames.</param>
|
||||
public async void StartRenderLoop(IFrameRequestQueue? frameRequestQueue, IShaderRunner shaderRunner)
|
||||
{
|
||||
Guard.IsNotNull(shaderRunner);
|
||||
default(ArgumentNullException).ThrowIfNull(shaderRunner);
|
||||
|
||||
using (await this.setupSemaphore.LockAsync())
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
|
||||
#if WINDOWS_UWP
|
||||
namespace ComputeSharp.Uwp;
|
||||
@@ -40,7 +39,7 @@ public sealed class ShaderRunner<T> : IShaderRunner
|
||||
/// <param name="shaderFactory">The <see cref="Func{T1,TResult}"/> instance used to create shaders to run.</param>
|
||||
public ShaderRunner(Func<TimeSpan, T> shaderFactory)
|
||||
{
|
||||
Guard.IsNotNull(shaderFactory);
|
||||
default(ArgumentNullException).ThrowIfNull(shaderFactory);
|
||||
|
||||
this.shaderFactory = shaderFactory;
|
||||
}
|
||||
@@ -51,7 +50,7 @@ public sealed class ShaderRunner<T> : IShaderRunner
|
||||
/// <param name="shaderFactory">The <see cref="Func{T1,T2,TResult}"/> instance used to create shaders to run.</param>
|
||||
public ShaderRunner(Func<TimeSpan, object?, T> shaderFactory)
|
||||
{
|
||||
Guard.IsNotNull(shaderFactory);
|
||||
default(ArgumentNullException).ThrowIfNull(shaderFactory);
|
||||
|
||||
this.statefulShaderFactory = shaderFactory;
|
||||
}
|
||||
|
||||
@@ -18,10 +18,6 @@
|
||||
<ProjectReference Include="..\ComputeSharp.Core\ComputeSharp.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommunityToolkit.Diagnostics" Version="8.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- .NET 6 uses the NuGet packages for TerraFX -->
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
|
||||
<PackageReference Include="TerraFX.Interop.D3D12MemoryAllocator" Version="2.0.1.3" />
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using System;
|
||||
#if !SOURCE_GENERATOR
|
||||
using CommunityToolkit.Diagnostics;
|
||||
#endif
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
@@ -64,7 +61,7 @@ public sealed class EmbeddedBytecodeAttribute : Attribute
|
||||
DispatchAxis.XZ => (8, 1, 8),
|
||||
DispatchAxis.YZ => (1, 8, 8),
|
||||
DispatchAxis.XYZ => (4, 4, 4),
|
||||
_ => ThrowHelper.ThrowArgumentException<(int, int, int)>(nameof(dispatchAxis), "Invalid dispatch axis value.")
|
||||
_ => default(ArgumentException).Throw<(int, int, int)>(nameof(dispatchAxis))
|
||||
};
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
@@ -94,10 +93,7 @@ internal unsafe struct ID3D12DescriptorHandleAllocator : IDisposable
|
||||
{
|
||||
lock (this.d3D12DescriptorHandlePairs)
|
||||
{
|
||||
if (this.size <= 0)
|
||||
{
|
||||
ThrowHelper.ThrowInvalidOperationException("There are no descriptor handles left in the pool.");
|
||||
}
|
||||
default(InvalidOperationException).ThrowIf(this.size <= 0);
|
||||
|
||||
d3D12ResourceDescriptorHandles = this.d3D12DescriptorHandlePairs[this.head++];
|
||||
|
||||
@@ -118,10 +114,7 @@ internal unsafe struct ID3D12DescriptorHandleAllocator : IDisposable
|
||||
{
|
||||
lock (this.d3D12DescriptorHandlePairs)
|
||||
{
|
||||
if (this.size >= DescriptorsPerHeap)
|
||||
{
|
||||
ThrowHelper.ThrowInvalidOperationException("The pool of descriptor heaps is already full.");
|
||||
}
|
||||
default(InvalidOperationException).ThrowIf(this.size >= DescriptorsPerHeap);
|
||||
|
||||
this.d3D12DescriptorHandlePairs[this.tail++] = d3D12ResourceDescriptorHandles;
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
|
||||
namespace ComputeSharp.Exceptions;
|
||||
|
||||
@@ -36,7 +35,7 @@ public sealed class UnsupportedTextureTypeException : NotSupportedException
|
||||
1 => $"{nameof(GraphicsDevice.IsReadOnlyTexture1DSupportedForType)}<T>() or {nameof(GraphicsDevice)}.{nameof(GraphicsDevice.IsReadWriteTexture1DSupportedForType)}<T>().",
|
||||
2 => $"{nameof(GraphicsDevice.IsReadOnlyTexture2DSupportedForType)}<T>() or {nameof(GraphicsDevice)}.{nameof(GraphicsDevice.IsReadWriteTexture2DSupportedForType)}<T>().",
|
||||
3 => $"{nameof(GraphicsDevice.IsReadOnlyTexture3DSupportedForType)}<T>() or {nameof(GraphicsDevice)}.{nameof(GraphicsDevice.IsReadWriteTexture3DSupportedForType)}<T>().",
|
||||
_ => ThrowHelper.ThrowArgumentException<string>("Invalid texture rank.")
|
||||
_ => default(ArgumentException).Throw<string>(nameof(rank))
|
||||
});
|
||||
|
||||
_ = builder.Append("As a possible workaround on older devices, consider using a texture type of lower rank, or a linear buffer.");
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using ComputeSharp.Resources;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using GC = ComputeSharp.NetStandard.GC;
|
||||
@@ -22,7 +21,7 @@ public static class BufferExtensions
|
||||
public static T[] ToArray<T>(this Buffer<T> source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
return source.ToArray(0, source.Length);
|
||||
}
|
||||
@@ -38,8 +37,8 @@ public static class BufferExtensions
|
||||
public static T[] ToArray<T>(this Buffer<T> source, int offset, int count)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsGreaterThanOrEqualTo(count, 0);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNegative(count);
|
||||
|
||||
T[] data = GC.AllocateUninitializedArray<T>(count);
|
||||
|
||||
@@ -57,8 +56,8 @@ public static class BufferExtensions
|
||||
public static void CopyTo<T>(this Buffer<T> source, T[] destination)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
source.CopyTo(destination.AsSpan(), 0);
|
||||
}
|
||||
@@ -75,8 +74,8 @@ public static class BufferExtensions
|
||||
public static void CopyTo<T>(this Buffer<T> source, T[] destination, int sourceOffset, int destinationOffset, int count)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
Span<T> span = destination.AsSpan(destinationOffset, count);
|
||||
|
||||
@@ -92,7 +91,7 @@ public static class BufferExtensions
|
||||
public static void CopyTo<T>(this Buffer<T> source, Span<T> destination)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
source.CopyTo(destination, 0);
|
||||
}
|
||||
@@ -107,7 +106,7 @@ public static class BufferExtensions
|
||||
public static void CopyTo<T>(this Buffer<T> source, Span<T> destination, int sourceOffset)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
source.CopyTo(ref MemoryMarshal.GetReference(destination), sourceOffset, destination.Length);
|
||||
}
|
||||
@@ -121,8 +120,8 @@ public static class BufferExtensions
|
||||
public static void CopyTo<T>(this Buffer<T> source, Buffer<T> destination)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
source.CopyTo(destination, 0, 0, source.Length);
|
||||
}
|
||||
@@ -139,8 +138,8 @@ public static class BufferExtensions
|
||||
public static void CopyTo<T>(this Buffer<T> source, Buffer<T> destination, int sourceOffset, int destinationOffset, int count)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
source.CopyTo(destination, sourceOffset, destinationOffset, count);
|
||||
}
|
||||
@@ -154,8 +153,8 @@ public static class BufferExtensions
|
||||
public static void CopyFrom<T>(this Buffer<T> destination, T[] source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
destination.CopyFrom(source.AsSpan(), 0);
|
||||
}
|
||||
@@ -172,8 +171,8 @@ public static class BufferExtensions
|
||||
public static void CopyFrom<T>(this Buffer<T> destination, T[] source, int sourceOffset, int destinationOffset, int count)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
ReadOnlySpan<T> span = source.AsSpan(sourceOffset, count);
|
||||
|
||||
@@ -189,7 +188,7 @@ public static class BufferExtensions
|
||||
public static void CopyFrom<T>(this Buffer<T> destination, ReadOnlySpan<T> source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
destination.CopyFrom(source, 0);
|
||||
}
|
||||
@@ -204,7 +203,7 @@ public static class BufferExtensions
|
||||
public static void CopyFrom<T>(this Buffer<T> destination, ReadOnlySpan<T> source, int destinationOffset)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
destination.CopyFrom(ref MemoryMarshal.GetReference(source), destinationOffset, source.Length);
|
||||
}
|
||||
@@ -218,8 +217,8 @@ public static class BufferExtensions
|
||||
public static void CopyFrom<T>(this Buffer<T> destination, Buffer<T> source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
source.CopyTo(destination, 0, 0, source.Length);
|
||||
}
|
||||
@@ -236,8 +235,8 @@ public static class BufferExtensions
|
||||
public static void CopyFrom<T>(this Buffer<T> destination, Buffer<T> source, int sourceOffset, int destinationOffset, int count)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
source.CopyTo(destination, sourceOffset, destinationOffset, count);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using ComputeSharp.Interop;
|
||||
|
||||
namespace ComputeSharp;
|
||||
@@ -19,7 +19,7 @@ public static partial class GraphicsDeviceExtensions
|
||||
public static void For<T>(this GraphicsDevice device, int x, in T shader)
|
||||
where T : struct, IComputeShader
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
using ComputeContext context = device.CreateComputeContext();
|
||||
|
||||
@@ -37,7 +37,7 @@ public static partial class GraphicsDeviceExtensions
|
||||
public static void For<T>(this GraphicsDevice device, int x, int y, in T shader)
|
||||
where T : struct, IComputeShader
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
using ComputeContext context = device.CreateComputeContext();
|
||||
|
||||
@@ -56,7 +56,7 @@ public static partial class GraphicsDeviceExtensions
|
||||
public static void For<T>(this GraphicsDevice device, int x, int y, int z, in T shader)
|
||||
where T : struct, IComputeShader
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
using ComputeContext context = device.CreateComputeContext();
|
||||
|
||||
@@ -78,7 +78,7 @@ public static partial class GraphicsDeviceExtensions
|
||||
public static void For<T>(this GraphicsDevice device, int x, int y, int z, int threadsX, int threadsY, int threadsZ, in T shader)
|
||||
where T : struct, IComputeShader
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
using ComputeContext context = device.CreateComputeContext();
|
||||
|
||||
@@ -96,8 +96,8 @@ public static partial class GraphicsDeviceExtensions
|
||||
where T : struct, IPixelShader<TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
using ComputeContext context = device.CreateComputeContext();
|
||||
|
||||
@@ -116,8 +116,8 @@ public static partial class GraphicsDeviceExtensions
|
||||
where T : struct, IPixelShader<TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
using ComputeContext context = device.CreateComputeContext();
|
||||
|
||||
@@ -149,7 +149,7 @@ public static partial class GraphicsDeviceExtensions
|
||||
/// </remarks>
|
||||
public static ComputeContext CreateComputeContext(this GraphicsDevice device)
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
using ReferenceTracker.Lease _0 = device.GetReferenceTracker().GetLease();
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
using ComputeSharp.Resources;
|
||||
|
||||
@@ -22,7 +21,7 @@ partial class GraphicsDeviceExtensions
|
||||
public static ConstantBuffer<T> AllocateConstantBuffer<T>(this GraphicsDevice device, int length, AllocationMode allocationMode = AllocationMode.Default)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
return new(device, length, allocationMode);
|
||||
}
|
||||
@@ -38,8 +37,8 @@ partial class GraphicsDeviceExtensions
|
||||
public static ConstantBuffer<T> AllocateConstantBuffer<T>(this GraphicsDevice device, T[] source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
return device.AllocateConstantBuffer<T>(source.AsSpan());
|
||||
}
|
||||
@@ -55,7 +54,7 @@ partial class GraphicsDeviceExtensions
|
||||
public static ConstantBuffer<T> AllocateConstantBuffer<T>(this GraphicsDevice device, ReadOnlySpan<T> source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
ConstantBuffer<T> buffer = new(device, source.Length, AllocationMode.Default);
|
||||
|
||||
@@ -75,8 +74,8 @@ partial class GraphicsDeviceExtensions
|
||||
public static ConstantBuffer<T> AllocateConstantBuffer<T>(this GraphicsDevice device, Buffer<T> source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
ConstantBuffer<T> constantBuffer = new(device, source.Length, AllocationMode.Default);
|
||||
|
||||
@@ -97,7 +96,7 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadOnlyBuffer<T> AllocateReadOnlyBuffer<T>(this GraphicsDevice device, int length, AllocationMode allocationMode = AllocationMode.Default)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
return new(device, length, allocationMode);
|
||||
}
|
||||
@@ -113,8 +112,8 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadOnlyBuffer<T> AllocateReadOnlyBuffer<T>(this GraphicsDevice device, T[] source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
return device.AllocateReadOnlyBuffer<T>(source.AsSpan());
|
||||
}
|
||||
@@ -130,7 +129,7 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadOnlyBuffer<T> AllocateReadOnlyBuffer<T>(this GraphicsDevice device, ReadOnlySpan<T> source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
ReadOnlyBuffer<T> buffer = new(device, source.Length, AllocationMode.Default);
|
||||
|
||||
@@ -150,8 +149,8 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadOnlyBuffer<T> AllocateReadOnlyBuffer<T>(this GraphicsDevice device, Buffer<T> source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
ReadOnlyBuffer<T> readWriteBuffer = new(device, source.Length, AllocationMode.Default);
|
||||
|
||||
@@ -171,7 +170,7 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadOnlyTexture1D<T> AllocateReadOnlyTexture1D<T>(this GraphicsDevice device, int width, AllocationMode allocationMode = AllocationMode.Default)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
return new(device, width, allocationMode);
|
||||
}
|
||||
@@ -187,8 +186,8 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadOnlyTexture1D<T> AllocateReadOnlyTexture1D<T>(this GraphicsDevice device, T[] source, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
return device.AllocateReadOnlyTexture1D<T>(source.AsSpan(0, width));
|
||||
}
|
||||
@@ -205,8 +204,8 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadOnlyTexture1D<T> AllocateReadOnlyTexture1D<T>(this GraphicsDevice device, T[] source, int offset, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
return device.AllocateReadOnlyTexture1D<T>(source.AsSpan(offset, width));
|
||||
}
|
||||
@@ -221,8 +220,8 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadOnlyTexture1D<T> AllocateReadOnlyTexture1D<T>(this GraphicsDevice device, T[] source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
ReadOnlyTexture1D<T> texture = new(device, source.Length, AllocationMode.Default);
|
||||
|
||||
@@ -241,7 +240,7 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadOnlyTexture1D<T> AllocateReadOnlyTexture1D<T>(this GraphicsDevice device, ReadOnlySpan<T> source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
ReadOnlyTexture1D<T> texture = new(device, source.Length, AllocationMode.Default);
|
||||
|
||||
@@ -263,7 +262,7 @@ partial class GraphicsDeviceExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
return new(device, width, allocationMode);
|
||||
}
|
||||
@@ -281,8 +280,8 @@ partial class GraphicsDeviceExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
return device.AllocateReadOnlyTexture1D<T, TPixel>(source.AsSpan(0, width));
|
||||
}
|
||||
@@ -301,8 +300,8 @@ partial class GraphicsDeviceExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
return device.AllocateReadOnlyTexture1D<T, TPixel>(source.AsSpan(offset, width));
|
||||
}
|
||||
@@ -319,8 +318,8 @@ partial class GraphicsDeviceExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
ReadOnlyTexture1D<T, TPixel> texture = new(device, source.Length, AllocationMode.Default);
|
||||
|
||||
@@ -341,7 +340,7 @@ partial class GraphicsDeviceExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
ReadOnlyTexture1D<T, TPixel> texture = new(device, source.Length, AllocationMode.Default);
|
||||
|
||||
@@ -362,7 +361,7 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadOnlyTexture2D<T> AllocateReadOnlyTexture2D<T>(this GraphicsDevice device, int width, int height, AllocationMode allocationMode = AllocationMode.Default)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
return new(device, width, height, allocationMode);
|
||||
}
|
||||
@@ -379,8 +378,8 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadOnlyTexture2D<T> AllocateReadOnlyTexture2D<T>(this GraphicsDevice device, T[] source, int width, int height)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
return device.AllocateReadOnlyTexture2D<T>(source.AsSpan(), width, height);
|
||||
}
|
||||
@@ -398,8 +397,8 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadOnlyTexture2D<T> AllocateReadOnlyTexture2D<T>(this GraphicsDevice device, T[] source, int offset, int width, int height)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
return device.AllocateReadOnlyTexture2D<T>(source.AsSpan(offset), width, height);
|
||||
}
|
||||
@@ -414,8 +413,8 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadOnlyTexture2D<T> AllocateReadOnlyTexture2D<T>(this GraphicsDevice device, T[,] source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
ReadOnlyTexture2D<T> texture = new(device, source.GetLength(1), source.GetLength(0), AllocationMode.Default);
|
||||
|
||||
@@ -436,7 +435,7 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadOnlyTexture2D<T> AllocateReadOnlyTexture2D<T>(this GraphicsDevice device, ReadOnlySpan<T> source, int width, int height)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
ReadOnlyTexture2D<T> texture = new(device, width, height, AllocationMode.Default);
|
||||
|
||||
@@ -459,7 +458,7 @@ partial class GraphicsDeviceExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
return new(device, width, height, allocationMode);
|
||||
}
|
||||
@@ -478,8 +477,8 @@ partial class GraphicsDeviceExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
return device.AllocateReadOnlyTexture2D<T, TPixel>(source.AsSpan(), width, height);
|
||||
}
|
||||
@@ -499,8 +498,8 @@ partial class GraphicsDeviceExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
return device.AllocateReadOnlyTexture2D<T, TPixel>(source.AsSpan(offset), width, height);
|
||||
}
|
||||
@@ -517,8 +516,8 @@ partial class GraphicsDeviceExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
ReadOnlyTexture2D<T, TPixel> texture = new(device, source.GetLength(1), source.GetLength(0), AllocationMode.Default);
|
||||
|
||||
@@ -541,7 +540,7 @@ partial class GraphicsDeviceExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
ReadOnlyTexture2D<T, TPixel> texture = new(device, width, height, AllocationMode.Default);
|
||||
|
||||
@@ -563,7 +562,7 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadOnlyTexture3D<T> AllocateReadOnlyTexture3D<T>(this GraphicsDevice device, int width, int height, int depth, AllocationMode allocationMode = AllocationMode.Default)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
return new(device, width, height, depth, allocationMode);
|
||||
}
|
||||
@@ -581,8 +580,8 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadOnlyTexture3D<T> AllocateReadOnlyTexture3D<T>(this GraphicsDevice device, T[] source, int width, int height, int depth)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
return device.AllocateReadOnlyTexture3D<T>(source.AsSpan(), width, height, depth);
|
||||
}
|
||||
@@ -601,8 +600,8 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadOnlyTexture3D<T> AllocateReadOnlyTexture3D<T>(this GraphicsDevice device, T[] source, int offset, int width, int height, int depth)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
return device.AllocateReadOnlyTexture3D<T>(source.AsSpan(offset), width, height, depth);
|
||||
}
|
||||
@@ -621,8 +620,8 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadOnlyTexture3D<T> AllocateReadOnlyTexture3D<T>(this GraphicsDevice device, T[,,] source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
ReadOnlyTexture3D<T> texture = new(device, source.GetLength(2), source.GetLength(1), source.GetLength(0), AllocationMode.Default);
|
||||
|
||||
@@ -644,7 +643,7 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadOnlyTexture3D<T> AllocateReadOnlyTexture3D<T>(this GraphicsDevice device, ReadOnlySpan<T> source, int width, int height, int depth)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
ReadOnlyTexture3D<T> texture = new(device, width, height, depth, AllocationMode.Default);
|
||||
|
||||
@@ -668,7 +667,7 @@ partial class GraphicsDeviceExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
return new(device, width, height, depth, allocationMode);
|
||||
}
|
||||
@@ -688,8 +687,8 @@ partial class GraphicsDeviceExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
return device.AllocateReadOnlyTexture3D<T, TPixel>(source.AsSpan(), width, height, depth);
|
||||
}
|
||||
@@ -710,8 +709,8 @@ partial class GraphicsDeviceExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
return device.AllocateReadOnlyTexture3D<T, TPixel>(source.AsSpan(offset), width, height, depth);
|
||||
}
|
||||
@@ -732,8 +731,8 @@ partial class GraphicsDeviceExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
ReadOnlyTexture3D<T, TPixel> texture = new(device, source.GetLength(2), source.GetLength(1), source.GetLength(0), AllocationMode.Default);
|
||||
|
||||
@@ -757,7 +756,7 @@ partial class GraphicsDeviceExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
ReadOnlyTexture3D<T, TPixel> texture = new(device, width, height, depth, AllocationMode.Default);
|
||||
|
||||
@@ -778,7 +777,7 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadWriteBuffer<T> AllocateReadWriteBuffer<T>(this GraphicsDevice device, int length, AllocationMode allocationMode = AllocationMode.Default)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
return new(device, length, allocationMode);
|
||||
}
|
||||
@@ -794,8 +793,8 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadWriteBuffer<T> AllocateReadWriteBuffer<T>(this GraphicsDevice device, T[] source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
return device.AllocateReadWriteBuffer<T>(source.AsSpan());
|
||||
}
|
||||
@@ -811,7 +810,7 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadWriteBuffer<T> AllocateReadWriteBuffer<T>(this GraphicsDevice device, ReadOnlySpan<T> source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
ReadWriteBuffer<T> buffer = new(device, source.Length, AllocationMode.Default);
|
||||
|
||||
@@ -831,8 +830,8 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadWriteBuffer<T> AllocateReadWriteBuffer<T>(this GraphicsDevice device, Buffer<T> source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
ReadWriteBuffer<T> readWriteBuffer = new(device, source.Length, AllocationMode.Default);
|
||||
|
||||
@@ -852,7 +851,7 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadWriteTexture1D<T> AllocateReadWriteTexture1D<T>(this GraphicsDevice device, int width, AllocationMode allocationMode = AllocationMode.Default)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
return new(device, width, allocationMode);
|
||||
}
|
||||
@@ -868,8 +867,8 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadWriteTexture1D<T> AllocateReadWriteTexture1D<T>(this GraphicsDevice device, T[] source, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
return device.AllocateReadWriteTexture1D<T>(source.AsSpan(0, width));
|
||||
}
|
||||
@@ -886,8 +885,8 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadWriteTexture1D<T> AllocateReadWriteTexture1D<T>(this GraphicsDevice device, T[] source, int offset, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
return device.AllocateReadWriteTexture1D<T>(source.AsSpan(offset, width));
|
||||
}
|
||||
@@ -902,8 +901,8 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadWriteTexture1D<T> AllocateReadWriteTexture1D<T>(this GraphicsDevice device, T[] source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
ReadWriteTexture1D<T> texture = new(device, source.Length, AllocationMode.Default);
|
||||
|
||||
@@ -922,7 +921,7 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadWriteTexture1D<T> AllocateReadWriteTexture1D<T>(this GraphicsDevice device, ReadOnlySpan<T> source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
ReadWriteTexture1D<T> texture = new(device, source.Length, AllocationMode.Default);
|
||||
|
||||
@@ -944,7 +943,7 @@ partial class GraphicsDeviceExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
return new(device, width, allocationMode);
|
||||
}
|
||||
@@ -962,8 +961,8 @@ partial class GraphicsDeviceExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
return device.AllocateReadWriteTexture1D<T, TPixel>(source.AsSpan(0, width));
|
||||
}
|
||||
@@ -982,8 +981,8 @@ partial class GraphicsDeviceExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
return device.AllocateReadWriteTexture1D<T, TPixel>(source.AsSpan(offset, width));
|
||||
}
|
||||
@@ -1000,8 +999,8 @@ partial class GraphicsDeviceExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
ReadWriteTexture1D<T, TPixel> texture = new(device, source.Length, AllocationMode.Default);
|
||||
|
||||
@@ -1022,7 +1021,7 @@ partial class GraphicsDeviceExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
ReadWriteTexture1D<T, TPixel> texture = new(device, source.Length, AllocationMode.Default);
|
||||
|
||||
@@ -1043,7 +1042,7 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadWriteTexture2D<T> AllocateReadWriteTexture2D<T>(this GraphicsDevice device, int width, int height, AllocationMode allocationMode = AllocationMode.Default)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
return new(device, width, height, allocationMode);
|
||||
}
|
||||
@@ -1060,8 +1059,8 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadWriteTexture2D<T> AllocateReadWriteTexture2D<T>(this GraphicsDevice device, T[] source, int width, int height)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
return device.AllocateReadWriteTexture2D<T>(source.AsSpan(), width, height);
|
||||
}
|
||||
@@ -1079,8 +1078,8 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadWriteTexture2D<T> AllocateReadWriteTexture2D<T>(this GraphicsDevice device, T[] source, int offset, int width, int height)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
return device.AllocateReadWriteTexture2D<T>(source.AsSpan(offset), width, height);
|
||||
}
|
||||
@@ -1095,8 +1094,8 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadWriteTexture2D<T> AllocateReadWriteTexture2D<T>(this GraphicsDevice device, T[,] source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
ReadWriteTexture2D<T> texture = new(device, source.GetLength(1), source.GetLength(0), AllocationMode.Default);
|
||||
|
||||
@@ -1117,7 +1116,7 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadWriteTexture2D<T> AllocateReadWriteTexture2D<T>(this GraphicsDevice device, ReadOnlySpan<T> source, int width, int height)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
ReadWriteTexture2D<T> texture = new(device, width, height, AllocationMode.Default);
|
||||
|
||||
@@ -1140,7 +1139,7 @@ partial class GraphicsDeviceExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
return new(device, width, height, allocationMode);
|
||||
}
|
||||
@@ -1159,8 +1158,8 @@ partial class GraphicsDeviceExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
return device.AllocateReadWriteTexture2D<T, TPixel>(source.AsSpan(), width, height);
|
||||
}
|
||||
@@ -1180,8 +1179,8 @@ partial class GraphicsDeviceExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
return device.AllocateReadWriteTexture2D<T, TPixel>(source.AsSpan(offset), width, height);
|
||||
}
|
||||
@@ -1198,8 +1197,8 @@ partial class GraphicsDeviceExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
ReadWriteTexture2D<T, TPixel> texture = new(device, source.GetLength(1), source.GetLength(0), AllocationMode.Default);
|
||||
|
||||
@@ -1222,7 +1221,7 @@ partial class GraphicsDeviceExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
ReadWriteTexture2D<T, TPixel> texture = new(device, width, height, AllocationMode.Default);
|
||||
|
||||
@@ -1244,7 +1243,7 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadWriteTexture3D<T> AllocateReadWriteTexture3D<T>(this GraphicsDevice device, int width, int height, int depth, AllocationMode allocationMode = AllocationMode.Default)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
return new(device, width, height, depth, allocationMode);
|
||||
}
|
||||
@@ -1262,8 +1261,8 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadWriteTexture3D<T> AllocateReadWriteTexture3D<T>(this GraphicsDevice device, T[] source, int width, int height, int depth)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
return device.AllocateReadWriteTexture3D<T>(source.AsSpan(), width, height, depth);
|
||||
}
|
||||
@@ -1282,8 +1281,8 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadWriteTexture3D<T> AllocateReadWriteTexture3D<T>(this GraphicsDevice device, T[] source, int offset, int width, int height, int depth)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
return device.AllocateReadWriteTexture3D<T>(source.AsSpan(offset), width, height, depth);
|
||||
}
|
||||
@@ -1302,8 +1301,8 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadWriteTexture3D<T> AllocateReadWriteTexture3D<T>(this GraphicsDevice device, T[,,] source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
ReadWriteTexture3D<T> texture = new(device, source.GetLength(2), source.GetLength(1), source.GetLength(0), AllocationMode.Default);
|
||||
|
||||
@@ -1325,7 +1324,7 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadWriteTexture3D<T> AllocateReadWriteTexture3D<T>(this GraphicsDevice device, ReadOnlySpan<T> source, int width, int height, int depth)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
ReadWriteTexture3D<T> texture = new(device, width, height, depth, AllocationMode.Default);
|
||||
|
||||
@@ -1349,7 +1348,7 @@ partial class GraphicsDeviceExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
return new(device, width, height, depth, allocationMode);
|
||||
}
|
||||
@@ -1369,8 +1368,8 @@ partial class GraphicsDeviceExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
return device.AllocateReadWriteTexture3D<T, TPixel>(source.AsSpan(), width, height, depth);
|
||||
}
|
||||
@@ -1391,8 +1390,8 @@ partial class GraphicsDeviceExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
return device.AllocateReadWriteTexture3D<T, TPixel>(source.AsSpan(offset), width, height, depth);
|
||||
}
|
||||
@@ -1413,8 +1412,8 @@ partial class GraphicsDeviceExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
ReadWriteTexture3D<T, TPixel> texture = new(device, source.GetLength(2), source.GetLength(1), source.GetLength(0), AllocationMode.Default);
|
||||
|
||||
@@ -1438,7 +1437,7 @@ partial class GraphicsDeviceExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
ReadWriteTexture3D<T, TPixel> texture = new(device, width, height, depth, AllocationMode.Default);
|
||||
|
||||
@@ -1459,7 +1458,7 @@ partial class GraphicsDeviceExtensions
|
||||
public static UploadBuffer<T> AllocateUploadBuffer<T>(this GraphicsDevice device, int length, AllocationMode allocationMode = AllocationMode.Default)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
return new(device, length, allocationMode);
|
||||
}
|
||||
@@ -1475,7 +1474,7 @@ partial class GraphicsDeviceExtensions
|
||||
public static UploadTexture1D<T> AllocateUploadTexture1D<T>(this GraphicsDevice device, int width, AllocationMode allocationMode = AllocationMode.Default)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
return new(device, width, allocationMode);
|
||||
}
|
||||
@@ -1492,7 +1491,7 @@ partial class GraphicsDeviceExtensions
|
||||
public static UploadTexture2D<T> AllocateUploadTexture2D<T>(this GraphicsDevice device, int width, int height, AllocationMode allocationMode = AllocationMode.Default)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
return new(device, width, height, allocationMode);
|
||||
}
|
||||
@@ -1510,7 +1509,7 @@ partial class GraphicsDeviceExtensions
|
||||
public static UploadTexture3D<T> AllocateUploadTexture3D<T>(this GraphicsDevice device, int width, int height, int depth, AllocationMode allocationMode = AllocationMode.Default)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
return new(device, width, height, depth, allocationMode);
|
||||
}
|
||||
@@ -1527,7 +1526,7 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadBackBuffer<T> AllocateReadBackBuffer<T>(this GraphicsDevice device, int length, AllocationMode allocationMode = AllocationMode.Default)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
return new(device, length, allocationMode);
|
||||
}
|
||||
@@ -1543,7 +1542,7 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadBackTexture1D<T> AllocateReadBackTexture1D<T>(this GraphicsDevice device, int width, AllocationMode allocationMode = AllocationMode.Default)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
return new(device, width, allocationMode);
|
||||
}
|
||||
@@ -1560,7 +1559,7 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadBackTexture2D<T> AllocateReadBackTexture2D<T>(this GraphicsDevice device, int width, int height, AllocationMode allocationMode = AllocationMode.Default)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
return new(device, width, height, allocationMode);
|
||||
}
|
||||
@@ -1578,7 +1577,7 @@ partial class GraphicsDeviceExtensions
|
||||
public static ReadBackTexture3D<T> AllocateReadBackTexture3D<T>(this GraphicsDevice device, int width, int height, int depth, AllocationMode allocationMode = AllocationMode.Default)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
return new(device, width, height, depth, allocationMode);
|
||||
}
|
||||
@@ -1595,8 +1594,8 @@ partial class GraphicsDeviceExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(filename);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(filename);
|
||||
|
||||
return device.LoadReadOnlyTexture2D<T, TPixel>(filename.AsSpan());
|
||||
}
|
||||
@@ -1613,7 +1612,7 @@ partial class GraphicsDeviceExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
using UploadTexture2D<T> upload = WICHelper.Instance.LoadTexture<T>(device, filename);
|
||||
|
||||
@@ -1636,7 +1635,7 @@ partial class GraphicsDeviceExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
using UploadTexture2D<T> upload = WICHelper.Instance.LoadTexture<T>(device, span);
|
||||
|
||||
@@ -1659,8 +1658,8 @@ partial class GraphicsDeviceExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(stream);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(stream);
|
||||
|
||||
using UploadTexture2D<T> upload = WICHelper.Instance.LoadTexture<T>(device, stream);
|
||||
|
||||
@@ -1683,8 +1682,8 @@ partial class GraphicsDeviceExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(filename);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(filename);
|
||||
|
||||
return device.LoadReadWriteTexture2D<T, TPixel>(filename.AsSpan());
|
||||
}
|
||||
@@ -1701,7 +1700,7 @@ partial class GraphicsDeviceExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
using UploadTexture2D<T> upload = WICHelper.Instance.LoadTexture<T>(device, filename);
|
||||
|
||||
@@ -1724,7 +1723,7 @@ partial class GraphicsDeviceExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
using UploadTexture2D<T> upload = WICHelper.Instance.LoadTexture<T>(device, span);
|
||||
|
||||
@@ -1747,8 +1746,8 @@ partial class GraphicsDeviceExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(stream);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(stream);
|
||||
|
||||
using UploadTexture2D<T> upload = WICHelper.Instance.LoadTexture<T>(device, stream);
|
||||
|
||||
@@ -1769,8 +1768,8 @@ partial class GraphicsDeviceExtensions
|
||||
public static UploadTexture2D<T> LoadUploadTexture2D<T>(this GraphicsDevice device, string filename)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(filename);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(filename);
|
||||
|
||||
return device.LoadUploadTexture2D<T>(filename.AsSpan());
|
||||
}
|
||||
@@ -1785,7 +1784,7 @@ partial class GraphicsDeviceExtensions
|
||||
public static UploadTexture2D<T> LoadUploadTexture2D<T>(this GraphicsDevice device, ReadOnlySpan<char> filename)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
return WICHelper.Instance.LoadTexture<T>(device, filename);
|
||||
}
|
||||
@@ -1800,7 +1799,7 @@ partial class GraphicsDeviceExtensions
|
||||
public static UploadTexture2D<T> LoadUploadTexture2D<T>(this GraphicsDevice device, ReadOnlySpan<byte> span)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
return WICHelper.Instance.LoadTexture<T>(device, span);
|
||||
}
|
||||
@@ -1815,8 +1814,8 @@ partial class GraphicsDeviceExtensions
|
||||
public static UploadTexture2D<T> LoadUploadTexture2D<T>(this GraphicsDevice device, Stream stream)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(stream);
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
default(ArgumentNullException).ThrowIfNull(stream);
|
||||
|
||||
return WICHelper.Instance.LoadTexture<T>(device, stream);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#if NET6_0_OR_GREATER
|
||||
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using System;
|
||||
using ComputeSharp.Core.Extensions;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
@@ -66,7 +66,7 @@ internal static unsafe class AllocatorExtensions
|
||||
ResourceType.ReadWrite => (D3D12_HEAP_TYPE_DEFAULT, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COMMON),
|
||||
ResourceType.ReadBack => (D3D12_HEAP_TYPE_READBACK, D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_COPY_DEST),
|
||||
ResourceType.Upload => (D3D12_HEAP_TYPE_UPLOAD, D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_GENERIC_READ),
|
||||
_ => ThrowHelper.ThrowArgumentException<(D3D12_HEAP_TYPE, D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>()
|
||||
_ => default(ArgumentException).Throw<(D3D12_HEAP_TYPE, D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>(nameof(resourceType))
|
||||
};
|
||||
|
||||
using ComPtr<D3D12MA_Allocation> allocation = default;
|
||||
@@ -117,7 +117,7 @@ internal static unsafe class AllocatorExtensions
|
||||
{
|
||||
ResourceType.ReadOnly => (D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_COMMON),
|
||||
ResourceType.ReadWrite => (D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_UNORDERED_ACCESS),
|
||||
_ => ThrowHelper.ThrowArgumentException<(D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>()
|
||||
_ => default(ArgumentException).Throw<(D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>(nameof(resourceType))
|
||||
};
|
||||
|
||||
using ComPtr<D3D12MA_Allocation> allocation = default;
|
||||
@@ -170,7 +170,7 @@ internal static unsafe class AllocatorExtensions
|
||||
{
|
||||
ResourceType.ReadOnly => (D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_COMMON),
|
||||
ResourceType.ReadWrite => (D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_UNORDERED_ACCESS),
|
||||
_ => ThrowHelper.ThrowArgumentException<(D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>()
|
||||
_ => default(ArgumentException).Throw<(D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>(nameof(resourceType))
|
||||
};
|
||||
|
||||
using ComPtr<D3D12MA_Allocation> allocation = default;
|
||||
@@ -225,7 +225,7 @@ internal static unsafe class AllocatorExtensions
|
||||
{
|
||||
ResourceType.ReadOnly => (D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_COMMON),
|
||||
ResourceType.ReadWrite => (D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_UNORDERED_ACCESS),
|
||||
_ => ThrowHelper.ThrowArgumentException<(D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>()
|
||||
_ => default(ArgumentException).Throw<(D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>(nameof(resourceType))
|
||||
};
|
||||
|
||||
using ComPtr<D3D12MA_Allocation> allocation = default;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
@@ -38,10 +37,7 @@ internal static class HRESULTExtensions
|
||||
// single branch can then be inlined without bloating the code size in the caller.
|
||||
if (!Configuration.IsDebugOutputEnabled)
|
||||
{
|
||||
if (result < 0)
|
||||
{
|
||||
ThrowHelper.ThrowWin32Exception(result);
|
||||
}
|
||||
default(Win32Exception).ThrowIfFailed(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -51,15 +47,11 @@ internal static class HRESULTExtensions
|
||||
{
|
||||
bool hasErrorsOrWarnings = DeviceHelper.FlushAllID3D12InfoQueueMessagesAndCheckForErrorsOrWarnings();
|
||||
|
||||
if (result < 0)
|
||||
{
|
||||
ThrowHelper.ThrowWin32Exception(result);
|
||||
}
|
||||
// First, check whether the current call has failed, and report that
|
||||
default(Win32Exception).ThrowIfFailed(result);
|
||||
|
||||
if (hasErrorsOrWarnings)
|
||||
{
|
||||
ThrowHelper.ThrowWin32Exception("Warning or error detected by ID3D12InfoQueue.");
|
||||
}
|
||||
// If that's not the case, then throw if any errors are present in the info queue
|
||||
default(Win32Exception).ThrowIf(hasErrorsOrWarnings, E.E_FAIL);
|
||||
}
|
||||
|
||||
AssertWithDebugInfo(result);
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using System;
|
||||
#if NET6_0_OR_GREATER
|
||||
using System.Runtime.CompilerServices;
|
||||
#else
|
||||
using CommunityToolkit.Diagnostics;
|
||||
#endif
|
||||
using ComputeSharp.Core.Extensions;
|
||||
#if !NET6_0_OR_GREATER
|
||||
@@ -82,7 +80,7 @@ internal static unsafe class ID3D12DeviceExtensions
|
||||
ResourceType.ReadWrite => (D3D12_HEAP_TYPE_DEFAULT, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COMMON),
|
||||
ResourceType.ReadBack => (D3D12_HEAP_TYPE_READBACK, D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_COPY_DEST),
|
||||
ResourceType.Upload => (D3D12_HEAP_TYPE_UPLOAD, D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_GENERIC_READ),
|
||||
_ => ThrowHelper.ThrowArgumentException<(D3D12_HEAP_TYPE, D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>()
|
||||
_ => default(ArgumentException).Throw<(D3D12_HEAP_TYPE, D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>(nameof(resourceType))
|
||||
};
|
||||
|
||||
using ComPtr<ID3D12Resource> d3D12Resource = default;
|
||||
@@ -142,7 +140,7 @@ internal static unsafe class ID3D12DeviceExtensions
|
||||
{
|
||||
ResourceType.ReadOnly => (D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_COMMON),
|
||||
ResourceType.ReadWrite => (D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_UNORDERED_ACCESS),
|
||||
_ => ThrowHelper.ThrowArgumentException<(D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>()
|
||||
_ => default(ArgumentException).Throw<(D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>(nameof(resourceType))
|
||||
};
|
||||
|
||||
using ComPtr<ID3D12Resource> d3D12Resource = default;
|
||||
@@ -204,7 +202,7 @@ internal static unsafe class ID3D12DeviceExtensions
|
||||
{
|
||||
ResourceType.ReadOnly => (D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_COMMON),
|
||||
ResourceType.ReadWrite => (D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_UNORDERED_ACCESS),
|
||||
_ => ThrowHelper.ThrowArgumentException<(D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>()
|
||||
_ => default(ArgumentException).Throw<(D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>(nameof(resourceType))
|
||||
};
|
||||
|
||||
using ComPtr<ID3D12Resource> d3D12Resource = default;
|
||||
@@ -268,7 +266,7 @@ internal static unsafe class ID3D12DeviceExtensions
|
||||
{
|
||||
ResourceType.ReadOnly => (D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_COMMON),
|
||||
ResourceType.ReadWrite => (D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_UNORDERED_ACCESS),
|
||||
_ => ThrowHelper.ThrowArgumentException<(D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>()
|
||||
_ => default(ArgumentException).Throw<(D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>(nameof(resourceType))
|
||||
};
|
||||
|
||||
using ComPtr<ID3D12Resource> d3D12Resource = default;
|
||||
|
||||
@@ -4,7 +4,6 @@ using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
#if NET6_0_OR_GREATER
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using TerraFX.Interop;
|
||||
#endif
|
||||
using TerraFX.Interop.Windows;
|
||||
@@ -49,7 +48,7 @@ unsafe partial class IWICStreamExtensions
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <inheritdoc/>
|
||||
static Guid* INativeGuid.NativeGuid => (Guid*)ThrowHelper.ThrowNotSupportedException<nint>();
|
||||
static Guid* INativeGuid.NativeGuid => (Guid*)default(NotSupportedException).Throw<nint>();
|
||||
#else
|
||||
/// <inheritdoc cref="QueryInterface"/>
|
||||
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
#if NET6_0_OR_GREATER
|
||||
using TerraFX.Interop;
|
||||
#endif
|
||||
@@ -51,7 +50,7 @@ internal static unsafe partial class IWICStreamExtensions
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <inheritdoc/>
|
||||
static Guid* INativeGuid.NativeGuid => (Guid*)ThrowHelper.ThrowNotSupportedException<nint>();
|
||||
static Guid* INativeGuid.NativeGuid => (Guid*)default(NotSupportedException).Throw<nint>();
|
||||
#else
|
||||
/// <inheritdoc cref="QueryInterface"/>
|
||||
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
|
||||
@@ -571,7 +570,7 @@ internal static unsafe partial class IWICStreamExtensions
|
||||
}
|
||||
else
|
||||
{
|
||||
ThrowHelper.ThrowNotSupportedException();
|
||||
default(NotSupportedException).Throw();
|
||||
}
|
||||
|
||||
pstatstg->type = (uint)STGTY_STREAM;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using System;
|
||||
using ComputeSharp.Resources;
|
||||
|
||||
namespace ComputeSharp;
|
||||
@@ -17,8 +17,8 @@ public static class ReadBackBufferExtensions
|
||||
public static void CopyFrom<T>(this ReadBackBuffer<T> destination, StructuredBuffer<T> source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
source.CopyTo(destination, 0, 0, source.Length);
|
||||
}
|
||||
@@ -35,8 +35,8 @@ public static class ReadBackBufferExtensions
|
||||
public static void CopyFrom<T>(this ReadBackBuffer<T> destination, StructuredBuffer<T> source, int sourceOffset, int destinationOffset, int count)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
source.CopyTo(destination, sourceOffset, destinationOffset, count);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using System;
|
||||
using ComputeSharp.Resources;
|
||||
|
||||
namespace ComputeSharp;
|
||||
@@ -17,8 +17,8 @@ public static class ReadBackTexture1DExtensions
|
||||
public static void CopyFrom<T>(this ReadBackTexture1D<T> destination, Texture1D<T> source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
source.CopyTo(destination, 0, 0, source.Width);
|
||||
}
|
||||
@@ -34,8 +34,8 @@ public static class ReadBackTexture1DExtensions
|
||||
public static void CopyFrom<T>(this ReadBackTexture1D<T> destination, Texture1D<T> source, int sourceOffsetX, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
source.CopyTo(destination, sourceOffsetX, 0, width);
|
||||
}
|
||||
@@ -52,8 +52,8 @@ public static class ReadBackTexture1DExtensions
|
||||
public static void CopyFrom<T>(this ReadBackTexture1D<T> destination, Texture1D<T> source, int sourceOffsetX, int destinationOffsetX, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
source.CopyTo(destination, sourceOffsetX, destinationOffsetX, width);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.IO;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
using ComputeSharp.Resources;
|
||||
|
||||
@@ -21,8 +20,8 @@ public static class ReadBackTexture2DExtensions
|
||||
public static void CopyFrom<T>(this ReadBackTexture2D<T> destination, Texture2D<T> source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
source.CopyTo(destination, 0, 0, 0, 0, source.Width, source.Height);
|
||||
}
|
||||
@@ -40,8 +39,8 @@ public static class ReadBackTexture2DExtensions
|
||||
public static void CopyFrom<T>(this ReadBackTexture2D<T> destination, Texture2D<T> source, int sourceOffsetX, int sourceOffsetY, int width, int height)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
source.CopyTo(destination, sourceOffsetX, sourceOffsetY, 0, 0, width, height);
|
||||
}
|
||||
@@ -61,8 +60,8 @@ public static class ReadBackTexture2DExtensions
|
||||
public static void CopyFrom<T>(this ReadBackTexture2D<T> destination, Texture2D<T> source, int sourceOffsetX, int sourceOffsetY, int destinationOffsetX, int destinationOffsetY, int width, int height)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
source.CopyTo(destination, sourceOffsetX, sourceOffsetY, destinationOffsetX, destinationOffsetY, width, height);
|
||||
}
|
||||
@@ -76,8 +75,8 @@ public static class ReadBackTexture2DExtensions
|
||||
public static void Save<T>(this ReadBackTexture2D<T> texture, string filename)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
Guard.IsNotNull(filename);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(filename);
|
||||
|
||||
WICHelper.Instance.SaveTexture(texture.View, filename.AsSpan());
|
||||
}
|
||||
@@ -91,7 +90,7 @@ public static class ReadBackTexture2DExtensions
|
||||
public static void Save<T>(this ReadBackTexture2D<T> texture, ReadOnlySpan<char> filename)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
WICHelper.Instance.SaveTexture(texture.View, filename);
|
||||
}
|
||||
@@ -106,8 +105,8 @@ public static class ReadBackTexture2DExtensions
|
||||
public static void Save<T>(this ReadBackTexture2D<T> texture, Stream stream, ImageFormat format)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
Guard.IsNotNull(stream);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(stream);
|
||||
|
||||
WICHelper.Instance.SaveTexture(texture.View, stream, format);
|
||||
}
|
||||
@@ -122,8 +121,8 @@ public static class ReadBackTexture2DExtensions
|
||||
public static void Save<T>(this ReadBackTexture2D<T> texture, IBufferWriter<byte> writer, ImageFormat format)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
Guard.IsNotNull(writer);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(writer);
|
||||
|
||||
WICHelper.Instance.SaveTexture(texture.View, writer, format);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using System;
|
||||
using ComputeSharp.Resources;
|
||||
|
||||
namespace ComputeSharp;
|
||||
@@ -17,8 +17,8 @@ public static class ReadBackTexture3DExtensions
|
||||
public static void CopyFrom<T>(this ReadBackTexture3D<T> destination, Texture3D<T> source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
source.CopyTo(destination, 0, 0, 0, 0, 0, 0, source.Width, source.Height, source.Depth);
|
||||
}
|
||||
@@ -38,8 +38,8 @@ public static class ReadBackTexture3DExtensions
|
||||
public static void CopyFrom<T>(this ReadBackTexture3D<T> destination, Texture3D<T> source, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int width, int height, int depth)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
source.CopyTo(destination, sourceOffsetX, sourceOffsetY, sourceOffsetZ, 0, 0, 0, width, height, depth);
|
||||
}
|
||||
@@ -62,8 +62,8 @@ public static class ReadBackTexture3DExtensions
|
||||
public static void CopyFrom<T>(this ReadBackTexture3D<T> destination, Texture3D<T> source, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
source.CopyTo(destination, sourceOffsetX, sourceOffsetY, sourceOffsetZ, destinationOffsetX, destinationOffsetY, destinationOffsetZ, width, height, depth);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
@@ -29,7 +28,7 @@ public static class ReadWriteTexture1DExtensions
|
||||
/// <exception cref="InvalidOperationException">Thrown if the current instance is not in a readonly state.</exception>
|
||||
public static IReadOnlyTexture1D<float> AsReadOnly(this ReadWriteTexture1D<float> texture)
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
return texture.AsReadOnly();
|
||||
}
|
||||
@@ -55,7 +54,7 @@ public static class ReadWriteTexture1DExtensions
|
||||
/// <exception cref="InvalidOperationException">Thrown if the current instance is not in a readonly state.</exception>
|
||||
public static IReadOnlyTexture1D<Float2> AsReadOnly(this ReadWriteTexture1D<Float2> texture)
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
return texture.AsReadOnly();
|
||||
}
|
||||
@@ -81,7 +80,7 @@ public static class ReadWriteTexture1DExtensions
|
||||
/// <exception cref="InvalidOperationException">Thrown if the current instance is not in a readonly state.</exception>
|
||||
public static IReadOnlyTexture1D<Float3> AsReadOnly(this ReadWriteTexture1D<Float3> texture)
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
return texture.AsReadOnly();
|
||||
}
|
||||
@@ -107,7 +106,7 @@ public static class ReadWriteTexture1DExtensions
|
||||
/// <exception cref="InvalidOperationException">Thrown if the current instance is not in a readonly state.</exception>
|
||||
public static IReadOnlyTexture1D<Float4> AsReadOnly(this ReadWriteTexture1D<Float4> texture)
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
return texture.AsReadOnly();
|
||||
}
|
||||
@@ -137,7 +136,7 @@ public static class ReadWriteTexture1DExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
return texture.AsReadOnly();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
@@ -29,7 +28,7 @@ public static class ReadWriteTexture2DExtensions
|
||||
/// <exception cref="InvalidOperationException">Thrown if the current instance is not in a readonly state.</exception>
|
||||
public static IReadOnlyTexture2D<float> AsReadOnly(this ReadWriteTexture2D<float> texture)
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
return texture.AsReadOnly();
|
||||
}
|
||||
@@ -55,7 +54,7 @@ public static class ReadWriteTexture2DExtensions
|
||||
/// <exception cref="InvalidOperationException">Thrown if the current instance is not in a readonly state.</exception>
|
||||
public static IReadOnlyTexture2D<Float2> AsReadOnly(this ReadWriteTexture2D<Float2> texture)
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
return texture.AsReadOnly();
|
||||
}
|
||||
@@ -81,7 +80,7 @@ public static class ReadWriteTexture2DExtensions
|
||||
/// <exception cref="InvalidOperationException">Thrown if the current instance is not in a readonly state.</exception>
|
||||
public static IReadOnlyTexture2D<Float3> AsReadOnly(this ReadWriteTexture2D<Float3> texture)
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
return texture.AsReadOnly();
|
||||
}
|
||||
@@ -107,7 +106,7 @@ public static class ReadWriteTexture2DExtensions
|
||||
/// <exception cref="InvalidOperationException">Thrown if the current instance is not in a readonly state.</exception>
|
||||
public static IReadOnlyTexture2D<Float4> AsReadOnly(this ReadWriteTexture2D<Float4> texture)
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
return texture.AsReadOnly();
|
||||
}
|
||||
@@ -137,7 +136,7 @@ public static class ReadWriteTexture2DExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
return texture.AsReadOnly();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
@@ -29,7 +28,7 @@ public static class ReadWriteTexture3DExtensions
|
||||
/// <exception cref="InvalidOperationException">Thrown if the current instance is not in a readonly state.</exception>
|
||||
public static IReadOnlyTexture3D<float> AsReadOnly(this ReadWriteTexture3D<float> texture)
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
return texture.AsReadOnly();
|
||||
}
|
||||
@@ -55,7 +54,7 @@ public static class ReadWriteTexture3DExtensions
|
||||
/// <exception cref="InvalidOperationException">Thrown if the current instance is not in a readonly state.</exception>
|
||||
public static IReadOnlyTexture3D<Float2> AsReadOnly(this ReadWriteTexture3D<Float2> texture)
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
return texture.AsReadOnly();
|
||||
}
|
||||
@@ -81,7 +80,7 @@ public static class ReadWriteTexture3DExtensions
|
||||
/// <exception cref="InvalidOperationException">Thrown if the current instance is not in a readonly state.</exception>
|
||||
public static IReadOnlyTexture3D<Float3> AsReadOnly(this ReadWriteTexture3D<Float3> texture)
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
return texture.AsReadOnly();
|
||||
}
|
||||
@@ -107,7 +106,7 @@ public static class ReadWriteTexture3DExtensions
|
||||
/// <exception cref="InvalidOperationException">Thrown if the current instance is not in a readonly state.</exception>
|
||||
public static IReadOnlyTexture3D<Float4> AsReadOnly(this ReadWriteTexture3D<Float4> texture)
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
return texture.AsReadOnly();
|
||||
}
|
||||
@@ -137,7 +136,7 @@ public static class ReadWriteTexture3DExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
return texture.AsReadOnly();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using System;
|
||||
using ComputeSharp.Resources;
|
||||
|
||||
namespace ComputeSharp;
|
||||
@@ -17,8 +17,8 @@ public static class StructuredBufferExtensions
|
||||
public static void CopyTo<T>(this StructuredBuffer<T> source, ReadBackBuffer<T> destination)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
source.CopyTo(destination, 0, 0, source.Length);
|
||||
}
|
||||
@@ -35,8 +35,8 @@ public static class StructuredBufferExtensions
|
||||
public static void CopyTo<T>(this StructuredBuffer<T> source, ReadBackBuffer<T> destination, int sourceOffset, int destinationOffset, int count)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
source.CopyTo(destination, sourceOffset, destinationOffset, count);
|
||||
}
|
||||
@@ -50,8 +50,8 @@ public static class StructuredBufferExtensions
|
||||
public static void CopyFrom<T>(this StructuredBuffer<T> destination, UploadBuffer<T> source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
source.CopyTo(destination, 0, 0, source.Length);
|
||||
}
|
||||
@@ -68,8 +68,8 @@ public static class StructuredBufferExtensions
|
||||
public static void CopyFrom<T>(this StructuredBuffer<T> destination, UploadBuffer<T> source, int sourceOffset, int destinationOffset, int count)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
source.CopyTo(destination, sourceOffset, destinationOffset, count);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using ComputeSharp.Resources;
|
||||
|
||||
namespace ComputeSharp;
|
||||
@@ -19,7 +18,7 @@ public static class Texture1DExtensions
|
||||
public static T[] ToArray<T>(this Texture1D<T> source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
T[] data = new T[source.Width];
|
||||
|
||||
@@ -39,8 +38,8 @@ public static class Texture1DExtensions
|
||||
public static unsafe T[] ToArray<T>(this Texture1D<T> source, int x, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsGreaterThanOrEqualTo(width, 0);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNegative(width);
|
||||
|
||||
T[] data = new T[width];
|
||||
|
||||
@@ -61,8 +60,8 @@ public static class Texture1DExtensions
|
||||
public static void CopyTo<T>(this Texture1D<T> source, T[] destination)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
source.CopyTo(destination.AsSpan(), 0, source.Width);
|
||||
}
|
||||
@@ -78,8 +77,8 @@ public static class Texture1DExtensions
|
||||
public static void CopyTo<T>(this Texture1D<T> source, T[] destination, Range x)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
source.CopyTo(destination.AsSpan(), x);
|
||||
}
|
||||
@@ -96,8 +95,8 @@ public static class Texture1DExtensions
|
||||
public static void CopyTo<T>(this Texture1D<T> source, T[] destination, int sourceOffsetX, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
source.CopyTo(destination.AsSpan(), sourceOffsetX, width);
|
||||
}
|
||||
@@ -112,8 +111,8 @@ public static class Texture1DExtensions
|
||||
public static void CopyTo<T>(this Texture1D<T> source, T[] destination, int destinationOffset)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
source.CopyTo(destination.AsSpan(destinationOffset), 0, source.Width);
|
||||
}
|
||||
@@ -130,8 +129,8 @@ public static class Texture1DExtensions
|
||||
public static void CopyTo<T>(this Texture1D<T> source, T[] destination, int destinationOffset, Range x)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
source.CopyTo(destination.AsSpan(destinationOffset), x);
|
||||
}
|
||||
@@ -149,8 +148,8 @@ public static class Texture1DExtensions
|
||||
public static void CopyTo<T>(this Texture1D<T> source, T[] destination, int destinationOffset, int sourceOffsetX, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
source.CopyTo(destination.AsSpan(destinationOffset), sourceOffsetX, width);
|
||||
}
|
||||
@@ -165,7 +164,7 @@ public static class Texture1DExtensions
|
||||
public static void CopyTo<T>(this Texture1D<T> source, Span<T> destination)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
source.CopyTo(destination, 0, source.Width);
|
||||
}
|
||||
@@ -181,7 +180,7 @@ public static class Texture1DExtensions
|
||||
public static void CopyTo<T>(this Texture1D<T> source, Span<T> destination, Range x)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
(int offsetX, int width) = x.GetOffsetAndLength(source.Width);
|
||||
|
||||
@@ -200,7 +199,7 @@ public static class Texture1DExtensions
|
||||
public static void CopyTo<T>(this Texture1D<T> source, Span<T> destination, int sourceOffsetX, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
source.CopyTo(ref MemoryMarshal.GetReference(destination), destination.Length, sourceOffsetX, width);
|
||||
}
|
||||
@@ -214,8 +213,8 @@ public static class Texture1DExtensions
|
||||
public static void CopyTo<T>(this Texture1D<T> source, Texture1D<T> destination)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
source.CopyTo(destination, 0, 0, source.Width);
|
||||
}
|
||||
@@ -231,8 +230,8 @@ public static class Texture1DExtensions
|
||||
public static void CopyTo<T>(this Texture1D<T> source, Texture1D<T> destination, int sourceOffsetX, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
source.CopyTo(destination, sourceOffsetX, 0, width);
|
||||
}
|
||||
@@ -249,8 +248,8 @@ public static class Texture1DExtensions
|
||||
public static void CopyTo<T>(this Texture1D<T> source, Texture1D<T> destination, int sourceOffsetX, int destinationOffsetX, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
source.CopyTo(destination, sourceOffsetX, destinationOffsetX, width);
|
||||
}
|
||||
@@ -264,8 +263,8 @@ public static class Texture1DExtensions
|
||||
public static void CopyTo<T>(this Texture1D<T> source, ReadBackTexture1D<T> destination)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
source.CopyTo(destination, 0, 0, source.Width);
|
||||
}
|
||||
@@ -281,8 +280,8 @@ public static class Texture1DExtensions
|
||||
public static void CopyTo<T>(this Texture1D<T> source, ReadBackTexture1D<T> destination, int sourceOffsetX, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
source.CopyTo(destination, sourceOffsetX, 0, width);
|
||||
}
|
||||
@@ -299,8 +298,8 @@ public static class Texture1DExtensions
|
||||
public static void CopyTo<T>(this Texture1D<T> source, ReadBackTexture1D<T> destination, int sourceOffsetX, int destinationOffsetX, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
source.CopyTo(destination, sourceOffsetX, destinationOffsetX, width);
|
||||
}
|
||||
@@ -314,8 +313,8 @@ public static class Texture1DExtensions
|
||||
public static void CopyFrom<T>(this Texture1D<T> destination, T[] source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
destination.CopyFrom(source.AsSpan(), 0, destination.Width);
|
||||
}
|
||||
@@ -331,8 +330,8 @@ public static class Texture1DExtensions
|
||||
public static void CopyFrom<T>(this Texture1D<T> destination, T[] source, Range x)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
destination.CopyFrom(source.AsSpan(), x);
|
||||
}
|
||||
@@ -349,8 +348,8 @@ public static class Texture1DExtensions
|
||||
public static void CopyFrom<T>(this Texture1D<T> destination, T[] source, int destinationOffsetX, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
destination.CopyFrom(source.AsSpan(), destinationOffsetX, width);
|
||||
}
|
||||
@@ -367,8 +366,8 @@ public static class Texture1DExtensions
|
||||
public static void CopyFrom<T>(this Texture1D<T> destination, T[] source, int sourceOffset, Range x)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
destination.CopyFrom(source.AsSpan(sourceOffset), x);
|
||||
}
|
||||
@@ -386,8 +385,8 @@ public static class Texture1DExtensions
|
||||
public static void CopyFrom<T>(this Texture1D<T> destination, T[] source, int sourceOffset, int destinationOffsetX, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
destination.CopyFrom(source.AsSpan(sourceOffset), destinationOffsetX, width);
|
||||
}
|
||||
@@ -402,7 +401,7 @@ public static class Texture1DExtensions
|
||||
public static void CopyFrom<T>(this Texture1D<T> destination, ReadOnlySpan<T> source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
destination.CopyFrom(source, 0, destination.Width);
|
||||
}
|
||||
@@ -418,7 +417,7 @@ public static class Texture1DExtensions
|
||||
public static void CopyFrom<T>(this Texture1D<T> destination, ReadOnlySpan<T> source, Range x)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
(int offsetX, int width) = x.GetOffsetAndLength(destination.Width);
|
||||
|
||||
@@ -437,7 +436,7 @@ public static class Texture1DExtensions
|
||||
public static void CopyFrom<T>(this Texture1D<T> destination, ReadOnlySpan<T> source, int destinationOffsetX, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
destination.CopyFrom(ref MemoryMarshal.GetReference(source), source.Length, destinationOffsetX, width);
|
||||
}
|
||||
@@ -451,8 +450,8 @@ public static class Texture1DExtensions
|
||||
public static void CopyFrom<T>(this Texture1D<T> destination, Texture1D<T> source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
destination.CopyFrom(source, 0, 0, source.Width);
|
||||
}
|
||||
@@ -468,8 +467,8 @@ public static class Texture1DExtensions
|
||||
public static void CopyFrom<T>(this Texture1D<T> destination, Texture1D<T> source, int sourceOffsetX, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
source.CopyTo(destination, sourceOffsetX, 0, width);
|
||||
}
|
||||
@@ -486,8 +485,8 @@ public static class Texture1DExtensions
|
||||
public static void CopyFrom<T>(this Texture1D<T> destination, Texture1D<T> source, int sourceOffsetX, int destinationOffsetX, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
source.CopyTo(destination, sourceOffsetX, destinationOffsetX, width);
|
||||
}
|
||||
@@ -501,8 +500,8 @@ public static class Texture1DExtensions
|
||||
public static void CopyFrom<T>(this Texture1D<T> destination, UploadTexture1D<T> source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
source.CopyTo(destination, 0, 0, source.Width);
|
||||
}
|
||||
@@ -518,8 +517,8 @@ public static class Texture1DExtensions
|
||||
public static void CopyFrom<T>(this Texture1D<T> destination, UploadTexture1D<T> source, int sourceOffsetX, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
destination.CopyFrom(source, sourceOffsetX, 0, width);
|
||||
}
|
||||
@@ -536,8 +535,8 @@ public static class Texture1DExtensions
|
||||
public static void CopyFrom<T>(this Texture1D<T> destination, UploadTexture1D<T> source, int sourceOffsetX, int destinationOffsetX, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
destination.CopyFrom(source, sourceOffsetX, destinationOffsetX, width);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ using System;
|
||||
using System.Buffers;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
using ComputeSharp.Resources;
|
||||
|
||||
@@ -22,7 +21,7 @@ public static class Texture2DExtensions
|
||||
public static T[,] ToArray<T>(this Texture2D<T> source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
T[,] data = new T[source.Height, source.Width];
|
||||
|
||||
@@ -44,9 +43,9 @@ public static class Texture2DExtensions
|
||||
public static unsafe T[,] ToArray<T>(this Texture2D<T> source, int x, int y, int width, int height)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsGreaterThanOrEqualTo(width, 0);
|
||||
Guard.IsGreaterThanOrEqualTo(height, 0);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNegative(width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNegative(height);
|
||||
|
||||
T[,] data = new T[height, width];
|
||||
|
||||
@@ -67,10 +66,10 @@ public static class Texture2DExtensions
|
||||
public static void CopyTo<T>(this Texture2D<T> source, T[,] destination)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsEqualTo(destination.GetLength(0), source.Height, nameof(destination));
|
||||
Guard.IsEqualTo(destination.GetLength(1), source.Width, nameof(destination));
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentException).ThrowIf(destination.GetLength(0) != source.Height, nameof(destination));
|
||||
default(ArgumentException).ThrowIf(destination.GetLength(1) != source.Width, nameof(destination));
|
||||
|
||||
source.CopyTo(ref destination[0, 0], destination.Length, 0, 0, source.Width, source.Height);
|
||||
}
|
||||
@@ -84,8 +83,8 @@ public static class Texture2DExtensions
|
||||
public static void CopyTo<T>(this Texture2D<T> source, T[] destination)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
source.CopyTo(destination.AsSpan(), 0, 0, source.Width, source.Height);
|
||||
}
|
||||
@@ -102,8 +101,8 @@ public static class Texture2DExtensions
|
||||
public static void CopyTo<T>(this Texture2D<T> source, T[] destination, Range x, Range y)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
source.CopyTo(destination.AsSpan(), x, y);
|
||||
}
|
||||
@@ -122,8 +121,8 @@ public static class Texture2DExtensions
|
||||
public static void CopyTo<T>(this Texture2D<T> source, T[] destination, int sourceOffsetX, int sourceOffsetY, int width, int height)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
source.CopyTo(destination.AsSpan(), sourceOffsetX, sourceOffsetY, width, height);
|
||||
}
|
||||
@@ -138,8 +137,8 @@ public static class Texture2DExtensions
|
||||
public static void CopyTo<T>(this Texture2D<T> source, T[] destination, int destinationOffset)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
source.CopyTo(destination.AsSpan(destinationOffset), 0, 0, source.Width, source.Height);
|
||||
}
|
||||
@@ -157,8 +156,8 @@ public static class Texture2DExtensions
|
||||
public static void CopyTo<T>(this Texture2D<T> source, T[] destination, int destinationOffset, Range x, Range y)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
source.CopyTo(destination.AsSpan(destinationOffset), x, y);
|
||||
}
|
||||
@@ -178,8 +177,8 @@ public static class Texture2DExtensions
|
||||
public static void CopyTo<T>(this Texture2D<T> source, T[] destination, int destinationOffset, int sourceOffsetX, int sourceOffsetY, int width, int height)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
source.CopyTo(destination.AsSpan(destinationOffset), sourceOffsetX, sourceOffsetY, width, height);
|
||||
}
|
||||
@@ -194,7 +193,7 @@ public static class Texture2DExtensions
|
||||
public static void CopyTo<T>(this Texture2D<T> source, Span<T> destination)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
source.CopyTo(destination, 0, 0, source.Width, source.Height);
|
||||
}
|
||||
@@ -211,7 +210,7 @@ public static class Texture2DExtensions
|
||||
public static void CopyTo<T>(this Texture2D<T> source, Span<T> destination, Range x, Range y)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
(int offsetX, int width) = x.GetOffsetAndLength(source.Width);
|
||||
(int offsetY, int height) = y.GetOffsetAndLength(source.Height);
|
||||
@@ -233,7 +232,7 @@ public static class Texture2DExtensions
|
||||
public static void CopyTo<T>(this Texture2D<T> source, Span<T> destination, int sourceOffsetX, int sourceOffsetY, int width, int height)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
source.CopyTo(ref MemoryMarshal.GetReference(destination), destination.Length, sourceOffsetX, sourceOffsetY, width, height);
|
||||
}
|
||||
@@ -247,8 +246,8 @@ public static class Texture2DExtensions
|
||||
public static void CopyTo<T>(this Texture2D<T> source, Texture2D<T> destination)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
source.CopyTo(destination, 0, 0, 0, 0, source.Width, source.Height);
|
||||
}
|
||||
@@ -266,8 +265,8 @@ public static class Texture2DExtensions
|
||||
public static void CopyTo<T>(this Texture2D<T> source, Texture2D<T> destination, int sourceOffsetX, int sourceOffsetY, int width, int height)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
source.CopyTo(destination, sourceOffsetX, sourceOffsetY, 0, 0, width, height);
|
||||
}
|
||||
@@ -287,8 +286,8 @@ public static class Texture2DExtensions
|
||||
public static void CopyTo<T>(this Texture2D<T> source, Texture2D<T> destination, int sourceOffsetX, int sourceOffsetY, int destinationOffsetX, int destinationOffsetY, int width, int height)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
source.CopyTo(destination, sourceOffsetX, sourceOffsetY, destinationOffsetX, destinationOffsetY, width, height);
|
||||
}
|
||||
@@ -302,8 +301,8 @@ public static class Texture2DExtensions
|
||||
public static void CopyTo<T>(this Texture2D<T> source, ReadBackTexture2D<T> destination)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
source.CopyTo(destination, 0, 0, 0, 0, source.Width, source.Height);
|
||||
}
|
||||
@@ -321,8 +320,8 @@ public static class Texture2DExtensions
|
||||
public static void CopyTo<T>(this Texture2D<T> source, ReadBackTexture2D<T> destination, int sourceOffsetX, int sourceOffsetY, int width, int height)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
source.CopyTo(destination, sourceOffsetX, sourceOffsetY, 0, 0, width, height);
|
||||
}
|
||||
@@ -342,8 +341,8 @@ public static class Texture2DExtensions
|
||||
public static void CopyTo<T>(this Texture2D<T> source, ReadBackTexture2D<T> destination, int sourceOffsetX, int sourceOffsetY, int destinationOffsetX, int destinationOffsetY, int width, int height)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
source.CopyTo(destination, sourceOffsetX, sourceOffsetY, destinationOffsetX, destinationOffsetY, width, height);
|
||||
}
|
||||
@@ -357,10 +356,10 @@ public static class Texture2DExtensions
|
||||
public static unsafe void CopyFrom<T>(this Texture2D<T> destination, T[,] source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsEqualTo(source.GetLength(0), destination.Height, nameof(source));
|
||||
Guard.IsEqualTo(source.GetLength(1), destination.Width, nameof(source));
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentException).ThrowIf(source.GetLength(0) != destination.Height, nameof(source));
|
||||
default(ArgumentException).ThrowIf(source.GetLength(1) != destination.Width, nameof(source));
|
||||
|
||||
destination.CopyFrom(ref source[0, 0], source.Length, 0, 0, destination.Width, destination.Height);
|
||||
}
|
||||
@@ -374,8 +373,8 @@ public static class Texture2DExtensions
|
||||
public static void CopyFrom<T>(this Texture2D<T> destination, T[] source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
destination.CopyFrom(source.AsSpan(), 0, 0, destination.Width, destination.Height);
|
||||
}
|
||||
@@ -392,8 +391,8 @@ public static class Texture2DExtensions
|
||||
public static void CopyFrom<T>(this Texture2D<T> destination, T[] source, Range x, Range y)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
destination.CopyFrom(source.AsSpan(), x, y);
|
||||
}
|
||||
@@ -412,8 +411,8 @@ public static class Texture2DExtensions
|
||||
public static void CopyFrom<T>(this Texture2D<T> destination, T[] source, int destinationOffsetX, int destinationOffsetY, int width, int height)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
destination.CopyFrom(source.AsSpan(), destinationOffsetX, destinationOffsetY, width, height);
|
||||
}
|
||||
@@ -431,8 +430,8 @@ public static class Texture2DExtensions
|
||||
public static void CopyFrom<T>(this Texture2D<T> destination, T[] source, int sourceOffset, Range x, Range y)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
destination.CopyFrom(source.AsSpan(sourceOffset), x, y);
|
||||
}
|
||||
@@ -452,8 +451,8 @@ public static class Texture2DExtensions
|
||||
public static void CopyFrom<T>(this Texture2D<T> destination, T[] source, int sourceOffset, int destinationOffsetX, int destinationOffsetY, int width, int height)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
destination.CopyFrom(source.AsSpan(sourceOffset), destinationOffsetX, destinationOffsetY, width, height);
|
||||
}
|
||||
@@ -468,7 +467,7 @@ public static class Texture2DExtensions
|
||||
public static void CopyFrom<T>(this Texture2D<T> destination, ReadOnlySpan<T> source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
destination.CopyFrom(source, 0, 0, destination.Width, destination.Height);
|
||||
}
|
||||
@@ -485,7 +484,7 @@ public static class Texture2DExtensions
|
||||
public static void CopyFrom<T>(this Texture2D<T> destination, ReadOnlySpan<T> source, Range x, Range y)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
(int offsetX, int width) = x.GetOffsetAndLength(destination.Width);
|
||||
(int offsetY, int height) = y.GetOffsetAndLength(destination.Height);
|
||||
@@ -507,7 +506,7 @@ public static class Texture2DExtensions
|
||||
public static void CopyFrom<T>(this Texture2D<T> destination, ReadOnlySpan<T> source, int destinationOffsetX, int destinationOffsetY, int width, int height)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
destination.CopyFrom(ref MemoryMarshal.GetReference(source), source.Length, destinationOffsetX, destinationOffsetY, width, height);
|
||||
}
|
||||
@@ -521,8 +520,8 @@ public static class Texture2DExtensions
|
||||
public static void CopyFrom<T>(this Texture2D<T> destination, Texture2D<T> source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
destination.CopyFrom(source, 0, 0, 0, 0, source.Width, source.Height);
|
||||
}
|
||||
@@ -540,8 +539,8 @@ public static class Texture2DExtensions
|
||||
public static void CopyFrom<T>(this Texture2D<T> destination, Texture2D<T> source, int sourceOffsetX, int sourceOffsetY, int width, int height)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
source.CopyTo(destination, sourceOffsetX, sourceOffsetY, 0, 0, width, height);
|
||||
}
|
||||
@@ -561,8 +560,8 @@ public static class Texture2DExtensions
|
||||
public static void CopyFrom<T>(this Texture2D<T> destination, Texture2D<T> source, int sourceOffsetX, int sourceOffsetY, int destinationOffsetX, int destinationOffsetY, int width, int height)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
source.CopyTo(destination, sourceOffsetX, sourceOffsetY, destinationOffsetX, destinationOffsetY, width, height);
|
||||
}
|
||||
@@ -576,8 +575,8 @@ public static class Texture2DExtensions
|
||||
public static void CopyFrom<T>(this Texture2D<T> destination, UploadTexture2D<T> source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
source.CopyTo(destination, 0, 0, 0, 0, source.Width, source.Height);
|
||||
}
|
||||
@@ -595,8 +594,8 @@ public static class Texture2DExtensions
|
||||
public static void CopyFrom<T>(this Texture2D<T> destination, UploadTexture2D<T> source, int sourceOffsetX, int sourceOffsetY, int width, int height)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
destination.CopyFrom(source, sourceOffsetX, sourceOffsetY, 0, 0, width, height);
|
||||
}
|
||||
@@ -616,8 +615,8 @@ public static class Texture2DExtensions
|
||||
public static void CopyFrom<T>(this Texture2D<T> destination, UploadTexture2D<T> source, int sourceOffsetX, int sourceOffsetY, int destinationOffsetX, int destinationOffsetY, int width, int height)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
destination.CopyFrom(source, sourceOffsetX, sourceOffsetY, destinationOffsetX, destinationOffsetY, width, height);
|
||||
}
|
||||
@@ -631,8 +630,8 @@ public static class Texture2DExtensions
|
||||
public static void Save<T>(this Texture2D<T> texture, string filename)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
Guard.IsNotNull(filename);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(filename);
|
||||
|
||||
texture.Save(filename.AsSpan());
|
||||
}
|
||||
@@ -646,7 +645,7 @@ public static class Texture2DExtensions
|
||||
public static void Save<T>(this Texture2D<T> texture, ReadOnlySpan<char> filename)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
using ReadBackTexture2D<T> readback = texture.GraphicsDevice.AllocateReadBackTexture2D<T>(texture.Width, texture.Height);
|
||||
|
||||
@@ -665,8 +664,8 @@ public static class Texture2DExtensions
|
||||
public static void Save<T>(this Texture2D<T> texture, Stream stream, ImageFormat format)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
Guard.IsNotNull(stream);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(stream);
|
||||
|
||||
using ReadBackTexture2D<T> readback = texture.GraphicsDevice.AllocateReadBackTexture2D<T>(texture.Width, texture.Height);
|
||||
|
||||
@@ -685,8 +684,8 @@ public static class Texture2DExtensions
|
||||
public static void Save<T>(this Texture2D<T> texture, IBufferWriter<byte> writer, ImageFormat format)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
Guard.IsNotNull(writer);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(writer);
|
||||
|
||||
using ReadBackTexture2D<T> readback = texture.GraphicsDevice.AllocateReadBackTexture2D<T>(texture.Width, texture.Height);
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using ComputeSharp.Resources;
|
||||
|
||||
namespace ComputeSharp;
|
||||
@@ -24,7 +23,7 @@ public static class Texture3DExtensions
|
||||
public static T[,,] ToArray<T>(this Texture3D<T> source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
T[,,] data = new T[source.Depth, source.Height, source.Width];
|
||||
|
||||
@@ -48,10 +47,10 @@ public static class Texture3DExtensions
|
||||
public static unsafe T[,,] ToArray<T>(this Texture3D<T> source, int x, int y, int z, int width, int height, int depth)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsGreaterThanOrEqualTo(width, 0);
|
||||
Guard.IsGreaterThanOrEqualTo(height, 0);
|
||||
Guard.IsGreaterThanOrEqualTo(depth, 0);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNegative(width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNegative(height);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNegative(depth);
|
||||
|
||||
T[,,] data = new T[depth, height, width];
|
||||
|
||||
@@ -76,11 +75,11 @@ public static class Texture3DExtensions
|
||||
public static void CopyTo<T>(this Texture3D<T> source, T[,,] destination)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsEqualTo(destination.GetLength(0), source.Depth, nameof(destination));
|
||||
Guard.IsEqualTo(destination.GetLength(1), source.Height, nameof(destination));
|
||||
Guard.IsEqualTo(destination.GetLength(2), source.Width, nameof(destination));
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentException).ThrowIf(destination.GetLength(0) != source.Depth, nameof(destination));
|
||||
default(ArgumentException).ThrowIf(destination.GetLength(1) != source.Height, nameof(destination));
|
||||
default(ArgumentException).ThrowIf(destination.GetLength(2) != source.Width, nameof(destination));
|
||||
|
||||
source.CopyTo(ref destination[0, 0, 0], destination.Length, 0, 0, 0, source.Width, source.Height, source.Depth);
|
||||
}
|
||||
@@ -95,8 +94,8 @@ public static class Texture3DExtensions
|
||||
public static void CopyTo<T>(this Texture3D<T> source, T[] destination, int destinationOffset)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
source.CopyTo(destination.AsSpan(destinationOffset), 0, 0, 0, source.Width, source.Height, source.Depth);
|
||||
}
|
||||
@@ -115,8 +114,8 @@ public static class Texture3DExtensions
|
||||
public static void CopyTo<T>(this Texture3D<T> source, T[] destination, int destinationOffset, Range x, Range y, Range z)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
source.CopyTo(destination.AsSpan(destinationOffset), x, y, z);
|
||||
}
|
||||
@@ -138,8 +137,8 @@ public static class Texture3DExtensions
|
||||
public static void CopyTo<T>(this Texture3D<T> source, T[] destination, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int destinationOffset, int width, int height, int depth)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
source.CopyTo(destination.AsSpan(destinationOffset), sourceOffsetX, sourceOffsetY, sourceOffsetZ, width, height, depth);
|
||||
}
|
||||
@@ -153,7 +152,7 @@ public static class Texture3DExtensions
|
||||
public static void CopyTo<T>(this Texture3D<T> source, Span<T> destination)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
source.CopyTo(destination, 0, 0, 0, source.Width, source.Height, source.Depth);
|
||||
}
|
||||
@@ -171,7 +170,7 @@ public static class Texture3DExtensions
|
||||
public static void CopyTo<T>(this Texture3D<T> source, Span<T> destination, Range x, Range y, Range z)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
(int offsetX, int width) = x.GetOffsetAndLength(source.Width);
|
||||
(int offsetY, int height) = y.GetOffsetAndLength(source.Height);
|
||||
@@ -196,7 +195,7 @@ public static class Texture3DExtensions
|
||||
public static void CopyTo<T>(this Texture3D<T> source, Span<T> destination, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int width, int height, int depth)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
source.CopyTo(ref MemoryMarshal.GetReference(destination), destination.Length, sourceOffsetX, sourceOffsetY, sourceOffsetZ, width, height, depth);
|
||||
}
|
||||
@@ -210,8 +209,8 @@ public static class Texture3DExtensions
|
||||
public static void CopyTo<T>(this Texture3D<T> source, Texture3D<T> destination)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
source.CopyTo(destination, 0, 0, 0, 0, 0, 0, source.Width, source.Height, source.Depth);
|
||||
}
|
||||
@@ -231,8 +230,8 @@ public static class Texture3DExtensions
|
||||
public static void CopyTo<T>(this Texture3D<T> source, Texture3D<T> destination, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int width, int height, int depth)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
source.CopyTo(destination, sourceOffsetX, sourceOffsetY, sourceOffsetZ, 0, 0, 0, width, height, depth);
|
||||
}
|
||||
@@ -255,8 +254,8 @@ public static class Texture3DExtensions
|
||||
public static void CopyTo<T>(this Texture3D<T> source, Texture3D<T> destination, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
source.CopyTo(destination, sourceOffsetX, sourceOffsetY, sourceOffsetZ, destinationOffsetX, destinationOffsetY, destinationOffsetZ, width, height, depth);
|
||||
}
|
||||
@@ -270,8 +269,8 @@ public static class Texture3DExtensions
|
||||
public static void CopyTo<T>(this Texture3D<T> source, ReadBackTexture3D<T> destination)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
source.CopyTo(destination, 0, 0, 0, 0, 0, 0, source.Width, source.Height, source.Depth);
|
||||
}
|
||||
@@ -291,8 +290,8 @@ public static class Texture3DExtensions
|
||||
public static void CopyTo<T>(this Texture3D<T> source, ReadBackTexture3D<T> destination, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int width, int height, int depth)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
source.CopyTo(destination, sourceOffsetX, sourceOffsetY, sourceOffsetZ, 0, 0, 0, width, height, depth);
|
||||
}
|
||||
@@ -315,8 +314,8 @@ public static class Texture3DExtensions
|
||||
public static void CopyTo<T>(this Texture3D<T> source, ReadBackTexture3D<T> destination, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
source.CopyTo(destination, sourceOffsetX, sourceOffsetY, sourceOffsetZ, destinationOffsetX, destinationOffsetY, destinationOffsetZ, width, height, depth);
|
||||
}
|
||||
@@ -334,11 +333,11 @@ public static class Texture3DExtensions
|
||||
public static void CopyFrom<T>(this Texture3D<T> destination, T[,,] source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsEqualTo(source.GetLength(0), destination.Depth, nameof(source));
|
||||
Guard.IsEqualTo(source.GetLength(1), destination.Height, nameof(source));
|
||||
Guard.IsEqualTo(source.GetLength(2), destination.Width, nameof(source));
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentException).ThrowIf(source.GetLength(0) != destination.Depth, nameof(source));
|
||||
default(ArgumentException).ThrowIf(source.GetLength(1) != destination.Height, nameof(source));
|
||||
default(ArgumentException).ThrowIf(source.GetLength(2) != destination.Width, nameof(source));
|
||||
|
||||
destination.CopyFrom(ref source[0, 0, 0], source.Length, 0, 0, 0, destination.Width, destination.Height, destination.Depth);
|
||||
}
|
||||
@@ -352,8 +351,8 @@ public static class Texture3DExtensions
|
||||
public static void CopyFrom<T>(this Texture3D<T> destination, T[] source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
destination.CopyFrom(source.AsSpan(), 0, 0, 0, destination.Width, destination.Height, destination.Depth);
|
||||
}
|
||||
@@ -371,8 +370,8 @@ public static class Texture3DExtensions
|
||||
public static void CopyFrom<T>(this Texture3D<T> destination, T[] source, Range x, Range y, Range z)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
destination.CopyFrom(source.AsSpan(), x, y, z);
|
||||
}
|
||||
@@ -393,8 +392,8 @@ public static class Texture3DExtensions
|
||||
public static void CopyFrom<T>(this Texture3D<T> destination, T[] source, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
destination.CopyFrom(source.AsSpan(), destinationOffsetX, destinationOffsetY, destinationOffsetZ, width, height, depth);
|
||||
}
|
||||
@@ -413,8 +412,8 @@ public static class Texture3DExtensions
|
||||
public static void CopyFrom<T>(this Texture3D<T> destination, T[] source, int sourceOffset, Range x, Range y, Range z)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
destination.CopyFrom(source.AsSpan(sourceOffset), x, y, z);
|
||||
}
|
||||
@@ -436,8 +435,8 @@ public static class Texture3DExtensions
|
||||
public static void CopyFrom<T>(this Texture3D<T> destination, T[] source, int sourceOffset, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
destination.CopyFrom(source.AsSpan(sourceOffset), destinationOffsetX, destinationOffsetY, destinationOffsetZ, width, height, depth);
|
||||
}
|
||||
@@ -452,7 +451,7 @@ public static class Texture3DExtensions
|
||||
public static void CopyFrom<T>(this Texture3D<T> destination, ReadOnlySpan<T> source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
destination.CopyFrom(source, 0, 0, 0, destination.Width, destination.Height, destination.Depth);
|
||||
}
|
||||
@@ -470,7 +469,7 @@ public static class Texture3DExtensions
|
||||
public static void CopyFrom<T>(this Texture3D<T> destination, ReadOnlySpan<T> source, Range x, Range y, Range z)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
(int offsetX, int width) = x.GetOffsetAndLength(destination.Width);
|
||||
(int offsetY, int height) = y.GetOffsetAndLength(destination.Height);
|
||||
@@ -495,7 +494,7 @@ public static class Texture3DExtensions
|
||||
public static void CopyFrom<T>(this Texture3D<T> destination, ReadOnlySpan<T> source, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
destination.CopyFrom(ref MemoryMarshal.GetReference(source), source.Length, destinationOffsetX, destinationOffsetY, destinationOffsetZ, width, height, depth);
|
||||
}
|
||||
@@ -509,8 +508,8 @@ public static class Texture3DExtensions
|
||||
public static void CopyFrom<T>(this Texture3D<T> destination, Texture3D<T> source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
source.CopyTo(destination, 0, 0, 0, 0, 0, 0, source.Width, source.Height, source.Depth);
|
||||
}
|
||||
@@ -530,8 +529,8 @@ public static class Texture3DExtensions
|
||||
public static void CopyFrom<T>(this Texture3D<T> destination, Texture3D<T> source, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int width, int height, int depth)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
source.CopyTo(destination, sourceOffsetX, sourceOffsetY, sourceOffsetZ, 0, 0, 0, width, height, depth);
|
||||
}
|
||||
@@ -554,8 +553,8 @@ public static class Texture3DExtensions
|
||||
public static void CopyFrom<T>(this Texture3D<T> destination, Texture3D<T> source, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
source.CopyTo(destination, sourceOffsetX, sourceOffsetY, sourceOffsetZ, destinationOffsetX, destinationOffsetY, destinationOffsetZ, width, height, depth);
|
||||
}
|
||||
@@ -569,8 +568,8 @@ public static class Texture3DExtensions
|
||||
public static void CopyFrom<T>(this Texture3D<T> destination, UploadTexture3D<T> source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
destination.CopyFrom(source, 0, 0, 0, 0, 0, 0, source.Width, source.Height, source.Depth);
|
||||
}
|
||||
@@ -590,8 +589,8 @@ public static class Texture3DExtensions
|
||||
public static void CopyFrom<T>(this Texture3D<T> destination, UploadTexture3D<T> source, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int width, int height, int depth)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
destination.CopyFrom(source, sourceOffsetX, sourceOffsetY, sourceOffsetZ, 0, 0, 0, width, height, depth);
|
||||
}
|
||||
@@ -614,8 +613,8 @@ public static class Texture3DExtensions
|
||||
public static void CopyFrom<T>(this Texture3D<T> destination, UploadTexture3D<T> source, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
|
||||
destination.CopyFrom(source, sourceOffsetX, sourceOffsetY, sourceOffsetZ, destinationOffsetX, destinationOffsetY, destinationOffsetZ, width, height, depth);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using System;
|
||||
using ComputeSharp.Resources;
|
||||
|
||||
namespace ComputeSharp;
|
||||
@@ -17,8 +17,8 @@ public static class UploadBufferExtensions
|
||||
public static void CopyTo<T>(this UploadBuffer<T> source, StructuredBuffer<T> destination)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
destination.CopyFrom(source, 0, 0, source.Length);
|
||||
}
|
||||
@@ -35,8 +35,8 @@ public static class UploadBufferExtensions
|
||||
public static void CopyTo<T>(this UploadBuffer<T> source, StructuredBuffer<T> destination, int sourceOffset, int destinationOffset, int count)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
destination.CopyFrom(source, sourceOffset, destinationOffset, count);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using System;
|
||||
using ComputeSharp.Resources;
|
||||
|
||||
namespace ComputeSharp;
|
||||
@@ -17,8 +17,8 @@ public static class UploadTexture1DExtensions
|
||||
public static void CopyTo<T>(this UploadTexture1D<T> source, Texture1D<T> destination)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
destination.CopyFrom(source, 0, 0, source.Width);
|
||||
}
|
||||
@@ -34,8 +34,8 @@ public static class UploadTexture1DExtensions
|
||||
public static void CopyTo<T>(this UploadTexture1D<T> source, Texture1D<T> destination, int sourceOffsetX, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
destination.CopyFrom(source, sourceOffsetX, 0, width);
|
||||
}
|
||||
@@ -52,8 +52,8 @@ public static class UploadTexture1DExtensions
|
||||
public static void CopyTo<T>(this UploadTexture1D<T> source, Texture1D<T> destination, int sourceOffsetX, int destinationOffsetX, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
destination.CopyFrom(source, sourceOffsetX, destinationOffsetX, width);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
using ComputeSharp.Resources;
|
||||
|
||||
@@ -20,8 +19,8 @@ public static class UploadTexture2DExtensions
|
||||
public static void CopyTo<T>(this UploadTexture2D<T> source, Texture2D<T> destination)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
destination.CopyFrom(source, 0, 0, 0, 0, source.Width, source.Height);
|
||||
}
|
||||
@@ -39,8 +38,8 @@ public static class UploadTexture2DExtensions
|
||||
public static void CopyTo<T>(this UploadTexture2D<T> source, Texture2D<T> destination, int sourceOffsetX, int sourceOffsetY, int width, int height)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
destination.CopyFrom(source, sourceOffsetX, sourceOffsetY, 0, 0, width, height);
|
||||
}
|
||||
@@ -60,8 +59,8 @@ public static class UploadTexture2DExtensions
|
||||
public static void CopyTo<T>(this UploadTexture2D<T> source, Texture2D<T> destination, int sourceOffsetX, int sourceOffsetY, int destinationOffsetX, int destinationOffsetY, int width, int height)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
destination.CopyFrom(source, sourceOffsetX, sourceOffsetY, destinationOffsetX, destinationOffsetY, width, height);
|
||||
}
|
||||
@@ -75,8 +74,8 @@ public static class UploadTexture2DExtensions
|
||||
public static void Load<T>(this UploadTexture2D<T> texture, string filename)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
Guard.IsNotNull(filename);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(filename);
|
||||
|
||||
texture.Load(filename.AsSpan());
|
||||
}
|
||||
@@ -90,7 +89,7 @@ public static class UploadTexture2DExtensions
|
||||
public static void Load<T>(this UploadTexture2D<T> texture, ReadOnlySpan<char> filename)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
WICHelper.Instance.LoadTexture(texture.View, filename);
|
||||
}
|
||||
@@ -105,7 +104,7 @@ public static class UploadTexture2DExtensions
|
||||
public static void Load<T>(this UploadTexture2D<T> texture, ReadOnlySpan<byte> span)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
WICHelper.Instance.LoadTexture(texture.View, span);
|
||||
}
|
||||
@@ -119,8 +118,8 @@ public static class UploadTexture2DExtensions
|
||||
public static void Load<T>(this UploadTexture2D<T> texture, Stream stream)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
Guard.IsNotNull(stream);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(stream);
|
||||
|
||||
WICHelper.Instance.LoadTexture(texture.View, stream);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using System;
|
||||
using ComputeSharp.Resources;
|
||||
|
||||
namespace ComputeSharp;
|
||||
@@ -17,8 +17,8 @@ public static class UploadTexture3DExtensions
|
||||
public static void CopyTo<T>(this UploadTexture3D<T> source, Texture3D<T> destination)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
destination.CopyFrom(source, 0, 0, 0, 0, 0, 0, source.Width, source.Height, source.Depth);
|
||||
}
|
||||
@@ -38,8 +38,8 @@ public static class UploadTexture3DExtensions
|
||||
public static void CopyTo<T>(this UploadTexture3D<T> source, Texture3D<T> destination, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int width, int height, int depth)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
destination.CopyFrom(source, sourceOffsetX, sourceOffsetY, sourceOffsetZ, 0, 0, 0, width, height, depth);
|
||||
}
|
||||
@@ -62,8 +62,8 @@ public static class UploadTexture3DExtensions
|
||||
public static void CopyTo<T>(this UploadTexture3D<T> source, Texture3D<T> destination, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
default(ArgumentNullException).ThrowIfNull(source);
|
||||
default(ArgumentNullException).ThrowIfNull(destination);
|
||||
|
||||
destination.CopyFrom(source, sourceOffsetX, sourceOffsetY, sourceOffsetZ, destinationOffsetX, destinationOffsetY, destinationOffsetZ, width, height, depth);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ unsafe partial class GraphicsDevice
|
||||
// For the same reason, this method doesn't have to worry about raising the event either.
|
||||
if (Volatile.Read(ref Unsafe.As<HRESULT, int>(ref this.deviceRemovedReason)) != S.S_OK)
|
||||
{
|
||||
static void Throw(object self) => throw new InvalidOperationException($"The device \"{self}\" has been lost and can no longer be used.");
|
||||
static void Throw(object self) => throw new InvalidOperationException($"""The device "{self}" has been lost and can no longer be used.""");
|
||||
|
||||
Throw(this);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks.Sources;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using ComputeSharp.Core.Extensions;
|
||||
using ComputeSharp.Graphics.Commands;
|
||||
using ComputeSharp.Graphics.Commands.Interop;
|
||||
@@ -59,7 +59,7 @@ unsafe partial class GraphicsDevice
|
||||
d3D12Fence = this.d3D12CopyFence;
|
||||
d3D12FenceValue = ref this.nextD3D12CopyFenceValue;
|
||||
break;
|
||||
default: ThrowHelper.ThrowArgumentException(); return;
|
||||
default: default(ArgumentException).Throw(nameof(commandList)); return;
|
||||
}
|
||||
|
||||
// Execute the command list
|
||||
@@ -215,7 +215,7 @@ unsafe partial class GraphicsDevice
|
||||
|
||||
NativeMemory.Free(callbackContext);
|
||||
|
||||
ThrowHelper.ThrowWin32Exception("Failed to register the compute context completion callback.");
|
||||
default(Win32Exception).Throw(E.E_FAIL);
|
||||
}
|
||||
|
||||
return waitForFenceValueTaskSource;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
|
||||
namespace ComputeSharp;
|
||||
@@ -71,7 +70,7 @@ partial class GraphicsDevice
|
||||
/// </remarks>
|
||||
public static IEnumerable<GraphicsDevice> QueryDevices(Predicate<GraphicsDeviceInfo> predicate)
|
||||
{
|
||||
Guard.IsNotNull(predicate);
|
||||
default(ArgumentNullException).ThrowIfNull(predicate);
|
||||
|
||||
return new DeviceHelper.DeviceQuery(predicate);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using ComputeSharp.Graphics.Commands.Interop;
|
||||
#if NET6_0_OR_GREATER
|
||||
using ComputeSharp.Core.Extensions;
|
||||
@@ -440,7 +439,7 @@ public sealed unsafe partial class GraphicsDevice : IReferenceTrackedObject
|
||||
this.copyCommandListPool.Rent(this.d3D12Device.Get(), null, out d3D12CommandList, out d3D12CommandAllocator);
|
||||
break;
|
||||
default:
|
||||
_ = ThrowHelper.ThrowArgumentException<ComPtr<ID3D12CommandAllocator>>();
|
||||
default(ArgumentException).Throw(nameof(d3D12CommandListType));
|
||||
d3D12CommandList = null;
|
||||
d3D12CommandAllocator = null;
|
||||
break;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using static TerraFX.Interop.DirectX.DXGI_FORMAT;
|
||||
|
||||
@@ -46,7 +46,7 @@ internal static class DXGIFormatHelper
|
||||
if (typeof(T) == typeof(Rg16)) return DXGI_FORMAT_R8G8_UNORM;
|
||||
if (typeof(T) == typeof(Rg32)) return DXGI_FORMAT_R16G16_UNORM;
|
||||
|
||||
return ThrowHelper.ThrowArgumentException<DXGI_FORMAT>("Invalid texture type.");
|
||||
return default(ArgumentException).Throw<DXGI_FORMAT>(nameof(T));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -89,7 +89,7 @@ internal static class DXGIFormatHelper
|
||||
return true;
|
||||
}
|
||||
|
||||
return ThrowHelper.ThrowArgumentException<bool>("Invalid texture type.");
|
||||
return default(ArgumentException).Throw<bool>(nameof(T));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -206,7 +206,7 @@ partial class DeviceHelper
|
||||
/// <inheritdoc/>
|
||||
public void Reset()
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
default(NotSupportedException).Throw();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using ComputeSharp.Core.Extensions;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
@@ -72,17 +72,26 @@ partial class DeviceHelper
|
||||
// If the device removal reason is available, also include that in the output message
|
||||
if (result != S.S_OK)
|
||||
{
|
||||
string deviceRemovalReason = (int)result switch
|
||||
string? deviceRemovalReason = (int)result switch
|
||||
{
|
||||
DXGI.DXGI_ERROR_DEVICE_HUNG => nameof(DXGI.DXGI_ERROR_DEVICE_HUNG),
|
||||
DXGI.DXGI_ERROR_DEVICE_REMOVED => nameof(DXGI.DXGI_ERROR_DEVICE_REMOVED),
|
||||
DXGI.DXGI_ERROR_DEVICE_RESET => nameof(DXGI.DXGI_ERROR_DEVICE_RESET),
|
||||
DXGI.DXGI_ERROR_DRIVER_INTERNAL_ERROR => nameof(DXGI.DXGI_ERROR_DRIVER_INTERNAL_ERROR),
|
||||
DXGI.DXGI_ERROR_INVALID_CALL => nameof(DXGI.DXGI_ERROR_INVALID_CALL),
|
||||
_ => ThrowHelper.ThrowArgumentOutOfRangeException<string>("Invalid GetDeviceRemovedReason HRESULT.")
|
||||
_ => null
|
||||
};
|
||||
|
||||
_ = builder.AppendLine($"[Reason]: {deviceRemovalReason}");
|
||||
// If it is a known HRESULT (this should always be the case), print the nicely formatted value
|
||||
if (deviceRemovalReason is not null)
|
||||
{
|
||||
_ = builder.AppendLine($"[Reason]: {deviceRemovalReason}");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise just format the HRESULT as a hexadecimal number
|
||||
_ = builder.AppendLine($"[Reason]: 0x{(int)result:X8}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,20 +107,14 @@ partial class DeviceHelper
|
||||
riid: Windows.__uuidof<ID3D12DeviceRemovedExtendedData1>(),
|
||||
ppvObject: d3D12DeviceRemovedExtendedData.GetVoidAddressOf());
|
||||
|
||||
if (hresult != S.S_OK)
|
||||
{
|
||||
ThrowHelper.ThrowWin32Exception(hresult);
|
||||
}
|
||||
default(Win32Exception).ThrowIfFailed(hresult);
|
||||
|
||||
D3D12_DRED_AUTO_BREADCRUMBS_OUTPUT1 d3D12DredAutoBreadcrumbsOutput;
|
||||
|
||||
// Get the auto breadcrumbs for the current event
|
||||
hresult = d3D12DeviceRemovedExtendedData.Get()->GetAutoBreadcrumbsOutput1(&d3D12DredAutoBreadcrumbsOutput);
|
||||
|
||||
if (hresult != S.S_OK)
|
||||
{
|
||||
ThrowHelper.ThrowWin32Exception(hresult);
|
||||
}
|
||||
default(Win32Exception).ThrowIfFailed(hresult);
|
||||
|
||||
_ = builder.AppendLine("[DRED breadcrumbs START] ===============================");
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using ComputeSharp.Core.Extensions;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using TerraFX.Interop.DirectX;
|
||||
@@ -45,7 +44,7 @@ internal static partial class DeviceHelper
|
||||
return GetOrCreateDevice(d3D12Device.Get(), dxgiAdapter.Get(), &dxgiDescription1);
|
||||
}
|
||||
|
||||
return ThrowHelper.ThrowNotSupportedException<GraphicsDevice>("Failed to retrieve the default device.");
|
||||
return default(NotSupportedException).Throw<GraphicsDevice>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -105,10 +104,7 @@ internal static partial class DeviceHelper
|
||||
d3D12DeviceCandidate.GetVoidAddressOf());
|
||||
|
||||
// Check and throw if the device is a device lost state and not disposed properly
|
||||
if (createDeviceResult.IsDeviceLostReason())
|
||||
{
|
||||
ThrowHelper.ThrowInvalidOperationException("The default device is in device lost state and has not been disposed properly.");
|
||||
}
|
||||
default(InvalidOperationException).ThrowIf(createDeviceResult.IsDeviceLostReason());
|
||||
|
||||
// Check for success, and then also filter out devices that support SM6.0. This can
|
||||
// only be checked on a concrete ID3D12Device instance, so it can't be done earlier.
|
||||
@@ -151,10 +147,7 @@ internal static partial class DeviceHelper
|
||||
Windows.__uuidof<ID3D12Device>(),
|
||||
d3D12DeviceCandidate.GetVoidAddressOf());
|
||||
|
||||
if (createDeviceResult.IsDeviceLostReason())
|
||||
{
|
||||
ThrowHelper.ThrowInvalidOperationException("The default device is in device lost state and has not been disposed properly.");
|
||||
}
|
||||
default(InvalidOperationException).ThrowIf(createDeviceResult.IsDeviceLostReason());
|
||||
|
||||
// There is no need to check for SM6.0, as it's guaranteed to be supported by Windows
|
||||
if (Windows.SUCCEEDED(createDeviceResult))
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using TerraFX.Interop.Windows;
|
||||
#if NET6_0_OR_GREATER
|
||||
using Path = System.IO.Path;
|
||||
@@ -33,7 +32,7 @@ internal static class WICFormatHelper
|
||||
if (typeof(T) == typeof(R8)) return GUID.GUID_WICPixelFormat8bppGray;
|
||||
if (typeof(T) == typeof(R16)) return GUID.GUID_WICPixelFormat16bppGray;
|
||||
|
||||
return ThrowHelper.ThrowArgumentException<Guid>("Invalid texture type.");
|
||||
return default(ArgumentException).Throw<Guid>(nameof(T));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -53,7 +52,7 @@ internal static class WICFormatHelper
|
||||
else if (typeof(T) == typeof(Rgba64)) intermediateFormat = GUID.GUID_WICPixelFormat32bppBGRA;
|
||||
else if (typeof(T) == typeof(R8)) intermediateFormat = GUID.GUID_WICPixelFormat24bppBGR;
|
||||
else if (typeof(T) == typeof(R16)) intermediateFormat = GUID.GUID_WICPixelFormat24bppBGR;
|
||||
else intermediateFormat = ThrowHelper.ThrowArgumentException<Guid>("Invalid texture type.");
|
||||
else intermediateFormat = default(ArgumentException).Throw<Guid>(nameof(T));
|
||||
}
|
||||
else if (containerFormat == GUID.GUID_ContainerFormatPng)
|
||||
{
|
||||
@@ -62,7 +61,7 @@ internal static class WICFormatHelper
|
||||
else if (typeof(T) == typeof(Rgba64)) intermediateFormat = default;
|
||||
else if (typeof(T) == typeof(R8)) intermediateFormat = default;
|
||||
else if (typeof(T) == typeof(R16)) intermediateFormat = GUID.GUID_WICPixelFormat8bppGray;
|
||||
else intermediateFormat = ThrowHelper.ThrowArgumentException<Guid>("Invalid texture type.");
|
||||
else intermediateFormat = default(ArgumentException).Throw<Guid>(nameof(T));
|
||||
}
|
||||
else if (containerFormat == GUID.GUID_ContainerFormatJpeg)
|
||||
{
|
||||
@@ -71,7 +70,7 @@ internal static class WICFormatHelper
|
||||
else if (typeof(T) == typeof(Rgba64)) intermediateFormat = GUID.GUID_WICPixelFormat24bppBGR;
|
||||
else if (typeof(T) == typeof(R8)) intermediateFormat = default;
|
||||
else if (typeof(T) == typeof(R16)) intermediateFormat = GUID.GUID_WICPixelFormat8bppGray;
|
||||
else intermediateFormat = ThrowHelper.ThrowArgumentException<Guid>("Invalid texture type.");
|
||||
else intermediateFormat = default(ArgumentException).Throw<Guid>(nameof(T));
|
||||
}
|
||||
else if (containerFormat == GUID.GUID_ContainerFormatWmp)
|
||||
{
|
||||
@@ -80,7 +79,7 @@ internal static class WICFormatHelper
|
||||
else if (typeof(T) == typeof(Rgba64)) intermediateFormat = default;
|
||||
else if (typeof(T) == typeof(R8)) intermediateFormat = default;
|
||||
else if (typeof(T) == typeof(R16)) intermediateFormat = default;
|
||||
else intermediateFormat = ThrowHelper.ThrowArgumentException<Guid>("Invalid texture type.");
|
||||
else intermediateFormat = default(ArgumentException).Throw<Guid>(nameof(T));
|
||||
}
|
||||
else if (containerFormat == GUID.GUID_ContainerFormatTiff)
|
||||
{
|
||||
@@ -89,7 +88,7 @@ internal static class WICFormatHelper
|
||||
else if (typeof(T) == typeof(Rgba64)) intermediateFormat = default;
|
||||
else if (typeof(T) == typeof(R8)) intermediateFormat = default;
|
||||
else if (typeof(T) == typeof(R16)) intermediateFormat = default;
|
||||
else intermediateFormat = ThrowHelper.ThrowArgumentException<Guid>("Invalid texture type.");
|
||||
else intermediateFormat = default(ArgumentException).Throw<Guid>(nameof(T));
|
||||
}
|
||||
else if (containerFormat == GUID.GUID_ContainerFormatDds)
|
||||
{
|
||||
@@ -98,11 +97,11 @@ internal static class WICFormatHelper
|
||||
else if (typeof(T) == typeof(Rgba64)) intermediateFormat = GUID.GUID_WICPixelFormat32bppBGRA;
|
||||
else if (typeof(T) == typeof(R8)) intermediateFormat = GUID.GUID_WICPixelFormat32bppBGRA;
|
||||
else if (typeof(T) == typeof(R16)) intermediateFormat = GUID.GUID_WICPixelFormat32bppBGRA;
|
||||
else intermediateFormat = ThrowHelper.ThrowArgumentException<Guid>("Invalid texture type.");
|
||||
else intermediateFormat = default(ArgumentException).Throw<Guid>(nameof(T));
|
||||
}
|
||||
else
|
||||
{
|
||||
intermediateFormat = ThrowHelper.ThrowArgumentException<Guid>("Invalid container format.");
|
||||
intermediateFormat = default(ArgumentException).Throw<Guid>(nameof(containerFormat));
|
||||
}
|
||||
|
||||
return intermediateFormat != default;
|
||||
@@ -128,7 +127,7 @@ internal static class WICFormatHelper
|
||||
".wmp" => GUID.GUID_ContainerFormatWmp,
|
||||
".tiff" => GUID.GUID_ContainerFormatTiff,
|
||||
".dds" => GUID.GUID_ContainerFormatDds,
|
||||
_ => ThrowHelper.ThrowArgumentException<Guid>("Invalid filename."),
|
||||
_ => default(ArgumentException).Throw<Guid>(nameof(filename))
|
||||
};
|
||||
}
|
||||
|
||||
@@ -148,7 +147,7 @@ internal static class WICFormatHelper
|
||||
ImageFormat.Wmp => GUID.GUID_ContainerFormatWmp,
|
||||
ImageFormat.Tiff => GUID.GUID_ContainerFormatTiff,
|
||||
ImageFormat.Dds => GUID.GUID_ContainerFormatDds,
|
||||
_ => ThrowHelper.ThrowArgumentException<Guid>("Invalid format."),
|
||||
_ => default(ArgumentException).Throw<Guid>(nameof(format))
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ using System;
|
||||
using System.Buffers;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using ComputeSharp.Core.Extensions;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using TerraFX.Interop.Windows;
|
||||
@@ -305,8 +304,8 @@ internal sealed unsafe class WICHelper
|
||||
wicBitmapFrameDecode.Get()->GetSize(&width, &height).Assert();
|
||||
|
||||
// Validate the target texture has the right size
|
||||
Guard.IsEqualTo((uint)texture.Width, width, nameof(texture.Width));
|
||||
Guard.IsEqualTo((uint)texture.Height, height, nameof(texture.Height));
|
||||
default(ArgumentException).ThrowIf((uint)texture.Width != width, nameof(texture.Width));
|
||||
default(ArgumentException).ThrowIf((uint)texture.Height != height, nameof(texture.Height));
|
||||
|
||||
Guid wicTargetPixelFormatGuid = WICFormatHelper.GetForType<T>();
|
||||
Guid wicActualPixelFormatGuid;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using ComputeSharp.Interop;
|
||||
using ComputeSharp.Resources;
|
||||
using TerraFX.Interop.DirectX;
|
||||
@@ -65,7 +64,7 @@ public static class GraphicsResourceHelper
|
||||
public static unsafe ulong ValidateAndGetGpuDescriptorHandle<T>(Buffer<T> buffer, GraphicsDevice device)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(buffer);
|
||||
default(ArgumentNullException).ThrowIfNull(buffer);
|
||||
|
||||
using ReferenceTracker.Lease _0 = buffer.GetReferenceTracker().GetLease();
|
||||
|
||||
@@ -87,7 +86,7 @@ public static class GraphicsResourceHelper
|
||||
public static unsafe ulong ValidateAndGetGpuDescriptorHandle<T>(ReadOnlyTexture1D<T> texture, GraphicsDevice device)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
using ReferenceTracker.Lease _0 = texture.GetReferenceTracker().GetLease();
|
||||
|
||||
@@ -109,7 +108,7 @@ public static class GraphicsResourceHelper
|
||||
public static unsafe ulong ValidateAndGetGpuDescriptorHandle<T>(ReadWriteTexture1D<T> texture, GraphicsDevice device)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
using ReferenceTracker.Lease _0 = texture.GetReferenceTracker().GetLease();
|
||||
|
||||
@@ -131,7 +130,7 @@ public static class GraphicsResourceHelper
|
||||
public static unsafe ulong ValidateAndGetGpuDescriptorHandle<T>(IReadOnlyTexture1D<T> texture, GraphicsDevice device)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
if (texture is IGraphicsResource resource)
|
||||
{
|
||||
@@ -140,7 +139,7 @@ public static class GraphicsResourceHelper
|
||||
return *(ulong*)&d3D12GpuDescriptorHandle;
|
||||
}
|
||||
|
||||
return ThrowHelper.ThrowArgumentException<ulong>("The input texture is not a valid instance.");
|
||||
return default(ArgumentException).Throw<ulong>(nameof(texture));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -154,7 +153,7 @@ public static class GraphicsResourceHelper
|
||||
public static unsafe ulong ValidateAndGetGpuDescriptorHandle<TPixel>(IReadOnlyNormalizedTexture1D<TPixel> texture, GraphicsDevice device)
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
if (texture is IGraphicsResource resource)
|
||||
{
|
||||
@@ -163,7 +162,7 @@ public static class GraphicsResourceHelper
|
||||
return *(ulong*)&d3D12GpuDescriptorHandle;
|
||||
}
|
||||
|
||||
return ThrowHelper.ThrowArgumentException<ulong>("The input texture is not a valid instance.");
|
||||
return default(ArgumentException).Throw<ulong>(nameof(texture));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -177,7 +176,7 @@ public static class GraphicsResourceHelper
|
||||
public static unsafe ulong ValidateAndGetGpuDescriptorHandle<TPixel>(IReadWriteNormalizedTexture1D<TPixel> texture, GraphicsDevice device)
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
if (texture is IGraphicsResource resource)
|
||||
{
|
||||
@@ -186,7 +185,7 @@ public static class GraphicsResourceHelper
|
||||
return *(ulong*)&d3D12GpuDescriptorHandle;
|
||||
}
|
||||
|
||||
return ThrowHelper.ThrowArgumentException<ulong>("The input texture is not a valid instance.");
|
||||
return default(ArgumentException).Throw<ulong>(nameof(texture));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -200,7 +199,7 @@ public static class GraphicsResourceHelper
|
||||
public static unsafe ulong ValidateAndGetGpuDescriptorHandle<T>(ReadOnlyTexture2D<T> texture, GraphicsDevice device)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
using ReferenceTracker.Lease _0 = texture.GetReferenceTracker().GetLease();
|
||||
|
||||
@@ -222,7 +221,7 @@ public static class GraphicsResourceHelper
|
||||
public static unsafe ulong ValidateAndGetGpuDescriptorHandle<T>(ReadWriteTexture2D<T> texture, GraphicsDevice device)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
using ReferenceTracker.Lease _0 = texture.GetReferenceTracker().GetLease();
|
||||
|
||||
@@ -244,7 +243,7 @@ public static class GraphicsResourceHelper
|
||||
public static unsafe ulong ValidateAndGetGpuDescriptorHandle<T>(IReadOnlyTexture2D<T> texture, GraphicsDevice device)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
if (texture is IGraphicsResource resource)
|
||||
{
|
||||
@@ -253,7 +252,7 @@ public static class GraphicsResourceHelper
|
||||
return *(ulong*)&d3D12GpuDescriptorHandle;
|
||||
}
|
||||
|
||||
return ThrowHelper.ThrowArgumentException<ulong>("The input texture is not a valid instance.");
|
||||
return default(ArgumentException).Throw<ulong>(nameof(texture));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -267,7 +266,7 @@ public static class GraphicsResourceHelper
|
||||
public static unsafe ulong ValidateAndGetGpuDescriptorHandle<TPixel>(IReadOnlyNormalizedTexture2D<TPixel> texture, GraphicsDevice device)
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
if (texture is IGraphicsResource resource)
|
||||
{
|
||||
@@ -276,7 +275,7 @@ public static class GraphicsResourceHelper
|
||||
return *(ulong*)&d3D12GpuDescriptorHandle;
|
||||
}
|
||||
|
||||
return ThrowHelper.ThrowArgumentException<ulong>("The input texture is not a valid instance.");
|
||||
return default(ArgumentException).Throw<ulong>(nameof(texture));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -290,7 +289,7 @@ public static class GraphicsResourceHelper
|
||||
public static unsafe ulong ValidateAndGetGpuDescriptorHandle<TPixel>(IReadWriteNormalizedTexture2D<TPixel> texture, GraphicsDevice device)
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
if (texture is IGraphicsResource resource)
|
||||
{
|
||||
@@ -299,7 +298,7 @@ public static class GraphicsResourceHelper
|
||||
return *(ulong*)&d3D12GpuDescriptorHandle;
|
||||
}
|
||||
|
||||
return ThrowHelper.ThrowArgumentException<ulong>("The input texture is not a valid instance.");
|
||||
return default(ArgumentException).Throw<ulong>(nameof(texture));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -313,7 +312,7 @@ public static class GraphicsResourceHelper
|
||||
public static unsafe ulong ValidateAndGetGpuDescriptorHandle<T>(ReadOnlyTexture3D<T> texture, GraphicsDevice device)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
using ReferenceTracker.Lease _0 = texture.GetReferenceTracker().GetLease();
|
||||
|
||||
@@ -335,7 +334,7 @@ public static class GraphicsResourceHelper
|
||||
public static unsafe ulong ValidateAndGetGpuDescriptorHandle<T>(ReadWriteTexture3D<T> texture, GraphicsDevice device)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
using ReferenceTracker.Lease _0 = texture.GetReferenceTracker().GetLease();
|
||||
|
||||
@@ -357,7 +356,7 @@ public static class GraphicsResourceHelper
|
||||
public static unsafe ulong ValidateAndGetGpuDescriptorHandle<T>(IReadOnlyTexture3D<T> texture, GraphicsDevice device)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
if (texture is IGraphicsResource resource)
|
||||
{
|
||||
@@ -366,7 +365,7 @@ public static class GraphicsResourceHelper
|
||||
return *(ulong*)&d3D12GpuDescriptorHandle;
|
||||
}
|
||||
|
||||
return ThrowHelper.ThrowArgumentException<ulong>("The input texture is not a valid instance.");
|
||||
return default(ArgumentException).Throw<ulong>(nameof(texture));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -380,7 +379,7 @@ public static class GraphicsResourceHelper
|
||||
public static unsafe ulong ValidateAndGetGpuDescriptorHandle<TPixel>(IReadOnlyNormalizedTexture3D<TPixel> texture, GraphicsDevice device)
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
if (texture is IGraphicsResource resource)
|
||||
{
|
||||
@@ -389,7 +388,7 @@ public static class GraphicsResourceHelper
|
||||
return *(ulong*)&d3D12GpuDescriptorHandle;
|
||||
}
|
||||
|
||||
return ThrowHelper.ThrowArgumentException<ulong>("The input texture is not a valid instance.");
|
||||
return default(ArgumentException).Throw<ulong>(nameof(texture));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -403,7 +402,7 @@ public static class GraphicsResourceHelper
|
||||
public static unsafe ulong ValidateAndGetGpuDescriptorHandle<TPixel>(IReadWriteNormalizedTexture3D<TPixel> texture, GraphicsDevice device)
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
if (texture is IGraphicsResource resource)
|
||||
{
|
||||
@@ -412,6 +411,6 @@ public static class GraphicsResourceHelper
|
||||
return *(ulong*)&d3D12GpuDescriptorHandle;
|
||||
}
|
||||
|
||||
return ThrowHelper.ThrowArgumentException<ulong>("The input texture is not a valid instance.");
|
||||
return default(ArgumentException).Throw<ulong>(nameof(texture));
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,7 @@ internal struct ReferenceTracker : IDisposable
|
||||
|
||||
if (!leaseTaken)
|
||||
{
|
||||
// We can't use ThrowHelper here as we only want to invoke ToString if we
|
||||
// We can't use a throw helper here as we only want to invoke ToString if we
|
||||
// are about to throw an exception. The JIT will recognize this pattern
|
||||
// as this method has a single basic block that always throws an exception.
|
||||
static void Throw(object trackedObject) => throw new ObjectDisposedException(trackedObject.ToString());
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using ComputeSharp.Core.Helpers;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Commands.Interop;
|
||||
@@ -75,12 +75,12 @@ public abstract unsafe partial class Buffer<T> : IReferenceTrackedObject, IGraph
|
||||
|
||||
if (resourceType == ResourceType.Constant)
|
||||
{
|
||||
Guard.IsBetweenOrEqualTo(length, 1, D3D12.D3D12_REQ_CONSTANT_BUFFER_ELEMENT_COUNT);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(length, 1, D3D12.D3D12_REQ_CONSTANT_BUFFER_ELEMENT_COUNT);
|
||||
}
|
||||
else
|
||||
{
|
||||
// The maximum length is set such that the aligned buffer size can't exceed uint.MaxValue
|
||||
Guard.IsBetweenOrEqualTo(length, 1, (uint.MaxValue / elementSizeInBytes) & ~255);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(length, 1, (uint.MaxValue / elementSizeInBytes) & ~255);
|
||||
}
|
||||
|
||||
using ReferenceTracker.Lease _0 = device.GetReferenceTracker().GetLease();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using ComputeSharp.Graphics.Commands;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
@@ -35,9 +35,9 @@ public abstract class StructuredBuffer<T> : Buffer<T>
|
||||
/// <inheritdoc/>
|
||||
internal override unsafe void CopyTo(ref T destination, int sourceOffset, int count)
|
||||
{
|
||||
Guard.IsBetweenOrEqualTo(count, 0, Length);
|
||||
Guard.IsInRange(sourceOffset, 0, Length);
|
||||
Guard.IsLessThanOrEqualTo(sourceOffset + count, Length, nameof(sourceOffset));
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(count, 0, Length);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffset, 0, Length);
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(sourceOffset + count, Length, nameof(sourceOffset));
|
||||
|
||||
using ReferenceTracker.Lease _0 = GraphicsDevice.GetReferenceTracker().GetLease();
|
||||
using ReferenceTracker.Lease _1 = GetReferenceTracker().GetLease();
|
||||
@@ -107,12 +107,12 @@ public abstract class StructuredBuffer<T> : Buffer<T>
|
||||
/// <inheritdoc/>
|
||||
internal override unsafe void CopyTo(Buffer<T> destination, int sourceOffset, int destinationOffset, int count)
|
||||
{
|
||||
Guard.IsBetweenOrEqualTo(count, 0, Length);
|
||||
Guard.IsBetweenOrEqualTo(count, 0, destination.Length);
|
||||
Guard.IsInRange(sourceOffset, 0, Length);
|
||||
Guard.IsLessThanOrEqualTo(sourceOffset + count, Length, nameof(sourceOffset));
|
||||
Guard.IsInRange(destinationOffset, 0, destination.Length);
|
||||
Guard.IsLessThanOrEqualTo(destinationOffset + count, destination.Length, nameof(destinationOffset));
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(count, 0, Length);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(count, 0, destination.Length);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffset, 0, Length);
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(sourceOffset + count, Length, nameof(sourceOffset));
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffset, 0, destination.Length);
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(destinationOffset + count, destination.Length, nameof(destinationOffset));
|
||||
|
||||
using ReferenceTracker.Lease _0 = GraphicsDevice.GetReferenceTracker().GetLease();
|
||||
using ReferenceTracker.Lease _1 = GetReferenceTracker().GetLease();
|
||||
@@ -155,12 +155,12 @@ public abstract class StructuredBuffer<T> : Buffer<T>
|
||||
/// <param name="count">The number of items to read.</param>
|
||||
internal unsafe void CopyTo(ReadBackBuffer<T> destination, int sourceOffset, int destinationOffset, int count)
|
||||
{
|
||||
Guard.IsBetweenOrEqualTo(count, 0, Length);
|
||||
Guard.IsBetweenOrEqualTo(count, 0, destination.Length);
|
||||
Guard.IsInRange(sourceOffset, 0, Length);
|
||||
Guard.IsLessThanOrEqualTo(sourceOffset + count, Length, nameof(sourceOffset));
|
||||
Guard.IsInRange(destinationOffset, 0, destination.Length);
|
||||
Guard.IsLessThanOrEqualTo(destinationOffset + count, destination.Length, nameof(destinationOffset));
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(count, 0, Length);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(count, 0, destination.Length);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffset, 0, Length);
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(sourceOffset + count, Length, nameof(sourceOffset));
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffset, 0, destination.Length);
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(destinationOffset + count, destination.Length, nameof(destinationOffset));
|
||||
|
||||
using ReferenceTracker.Lease _0 = GraphicsDevice.GetReferenceTracker().GetLease();
|
||||
using ReferenceTracker.Lease _1 = GetReferenceTracker().GetLease();
|
||||
@@ -199,9 +199,9 @@ public abstract class StructuredBuffer<T> : Buffer<T>
|
||||
/// <inheritdoc/>
|
||||
internal override unsafe void CopyFrom(ref T source, int offset, int length)
|
||||
{
|
||||
Guard.IsBetweenOrEqualTo(length, 0, Length);
|
||||
Guard.IsInRange(offset, 0, Length);
|
||||
Guard.IsLessThanOrEqualTo(offset + length, Length, nameof(offset));
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(length, 0, Length);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(offset, 0, Length);
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(offset + length, Length, nameof(offset));
|
||||
|
||||
using ReferenceTracker.Lease _0 = GraphicsDevice.GetReferenceTracker().GetLease();
|
||||
using ReferenceTracker.Lease _1 = GetReferenceTracker().GetLease();
|
||||
@@ -275,12 +275,12 @@ public abstract class StructuredBuffer<T> : Buffer<T>
|
||||
/// <param name="count">The number of items to read.</param>
|
||||
internal unsafe void CopyFrom(UploadBuffer<T> source, int sourceOffset, int destinationOffset, int count)
|
||||
{
|
||||
Guard.IsBetweenOrEqualTo(count, 0, Length);
|
||||
Guard.IsBetweenOrEqualTo(count, 0, source.Length);
|
||||
Guard.IsInRange(sourceOffset, 0, source.Length);
|
||||
Guard.IsLessThanOrEqualTo(sourceOffset + count, source.Length, nameof(sourceOffset));
|
||||
Guard.IsInRange(destinationOffset, 0, Length);
|
||||
Guard.IsLessThanOrEqualTo(destinationOffset + count, Length, nameof(destinationOffset));
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(count, 0, Length);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(count, 0, source.Length);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffset, 0, source.Length);
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(sourceOffset + count, source.Length, nameof(sourceOffset));
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffset, 0, Length);
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(destinationOffset + count, Length, nameof(destinationOffset));
|
||||
|
||||
using ReferenceTracker.Lease _0 = GraphicsDevice.GetReferenceTracker().GetLease();
|
||||
using ReferenceTracker.Lease _1 = GetReferenceTracker().GetLease();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Commands;
|
||||
@@ -78,7 +77,7 @@ public abstract unsafe partial class Texture1D<T> : IReferenceTrackedObject, IGr
|
||||
{
|
||||
this.referenceTracker = new ReferenceTracker(this);
|
||||
|
||||
Guard.IsBetweenOrEqualTo(width, 1, D3D12.D3D12_REQ_TEXTURE1D_U_DIMENSION);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, D3D12.D3D12_REQ_TEXTURE1D_U_DIMENSION);
|
||||
|
||||
using ReferenceTracker.Lease _0 = device.GetReferenceTracker().GetLease();
|
||||
|
||||
@@ -165,10 +164,10 @@ public abstract unsafe partial class Texture1D<T> : IReferenceTrackedObject, IGr
|
||||
/// <param name="width">The width of the memory area to copy.</param>
|
||||
internal void CopyTo(ref T destination, int size, int sourceOffsetX, int width)
|
||||
{
|
||||
Guard.IsInRange(sourceOffsetX, 0, Width);
|
||||
Guard.IsBetweenOrEqualTo(width, 1, Width);
|
||||
Guard.IsLessThanOrEqualTo(sourceOffsetX + width, Width, nameof(sourceOffsetX));
|
||||
Guard.IsGreaterThanOrEqualTo(size, width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetX, 0, Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(sourceOffsetX + width, Width, nameof(sourceOffsetX));
|
||||
default(ArgumentOutOfRangeException).ThrowIfLessThan(size, width);
|
||||
|
||||
using ReferenceTracker.Lease _0 = GraphicsDevice.GetReferenceTracker().GetLease();
|
||||
using ReferenceTracker.Lease _1 = GetReferenceTracker().GetLease();
|
||||
@@ -247,12 +246,12 @@ public abstract unsafe partial class Texture1D<T> : IReferenceTrackedObject, IGr
|
||||
/// <param name="width">The width of the memory area to copy.</param>
|
||||
internal void CopyTo(Texture1D<T> destination, int sourceOffsetX, int destinationOffsetX, int width)
|
||||
{
|
||||
Guard.IsInRange(sourceOffsetX, 0, Width);
|
||||
Guard.IsInRange(destinationOffsetX, 0, destination.Width);
|
||||
Guard.IsBetweenOrEqualTo(width, 1, Width);
|
||||
Guard.IsBetweenOrEqualTo(width, 1, destination.Width);
|
||||
Guard.IsBetweenOrEqualTo(destinationOffsetX + width, 1, destination.Width, nameof(destinationOffsetX));
|
||||
Guard.IsLessThanOrEqualTo(sourceOffsetX + width, Width, nameof(sourceOffsetX));
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetX, 0, Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetX, 0, destination.Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, destination.Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(destinationOffsetX + width, 1, destination.Width, nameof(destinationOffsetX));
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(sourceOffsetX + width, Width, nameof(sourceOffsetX));
|
||||
|
||||
using ReferenceTracker.Lease _0 = GraphicsDevice.GetReferenceTracker().GetLease();
|
||||
using ReferenceTracker.Lease _1 = GetReferenceTracker().GetLease();
|
||||
@@ -307,12 +306,12 @@ public abstract unsafe partial class Texture1D<T> : IReferenceTrackedObject, IGr
|
||||
/// <param name="width">The width of the memory area to copy.</param>
|
||||
internal void CopyTo(ReadBackTexture1D<T> destination, int sourceOffsetX, int destinationOffsetX, int width)
|
||||
{
|
||||
Guard.IsInRange(sourceOffsetX, 0, Width);
|
||||
Guard.IsInRange(destinationOffsetX, 0, destination.Width);
|
||||
Guard.IsBetweenOrEqualTo(width, 1, Width);
|
||||
Guard.IsBetweenOrEqualTo(width, 1, destination.Width);
|
||||
Guard.IsBetweenOrEqualTo(destinationOffsetX + width, 1, destination.Width, nameof(destinationOffsetX));
|
||||
Guard.IsLessThanOrEqualTo(sourceOffsetX + width, Width, nameof(sourceOffsetX));
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetX, 0, Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetX, 0, destination.Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, destination.Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(destinationOffsetX + width, 1, destination.Width, nameof(destinationOffsetX));
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(sourceOffsetX + width, Width, nameof(sourceOffsetX));
|
||||
|
||||
using ReferenceTracker.Lease _0 = GraphicsDevice.GetReferenceTracker().GetLease();
|
||||
using ReferenceTracker.Lease _1 = GetReferenceTracker().GetLease();
|
||||
@@ -363,10 +362,10 @@ public abstract unsafe partial class Texture1D<T> : IReferenceTrackedObject, IGr
|
||||
/// <param name="width">The width of the memory area to write to.</param>
|
||||
internal void CopyFrom(ref T source, int size, int destinationOffsetX, int width)
|
||||
{
|
||||
Guard.IsInRange(destinationOffsetX, 0, Width);
|
||||
Guard.IsBetweenOrEqualTo(width, 1, Width);
|
||||
Guard.IsLessThanOrEqualTo(destinationOffsetX + width, Width, nameof(destinationOffsetX));
|
||||
Guard.IsGreaterThanOrEqualTo(size, width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetX, 0, Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(destinationOffsetX + width, Width, nameof(destinationOffsetX));
|
||||
default(ArgumentOutOfRangeException).ThrowIfLessThan(size, width);
|
||||
|
||||
using ReferenceTracker.Lease _0 = GraphicsDevice.GetReferenceTracker().GetLease();
|
||||
using ReferenceTracker.Lease _1 = GetReferenceTracker().GetLease();
|
||||
@@ -445,12 +444,12 @@ public abstract unsafe partial class Texture1D<T> : IReferenceTrackedObject, IGr
|
||||
/// <param name="width">The width of the memory area to write to.</param>
|
||||
internal void CopyFrom(UploadTexture1D<T> source, int sourceOffsetX, int destinationOffsetX, int width)
|
||||
{
|
||||
Guard.IsInRange(sourceOffsetX, 0, source.Width);
|
||||
Guard.IsInRange(destinationOffsetX, 0, Width);
|
||||
Guard.IsBetweenOrEqualTo(width, 1, Width);
|
||||
Guard.IsBetweenOrEqualTo(width, 1, source.Width);
|
||||
Guard.IsLessThanOrEqualTo(sourceOffsetX + width, source.Width, nameof(sourceOffsetX));
|
||||
Guard.IsLessThanOrEqualTo(destinationOffsetX + width, Width, nameof(destinationOffsetX));
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetX, 0, source.Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetX, 0, Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, source.Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(sourceOffsetX + width, source.Width, nameof(sourceOffsetX));
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(destinationOffsetX + width, Width, nameof(destinationOffsetX));
|
||||
|
||||
using ReferenceTracker.Lease _0 = GraphicsDevice.GetReferenceTracker().GetLease();
|
||||
using ReferenceTracker.Lease _1 = GetReferenceTracker().GetLease();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Commands;
|
||||
@@ -79,8 +78,8 @@ public abstract unsafe partial class Texture2D<T> : IReferenceTrackedObject, IGr
|
||||
{
|
||||
this.referenceTracker = new ReferenceTracker(this);
|
||||
|
||||
Guard.IsBetweenOrEqualTo(width, 1, D3D12.D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION);
|
||||
Guard.IsBetweenOrEqualTo(height, 1, D3D12.D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, D3D12.D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(height, 1, D3D12.D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION);
|
||||
|
||||
using ReferenceTracker.Lease _0 = device.GetReferenceTracker().GetLease();
|
||||
|
||||
@@ -177,13 +176,13 @@ public abstract unsafe partial class Texture2D<T> : IReferenceTrackedObject, IGr
|
||||
/// <param name="height">The height of the memory area to copy.</param>
|
||||
internal void CopyTo(ref T destination, int size, int sourceOffsetX, int sourceOffsetY, int width, int height)
|
||||
{
|
||||
Guard.IsInRange(sourceOffsetX, 0, Width);
|
||||
Guard.IsInRange(sourceOffsetY, 0, Height);
|
||||
Guard.IsBetweenOrEqualTo(width, 1, Width);
|
||||
Guard.IsBetweenOrEqualTo(height, 1, Height);
|
||||
Guard.IsLessThanOrEqualTo(sourceOffsetX + width, Width, nameof(sourceOffsetX));
|
||||
Guard.IsLessThanOrEqualTo(sourceOffsetY + height, Height, nameof(sourceOffsetY));
|
||||
Guard.IsGreaterThanOrEqualTo(size, (nint)width * height);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetX, 0, Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetY, 0, Height);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(height, 1, Height);
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(sourceOffsetX + width, Width, nameof(sourceOffsetX));
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(sourceOffsetY + height, Height, nameof(sourceOffsetY));
|
||||
default(ArgumentOutOfRangeException).ThrowIfLessThan(size, (long)width * height);
|
||||
|
||||
using ReferenceTracker.Lease _0 = GraphicsDevice.GetReferenceTracker().GetLease();
|
||||
using ReferenceTracker.Lease _1 = GetReferenceTracker().GetLease();
|
||||
@@ -267,18 +266,18 @@ public abstract unsafe partial class Texture2D<T> : IReferenceTrackedObject, IGr
|
||||
/// <param name="height">The height of the memory area to copy.</param>
|
||||
internal void CopyTo(Texture2D<T> destination, int sourceOffsetX, int sourceOffsetY, int destinationOffsetX, int destinationOffsetY, int width, int height)
|
||||
{
|
||||
Guard.IsInRange(sourceOffsetX, 0, Width);
|
||||
Guard.IsInRange(sourceOffsetY, 0, Height);
|
||||
Guard.IsInRange(destinationOffsetX, 0, destination.Width);
|
||||
Guard.IsInRange(destinationOffsetY, 0, destination.Height);
|
||||
Guard.IsBetweenOrEqualTo(width, 1, Width);
|
||||
Guard.IsBetweenOrEqualTo(height, 1, Height);
|
||||
Guard.IsBetweenOrEqualTo(width, 1, destination.Width);
|
||||
Guard.IsBetweenOrEqualTo(height, 1, destination.Height);
|
||||
Guard.IsBetweenOrEqualTo(destinationOffsetX + width, 1, destination.Width, nameof(destinationOffsetX));
|
||||
Guard.IsBetweenOrEqualTo(destinationOffsetY + height, 1, destination.Height, nameof(destinationOffsetY));
|
||||
Guard.IsLessThanOrEqualTo(sourceOffsetX + width, Width, nameof(sourceOffsetX));
|
||||
Guard.IsLessThanOrEqualTo(sourceOffsetY + height, Height, nameof(sourceOffsetY));
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetX, 0, Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetY, 0, Height);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetX, 0, destination.Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetY, 0, destination.Height);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(height, 1, Height);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, destination.Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(height, 1, destination.Height);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(destinationOffsetX + width, 1, destination.Width, nameof(destinationOffsetX));
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(destinationOffsetY + height, 1, destination.Height, nameof(destinationOffsetY));
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(sourceOffsetX + width, Width, nameof(sourceOffsetX));
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(sourceOffsetY + height, Height, nameof(sourceOffsetY));
|
||||
|
||||
using ReferenceTracker.Lease _0 = GraphicsDevice.GetReferenceTracker().GetLease();
|
||||
using ReferenceTracker.Lease _1 = GetReferenceTracker().GetLease();
|
||||
@@ -336,18 +335,18 @@ public abstract unsafe partial class Texture2D<T> : IReferenceTrackedObject, IGr
|
||||
/// <param name="height">The height of the memory area to copy.</param>
|
||||
internal void CopyTo(ReadBackTexture2D<T> destination, int sourceOffsetX, int sourceOffsetY, int destinationOffsetX, int destinationOffsetY, int width, int height)
|
||||
{
|
||||
Guard.IsInRange(sourceOffsetX, 0, Width);
|
||||
Guard.IsInRange(sourceOffsetY, 0, Height);
|
||||
Guard.IsInRange(destinationOffsetX, 0, destination.Width);
|
||||
Guard.IsInRange(destinationOffsetY, 0, destination.Height);
|
||||
Guard.IsBetweenOrEqualTo(width, 1, Width);
|
||||
Guard.IsBetweenOrEqualTo(height, 1, Height);
|
||||
Guard.IsBetweenOrEqualTo(width, 1, destination.Width);
|
||||
Guard.IsBetweenOrEqualTo(height, 1, destination.Height);
|
||||
Guard.IsBetweenOrEqualTo(destinationOffsetX + width, 1, destination.Width, nameof(destinationOffsetX));
|
||||
Guard.IsBetweenOrEqualTo(destinationOffsetY + height, 1, destination.Height, nameof(destinationOffsetY));
|
||||
Guard.IsLessThanOrEqualTo(sourceOffsetX + width, Width, nameof(sourceOffsetX));
|
||||
Guard.IsLessThanOrEqualTo(sourceOffsetY + height, Height, nameof(sourceOffsetY));
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetX, 0, Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetY, 0, Height);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetX, 0, destination.Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetY, 0, destination.Height);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(height, 1, Height);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, destination.Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(height, 1, destination.Height);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(destinationOffsetX + width, 1, destination.Width, nameof(destinationOffsetX));
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(destinationOffsetY + height, 1, destination.Height, nameof(destinationOffsetY));
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(sourceOffsetX + width, Width, nameof(sourceOffsetX));
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(sourceOffsetY + height, Height, nameof(sourceOffsetY));
|
||||
|
||||
using ReferenceTracker.Lease _0 = GraphicsDevice.GetReferenceTracker().GetLease();
|
||||
using ReferenceTracker.Lease _1 = GetReferenceTracker().GetLease();
|
||||
@@ -400,13 +399,13 @@ public abstract unsafe partial class Texture2D<T> : IReferenceTrackedObject, IGr
|
||||
/// <param name="height">The height of the memory area to write to.</param>
|
||||
internal void CopyFrom(ref T source, int size, int destinationOffsetX, int destinationOffsetY, int width, int height)
|
||||
{
|
||||
Guard.IsInRange(destinationOffsetX, 0, Width);
|
||||
Guard.IsInRange(destinationOffsetY, 0, Height);
|
||||
Guard.IsBetweenOrEqualTo(width, 1, Width);
|
||||
Guard.IsBetweenOrEqualTo(height, 1, Height);
|
||||
Guard.IsLessThanOrEqualTo(destinationOffsetX + width, Width, nameof(destinationOffsetX));
|
||||
Guard.IsLessThanOrEqualTo(destinationOffsetY + height, Height, nameof(destinationOffsetY));
|
||||
Guard.IsGreaterThanOrEqualTo(size, (nint)width * height);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetX, 0, Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetY, 0, Height);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(height, 1, Height);
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(destinationOffsetX + width, Width, nameof(destinationOffsetX));
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(destinationOffsetY + height, Height, nameof(destinationOffsetY));
|
||||
default(ArgumentOutOfRangeException).ThrowIfLessThan(size, (long)width * height);
|
||||
|
||||
using ReferenceTracker.Lease _0 = GraphicsDevice.GetReferenceTracker().GetLease();
|
||||
using ReferenceTracker.Lease _1 = GetReferenceTracker().GetLease();
|
||||
@@ -490,18 +489,18 @@ public abstract unsafe partial class Texture2D<T> : IReferenceTrackedObject, IGr
|
||||
/// <param name="height">The height of the memory area to write to.</param>
|
||||
internal void CopyFrom(UploadTexture2D<T> source, int sourceOffsetX, int sourceOffsetY, int destinationOffsetX, int destinationOffsetY, int width, int height)
|
||||
{
|
||||
Guard.IsInRange(sourceOffsetX, 0, source.Width);
|
||||
Guard.IsInRange(sourceOffsetY, 0, source.Height);
|
||||
Guard.IsInRange(destinationOffsetX, 0, Width);
|
||||
Guard.IsInRange(destinationOffsetY, 0, Height);
|
||||
Guard.IsBetweenOrEqualTo(width, 1, Width);
|
||||
Guard.IsBetweenOrEqualTo(height, 1, Height);
|
||||
Guard.IsBetweenOrEqualTo(width, 1, source.Width);
|
||||
Guard.IsBetweenOrEqualTo(height, 1, source.Height);
|
||||
Guard.IsLessThanOrEqualTo(sourceOffsetX + width, source.Width, nameof(sourceOffsetX));
|
||||
Guard.IsLessThanOrEqualTo(sourceOffsetY + height, source.Height, nameof(sourceOffsetY));
|
||||
Guard.IsLessThanOrEqualTo(destinationOffsetX + width, Width, nameof(destinationOffsetX));
|
||||
Guard.IsLessThanOrEqualTo(destinationOffsetY + height, Height, nameof(destinationOffsetY));
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetX, 0, source.Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetY, 0, source.Height);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetX, 0, Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetY, 0, Height);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(height, 1, Height);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, source.Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(height, 1, source.Height);
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(sourceOffsetX + width, source.Width, nameof(sourceOffsetX));
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(sourceOffsetY + height, source.Height, nameof(sourceOffsetY));
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(destinationOffsetX + width, Width, nameof(destinationOffsetX));
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(destinationOffsetY + height, Height, nameof(destinationOffsetY));
|
||||
|
||||
using ReferenceTracker.Lease _0 = GraphicsDevice.GetReferenceTracker().GetLease();
|
||||
using ReferenceTracker.Lease _1 = GetReferenceTracker().GetLease();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Commands;
|
||||
@@ -80,9 +79,9 @@ public abstract unsafe partial class Texture3D<T> : IReferenceTrackedObject, IGr
|
||||
{
|
||||
this.referenceTracker = new ReferenceTracker(this);
|
||||
|
||||
Guard.IsBetweenOrEqualTo(width, 1, D3D12.D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION);
|
||||
Guard.IsBetweenOrEqualTo(height, 1, D3D12.D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION);
|
||||
Guard.IsBetweenOrEqualTo(depth, 1, D3D12.D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, D3D12.D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(height, 1, D3D12.D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(depth, 1, D3D12.D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION);
|
||||
|
||||
using ReferenceTracker.Lease _0 = device.GetReferenceTracker().GetLease();
|
||||
|
||||
@@ -189,16 +188,16 @@ public abstract unsafe partial class Texture3D<T> : IReferenceTrackedObject, IGr
|
||||
/// <param name="depth">The depth of the memory area to copy.</param>
|
||||
internal void CopyTo(ref T destination, int size, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int width, int height, int depth)
|
||||
{
|
||||
Guard.IsInRange(sourceOffsetX, 0, Width);
|
||||
Guard.IsInRange(sourceOffsetY, 0, Height);
|
||||
Guard.IsInRange(sourceOffsetZ, 0, Depth);
|
||||
Guard.IsBetweenOrEqualTo(width, 1, Width);
|
||||
Guard.IsBetweenOrEqualTo(height, 1, Height);
|
||||
Guard.IsBetweenOrEqualTo(depth, 1, Depth);
|
||||
Guard.IsLessThanOrEqualTo(sourceOffsetX + width, Width, nameof(sourceOffsetX));
|
||||
Guard.IsLessThanOrEqualTo(sourceOffsetY + height, Height, nameof(sourceOffsetY));
|
||||
Guard.IsLessThanOrEqualTo(sourceOffsetZ + depth, Depth, nameof(sourceOffsetZ));
|
||||
Guard.IsGreaterThanOrEqualTo(size, (nint)width * height * depth);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetX, 0, Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetY, 0, Height);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetZ, 0, Depth);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(height, 1, Height);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(depth, 1, Depth);
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(sourceOffsetX + width, Width, nameof(sourceOffsetX));
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(sourceOffsetY + height, Height, nameof(sourceOffsetY));
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(sourceOffsetZ + depth, Depth, nameof(sourceOffsetZ));
|
||||
default(ArgumentOutOfRangeException).ThrowIfLessThan(size, (long)width * height * depth);
|
||||
|
||||
using ReferenceTracker.Lease _0 = GraphicsDevice.GetReferenceTracker().GetLease();
|
||||
using ReferenceTracker.Lease _1 = GetReferenceTracker().GetLease();
|
||||
@@ -288,24 +287,24 @@ public abstract unsafe partial class Texture3D<T> : IReferenceTrackedObject, IGr
|
||||
/// <param name="depth">The depth of the memory area to copy.</param>
|
||||
internal void CopyTo(Texture3D<T> destination, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth)
|
||||
{
|
||||
Guard.IsInRange(sourceOffsetX, 0, Width);
|
||||
Guard.IsInRange(sourceOffsetY, 0, Height);
|
||||
Guard.IsInRange(sourceOffsetZ, 0, Depth);
|
||||
Guard.IsInRange(destinationOffsetX, 0, destination.Width);
|
||||
Guard.IsInRange(destinationOffsetY, 0, destination.Height);
|
||||
Guard.IsInRange(destinationOffsetZ, 0, destination.Depth);
|
||||
Guard.IsBetweenOrEqualTo(width, 1, Width);
|
||||
Guard.IsBetweenOrEqualTo(height, 1, Height);
|
||||
Guard.IsBetweenOrEqualTo(depth, 1, Depth);
|
||||
Guard.IsBetweenOrEqualTo(width, 1, destination.Width);
|
||||
Guard.IsBetweenOrEqualTo(height, 1, destination.Height);
|
||||
Guard.IsBetweenOrEqualTo(depth, 1, destination.Depth);
|
||||
Guard.IsBetweenOrEqualTo(destinationOffsetX + width, 1, destination.Width, nameof(destinationOffsetX));
|
||||
Guard.IsBetweenOrEqualTo(destinationOffsetY + height, 1, destination.Height, nameof(destinationOffsetY));
|
||||
Guard.IsBetweenOrEqualTo(destinationOffsetZ + depth, 1, destination.Depth, nameof(destinationOffsetZ));
|
||||
Guard.IsLessThanOrEqualTo(sourceOffsetX + width, Width, nameof(sourceOffsetX));
|
||||
Guard.IsLessThanOrEqualTo(sourceOffsetY + height, Height, nameof(sourceOffsetY));
|
||||
Guard.IsLessThanOrEqualTo(sourceOffsetZ + depth, Depth, nameof(sourceOffsetZ));
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetX, 0, Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetY, 0, Height);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetZ, 0, Depth);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetX, 0, destination.Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetY, 0, destination.Height);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetZ, 0, destination.Depth);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(height, 1, Height);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(depth, 1, Depth);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, destination.Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(height, 1, destination.Height);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(depth, 1, destination.Depth);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(destinationOffsetX + width, 1, destination.Width, nameof(destinationOffsetX));
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(destinationOffsetY + height, 1, destination.Height, nameof(destinationOffsetY));
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(destinationOffsetZ + depth, 1, destination.Depth, nameof(destinationOffsetZ));
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(sourceOffsetX + width, Width, nameof(sourceOffsetX));
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(sourceOffsetY + height, Height, nameof(sourceOffsetY));
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(sourceOffsetZ + depth, Depth, nameof(sourceOffsetZ));
|
||||
|
||||
using ReferenceTracker.Lease _0 = GraphicsDevice.GetReferenceTracker().GetLease();
|
||||
using ReferenceTracker.Lease _1 = GetReferenceTracker().GetLease();
|
||||
@@ -366,24 +365,24 @@ public abstract unsafe partial class Texture3D<T> : IReferenceTrackedObject, IGr
|
||||
/// <param name="depth">The depth of the memory area to copy.</param>
|
||||
internal void CopyTo(ReadBackTexture3D<T> destination, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth)
|
||||
{
|
||||
Guard.IsInRange(sourceOffsetX, 0, Width);
|
||||
Guard.IsInRange(sourceOffsetY, 0, Height);
|
||||
Guard.IsInRange(sourceOffsetZ, 0, Depth);
|
||||
Guard.IsInRange(destinationOffsetX, 0, destination.Width);
|
||||
Guard.IsInRange(destinationOffsetY, 0, destination.Height);
|
||||
Guard.IsInRange(destinationOffsetZ, 0, destination.Depth);
|
||||
Guard.IsBetweenOrEqualTo(width, 1, Width);
|
||||
Guard.IsBetweenOrEqualTo(height, 1, Height);
|
||||
Guard.IsBetweenOrEqualTo(depth, 1, Depth);
|
||||
Guard.IsBetweenOrEqualTo(width, 1, destination.Width);
|
||||
Guard.IsBetweenOrEqualTo(height, 1, destination.Height);
|
||||
Guard.IsBetweenOrEqualTo(depth, 1, destination.Depth);
|
||||
Guard.IsBetweenOrEqualTo(destinationOffsetX + width, 1, destination.Width, nameof(destinationOffsetX));
|
||||
Guard.IsBetweenOrEqualTo(destinationOffsetY + height, 1, destination.Height, nameof(destinationOffsetY));
|
||||
Guard.IsBetweenOrEqualTo(destinationOffsetZ + depth, 1, destination.Depth, nameof(destinationOffsetZ));
|
||||
Guard.IsLessThanOrEqualTo(sourceOffsetX + width, Width, nameof(sourceOffsetX));
|
||||
Guard.IsLessThanOrEqualTo(sourceOffsetY + height, Height, nameof(sourceOffsetY));
|
||||
Guard.IsLessThanOrEqualTo(sourceOffsetZ + depth, Depth, nameof(sourceOffsetZ));
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetX, 0, Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetY, 0, Height);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetZ, 0, Depth);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetX, 0, destination.Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetY, 0, destination.Height);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetZ, 0, destination.Depth);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(height, 1, Height);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(depth, 1, Depth);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, destination.Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(height, 1, destination.Height);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(depth, 1, destination.Depth);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(destinationOffsetX + width, 1, destination.Width, nameof(destinationOffsetX));
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(destinationOffsetY + height, 1, destination.Height, nameof(destinationOffsetY));
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(destinationOffsetZ + depth, 1, destination.Depth, nameof(destinationOffsetZ));
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(sourceOffsetX + width, Width, nameof(sourceOffsetX));
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(sourceOffsetY + height, Height, nameof(sourceOffsetY));
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(sourceOffsetZ + depth, Depth, nameof(sourceOffsetZ));
|
||||
|
||||
using ReferenceTracker.Lease _0 = GraphicsDevice.GetReferenceTracker().GetLease();
|
||||
using ReferenceTracker.Lease _1 = GetReferenceTracker().GetLease();
|
||||
@@ -438,16 +437,16 @@ public abstract unsafe partial class Texture3D<T> : IReferenceTrackedObject, IGr
|
||||
/// <param name="depth">The depth of the memory area to write to.</param>
|
||||
internal void CopyFrom(ref T source, int size, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth)
|
||||
{
|
||||
Guard.IsInRange(destinationOffsetX, 0, Width);
|
||||
Guard.IsInRange(destinationOffsetY, 0, Height);
|
||||
Guard.IsInRange(destinationOffsetZ, 0, Depth);
|
||||
Guard.IsBetweenOrEqualTo(width, 1, Width);
|
||||
Guard.IsBetweenOrEqualTo(height, 1, Height);
|
||||
Guard.IsBetweenOrEqualTo(depth, 1, Depth);
|
||||
Guard.IsLessThanOrEqualTo(destinationOffsetX + width, Width, nameof(destinationOffsetX));
|
||||
Guard.IsLessThanOrEqualTo(destinationOffsetY + height, Height, nameof(destinationOffsetY));
|
||||
Guard.IsLessThanOrEqualTo(destinationOffsetZ + depth, Depth, nameof(destinationOffsetZ));
|
||||
Guard.IsGreaterThanOrEqualTo(size, (nint)width * height * depth);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetX, 0, Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetY, 0, Height);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetZ, 0, Depth);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(height, 1, Height);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(depth, 1, Depth);
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(destinationOffsetX + width, Width, nameof(destinationOffsetX));
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(destinationOffsetY + height, Height, nameof(destinationOffsetY));
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(destinationOffsetZ + depth, Depth, nameof(destinationOffsetZ));
|
||||
default(ArgumentOutOfRangeException).ThrowIfLessThan(size, (long)width * height * depth);
|
||||
|
||||
using ReferenceTracker.Lease _0 = GraphicsDevice.GetReferenceTracker().GetLease();
|
||||
using ReferenceTracker.Lease _1 = GetReferenceTracker().GetLease();
|
||||
@@ -537,24 +536,24 @@ public abstract unsafe partial class Texture3D<T> : IReferenceTrackedObject, IGr
|
||||
/// <param name="depth">The depth of the memory area to write to.</param>
|
||||
internal void CopyFrom(UploadTexture3D<T> source, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth)
|
||||
{
|
||||
Guard.IsInRange(sourceOffsetX, 0, source.Width);
|
||||
Guard.IsInRange(sourceOffsetY, 0, source.Height);
|
||||
Guard.IsInRange(sourceOffsetZ, 0, source.Depth);
|
||||
Guard.IsInRange(destinationOffsetX, 0, Width);
|
||||
Guard.IsInRange(destinationOffsetY, 0, Height);
|
||||
Guard.IsInRange(destinationOffsetZ, 0, Depth);
|
||||
Guard.IsBetweenOrEqualTo(width, 1, Width);
|
||||
Guard.IsBetweenOrEqualTo(height, 1, Height);
|
||||
Guard.IsBetweenOrEqualTo(depth, 1, Depth);
|
||||
Guard.IsBetweenOrEqualTo(width, 1, source.Width);
|
||||
Guard.IsBetweenOrEqualTo(height, 1, source.Height);
|
||||
Guard.IsBetweenOrEqualTo(depth, 1, source.Depth);
|
||||
Guard.IsLessThanOrEqualTo(sourceOffsetX + width, source.Width, nameof(sourceOffsetX));
|
||||
Guard.IsLessThanOrEqualTo(sourceOffsetY + height, source.Height, nameof(sourceOffsetY));
|
||||
Guard.IsLessThanOrEqualTo(sourceOffsetZ + depth, source.Depth, nameof(sourceOffsetZ));
|
||||
Guard.IsLessThanOrEqualTo(destinationOffsetX + width, Width, nameof(destinationOffsetX));
|
||||
Guard.IsLessThanOrEqualTo(destinationOffsetY + height, Height, nameof(destinationOffsetY));
|
||||
Guard.IsLessThanOrEqualTo(destinationOffsetZ + depth, Depth, nameof(destinationOffsetZ));
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetX, 0, source.Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetY, 0, source.Height);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetZ, 0, source.Depth);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetX, 0, Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetY, 0, Height);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetZ, 0, Depth);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(height, 1, Height);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(depth, 1, Depth);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, source.Width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(height, 1, source.Height);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(depth, 1, source.Depth);
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(sourceOffsetX + width, source.Width, nameof(sourceOffsetX));
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(sourceOffsetY + height, source.Height, nameof(sourceOffsetY));
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(sourceOffsetZ + depth, source.Depth, nameof(sourceOffsetZ));
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(destinationOffsetX + width, Width, nameof(destinationOffsetX));
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(destinationOffsetY + height, Height, nameof(destinationOffsetY));
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(destinationOffsetZ + depth, Depth, nameof(destinationOffsetZ));
|
||||
|
||||
using ReferenceTracker.Lease _0 = GraphicsDevice.GetReferenceTracker().GetLease();
|
||||
using ReferenceTracker.Lease _1 = GetReferenceTracker().GetLease();
|
||||
|
||||
@@ -2,7 +2,6 @@ using System;
|
||||
using System.Buffers;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
@@ -58,7 +57,7 @@ public abstract unsafe partial class TransferBuffer<T> : IReferenceTrackedObject
|
||||
this.referenceTracker = new ReferenceTracker(this);
|
||||
|
||||
// The maximum length is set such that the aligned buffer size can't exceed uint.MaxValue
|
||||
Guard.IsBetweenOrEqualTo(length, 1, (uint.MaxValue / (uint)sizeof(T)) & ~255);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(length, 1, (uint.MaxValue / (uint)sizeof(T)) & ~255);
|
||||
|
||||
using ReferenceTracker.Lease _0 = device.GetReferenceTracker().GetLease();
|
||||
|
||||
@@ -192,7 +191,7 @@ public abstract unsafe partial class TransferBuffer<T> : IReferenceTrackedObject
|
||||
/// <inheritdoc/>
|
||||
public override MemoryHandle Pin(int elementIndex = 0)
|
||||
{
|
||||
Guard.IsEqualTo(elementIndex, 0);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotZero(elementIndex);
|
||||
|
||||
using ReferenceTracker.Lease _0 = this.buffer.GetReferenceTracker().GetLease();
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Runtime.CompilerServices;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
@@ -60,7 +59,7 @@ public abstract unsafe partial class TransferTexture1D<T> : IReferenceTrackedObj
|
||||
{
|
||||
this.referenceTracker = new ReferenceTracker(this);
|
||||
|
||||
Guard.IsBetweenOrEqualTo(width, 1, D3D12.D3D12_REQ_TEXTURE1D_U_DIMENSION);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, D3D12.D3D12_REQ_TEXTURE1D_U_DIMENSION);
|
||||
|
||||
using ReferenceTracker.Lease _0 = device.GetReferenceTracker().GetLease();
|
||||
|
||||
@@ -197,7 +196,7 @@ public abstract unsafe partial class TransferTexture1D<T> : IReferenceTrackedObj
|
||||
/// <inheritdoc/>
|
||||
public override MemoryHandle Pin(int elementIndex = 0)
|
||||
{
|
||||
Guard.IsEqualTo(elementIndex, 0);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotZero(elementIndex);
|
||||
|
||||
using ReferenceTracker.Lease _0 = this.buffer.GetReferenceTracker().GetLease();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
@@ -59,8 +59,8 @@ public abstract unsafe partial class TransferTexture2D<T> : IReferenceTrackedObj
|
||||
{
|
||||
this.referenceTracker = new ReferenceTracker(this);
|
||||
|
||||
Guard.IsBetweenOrEqualTo(width, 1, D3D12.D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION);
|
||||
Guard.IsBetweenOrEqualTo(height, 1, D3D12.D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, D3D12.D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(height, 1, D3D12.D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION);
|
||||
|
||||
using ReferenceTracker.Lease _0 = device.GetReferenceTracker().GetLease();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
@@ -60,9 +60,9 @@ public abstract unsafe partial class TransferTexture3D<T> : IReferenceTrackedObj
|
||||
{
|
||||
this.referenceTracker = new ReferenceTracker(this);
|
||||
|
||||
Guard.IsBetweenOrEqualTo(width, 1, D3D12.D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION);
|
||||
Guard.IsBetweenOrEqualTo(height, 1, D3D12.D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION);
|
||||
Guard.IsBetweenOrEqualTo(depth, 1, D3D12.D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, D3D12.D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(height, 1, D3D12.D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(depth, 1, D3D12.D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION);
|
||||
|
||||
using ReferenceTracker.Lease _0 = device.GetReferenceTracker().GetLease();
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using ComputeSharp.Core.Helpers;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
@@ -60,9 +60,9 @@ public sealed class ConstantBuffer<T> : Buffer<T>
|
||||
/// <inheritdoc/>
|
||||
internal override unsafe void CopyTo(ref T destination, int offset, int length)
|
||||
{
|
||||
Guard.IsBetweenOrEqualTo(length, 0, Length);
|
||||
Guard.IsInRange(offset, 0, Length);
|
||||
Guard.IsLessThanOrEqualTo(offset + length, Length, nameof(offset));
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(length, 0, Length);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(offset, 0, Length);
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(offset + length, Length, nameof(offset));
|
||||
|
||||
using ReferenceTracker.Lease _0 = GraphicsDevice.GetReferenceTracker().GetLease();
|
||||
using ReferenceTracker.Lease _1 = GetReferenceTracker().GetLease();
|
||||
@@ -87,12 +87,12 @@ public sealed class ConstantBuffer<T> : Buffer<T>
|
||||
/// <inheritdoc/>
|
||||
internal override unsafe void CopyTo(Buffer<T> destination, int sourceOffset, int destinationOffset, int length)
|
||||
{
|
||||
Guard.IsBetweenOrEqualTo(length, 0, Length);
|
||||
Guard.IsBetweenOrEqualTo(length, 0, destination.Length);
|
||||
Guard.IsInRange(sourceOffset, 0, Length);
|
||||
Guard.IsLessThanOrEqualTo(sourceOffset + length, Length, nameof(sourceOffset));
|
||||
Guard.IsInRange(destinationOffset, 0, destination.Length);
|
||||
Guard.IsLessThanOrEqualTo(destinationOffset + length, destination.Length, nameof(destinationOffset));
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(length, 0, Length);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(length, 0, destination.Length);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffset, 0, Length);
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(sourceOffset + length, Length, nameof(sourceOffset));
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffset, 0, destination.Length);
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(destinationOffset + length, destination.Length, nameof(destinationOffset));
|
||||
|
||||
using ReferenceTracker.Lease _0 = GraphicsDevice.GetReferenceTracker().GetLease();
|
||||
using ReferenceTracker.Lease _1 = GetReferenceTracker().GetLease();
|
||||
@@ -125,9 +125,9 @@ public sealed class ConstantBuffer<T> : Buffer<T>
|
||||
/// <inheritdoc/>
|
||||
internal override unsafe void CopyFrom(ref T source, int offset, int length)
|
||||
{
|
||||
Guard.IsBetweenOrEqualTo(length, 0, Length);
|
||||
Guard.IsInRange(offset, 0, Length);
|
||||
Guard.IsLessThanOrEqualTo(offset + length, Length, nameof(offset));
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(length, 0, Length);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(offset, 0, Length);
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(offset + length, Length, nameof(offset));
|
||||
|
||||
using ReferenceTracker.Lease _0 = GraphicsDevice.GetReferenceTracker().GetLease();
|
||||
using ReferenceTracker.Lease _1 = GetReferenceTracker().GetLease();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using static TerraFX.Interop.DirectX.D3D12_RESOURCE_STATES;
|
||||
|
||||
@@ -28,6 +28,6 @@ internal static class ResourceStateHelper
|
||||
return D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
|
||||
}
|
||||
|
||||
return ThrowHelper.ThrowArgumentException<D3D12_RESOURCE_STATES>("The target resource state is not valid.");
|
||||
return default(ArgumentException).Throw<D3D12_RESOURCE_STATES>(nameof(resourceState));
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
|
||||
#pragma warning disable CS0809, CA1065
|
||||
|
||||
@@ -127,8 +126,8 @@ public readonly unsafe ref struct TextureView2D<T>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get
|
||||
{
|
||||
Guard.IsInRange(x, 0, this.width);
|
||||
Guard.IsInRange(y, 0, this.height);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(x, 0, this.width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(y, 0, this.height);
|
||||
|
||||
return ref *((T*)((byte*)this.pointer + (y * this.strideInBytes)) + x);
|
||||
}
|
||||
@@ -177,7 +176,7 @@ public readonly unsafe ref struct TextureView2D<T>
|
||||
}
|
||||
else
|
||||
{
|
||||
Guard.HasSizeGreaterThanOrEqualTo(destination, Length);
|
||||
default(ArgumentException).ThrowIf(destination.Length != Length, nameof(destination));
|
||||
|
||||
for (int y = 0, j = 0; y < this.height; y++, j += this.width)
|
||||
{
|
||||
@@ -194,11 +193,8 @@ public readonly unsafe ref struct TextureView2D<T>
|
||||
/// <exception cref="ArgumentException">Thrown when <paramref name="destination"/> doesn't match the size of the current <see cref="TextureView2D{T}"/> instance.</exception>
|
||||
public void CopyTo(TextureView2D<T> destination)
|
||||
{
|
||||
if (destination.width != this.width ||
|
||||
destination.height != this.height)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentException();
|
||||
}
|
||||
default(ArgumentException).ThrowIf(destination.width != this.width, nameof(destination));
|
||||
default(ArgumentException).ThrowIf(destination.height != this.height, nameof(destination));
|
||||
|
||||
if (IsEmpty)
|
||||
{
|
||||
@@ -297,7 +293,7 @@ public readonly unsafe ref struct TextureView2D<T>
|
||||
/// <returns>The resulting row <see cref="Span{T}"/>.</returns>
|
||||
public Span<T> GetRowSpan(int y)
|
||||
{
|
||||
Guard.IsInRange(y, 0, this.height);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(y, 0, this.height);
|
||||
|
||||
return new((byte*)this.pointer + (y * this.strideInBytes), this.width);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
|
||||
#pragma warning disable CS0809, CA1065
|
||||
|
||||
@@ -152,9 +151,9 @@ public readonly unsafe ref struct TextureView3D<T>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get
|
||||
{
|
||||
Guard.IsInRange(x, 0, this.width);
|
||||
Guard.IsInRange(y, 0, this.height);
|
||||
Guard.IsInRange(z, 0, this.depth);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(x, 0, this.width);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(y, 0, this.height);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(z, 0, this.depth);
|
||||
|
||||
return ref *((T*)((byte*)this.pointer + (z * this.height * this.strideInBytes) + (y * this.strideInBytes)) + x);
|
||||
}
|
||||
@@ -224,12 +223,9 @@ public readonly unsafe ref struct TextureView3D<T>
|
||||
/// <exception cref="ArgumentException">Thrown when <paramref name="destination"/> doesn't match the size of the current <see cref="TextureView3D{T}"/> instance.</exception>
|
||||
public void CopyTo(TextureView3D<T> destination)
|
||||
{
|
||||
if (destination.width != this.width ||
|
||||
destination.height != this.height ||
|
||||
destination.depth != this.depth)
|
||||
{
|
||||
ThrowHelper.ThrowArgumentException();
|
||||
}
|
||||
default(ArgumentException).ThrowIf(destination.width != this.width, nameof(destination));
|
||||
default(ArgumentException).ThrowIf(destination.height != this.height, nameof(destination));
|
||||
default(ArgumentException).ThrowIf(destination.depth != this.depth, nameof(destination));
|
||||
|
||||
if (IsEmpty)
|
||||
{
|
||||
@@ -336,8 +332,8 @@ public readonly unsafe ref struct TextureView3D<T>
|
||||
/// <returns>The resulting row <see cref="Span{T}"/>.</returns>
|
||||
public Span<T> GetRowSpan(int y, int z)
|
||||
{
|
||||
Guard.IsInRange(y, 0, this.height);
|
||||
Guard.IsInRange(z, 0, this.depth);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(y, 0, this.height);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(z, 0, this.depth);
|
||||
|
||||
return new((byte*)this.pointer + (z * this.height * this.strideInBytes) + (y * this.strideInBytes), this.width);
|
||||
}
|
||||
@@ -350,7 +346,7 @@ public readonly unsafe ref struct TextureView3D<T>
|
||||
/// <returns>The resulting row <see cref="TextureView2D{T}"/>.</returns>
|
||||
public TextureView2D<T> GetDepthView(int z)
|
||||
{
|
||||
Guard.IsInRange(z, 0, this.depth);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotInRange(z, 0, this.depth);
|
||||
|
||||
return new(
|
||||
(T*)((byte*)this.pointer + (z * this.height * this.strideInBytes)),
|
||||
|
||||
@@ -2,7 +2,6 @@ using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Graphics.Commands;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
@@ -60,7 +59,7 @@ public struct ComputeContext : IDisposable, IAsyncDisposable
|
||||
{
|
||||
get
|
||||
{
|
||||
ThrowInvalidOperationExceptionIfDeviceIsNull();
|
||||
default(InvalidOperationException).ThrowIf(this.device is null);
|
||||
|
||||
return this.device;
|
||||
}
|
||||
@@ -72,7 +71,7 @@ public struct ComputeContext : IDisposable, IAsyncDisposable
|
||||
/// <param name="d3D12Resource">The <see cref="ID3D12Resource"/> to insert the barrier for.</param>
|
||||
internal readonly unsafe void Barrier(ID3D12Resource* d3D12Resource)
|
||||
{
|
||||
ThrowInvalidOperationExceptionIfDeviceIsNull();
|
||||
default(InvalidOperationException).ThrowIf(this.device is null);
|
||||
|
||||
ref CommandList commandList = ref GetCommandList();
|
||||
|
||||
@@ -92,7 +91,7 @@ public struct ComputeContext : IDisposable, IAsyncDisposable
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandle,
|
||||
bool isNormalized)
|
||||
{
|
||||
ThrowInvalidOperationExceptionIfDeviceIsNull();
|
||||
default(InvalidOperationException).ThrowIf(this.device is null);
|
||||
|
||||
ref CommandList commandList = ref GetCommandList(pipelineState: null);
|
||||
|
||||
@@ -112,7 +111,7 @@ public struct ComputeContext : IDisposable, IAsyncDisposable
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandle,
|
||||
Float4 value)
|
||||
{
|
||||
ThrowInvalidOperationExceptionIfDeviceIsNull();
|
||||
default(InvalidOperationException).ThrowIf(this.device is null);
|
||||
|
||||
ref CommandList commandList = ref GetCommandList(pipelineState: null);
|
||||
|
||||
@@ -179,23 +178,22 @@ public struct ComputeContext : IDisposable, IAsyncDisposable
|
||||
ref T shader)
|
||||
where T : struct, IComputeShader
|
||||
{
|
||||
ThrowInvalidOperationExceptionIfDeviceIsNull();
|
||||
|
||||
Guard.IsGreaterThan(x, 0);
|
||||
Guard.IsGreaterThan(y, 0);
|
||||
Guard.IsGreaterThan(z, 0);
|
||||
Guard.IsBetweenOrEqualTo(threadsX, 1, 1024);
|
||||
Guard.IsBetweenOrEqualTo(threadsY, 1, 1024);
|
||||
Guard.IsBetweenOrEqualTo(threadsZ, 1, 64);
|
||||
Guard.IsLessThanOrEqualTo(threadsX * threadsY * threadsZ, 1024, "threadsXYZ");
|
||||
default(InvalidOperationException).ThrowIf(this.device is null);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNegativeOrZero(x);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNegativeOrZero(y);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNegativeOrZero(z);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(threadsX, 1, 1024);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(threadsY, 1, 1024);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(threadsZ, 1, 64);
|
||||
default(ArgumentOutOfRangeException).ThrowIfGreaterThan(threadsX * threadsY * threadsZ, 1024, "threadsXYZ");
|
||||
|
||||
int groupsX = Math.DivRem(x, threadsX, out int modX) + (modX == 0 ? 0 : 1);
|
||||
int groupsY = Math.DivRem(y, threadsY, out int modY) + (modY == 0 ? 0 : 1);
|
||||
int groupsZ = Math.DivRem(z, threadsZ, out int modZ) + (modZ == 0 ? 0 : 1);
|
||||
|
||||
Guard.IsBetweenOrEqualTo(groupsX, 1, D3D11.D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION);
|
||||
Guard.IsBetweenOrEqualTo(groupsY, 1, D3D11.D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION, nameof(groupsX));
|
||||
Guard.IsBetweenOrEqualTo(groupsZ, 1, D3D11.D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION, nameof(groupsX));
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(groupsX, 1, D3D11.D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(groupsY, 1, D3D11.D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION, nameof(groupsX));
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(groupsZ, 1, D3D11.D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION, nameof(groupsX));
|
||||
|
||||
PipelineData pipelineData = PipelineDataLoader<T>.GetPipelineData(this.device, threadsX, threadsY, threadsZ, ref shader);
|
||||
|
||||
@@ -221,7 +219,7 @@ public struct ComputeContext : IDisposable, IAsyncDisposable
|
||||
where T : struct, IPixelShader<TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
ThrowInvalidOperationExceptionIfDeviceIsNull();
|
||||
default(InvalidOperationException).ThrowIf(this.device is null);
|
||||
|
||||
int x = texture.Width;
|
||||
int y = texture.Height;
|
||||
@@ -231,8 +229,8 @@ public struct ComputeContext : IDisposable, IAsyncDisposable
|
||||
int groupsX = Math.DivRem(x, threadsX, out int modX) + (modX == 0 ? 0 : 1);
|
||||
int groupsY = Math.DivRem(y, threadsY, out int modY) + (modY == 0 ? 0 : 1);
|
||||
|
||||
Guard.IsBetweenOrEqualTo(groupsX, 1, D3D11.D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION);
|
||||
Guard.IsBetweenOrEqualTo(groupsY, 1, D3D11.D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION, nameof(groupsX));
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(groupsX, 1, D3D11.D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(groupsY, 1, D3D11.D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION, nameof(groupsX));
|
||||
|
||||
PipelineData pipelineData = PipelineDataLoader<T>.GetPipelineData(this.device, threadsX, threadsY, threadsZ, ref shader);
|
||||
|
||||
@@ -263,7 +261,7 @@ public struct ComputeContext : IDisposable, IAsyncDisposable
|
||||
D3D12_RESOURCE_STATES d3D12ResourceStatesBefore,
|
||||
D3D12_RESOURCE_STATES d3D12ResourceStatesAfter)
|
||||
{
|
||||
ThrowInvalidOperationExceptionIfDeviceIsNull();
|
||||
default(InvalidOperationException).ThrowIf(this.device is null);
|
||||
|
||||
ref CommandList commandList = ref GetCommandList(pipelineState: null);
|
||||
|
||||
@@ -274,7 +272,7 @@ public struct ComputeContext : IDisposable, IAsyncDisposable
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Dispose()
|
||||
{
|
||||
ThrowInvalidOperationExceptionIfDeviceIsNull();
|
||||
default(InvalidOperationException).ThrowIf(this.device is null);
|
||||
|
||||
GraphicsDevice device = this.device;
|
||||
|
||||
@@ -301,7 +299,7 @@ public struct ComputeContext : IDisposable, IAsyncDisposable
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public ValueTask DisposeAsync()
|
||||
{
|
||||
ThrowInvalidOperationExceptionIfDeviceIsNull();
|
||||
default(InvalidOperationException).ThrowIf(this.device is null);
|
||||
|
||||
GraphicsDevice device = this.device;
|
||||
|
||||
@@ -342,10 +340,7 @@ public struct ComputeContext : IDisposable, IAsyncDisposable
|
||||
// original context would not see the changes done by the following queued dispatches.
|
||||
ref CommandList commandList = ref Unsafe.AsRef(in this.commandList);
|
||||
|
||||
if (!commandList.IsAllocated)
|
||||
{
|
||||
ThrowHelper.ThrowInvalidOperationException("The current compute context has not yet been initialized.");
|
||||
}
|
||||
default(InvalidOperationException).ThrowIf(!commandList.IsAllocated);
|
||||
|
||||
return ref commandList;
|
||||
}
|
||||
@@ -377,18 +372,4 @@ public struct ComputeContext : IDisposable, IAsyncDisposable
|
||||
|
||||
return ref commandList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an <see cref="InvalidOperationException"/> if <see cref="device"/> is <see langword="null"/>.
|
||||
/// </summary>
|
||||
/// <exception cref="InvalidOperationException">Thrown if <see cref="device"/> is <see langword="null"/>.</exception>
|
||||
[MemberNotNull(nameof(device))]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private readonly void ThrowInvalidOperationExceptionIfDeviceIsNull()
|
||||
{
|
||||
if (this.device is null)
|
||||
{
|
||||
ThrowHelper.ThrowInvalidOperationException("The current compute context is not in a valid state.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Shaders.Models;
|
||||
using TerraFX.Interop.DirectX;
|
||||
@@ -27,26 +26,16 @@ internal struct ShaderBytecodeLoader : IBytecodeLoader
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public ICachedShader GetCachedShader()
|
||||
{
|
||||
if (this.cachedShader is not ICachedShader cachedShader)
|
||||
{
|
||||
return ThrowHelper.ThrowInvalidOperationException<ICachedShader>("The shader has not been initialized.");
|
||||
}
|
||||
default(InvalidOperationException).ThrowIf(this.cachedShader is null);
|
||||
|
||||
return cachedShader;
|
||||
return this.cachedShader;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public unsafe void LoadDynamicBytecode(IntPtr handle)
|
||||
{
|
||||
if (this.cachedShader is not null)
|
||||
{
|
||||
ThrowHelper.ThrowInvalidOperationException("The shader has already been initialized.");
|
||||
}
|
||||
|
||||
if (handle == IntPtr.Zero)
|
||||
{
|
||||
ThrowHelper.ThrowNotSupportedException("Runtime shader compilation is not supported by the current configuration.");
|
||||
}
|
||||
default(InvalidOperationException).ThrowIf(this.cachedShader is not null);
|
||||
default(NotSupportedException).ThrowIf(handle == IntPtr.Zero);
|
||||
|
||||
this.cachedShader = new ICachedShader.Dynamic((IDxcBlob*)handle);
|
||||
}
|
||||
@@ -55,10 +44,7 @@ internal struct ShaderBytecodeLoader : IBytecodeLoader
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void LoadEmbeddedBytecode(ReadOnlySpan<byte> bytecode)
|
||||
{
|
||||
if (this.cachedShader is not null)
|
||||
{
|
||||
ThrowHelper.ThrowInvalidOperationException("The shader has already been initialized.");
|
||||
}
|
||||
default(InvalidOperationException).ThrowIf(this.cachedShader is not null);
|
||||
|
||||
this.cachedShader = new ICachedShader.Embedded(bytecode);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using ComputeSharp.Shaders.Extensions;
|
||||
using ComputeSharp.__Internals;
|
||||
using TerraFX.Interop.DirectX;
|
||||
@@ -34,7 +33,7 @@ internal readonly unsafe struct ShaderDispatchMetadataLoader : IDispatchMetadata
|
||||
/// <inheritdoc/>
|
||||
public unsafe void LoadMetadataHandle(ReadOnlySpan<byte> serializedMetadata, ReadOnlySpan<ResourceDescriptor> resourceDescriptors, out IntPtr result)
|
||||
{
|
||||
Guard.HasSizeEqualTo(serializedMetadata, 5);
|
||||
default(ArgumentException).ThrowIf(serializedMetadata.Length != 5, nameof(serializedMetadata));
|
||||
|
||||
fixed (IntPtr* p = &result)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
using ComputeSharp.Interop;
|
||||
@@ -23,7 +23,7 @@ public static class ComputeContextExtensions
|
||||
public static unsafe void Barrier<T>(this in ComputeContext context, ReadWriteBuffer<T> buffer)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(buffer);
|
||||
default(ArgumentNullException).ThrowIfNull(buffer);
|
||||
|
||||
using ReferenceTracker.Lease lease = default;
|
||||
|
||||
@@ -39,7 +39,7 @@ public static class ComputeContextExtensions
|
||||
public static unsafe void Barrier<T>(this in ComputeContext context, ReadWriteTexture1D<T> texture)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
using ReferenceTracker.Lease lease = default;
|
||||
|
||||
@@ -55,7 +55,7 @@ public static class ComputeContextExtensions
|
||||
public static unsafe void Barrier<T>(this in ComputeContext context, ReadWriteTexture2D<T> texture)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
using ReferenceTracker.Lease lease = default;
|
||||
|
||||
@@ -71,7 +71,7 @@ public static class ComputeContextExtensions
|
||||
public static unsafe void Barrier<T>(this in ComputeContext context, ReadWriteTexture3D<T> texture)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
using ReferenceTracker.Lease lease = default;
|
||||
|
||||
@@ -89,7 +89,7 @@ public static class ComputeContextExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
using ReferenceTracker.Lease lease = default;
|
||||
|
||||
@@ -107,7 +107,7 @@ public static class ComputeContextExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
using ReferenceTracker.Lease lease = default;
|
||||
|
||||
@@ -125,7 +125,7 @@ public static class ComputeContextExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
using ReferenceTracker.Lease lease = default;
|
||||
|
||||
@@ -141,7 +141,7 @@ public static class ComputeContextExtensions
|
||||
public static unsafe void Barrier<TPixel>(this in ComputeContext context, IReadWriteNormalizedTexture1D<TPixel> texture)
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
using ReferenceTracker.Lease lease = default;
|
||||
|
||||
@@ -157,7 +157,7 @@ public static class ComputeContextExtensions
|
||||
public static unsafe void Barrier<TPixel>(this in ComputeContext context, IReadWriteNormalizedTexture2D<TPixel> texture)
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
using ReferenceTracker.Lease lease = default;
|
||||
|
||||
@@ -173,7 +173,7 @@ public static class ComputeContextExtensions
|
||||
public static unsafe void Barrier<TPixel>(this in ComputeContext context, IReadWriteNormalizedTexture3D<TPixel> texture)
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
using ReferenceTracker.Lease lease = default;
|
||||
|
||||
@@ -189,7 +189,7 @@ public static class ComputeContextExtensions
|
||||
public static unsafe void Clear<T>(this in ComputeContext context, ReadWriteBuffer<T> buffer)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(buffer);
|
||||
default(ArgumentNullException).ThrowIfNull(buffer);
|
||||
|
||||
(D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = buffer.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice);
|
||||
|
||||
@@ -205,7 +205,7 @@ public static class ComputeContextExtensions
|
||||
public static unsafe void Clear<T>(this in ComputeContext context, ReadWriteTexture1D<T> texture)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
(D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = texture.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out bool isNormalized);
|
||||
|
||||
@@ -221,7 +221,7 @@ public static class ComputeContextExtensions
|
||||
public static unsafe void Clear<T>(this in ComputeContext context, ReadWriteTexture2D<T> texture)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
(D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = texture.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out bool isNormalized);
|
||||
|
||||
@@ -237,7 +237,7 @@ public static class ComputeContextExtensions
|
||||
public static unsafe void Clear<T>(this in ComputeContext context, ReadWriteTexture3D<T> texture)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
(D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = texture.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out bool isNormalized);
|
||||
|
||||
@@ -255,7 +255,7 @@ public static class ComputeContextExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
(D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = texture.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _);
|
||||
|
||||
@@ -273,7 +273,7 @@ public static class ComputeContextExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
(D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = texture.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _);
|
||||
|
||||
@@ -291,7 +291,7 @@ public static class ComputeContextExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
(D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = texture.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _);
|
||||
|
||||
@@ -307,7 +307,7 @@ public static class ComputeContextExtensions
|
||||
public static unsafe void Clear<TPixel>(this in ComputeContext context, IReadWriteNormalizedTexture1D<TPixel> texture)
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
(D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = ((GraphicsResourceHelper.IGraphicsResource)texture).ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _);
|
||||
|
||||
@@ -325,7 +325,7 @@ public static class ComputeContextExtensions
|
||||
public static unsafe void Clear<TPixel>(this in ComputeContext context, IReadWriteNormalizedTexture2D<TPixel> texture)
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
(D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = ((GraphicsResourceHelper.IGraphicsResource)texture).ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _);
|
||||
|
||||
@@ -343,7 +343,7 @@ public static class ComputeContextExtensions
|
||||
public static unsafe void Clear<TPixel>(this in ComputeContext context, IReadWriteNormalizedTexture3D<TPixel> texture)
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
(D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = ((GraphicsResourceHelper.IGraphicsResource)texture).ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _);
|
||||
|
||||
@@ -364,7 +364,7 @@ public static class ComputeContextExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
(D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = texture.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _);
|
||||
|
||||
@@ -383,7 +383,7 @@ public static class ComputeContextExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
(D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = texture.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _);
|
||||
|
||||
@@ -402,7 +402,7 @@ public static class ComputeContextExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
(D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = texture.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _);
|
||||
|
||||
@@ -419,7 +419,7 @@ public static class ComputeContextExtensions
|
||||
public static unsafe void Fill<TPixel>(this in ComputeContext context, IReadWriteNormalizedTexture1D<TPixel> texture, TPixel value)
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
(D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = ((GraphicsResourceHelper.IGraphicsResource)texture).ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _);
|
||||
|
||||
@@ -442,7 +442,7 @@ public static class ComputeContextExtensions
|
||||
public static unsafe void Fill<TPixel>(this in ComputeContext context, IReadWriteNormalizedTexture2D<TPixel> texture, TPixel value)
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
(D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = ((GraphicsResourceHelper.IGraphicsResource)texture).ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _);
|
||||
|
||||
@@ -465,7 +465,7 @@ public static class ComputeContextExtensions
|
||||
public static unsafe void Fill<TPixel>(this in ComputeContext context, IReadWriteNormalizedTexture3D<TPixel> texture, TPixel value)
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
(D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = ((GraphicsResourceHelper.IGraphicsResource)texture).ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _);
|
||||
|
||||
@@ -549,7 +549,7 @@ public static class ComputeContextExtensions
|
||||
where T : struct, IPixelShader<TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
context.Run(texture, ref Unsafe.AsRef(default(T)));
|
||||
}
|
||||
@@ -566,7 +566,7 @@ public static class ComputeContextExtensions
|
||||
where T : struct, IPixelShader<TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
context.Run(texture, ref Unsafe.AsRef(in shader));
|
||||
}
|
||||
@@ -579,7 +579,7 @@ public static class ComputeContextExtensions
|
||||
/// <param name="resourceState">The state to transition the input resource to.</param>
|
||||
public static unsafe void Transition(this in ComputeContext context, ReadWriteTexture1D<float> texture, ResourceState resourceState)
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
using ReferenceTracker.Lease lease = default;
|
||||
|
||||
@@ -596,7 +596,7 @@ public static class ComputeContextExtensions
|
||||
/// <param name="resourceState">The state to transition the input resource to.</param>
|
||||
public static unsafe void Transition(this in ComputeContext context, ReadWriteTexture1D<Float2> texture, ResourceState resourceState)
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
using ReferenceTracker.Lease lease = default;
|
||||
|
||||
@@ -613,7 +613,7 @@ public static class ComputeContextExtensions
|
||||
/// <param name="resourceState">The state to transition the input resource to.</param>
|
||||
public static unsafe void Transition(this in ComputeContext context, ReadWriteTexture1D<Float3> texture, ResourceState resourceState)
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
using ReferenceTracker.Lease lease = default;
|
||||
|
||||
@@ -630,7 +630,7 @@ public static class ComputeContextExtensions
|
||||
/// <param name="resourceState">The state to transition the input resource to.</param>
|
||||
public static unsafe void Transition(this in ComputeContext context, ReadWriteTexture1D<Float4> texture, ResourceState resourceState)
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
using ReferenceTracker.Lease lease = default;
|
||||
|
||||
@@ -651,7 +651,7 @@ public static class ComputeContextExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
using ReferenceTracker.Lease lease = default;
|
||||
|
||||
@@ -668,7 +668,7 @@ public static class ComputeContextExtensions
|
||||
/// <param name="resourceState">The state to transition the input resource to.</param>
|
||||
public static unsafe void Transition(this in ComputeContext context, ReadWriteTexture2D<float> texture, ResourceState resourceState)
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
using ReferenceTracker.Lease lease = default;
|
||||
|
||||
@@ -685,7 +685,7 @@ public static class ComputeContextExtensions
|
||||
/// <param name="resourceState">The state to transition the input resource to.</param>
|
||||
public static unsafe void Transition(this in ComputeContext context, ReadWriteTexture2D<Float2> texture, ResourceState resourceState)
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
using ReferenceTracker.Lease lease = default;
|
||||
|
||||
@@ -702,7 +702,7 @@ public static class ComputeContextExtensions
|
||||
/// <param name="resourceState">The state to transition the input resource to.</param>
|
||||
public static unsafe void Transition(this in ComputeContext context, ReadWriteTexture2D<Float3> texture, ResourceState resourceState)
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
using ReferenceTracker.Lease lease = default;
|
||||
|
||||
@@ -719,7 +719,7 @@ public static class ComputeContextExtensions
|
||||
/// <param name="resourceState">The state to transition the input resource to.</param>
|
||||
public static unsafe void Transition(this in ComputeContext context, ReadWriteTexture2D<Float4> texture, ResourceState resourceState)
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
using ReferenceTracker.Lease lease = default;
|
||||
|
||||
@@ -740,7 +740,7 @@ public static class ComputeContextExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
using ReferenceTracker.Lease lease = default;
|
||||
|
||||
@@ -757,7 +757,7 @@ public static class ComputeContextExtensions
|
||||
/// <param name="resourceState">The state to transition the input resource to.</param>
|
||||
public static unsafe void Transition(this in ComputeContext context, ReadWriteTexture3D<float> texture, ResourceState resourceState)
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
using ReferenceTracker.Lease lease = default;
|
||||
|
||||
@@ -774,7 +774,7 @@ public static class ComputeContextExtensions
|
||||
/// <param name="resourceState">The state to transition the input resource to.</param>
|
||||
public static unsafe void Transition(this in ComputeContext context, ReadWriteTexture3D<Float2> texture, ResourceState resourceState)
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
using ReferenceTracker.Lease lease = default;
|
||||
|
||||
@@ -791,7 +791,7 @@ public static class ComputeContextExtensions
|
||||
/// <param name="resourceState">The state to transition the input resource to.</param>
|
||||
public static unsafe void Transition(this in ComputeContext context, ReadWriteTexture3D<Float3> texture, ResourceState resourceState)
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
using ReferenceTracker.Lease lease = default;
|
||||
|
||||
@@ -808,7 +808,7 @@ public static class ComputeContextExtensions
|
||||
/// <param name="resourceState">The state to transition the input resource to.</param>
|
||||
public static unsafe void Transition(this in ComputeContext context, ReadWriteTexture3D<Float4> texture, ResourceState resourceState)
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
using ReferenceTracker.Lease lease = default;
|
||||
|
||||
@@ -829,7 +829,7 @@ public static class ComputeContextExtensions
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
using ReferenceTracker.Lease lease = default;
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommunityToolkit.Diagnostics" Version="8.1.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="3.0.2" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="3.0.2" />
|
||||
|
||||
+1
@@ -7,6 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommunityToolkit.Diagnostics" Version="8.1.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="3.0.2" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="3.0.2" />
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommunityToolkit.Diagnostics" Version="8.1.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="3.0.2" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="3.0.2" />
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommunityToolkit.Diagnostics" Version="8.1.0" />
|
||||
<PackageReference Include="CommunityToolkit.HighPerformance" Version="8.1.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="3.0.2" />
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする