Add and use ArgumentOutOfRangeException.ThrowIfNotBetweenOrEqual

このコミットが含まれているのは:
Sergio Pedri committed 2023-02-25 16:54:54 +01:00
1 親 56031f443a
コミット cd19e8cdc1
12ファイル変更
+139 -98

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

+41
ファイルの表示
@@ -55,6 +55,40 @@ internal static class ArgumentOutOfRangeExceptionExtensions
}
}
/// <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>
@@ -66,4 +100,11 @@ internal static class ArgumentOutOfRangeExceptionExtensions
{
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);
}
}
+3 -3
ファイルの表示
@@ -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();
+8 -8
ファイルの表示
@@ -36,7 +36,7 @@ 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);
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(count, 0, Length);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffset, 0, Length);
Guard.IsLessThanOrEqualTo(sourceOffset + count, Length, nameof(sourceOffset));
@@ -108,8 +108,8 @@ 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);
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(count, 0, Length);
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(count, 0, destination.Length);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffset, 0, Length);
Guard.IsLessThanOrEqualTo(sourceOffset + count, Length, nameof(sourceOffset));
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffset, 0, destination.Length);
@@ -156,8 +156,8 @@ 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);
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(count, 0, Length);
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(count, 0, destination.Length);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffset, 0, Length);
Guard.IsLessThanOrEqualTo(sourceOffset + count, Length, nameof(sourceOffset));
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffset, 0, destination.Length);
@@ -200,7 +200,7 @@ 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);
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(length, 0, Length);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(offset, 0, Length);
Guard.IsLessThanOrEqualTo(offset + length, Length, nameof(offset));
@@ -276,8 +276,8 @@ 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);
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(count, 0, Length);
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(count, 0, source.Length);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffset, 0, source.Length);
Guard.IsLessThanOrEqualTo(sourceOffset + count, source.Length, nameof(sourceOffset));
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffset, 0, Length);
+11 -11
ファイルの表示
@@ -78,7 +78,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();
@@ -166,7 +166,7 @@ public abstract unsafe partial class Texture1D<T> : IReferenceTrackedObject, IGr
internal void CopyTo(ref T destination, int size, int sourceOffsetX, int width)
{
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetX, 0, Width);
Guard.IsBetweenOrEqualTo(width, 1, Width);
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, Width);
Guard.IsLessThanOrEqualTo(sourceOffsetX + width, Width, nameof(sourceOffsetX));
Guard.IsGreaterThanOrEqualTo(size, width);
@@ -249,9 +249,9 @@ public abstract unsafe partial class Texture1D<T> : IReferenceTrackedObject, IGr
{
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetX, 0, Width);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetX, 0, destination.Width);
Guard.IsBetweenOrEqualTo(width, 1, Width);
Guard.IsBetweenOrEqualTo(width, 1, destination.Width);
Guard.IsBetweenOrEqualTo(destinationOffsetX + width, 1, destination.Width, nameof(destinationOffsetX));
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, Width);
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, destination.Width);
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(destinationOffsetX + width, 1, destination.Width, nameof(destinationOffsetX));
Guard.IsLessThanOrEqualTo(sourceOffsetX + width, Width, nameof(sourceOffsetX));
using ReferenceTracker.Lease _0 = GraphicsDevice.GetReferenceTracker().GetLease();
@@ -309,9 +309,9 @@ public abstract unsafe partial class Texture1D<T> : IReferenceTrackedObject, IGr
{
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetX, 0, Width);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetX, 0, destination.Width);
Guard.IsBetweenOrEqualTo(width, 1, Width);
Guard.IsBetweenOrEqualTo(width, 1, destination.Width);
Guard.IsBetweenOrEqualTo(destinationOffsetX + width, 1, destination.Width, nameof(destinationOffsetX));
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, Width);
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, destination.Width);
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(destinationOffsetX + width, 1, destination.Width, nameof(destinationOffsetX));
Guard.IsLessThanOrEqualTo(sourceOffsetX + width, Width, nameof(sourceOffsetX));
using ReferenceTracker.Lease _0 = GraphicsDevice.GetReferenceTracker().GetLease();
@@ -364,7 +364,7 @@ public abstract unsafe partial class Texture1D<T> : IReferenceTrackedObject, IGr
internal void CopyFrom(ref T source, int size, int destinationOffsetX, int width)
{
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetX, 0, Width);
Guard.IsBetweenOrEqualTo(width, 1, Width);
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, Width);
Guard.IsLessThanOrEqualTo(destinationOffsetX + width, Width, nameof(destinationOffsetX));
Guard.IsGreaterThanOrEqualTo(size, width);
@@ -447,8 +447,8 @@ public abstract unsafe partial class Texture1D<T> : IReferenceTrackedObject, IGr
{
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetX, 0, source.Width);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetX, 0, Width);
Guard.IsBetweenOrEqualTo(width, 1, Width);
Guard.IsBetweenOrEqualTo(width, 1, source.Width);
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, Width);
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, source.Width);
Guard.IsLessThanOrEqualTo(sourceOffsetX + width, source.Width, nameof(sourceOffsetX));
Guard.IsLessThanOrEqualTo(destinationOffsetX + width, Width, nameof(destinationOffsetX));
+22 -22
ファイルの表示
@@ -79,8 +79,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();
@@ -179,8 +179,8 @@ public abstract unsafe partial class Texture2D<T> : IReferenceTrackedObject, IGr
{
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetX, 0, Width);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetY, 0, Height);
Guard.IsBetweenOrEqualTo(width, 1, Width);
Guard.IsBetweenOrEqualTo(height, 1, Height);
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, Width);
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(height, 1, Height);
Guard.IsLessThanOrEqualTo(sourceOffsetX + width, Width, nameof(sourceOffsetX));
Guard.IsLessThanOrEqualTo(sourceOffsetY + height, Height, nameof(sourceOffsetY));
Guard.IsGreaterThanOrEqualTo(size, (nint)width * height);
@@ -271,12 +271,12 @@ public abstract unsafe partial class Texture2D<T> : IReferenceTrackedObject, IGr
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetY, 0, Height);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetX, 0, destination.Width);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(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));
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));
Guard.IsLessThanOrEqualTo(sourceOffsetX + width, Width, nameof(sourceOffsetX));
Guard.IsLessThanOrEqualTo(sourceOffsetY + height, Height, nameof(sourceOffsetY));
@@ -340,12 +340,12 @@ public abstract unsafe partial class Texture2D<T> : IReferenceTrackedObject, IGr
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetY, 0, Height);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetX, 0, destination.Width);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(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));
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));
Guard.IsLessThanOrEqualTo(sourceOffsetX + width, Width, nameof(sourceOffsetX));
Guard.IsLessThanOrEqualTo(sourceOffsetY + height, Height, nameof(sourceOffsetY));
@@ -402,8 +402,8 @@ public abstract unsafe partial class Texture2D<T> : IReferenceTrackedObject, IGr
{
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetX, 0, Width);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetY, 0, Height);
Guard.IsBetweenOrEqualTo(width, 1, Width);
Guard.IsBetweenOrEqualTo(height, 1, Height);
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, Width);
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(height, 1, Height);
Guard.IsLessThanOrEqualTo(destinationOffsetX + width, Width, nameof(destinationOffsetX));
Guard.IsLessThanOrEqualTo(destinationOffsetY + height, Height, nameof(destinationOffsetY));
Guard.IsGreaterThanOrEqualTo(size, (nint)width * height);
@@ -494,10 +494,10 @@ public abstract unsafe partial class Texture2D<T> : IReferenceTrackedObject, IGr
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetY, 0, source.Height);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetX, 0, Width);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(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);
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);
Guard.IsLessThanOrEqualTo(sourceOffsetX + width, source.Width, nameof(sourceOffsetX));
Guard.IsLessThanOrEqualTo(sourceOffsetY + height, source.Height, nameof(sourceOffsetY));
Guard.IsLessThanOrEqualTo(destinationOffsetX + width, Width, nameof(destinationOffsetX));
+33 -33
ファイルの表示
@@ -80,9 +80,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();
@@ -192,9 +192,9 @@ public abstract unsafe partial class Texture3D<T> : IReferenceTrackedObject, IGr
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetX, 0, Width);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetY, 0, Height);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffsetZ, 0, Depth);
Guard.IsBetweenOrEqualTo(width, 1, Width);
Guard.IsBetweenOrEqualTo(height, 1, Height);
Guard.IsBetweenOrEqualTo(depth, 1, Depth);
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, Width);
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(height, 1, Height);
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(depth, 1, Depth);
Guard.IsLessThanOrEqualTo(sourceOffsetX + width, Width, nameof(sourceOffsetX));
Guard.IsLessThanOrEqualTo(sourceOffsetY + height, Height, nameof(sourceOffsetY));
Guard.IsLessThanOrEqualTo(sourceOffsetZ + depth, Depth, nameof(sourceOffsetZ));
@@ -294,15 +294,15 @@ public abstract unsafe partial class Texture3D<T> : IReferenceTrackedObject, IGr
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetX, 0, destination.Width);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetY, 0, destination.Height);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(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));
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));
Guard.IsLessThanOrEqualTo(sourceOffsetX + width, Width, nameof(sourceOffsetX));
Guard.IsLessThanOrEqualTo(sourceOffsetY + height, Height, nameof(sourceOffsetY));
Guard.IsLessThanOrEqualTo(sourceOffsetZ + depth, Depth, nameof(sourceOffsetZ));
@@ -372,15 +372,15 @@ public abstract unsafe partial class Texture3D<T> : IReferenceTrackedObject, IGr
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetX, 0, destination.Width);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetY, 0, destination.Height);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(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));
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));
Guard.IsLessThanOrEqualTo(sourceOffsetX + width, Width, nameof(sourceOffsetX));
Guard.IsLessThanOrEqualTo(sourceOffsetY + height, Height, nameof(sourceOffsetY));
Guard.IsLessThanOrEqualTo(sourceOffsetZ + depth, Depth, nameof(sourceOffsetZ));
@@ -441,9 +441,9 @@ public abstract unsafe partial class Texture3D<T> : IReferenceTrackedObject, IGr
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetX, 0, Width);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetY, 0, Height);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetZ, 0, Depth);
Guard.IsBetweenOrEqualTo(width, 1, Width);
Guard.IsBetweenOrEqualTo(height, 1, Height);
Guard.IsBetweenOrEqualTo(depth, 1, Depth);
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(width, 1, Width);
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(height, 1, Height);
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(depth, 1, Depth);
Guard.IsLessThanOrEqualTo(destinationOffsetX + width, Width, nameof(destinationOffsetX));
Guard.IsLessThanOrEqualTo(destinationOffsetY + height, Height, nameof(destinationOffsetY));
Guard.IsLessThanOrEqualTo(destinationOffsetZ + depth, Depth, nameof(destinationOffsetZ));
@@ -543,12 +543,12 @@ public abstract unsafe partial class Texture3D<T> : IReferenceTrackedObject, IGr
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetX, 0, Width);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffsetY, 0, Height);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(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);
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);
Guard.IsLessThanOrEqualTo(sourceOffsetX + width, source.Width, nameof(sourceOffsetX));
Guard.IsLessThanOrEqualTo(sourceOffsetY + height, source.Height, nameof(sourceOffsetY));
Guard.IsLessThanOrEqualTo(sourceOffsetZ + depth, source.Depth, nameof(sourceOffsetZ));
+1 -1
ファイルの表示
@@ -58,7 +58,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();
+1 -1
ファイルの表示
@@ -60,7 +60,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();
+3 -3
ファイルの表示
@@ -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();
+4 -4
ファイルの表示
@@ -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();
+4 -4
ファイルの表示
@@ -61,7 +61,7 @@ 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);
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(length, 0, Length);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(offset, 0, Length);
Guard.IsLessThanOrEqualTo(offset + length, Length, nameof(offset));
@@ -88,8 +88,8 @@ 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);
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(length, 0, Length);
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(length, 0, destination.Length);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(sourceOffset, 0, Length);
Guard.IsLessThanOrEqualTo(sourceOffset + length, Length, nameof(sourceOffset));
default(ArgumentOutOfRangeException).ThrowIfNotInRange(destinationOffset, 0, destination.Length);
@@ -126,7 +126,7 @@ 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);
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(length, 0, Length);
default(ArgumentOutOfRangeException).ThrowIfNotInRange(offset, 0, Length);
Guard.IsLessThanOrEqualTo(offset + length, Length, nameof(offset));
+8 -8
ファイルの表示
@@ -184,18 +184,18 @@ public struct ComputeContext : IDisposable, IAsyncDisposable
default(ArgumentOutOfRangeException).ThrowIfNegativeOrZero(x);
default(ArgumentOutOfRangeException).ThrowIfNegativeOrZero(y);
default(ArgumentOutOfRangeException).ThrowIfNegativeOrZero(z);
Guard.IsBetweenOrEqualTo(threadsX, 1, 1024);
Guard.IsBetweenOrEqualTo(threadsY, 1, 1024);
Guard.IsBetweenOrEqualTo(threadsZ, 1, 64);
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(threadsX, 1, 1024);
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(threadsY, 1, 1024);
default(ArgumentOutOfRangeException).ThrowIfNotBetweenOrEqual(threadsZ, 1, 64);
Guard.IsLessThanOrEqualTo(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);
@@ -231,8 +231,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);