Merge pull request #591 from Sergio0694/dev/tweaks
Minor refactoring, remove unnecessary code
このコミットが含まれているのは:
78ファイル変更
+65
-1145
検索条件に一致するファイルはありません
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
|
||||
namespace ComputeSharp.Exceptions;
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
/// A custom <see cref="InvalidOperationException"/> that indicates when an HLSL-only API is called from C#.
|
||||
@@ -10,9 +10,9 @@ public sealed class InvalidExecutionContextException : InvalidOperationException
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="InvalidExecutionContextException"/> instance.
|
||||
/// </summary>
|
||||
/// <param name="memberName">The member name of the caller API.</param>
|
||||
/// <param name="memberName">The member name of the invoked API.</param>
|
||||
internal InvalidExecutionContextException(string memberName)
|
||||
: base($"The API {memberName} can only be used from within an HLSL shader.")
|
||||
: base("The invoked API can only be used from within an HLSL shader.")
|
||||
{
|
||||
MemberName = memberName;
|
||||
}
|
||||
|
||||
@@ -1,319 +0,0 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
using System.Buffers;
|
||||
using System.Globalization;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace System.Runtime.CompilerServices;
|
||||
|
||||
/// <summary>
|
||||
/// Provides a handler used by the language compiler to process interpolated strings into <see cref="string"/> instances.
|
||||
/// </summary>
|
||||
[InterpolatedStringHandler]
|
||||
internal ref struct FormatInterpolatedStringHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// Minimum size array to rent from the pool.
|
||||
/// </summary>
|
||||
private const int MinimumArrayPoolLength = 256;
|
||||
|
||||
/// <summary>
|
||||
/// The format to use to print individual values to the target buffer.
|
||||
/// </summary>
|
||||
private readonly string? format;
|
||||
|
||||
/// <summary>
|
||||
/// Optional provider to pass to <see cref="IFormattable.ToString(string?, IFormatProvider?)"/> calls.
|
||||
/// </summary>
|
||||
private readonly IFormatProvider? formatProvider;
|
||||
|
||||
/// <summary>
|
||||
/// Array rented from the array pool and used to back <see cref="characters"/>.
|
||||
/// </summary>
|
||||
private char[]? arrayToReturnToPool;
|
||||
|
||||
/// <summary>
|
||||
/// The span to write into.
|
||||
/// </summary>
|
||||
private Span<char> characters;
|
||||
|
||||
/// <summary>
|
||||
/// Position at which to write the next character.
|
||||
/// </summary>
|
||||
private int position;
|
||||
|
||||
/// <summary>
|
||||
/// Whether <see cref="formatProvider"/> provides an <see cref="ICustomFormatter"/>.
|
||||
/// </summary>
|
||||
private readonly bool hasCustomFormatter;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a handler used to translate an interpolated string into a <see cref="string"/>.
|
||||
/// </summary>
|
||||
/// <param name="literalLength">The number of constant characters outside of interpolation expressions in the interpolated string.</param>
|
||||
/// <param name="formattedCount">The number of interpolation expressions in the interpolated string.</param>
|
||||
/// <param name="format">The format to use, if available.</param>
|
||||
/// <param name="formatProvider">An object that supplies culture-specific formatting information.</param>
|
||||
/// <param name="initialBuffer">A buffer temporarily transferred to the handler for use as part of its formatting. Contents may be overwritten.</param>
|
||||
/// <remarks>This is intended to be called only by compiler-generated code. Arguments are not validated as they'd otherwise be for members intended to be used directly.</remarks>
|
||||
public FormatInterpolatedStringHandler(int literalLength, int formattedCount, string? format, IFormatProvider? formatProvider, Span<char> initialBuffer)
|
||||
{
|
||||
this.format = format;
|
||||
this.formatProvider = formatProvider;
|
||||
this.characters = initialBuffer;
|
||||
this.arrayToReturnToPool = null;
|
||||
this.position = 0;
|
||||
this.hasCustomFormatter = formatProvider is not null && HasCustomFormatter(formatProvider);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="string"/> with the specified arguments.
|
||||
/// </summary>
|
||||
/// <param name="format">The format to use, if available.</param>
|
||||
/// <param name="formatProvider">An object that supplies culture-specific formatting information.</param>
|
||||
/// <param name="initialBuffer">A buffer temporarily transferred to the handler for use as part of its formatting. Contents may be overwritten.</param>
|
||||
/// <param name="handler">The input <see cref="FormatInterpolatedStringHandler"/> instance responsible for formatting the resulting <see cref="string"/>.</param>
|
||||
/// <returns>The resulting formatted <see cref="string"/> instance.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static string Create(
|
||||
string? format,
|
||||
IFormatProvider? formatProvider,
|
||||
Span<char> initialBuffer,
|
||||
[InterpolatedStringHandlerArgument("format", "formatProvider", "initialBuffer")] ref FormatInterpolatedStringHandler handler)
|
||||
{
|
||||
return handler.ToStringAndClear();
|
||||
}
|
||||
|
||||
/// <summary>Gets the built <see cref="string"/> and clears the handler.</summary>
|
||||
/// <returns>The built string.</returns>
|
||||
/// <remarks>
|
||||
/// This releases any resources used by the handler. The method should be invoked only
|
||||
/// once and as the last thing performed on the handler. Subsequent use is erroneous, ill-defined,
|
||||
/// and may destabilize the process, as may using any other copies of the handler after ToStringAndClear
|
||||
/// is called on any one of them.
|
||||
/// </remarks>
|
||||
public string ToStringAndClear()
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
string result = new(this.characters.Slice(0, this.position));
|
||||
#else
|
||||
string result = this.characters.Slice(0, this.position).ToString();
|
||||
#endif
|
||||
char[]? toReturn = this.arrayToReturnToPool;
|
||||
|
||||
this = default;
|
||||
|
||||
if (toReturn is not null)
|
||||
{
|
||||
ArrayPool<char>.Shared.Return(toReturn);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the specified string to the handler.
|
||||
/// </summary>
|
||||
/// <param name="value">The string to write.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void AppendLiteral(string value)
|
||||
{
|
||||
if (value.Length == 1)
|
||||
{
|
||||
Span<char> chars = this.characters;
|
||||
int pos = this.position;
|
||||
|
||||
if ((uint)pos < (uint)chars.Length)
|
||||
{
|
||||
chars[pos] = value[0];
|
||||
|
||||
this.position = pos + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
GrowThenCopyString(value);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (value.Length == 2)
|
||||
{
|
||||
Span<char> chars = this.characters;
|
||||
int pos = this.position;
|
||||
|
||||
if ((uint)pos < chars.Length - 1)
|
||||
{
|
||||
Unsafe.WriteUnaligned(
|
||||
ref Unsafe.As<char, byte>(ref Unsafe.Add(ref MemoryMarshal.GetReference(chars), pos)),
|
||||
#if NET6_0_OR_GREATER
|
||||
Unsafe.ReadUnaligned<int>(ref Unsafe.As<char, byte>(ref Unsafe.AsRef(in value.GetPinnableReference()))));
|
||||
#else
|
||||
Unsafe.ReadUnaligned<int>(ref Unsafe.As<char, byte>(ref MemoryMarshal.GetReference(value.AsSpan()))));
|
||||
#endif
|
||||
|
||||
this.position = pos + 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
GrowThenCopyString(value);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
AppendStringDirect(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the specified string to the handler.
|
||||
/// </summary>
|
||||
/// <param name="value">The string to write.</param>
|
||||
private void AppendStringDirect(string value)
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
if (value.TryCopyTo(this.characters.Slice(this.position)))
|
||||
#else
|
||||
if (value.AsSpan().TryCopyTo(this.characters.Slice(this.position)))
|
||||
#endif
|
||||
{
|
||||
this.position += value.Length;
|
||||
}
|
||||
else
|
||||
{
|
||||
GrowThenCopyString(value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the specified value to the handler.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to write.</param>
|
||||
public void AppendFormatted(string value)
|
||||
{
|
||||
AppendLiteral(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the specified value to the handler.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to write.</param>
|
||||
public void AppendFormatted<T>(T value)
|
||||
#if NET6_0_OR_GREATER
|
||||
where T : ISpanFormattable
|
||||
#else
|
||||
where T : IFormattable
|
||||
#endif
|
||||
{
|
||||
if (this.hasCustomFormatter)
|
||||
{
|
||||
AppendCustomFormatter(value, this.format);
|
||||
return;
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
int charsWritten;
|
||||
|
||||
while (!value.TryFormat(this.characters.Slice(this.position), out charsWritten, this.format, this.formatProvider))
|
||||
{
|
||||
Grow();
|
||||
}
|
||||
|
||||
this.position += charsWritten;
|
||||
#else
|
||||
AppendStringDirect(value.ToString(this.format, this.formatProvider));
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the provider provides a custom formatter.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static bool HasCustomFormatter(IFormatProvider provider)
|
||||
{
|
||||
return
|
||||
provider.GetType() != typeof(CultureInfo) &&
|
||||
provider.GetFormat(typeof(ICustomFormatter)) != null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Formats the value using the custom formatter from the provider.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to write.</param>
|
||||
/// <param name="format">The format string.</param>
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
private void AppendCustomFormatter<T>(T value, string? format)
|
||||
{
|
||||
ICustomFormatter? formatter = (ICustomFormatter?)this.formatProvider?.GetFormat(typeof(ICustomFormatter));
|
||||
|
||||
if (formatter is not null && formatter.Format(format, value, this.formatProvider) is string customFormatted)
|
||||
{
|
||||
AppendStringDirect(customFormatted);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fallback for fast path in <see cref="AppendStringDirect"/> when there's not enough space in the destination.
|
||||
/// </summary>
|
||||
/// <param name="value">The string to write.</param>
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
private void GrowThenCopyString(string value)
|
||||
{
|
||||
Grow(value.Length);
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
value.CopyTo(this.characters.Slice(this.position));
|
||||
#else
|
||||
value.AsSpan().CopyTo(this.characters.Slice(this.position));
|
||||
#endif
|
||||
|
||||
this.position += value.Length;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Grows <see cref="characters"/> to have the capacity to store at least <paramref name="additionalChars"/> beyond <see cref="position"/>.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
private void Grow(int additionalChars)
|
||||
{
|
||||
GrowCore((uint)this.position + (uint)additionalChars);
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <summary>
|
||||
/// Grows the size of <see cref="characters"/>.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
private void Grow()
|
||||
{
|
||||
GrowCore((uint)this.characters.Length + 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Grow the size of <see cref="characters"/> to at least the specified <paramref name="requiredMinCapacity"/>.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private void GrowCore(uint requiredMinCapacity)
|
||||
{
|
||||
uint newCapacity = Math.Max(requiredMinCapacity, Math.Min((uint)this.characters.Length * 2, 0x3FFFFFDF));
|
||||
#if NET6_0_OR_GREATER
|
||||
int arraySize = (int)Math.Clamp(newCapacity, MinimumArrayPoolLength, int.MaxValue);
|
||||
#else
|
||||
int arraySize = (int)Math.Min(Math.Max(newCapacity, MinimumArrayPoolLength), int.MaxValue);
|
||||
#endif
|
||||
char[] newArray = ArrayPool<char>.Shared.Rent(arraySize);
|
||||
|
||||
this.characters.Slice(0, this.position).CopyTo(newArray);
|
||||
|
||||
char[]? toReturn = this.arrayToReturnToPool;
|
||||
|
||||
this.characters = this.arrayToReturnToPool = newArray;
|
||||
|
||||
if (toReturn is not null)
|
||||
{
|
||||
ArrayPool<char>.Shared.Return(toReturn);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,256 +0,0 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace System.Runtime.CompilerServices;
|
||||
|
||||
/// <summary>
|
||||
/// Provides a handler used by the language compiler to format interpolated strings into character spans.
|
||||
/// </summary>
|
||||
[InterpolatedStringHandler]
|
||||
internal ref struct TryWriteFormatInterpolatedStringHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// The destination buffer.
|
||||
/// </summary>
|
||||
private readonly Span<char> destination;
|
||||
|
||||
/// <summary>
|
||||
/// The format to use to print individual values to the target buffer.
|
||||
/// </summary>
|
||||
private readonly ReadOnlySpan<char> format;
|
||||
|
||||
/// <summary>
|
||||
/// The value of <see cref="format"/>, as a <see cref="string"/>.
|
||||
/// </summary>
|
||||
private string? formatAsString;
|
||||
|
||||
/// <summary>
|
||||
/// Optional provider to pass to <see cref="IFormattable.ToString(string?, IFormatProvider?)"/> calls.
|
||||
/// </summary>
|
||||
private readonly IFormatProvider? formatProvider;
|
||||
|
||||
/// <summary>
|
||||
/// The number of characters written to <see cref="destination"/>.
|
||||
/// </summary>
|
||||
private int position;
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether all formatting operations have succeeded.
|
||||
/// </summary>
|
||||
private bool success;
|
||||
|
||||
/// <summary>
|
||||
/// Whether <see cref="formatProvider"/> provides an <see cref="ICustomFormatter"/>.
|
||||
/// </summary>
|
||||
private readonly bool hasCustomFormatter;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a handler used to write an interpolated string into a <see cref="Span{Char}"/>.
|
||||
/// </summary>
|
||||
/// <param name="literalLength">The number of constant characters outside of interpolation expressions in the interpolated string.</param>
|
||||
/// <param name="formattedCount">The number of interpolation expressions in the interpolated string.</param>
|
||||
/// <param name="destination">The destination buffer.</param>
|
||||
/// <param name="format">The format to use, if available.</param>
|
||||
/// <param name="formatProvider">An object that supplies culture-specific formatting information.</param>
|
||||
/// <param name="shouldAppend">Upon return, true if the destination may be long enough to support the formatting, or false if it won't be.</param>
|
||||
/// <remarks>This is intended to be called only by compiler-generated code. Arguments are not validated as they'd otherwise be for members intended to be used directly.</remarks>
|
||||
public TryWriteFormatInterpolatedStringHandler(int literalLength, int formattedCount, Span<char> destination, ReadOnlySpan<char> format, IFormatProvider? formatProvider, out bool shouldAppend)
|
||||
{
|
||||
this.destination = destination;
|
||||
this.format = format;
|
||||
this.formatAsString = null;
|
||||
this.formatProvider = formatProvider;
|
||||
this.position = 0;
|
||||
this.success = shouldAppend = destination.Length >= literalLength;
|
||||
this.hasCustomFormatter = formatProvider is not null && FormatInterpolatedStringHandler.HasCustomFormatter(formatProvider);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the specified interpolated string to the character span.
|
||||
/// </summary>
|
||||
/// <param name="destination">The span to which the interpolated string should be formatted.</param>
|
||||
/// <param name="format">The format to use, if available.</param>
|
||||
/// <param name="formatProvider">An object that supplies culture-specific formatting information.</param>
|
||||
/// <param name="handler">The interpolated string.</param>
|
||||
/// <param name="charsWritten">The number of characters written to the span.</param>
|
||||
/// <returns>true if the entire interpolated string could be formatted successfully; otherwise, false.</returns>
|
||||
public static bool TryWrite(
|
||||
Span<char> destination,
|
||||
ReadOnlySpan<char> format,
|
||||
IFormatProvider? formatProvider,
|
||||
[InterpolatedStringHandlerArgument("destination", "format", "formatProvider")] ref TryWriteFormatInterpolatedStringHandler handler,
|
||||
out int charsWritten)
|
||||
{
|
||||
if (handler.success)
|
||||
{
|
||||
charsWritten = handler.position;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
charsWritten = 0;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the specified <see cref="string"/> to the handler.
|
||||
/// </summary>
|
||||
/// <param name="value">The <see cref="string"/> to write.</param>
|
||||
/// <returns>Whether the value could be formatted to the span.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool AppendLiteral(string value)
|
||||
{
|
||||
if (value.Length == 1)
|
||||
{
|
||||
Span<char> destination = this.destination;
|
||||
int pos = this.position;
|
||||
|
||||
if ((uint)pos < (uint)destination.Length)
|
||||
{
|
||||
destination[pos] = value[0];
|
||||
|
||||
this.position = pos + 1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return Fail();
|
||||
}
|
||||
|
||||
if (value.Length == 2)
|
||||
{
|
||||
Span<char> destination = this.destination;
|
||||
int pos = this.position;
|
||||
|
||||
if ((uint)pos < destination.Length - 1)
|
||||
{
|
||||
Unsafe.WriteUnaligned(
|
||||
ref Unsafe.As<char, byte>(ref Unsafe.Add(ref MemoryMarshal.GetReference(destination), pos)),
|
||||
#if NET6_0_OR_GREATER
|
||||
Unsafe.ReadUnaligned<int>(ref Unsafe.As<char, byte>(ref Unsafe.AsRef(in value.GetPinnableReference()))));
|
||||
#else
|
||||
Unsafe.ReadUnaligned<int>(ref Unsafe.As<char, byte>(ref MemoryMarshal.GetReference(value.AsSpan()))));
|
||||
#endif
|
||||
|
||||
this.position = pos + 2;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return Fail();
|
||||
}
|
||||
|
||||
return AppendStringDirect(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the specified string to the handler.
|
||||
/// </summary>
|
||||
/// <param name="value">The string to write.</param>
|
||||
/// <returns>Whether the value could be appended to the span.</returns>
|
||||
private bool AppendStringDirect(string value)
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
if (value.TryCopyTo(this.destination.Slice(this.position)))
|
||||
#else
|
||||
if (value.AsSpan().TryCopyTo(this.destination.Slice(this.position)))
|
||||
#endif
|
||||
{
|
||||
this.position += value.Length;
|
||||
return true;
|
||||
}
|
||||
|
||||
return Fail();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the specified value to the handler.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to write.</param>
|
||||
public bool AppendFormatted<T>(T value)
|
||||
#if NET6_0_OR_GREATER
|
||||
where T : ISpanFormattable
|
||||
#else
|
||||
where T : IFormattable
|
||||
#endif
|
||||
{
|
||||
if (this.hasCustomFormatter)
|
||||
{
|
||||
return AppendCustomFormatter(value, this.formatAsString ??= this.format.ToString());
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
if (value.TryFormat(this.destination.Slice(this.position), out int charsWritten, this.format, this.formatProvider))
|
||||
{
|
||||
this.position += charsWritten;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return Fail();
|
||||
#else
|
||||
return AppendStringDirect(value.ToString(this.formatAsString ??= this.format.ToString(), this.formatProvider));
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the specified value to the handler.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to write.</param>
|
||||
public bool AppendFormatted(string? value)
|
||||
{
|
||||
if (this.hasCustomFormatter)
|
||||
{
|
||||
return AppendCustomFormatter(value, format: null);
|
||||
}
|
||||
|
||||
if (value is null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
if (value.TryCopyTo(this.destination.Slice(this.position)))
|
||||
#else
|
||||
if (value.AsSpan().TryCopyTo(this.destination.Slice(this.position)))
|
||||
#endif
|
||||
{
|
||||
this.position += value.Length;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return Fail();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Formats the value using the custom formatter from the provider.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to write.</param>
|
||||
/// <param name="format">The format string.</param>
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
private bool AppendCustomFormatter<T>(T value, string? format)
|
||||
{
|
||||
ICustomFormatter? formatter = (ICustomFormatter?)this.formatProvider?.GetFormat(typeof(ICustomFormatter));
|
||||
|
||||
if (formatter is not null && formatter.Format(format, value, this.formatProvider) is string customFormatted)
|
||||
{
|
||||
return AppendStringDirect(customFormatted);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Marks formatting as having failed and returns false.
|
||||
/// </summary>
|
||||
private bool Fail()
|
||||
{
|
||||
this.success = false;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using ComputeSharp.Core.Intrinsics.Attributes;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Core.Intrinsics.Attributes;
|
||||
|
||||
#pragma warning disable IDE0022
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<#@include file="Hlsl.Void.ttinclude" #>
|
||||
<#@include file="Hlsl.Void.ttinclude" #>
|
||||
using ComputeSharp.Core.Intrinsics.Attributes;
|
||||
using ComputeSharp.Exceptions;
|
||||
|
||||
#pragma warning disable IDE0022
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using ComputeSharp.Core.Intrinsics.Attributes;
|
||||
using ComputeSharp.Exceptions;
|
||||
|
||||
#pragma warning disable IDE0022
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using ComputeSharp.Core.Intrinsics.Attributes;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Core.Intrinsics.Attributes;
|
||||
|
||||
#pragma warning disable IDE0022
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<#@include file="Hlsl.ttinclude" #>
|
||||
using ComputeSharp.Core.Intrinsics.Attributes;
|
||||
using ComputeSharp.Exceptions;
|
||||
|
||||
#pragma warning disable IDE0022
|
||||
|
||||
|
||||
@@ -474,11 +474,7 @@ public unsafe partial struct Bool2
|
||||
/// <inheritdoc/>
|
||||
public override readonly string ToString()
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
return string.Create(null, stackalloc char[32], $"<{this.x != 0}, {this.y != 0}>");
|
||||
#else
|
||||
return $"<{this.x != 0}, {this.y != 0}>";
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1740,11 +1740,7 @@ public unsafe partial struct Bool3
|
||||
/// <inheritdoc/>
|
||||
public override readonly string ToString()
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
return string.Create(null, stackalloc char[32], $"<{this.x != 0}, {this.y != 0}, {this.z != 0}>");
|
||||
#else
|
||||
return $"<{this.x != 0}, {this.y != 0}, {this.z != 0}>";
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4826,11 +4826,7 @@ public unsafe partial struct Bool4
|
||||
/// <inheritdoc/>
|
||||
public override readonly string ToString()
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
return string.Create(null, stackalloc char[32], $"<{this.x != 0}, {this.y != 0}, {this.z != 0}, {this.w != 0}>");
|
||||
#else
|
||||
return $"<{this.x != 0}, {this.y != 0}, {this.z != 0}, {this.w != 0}>";
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -15,9 +15,6 @@ namespace ComputeSharp;
|
||||
/// <inheritdoc cref="Double2"/>
|
||||
[StructLayout(LayoutKind.Explicit, Size = 16, Pack = 8)]
|
||||
public unsafe partial struct Double2
|
||||
#if NET6_0_OR_GREATER
|
||||
: ISpanFormattable
|
||||
#endif
|
||||
{
|
||||
/// <summary>
|
||||
/// A private buffer to which the undefined properties will point to.
|
||||
@@ -481,36 +478,7 @@ public unsafe partial struct Double2
|
||||
{
|
||||
string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
return string.Create(null, stackalloc char[64], $"<{this.x}{separator} {this.y}>");
|
||||
#else
|
||||
return $"<{this.x}{separator} {this.y}>";
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public readonly string ToString(string? format, IFormatProvider? formatProvider)
|
||||
{
|
||||
string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
|
||||
|
||||
return FormatInterpolatedStringHandler.Create(
|
||||
format,
|
||||
formatProvider,
|
||||
stackalloc char[64],
|
||||
$"<{this.x}{separator} {this.y}>");
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public readonly bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
|
||||
{
|
||||
string separator = NumberFormatInfo.GetInstance(provider).NumberGroupSeparator;
|
||||
|
||||
return TryWriteFormatInterpolatedStringHandler.TryWrite(
|
||||
destination,
|
||||
format,
|
||||
provider,
|
||||
$"<{this.x}{separator} {this.y}>",
|
||||
out charsWritten);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -15,9 +15,6 @@ namespace ComputeSharp;
|
||||
/// <inheritdoc cref="Double3"/>
|
||||
[StructLayout(LayoutKind.Explicit, Size = 24, Pack = 8)]
|
||||
public unsafe partial struct Double3
|
||||
#if NET6_0_OR_GREATER
|
||||
: ISpanFormattable
|
||||
#endif
|
||||
{
|
||||
/// <summary>
|
||||
/// A private buffer to which the undefined properties will point to.
|
||||
@@ -1747,36 +1744,7 @@ public unsafe partial struct Double3
|
||||
{
|
||||
string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
return string.Create(null, stackalloc char[64], $"<{this.x}{separator} {this.y}{separator} {this.z}>");
|
||||
#else
|
||||
return $"<{this.x}{separator} {this.y}{separator} {this.z}>";
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public readonly string ToString(string? format, IFormatProvider? formatProvider)
|
||||
{
|
||||
string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
|
||||
|
||||
return FormatInterpolatedStringHandler.Create(
|
||||
format,
|
||||
formatProvider,
|
||||
stackalloc char[64],
|
||||
$"<{this.x}{separator} {this.y}{separator} {this.z}>");
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public readonly bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
|
||||
{
|
||||
string separator = NumberFormatInfo.GetInstance(provider).NumberGroupSeparator;
|
||||
|
||||
return TryWriteFormatInterpolatedStringHandler.TryWrite(
|
||||
destination,
|
||||
format,
|
||||
provider,
|
||||
$"<{this.x}{separator} {this.y}{separator} {this.z}>",
|
||||
out charsWritten);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -15,9 +15,6 @@ namespace ComputeSharp;
|
||||
/// <inheritdoc cref="Double4"/>
|
||||
[StructLayout(LayoutKind.Explicit, Size = 32, Pack = 8)]
|
||||
public unsafe partial struct Double4
|
||||
#if NET6_0_OR_GREATER
|
||||
: ISpanFormattable
|
||||
#endif
|
||||
{
|
||||
/// <summary>
|
||||
/// A private buffer to which the undefined properties will point to.
|
||||
@@ -4833,36 +4830,7 @@ public unsafe partial struct Double4
|
||||
{
|
||||
string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
return string.Create(null, stackalloc char[64], $"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>");
|
||||
#else
|
||||
return $"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>";
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public readonly string ToString(string? format, IFormatProvider? formatProvider)
|
||||
{
|
||||
string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
|
||||
|
||||
return FormatInterpolatedStringHandler.Create(
|
||||
format,
|
||||
formatProvider,
|
||||
stackalloc char[64],
|
||||
$"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>");
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public readonly bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
|
||||
{
|
||||
string separator = NumberFormatInfo.GetInstance(provider).NumberGroupSeparator;
|
||||
|
||||
return TryWriteFormatInterpolatedStringHandler.TryWrite(
|
||||
destination,
|
||||
format,
|
||||
provider,
|
||||
$"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>",
|
||||
out charsWritten);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -16,9 +16,6 @@ namespace ComputeSharp;
|
||||
/// <inheritdoc cref="Float2"/>
|
||||
[StructLayout(LayoutKind.Explicit, Size = 8, Pack = 4)]
|
||||
public unsafe partial struct Float2
|
||||
#if NET6_0_OR_GREATER
|
||||
: ISpanFormattable
|
||||
#endif
|
||||
{
|
||||
/// <summary>
|
||||
/// A private buffer to which the undefined properties will point to.
|
||||
@@ -482,36 +479,7 @@ public unsafe partial struct Float2
|
||||
{
|
||||
string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
return string.Create(null, stackalloc char[64], $"<{this.x}{separator} {this.y}>");
|
||||
#else
|
||||
return $"<{this.x}{separator} {this.y}>";
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public readonly string ToString(string? format, IFormatProvider? formatProvider)
|
||||
{
|
||||
string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
|
||||
|
||||
return FormatInterpolatedStringHandler.Create(
|
||||
format,
|
||||
formatProvider,
|
||||
stackalloc char[64],
|
||||
$"<{this.x}{separator} {this.y}>");
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public readonly bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
|
||||
{
|
||||
string separator = NumberFormatInfo.GetInstance(provider).NumberGroupSeparator;
|
||||
|
||||
return TryWriteFormatInterpolatedStringHandler.TryWrite(
|
||||
destination,
|
||||
format,
|
||||
provider,
|
||||
$"<{this.x}{separator} {this.y}>",
|
||||
out charsWritten);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -16,9 +16,6 @@ namespace ComputeSharp;
|
||||
/// <inheritdoc cref="Float3"/>
|
||||
[StructLayout(LayoutKind.Explicit, Size = 12, Pack = 4)]
|
||||
public unsafe partial struct Float3
|
||||
#if NET6_0_OR_GREATER
|
||||
: ISpanFormattable
|
||||
#endif
|
||||
{
|
||||
/// <summary>
|
||||
/// A private buffer to which the undefined properties will point to.
|
||||
@@ -1748,36 +1745,7 @@ public unsafe partial struct Float3
|
||||
{
|
||||
string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
return string.Create(null, stackalloc char[64], $"<{this.x}{separator} {this.y}{separator} {this.z}>");
|
||||
#else
|
||||
return $"<{this.x}{separator} {this.y}{separator} {this.z}>";
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public readonly string ToString(string? format, IFormatProvider? formatProvider)
|
||||
{
|
||||
string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
|
||||
|
||||
return FormatInterpolatedStringHandler.Create(
|
||||
format,
|
||||
formatProvider,
|
||||
stackalloc char[64],
|
||||
$"<{this.x}{separator} {this.y}{separator} {this.z}>");
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public readonly bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
|
||||
{
|
||||
string separator = NumberFormatInfo.GetInstance(provider).NumberGroupSeparator;
|
||||
|
||||
return TryWriteFormatInterpolatedStringHandler.TryWrite(
|
||||
destination,
|
||||
format,
|
||||
provider,
|
||||
$"<{this.x}{separator} {this.y}{separator} {this.z}>",
|
||||
out charsWritten);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -16,9 +16,6 @@ namespace ComputeSharp;
|
||||
/// <inheritdoc cref="Float4"/>
|
||||
[StructLayout(LayoutKind.Explicit, Size = 16, Pack = 4)]
|
||||
public unsafe partial struct Float4
|
||||
#if NET6_0_OR_GREATER
|
||||
: ISpanFormattable
|
||||
#endif
|
||||
{
|
||||
/// <summary>
|
||||
/// A private buffer to which the undefined properties will point to.
|
||||
@@ -4834,36 +4831,7 @@ public unsafe partial struct Float4
|
||||
{
|
||||
string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
return string.Create(null, stackalloc char[64], $"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>");
|
||||
#else
|
||||
return $"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>";
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public readonly string ToString(string? format, IFormatProvider? formatProvider)
|
||||
{
|
||||
string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
|
||||
|
||||
return FormatInterpolatedStringHandler.Create(
|
||||
format,
|
||||
formatProvider,
|
||||
stackalloc char[64],
|
||||
$"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>");
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public readonly bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
|
||||
{
|
||||
string separator = NumberFormatInfo.GetInstance(provider).NumberGroupSeparator;
|
||||
|
||||
return TryWriteFormatInterpolatedStringHandler.TryWrite(
|
||||
destination,
|
||||
format,
|
||||
provider,
|
||||
$"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>",
|
||||
out charsWritten);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -16,9 +16,6 @@ namespace ComputeSharp;
|
||||
/// <inheritdoc cref="Int2"/>
|
||||
[StructLayout(LayoutKind.Explicit, Size = 8, Pack = 4)]
|
||||
public unsafe partial struct Int2
|
||||
#if NET6_0_OR_GREATER
|
||||
: ISpanFormattable
|
||||
#endif
|
||||
{
|
||||
/// <summary>
|
||||
/// A private buffer to which the undefined properties will point to.
|
||||
@@ -482,36 +479,7 @@ public unsafe partial struct Int2
|
||||
{
|
||||
string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
return string.Create(null, stackalloc char[64], $"<{this.x}{separator} {this.y}>");
|
||||
#else
|
||||
return $"<{this.x}{separator} {this.y}>";
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public readonly string ToString(string? format, IFormatProvider? formatProvider)
|
||||
{
|
||||
string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
|
||||
|
||||
return FormatInterpolatedStringHandler.Create(
|
||||
format,
|
||||
formatProvider,
|
||||
stackalloc char[64],
|
||||
$"<{this.x}{separator} {this.y}>");
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public readonly bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
|
||||
{
|
||||
string separator = NumberFormatInfo.GetInstance(provider).NumberGroupSeparator;
|
||||
|
||||
return TryWriteFormatInterpolatedStringHandler.TryWrite(
|
||||
destination,
|
||||
format,
|
||||
provider,
|
||||
$"<{this.x}{separator} {this.y}>",
|
||||
out charsWritten);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -16,9 +16,6 @@ namespace ComputeSharp;
|
||||
/// <inheritdoc cref="Int3"/>
|
||||
[StructLayout(LayoutKind.Explicit, Size = 12, Pack = 4)]
|
||||
public unsafe partial struct Int3
|
||||
#if NET6_0_OR_GREATER
|
||||
: ISpanFormattable
|
||||
#endif
|
||||
{
|
||||
/// <summary>
|
||||
/// A private buffer to which the undefined properties will point to.
|
||||
@@ -1748,36 +1745,7 @@ public unsafe partial struct Int3
|
||||
{
|
||||
string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
return string.Create(null, stackalloc char[64], $"<{this.x}{separator} {this.y}{separator} {this.z}>");
|
||||
#else
|
||||
return $"<{this.x}{separator} {this.y}{separator} {this.z}>";
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public readonly string ToString(string? format, IFormatProvider? formatProvider)
|
||||
{
|
||||
string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
|
||||
|
||||
return FormatInterpolatedStringHandler.Create(
|
||||
format,
|
||||
formatProvider,
|
||||
stackalloc char[64],
|
||||
$"<{this.x}{separator} {this.y}{separator} {this.z}>");
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public readonly bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
|
||||
{
|
||||
string separator = NumberFormatInfo.GetInstance(provider).NumberGroupSeparator;
|
||||
|
||||
return TryWriteFormatInterpolatedStringHandler.TryWrite(
|
||||
destination,
|
||||
format,
|
||||
provider,
|
||||
$"<{this.x}{separator} {this.y}{separator} {this.z}>",
|
||||
out charsWritten);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -16,9 +16,6 @@ namespace ComputeSharp;
|
||||
/// <inheritdoc cref="Int4"/>
|
||||
[StructLayout(LayoutKind.Explicit, Size = 16, Pack = 4)]
|
||||
public unsafe partial struct Int4
|
||||
#if NET6_0_OR_GREATER
|
||||
: ISpanFormattable
|
||||
#endif
|
||||
{
|
||||
/// <summary>
|
||||
/// A private buffer to which the undefined properties will point to.
|
||||
@@ -4834,36 +4831,7 @@ public unsafe partial struct Int4
|
||||
{
|
||||
string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
return string.Create(null, stackalloc char[64], $"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>");
|
||||
#else
|
||||
return $"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>";
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public readonly string ToString(string? format, IFormatProvider? formatProvider)
|
||||
{
|
||||
string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
|
||||
|
||||
return FormatInterpolatedStringHandler.Create(
|
||||
format,
|
||||
formatProvider,
|
||||
stackalloc char[64],
|
||||
$"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>");
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public readonly bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
|
||||
{
|
||||
string separator = NumberFormatInfo.GetInstance(provider).NumberGroupSeparator;
|
||||
|
||||
return TryWriteFormatInterpolatedStringHandler.TryWrite(
|
||||
destination,
|
||||
format,
|
||||
provider,
|
||||
$"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>",
|
||||
out charsWritten);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -15,9 +15,6 @@ namespace ComputeSharp;
|
||||
/// <inheritdoc cref="UInt2"/>
|
||||
[StructLayout(LayoutKind.Explicit, Size = 8, Pack = 4)]
|
||||
public unsafe partial struct UInt2
|
||||
#if NET6_0_OR_GREATER
|
||||
: ISpanFormattable
|
||||
#endif
|
||||
{
|
||||
/// <summary>
|
||||
/// A private buffer to which the undefined properties will point to.
|
||||
@@ -481,36 +478,7 @@ public unsafe partial struct UInt2
|
||||
{
|
||||
string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
return string.Create(null, stackalloc char[64], $"<{this.x}{separator} {this.y}>");
|
||||
#else
|
||||
return $"<{this.x}{separator} {this.y}>";
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public readonly string ToString(string? format, IFormatProvider? formatProvider)
|
||||
{
|
||||
string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
|
||||
|
||||
return FormatInterpolatedStringHandler.Create(
|
||||
format,
|
||||
formatProvider,
|
||||
stackalloc char[64],
|
||||
$"<{this.x}{separator} {this.y}>");
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public readonly bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
|
||||
{
|
||||
string separator = NumberFormatInfo.GetInstance(provider).NumberGroupSeparator;
|
||||
|
||||
return TryWriteFormatInterpolatedStringHandler.TryWrite(
|
||||
destination,
|
||||
format,
|
||||
provider,
|
||||
$"<{this.x}{separator} {this.y}>",
|
||||
out charsWritten);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -15,9 +15,6 @@ namespace ComputeSharp;
|
||||
/// <inheritdoc cref="UInt3"/>
|
||||
[StructLayout(LayoutKind.Explicit, Size = 12, Pack = 4)]
|
||||
public unsafe partial struct UInt3
|
||||
#if NET6_0_OR_GREATER
|
||||
: ISpanFormattable
|
||||
#endif
|
||||
{
|
||||
/// <summary>
|
||||
/// A private buffer to which the undefined properties will point to.
|
||||
@@ -1747,36 +1744,7 @@ public unsafe partial struct UInt3
|
||||
{
|
||||
string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
return string.Create(null, stackalloc char[64], $"<{this.x}{separator} {this.y}{separator} {this.z}>");
|
||||
#else
|
||||
return $"<{this.x}{separator} {this.y}{separator} {this.z}>";
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public readonly string ToString(string? format, IFormatProvider? formatProvider)
|
||||
{
|
||||
string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
|
||||
|
||||
return FormatInterpolatedStringHandler.Create(
|
||||
format,
|
||||
formatProvider,
|
||||
stackalloc char[64],
|
||||
$"<{this.x}{separator} {this.y}{separator} {this.z}>");
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public readonly bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
|
||||
{
|
||||
string separator = NumberFormatInfo.GetInstance(provider).NumberGroupSeparator;
|
||||
|
||||
return TryWriteFormatInterpolatedStringHandler.TryWrite(
|
||||
destination,
|
||||
format,
|
||||
provider,
|
||||
$"<{this.x}{separator} {this.y}{separator} {this.z}>",
|
||||
out charsWritten);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -15,9 +15,6 @@ namespace ComputeSharp;
|
||||
/// <inheritdoc cref="UInt4"/>
|
||||
[StructLayout(LayoutKind.Explicit, Size = 16, Pack = 4)]
|
||||
public unsafe partial struct UInt4
|
||||
#if NET6_0_OR_GREATER
|
||||
: ISpanFormattable
|
||||
#endif
|
||||
{
|
||||
/// <summary>
|
||||
/// A private buffer to which the undefined properties will point to.
|
||||
@@ -4833,36 +4830,7 @@ public unsafe partial struct UInt4
|
||||
{
|
||||
string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
return string.Create(null, stackalloc char[64], $"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>");
|
||||
#else
|
||||
return $"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>";
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public readonly string ToString(string? format, IFormatProvider? formatProvider)
|
||||
{
|
||||
string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
|
||||
|
||||
return FormatInterpolatedStringHandler.Create(
|
||||
format,
|
||||
formatProvider,
|
||||
stackalloc char[64],
|
||||
$"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>");
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public readonly bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
|
||||
{
|
||||
string separator = NumberFormatInfo.GetInstance(provider).NumberGroupSeparator;
|
||||
|
||||
return TryWriteFormatInterpolatedStringHandler.TryWrite(
|
||||
destination,
|
||||
format,
|
||||
provider,
|
||||
$"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>",
|
||||
out charsWritten);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -51,7 +51,6 @@ void GenerateVectorProperties(string typeName, int elementSize)
|
||||
bool isBoolType = hlslElementTypeName == "bool";
|
||||
string fieldElementTypeName = isBoolType ? "int" : hlslElementTypeName;
|
||||
int i = int.Parse(Regex.Match(typeName, @"\d+$").Value);
|
||||
string formattable = elementTypeName == "Bool" ? "" : "ISpanFormattable";
|
||||
|
||||
List<string> namespaces = new List<string>
|
||||
{
|
||||
@@ -88,16 +87,6 @@ namespace ComputeSharp;
|
||||
/// <inheritdoc cref="<#=typeName#>"/>
|
||||
[StructLayout(LayoutKind.Explicit, Size = <#=(elementSize * i)#>, Pack = <#=elementSize#>)]
|
||||
public unsafe partial struct <#=typeName#>
|
||||
<#
|
||||
if (formattable != "")
|
||||
{
|
||||
#>
|
||||
#if NET6_0_OR_GREATER
|
||||
: <#=formattable#>
|
||||
#endif
|
||||
<#
|
||||
}
|
||||
#>
|
||||
{
|
||||
/// <summary>
|
||||
/// A private buffer to which the undefined properties will point to.
|
||||
@@ -258,11 +247,7 @@ public unsafe partial struct <#=typeName#>
|
||||
/// <inheritdoc/>
|
||||
public override readonly string ToString()
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
return string.Create(null, stackalloc char[32], $"<<#=string.Join(", ", "xyzw".Take(i).Select(c => $"{{this.{c} != 0}}"))#>>");
|
||||
#else
|
||||
return $"<<#=string.Join(", ", "xyzw".Take(i).Select(c => $"{{this.{c} != 0}}"))#>>";
|
||||
#endif
|
||||
}
|
||||
<#
|
||||
}
|
||||
@@ -274,36 +259,7 @@ public unsafe partial struct <#=typeName#>
|
||||
{
|
||||
string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
return string.Create(null, stackalloc char[64], $"<<#=string.Join("{separator} ", "xyzw".Take(i).Select(c => $"{{this.{c}}}"))#>>");
|
||||
#else
|
||||
return $"<<#=string.Join("{separator} ", "xyzw".Take(i).Select(c => $"{{this.{c}}}"))#>>";
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public readonly string ToString(string? format, IFormatProvider? formatProvider)
|
||||
{
|
||||
string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
|
||||
|
||||
return FormatInterpolatedStringHandler.Create(
|
||||
format,
|
||||
formatProvider,
|
||||
stackalloc char[64],
|
||||
$"<<#=string.Join("{separator} ", "xyzw".Take(i).Select(c => $"{{this.{c}}}"))#>>");
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public readonly bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
|
||||
{
|
||||
string separator = NumberFormatInfo.GetInstance(provider).NumberGroupSeparator;
|
||||
|
||||
return TryWriteFormatInterpolatedStringHandler.TryWrite(
|
||||
destination,
|
||||
format,
|
||||
provider,
|
||||
$"<<#=string.Join("{separator} ", "xyzw".Take(i).Select(c => $"{{this.{c}}}"))#>>",
|
||||
out charsWritten);
|
||||
}
|
||||
<#
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
using ComputeSharp.D2D1.Exceptions;
|
||||
using ComputeSharp.D2D1.Shaders.Translation;
|
||||
using ComputeSharp.D2D1.SourceGenerators.Models;
|
||||
using ComputeSharp.SourceGeneration.Extensions;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using ComputeSharp.Core.Intrinsics.Attributes;
|
||||
using ComputeSharp.Exceptions;
|
||||
|
||||
#pragma warning disable IDE0022
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
using ComputeSharp.Exceptions;
|
||||
|
||||
#pragma warning disable IDE0022
|
||||
|
||||
namespace ComputeSharp.D2D1;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
using ComputeSharp.Exceptions;
|
||||
|
||||
#pragma warning disable IDE0022
|
||||
|
||||
namespace ComputeSharp.D2D1;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
using ComputeSharp.Exceptions;
|
||||
|
||||
#pragma warning disable IDE0022
|
||||
|
||||
namespace ComputeSharp.D2D1;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace ComputeSharp.D2D1.Exceptions;
|
||||
namespace ComputeSharp.D2D1;
|
||||
|
||||
/// <summary>
|
||||
/// A custom <see cref="Exception"/> type that indicates when a shader compilation with the FXC compiler has failed.
|
||||
@@ -24,15 +23,15 @@ public sealed class FxcCompilationException : Exception
|
||||
/// <returns>A formatted error message for a new <see cref="FxcCompilationException"/> instance.</returns>
|
||||
private static string GetExceptionMessage(string error)
|
||||
{
|
||||
StringBuilder builder = new(512);
|
||||
#if NET6_0_OR_GREATER
|
||||
ReadOnlySpan<char> message = error.AsSpan().Trim();
|
||||
#else
|
||||
string message = error.Trim();
|
||||
#endif
|
||||
|
||||
_ = builder.AppendLine("The FXC compiler encountered one or more errors while trying to compile the shader:");
|
||||
_ = builder.AppendLine();
|
||||
_ = builder.AppendLine(error.Trim());
|
||||
_ = builder.AppendLine();
|
||||
_ = builder.AppendLine("Make sure to only be using supported features by checking the README file in the ComputeSharp repository: https://github.com/Sergio0694/ComputeSharp.");
|
||||
_ = builder.Append("If you're sure that your C# shader code is valid, please open an issue an include a working repro and this error message.");
|
||||
|
||||
return builder.ToString();
|
||||
return
|
||||
$"""The FXC compiler encountered one or more errors while trying to compile the shader: "{message}". """ +
|
||||
$"""Make sure to only be using supported features by checking the README file in the ComputeSharp repository: https://github.com/Sergio0694/ComputeSharp. """ +
|
||||
$"""If you're sure that your C# shader code is valid, please open an issue an include a working repro and this error message.""";
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Text;
|
||||
using ComputeSharp.D2D1.Exceptions;
|
||||
using ComputeSharp.D2D1.Shaders.Translation;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
|
||||
@@ -25,6 +25,14 @@ internal static unsafe class D2D1EffectXmlFactory
|
||||
public static EffectXml GetXmlBuffer<T>()
|
||||
where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor<T>
|
||||
{
|
||||
// Compute all necessary values first, outside of the lock
|
||||
string? displayName = D2D1PixelShaderEffect.GetEffectDisplayName<T>();
|
||||
string? description = D2D1PixelShaderEffect.GetEffectDescription<T>();
|
||||
string? category = D2D1PixelShaderEffect.GetEffectCategory<T>();
|
||||
string? author = D2D1PixelShaderEffect.GetEffectAuthor<T>();
|
||||
int inputCount = D2D1PixelShader.GetInputCount<T>();
|
||||
int resourceTextureCount = D2D1PixelShader.GetResourceTextureCount<T>();
|
||||
|
||||
StringBuilder builder = XmlBuilder;
|
||||
|
||||
// We use a simple caching schema here with a single StringBuilder instance shared across all threads.
|
||||
@@ -39,15 +47,15 @@ internal static unsafe class D2D1EffectXmlFactory
|
||||
_ = builder.Append($"""
|
||||
<?xml version='1.0'?>
|
||||
<Effect>
|
||||
<Property name='DisplayName' type='string' value='{D2D1PixelShaderEffect.GetEffectDisplayName<T>()}'/>
|
||||
<Property name='Description' type='string' value='{D2D1PixelShaderEffect.GetEffectDescription<T>()}'/>
|
||||
<Property name='Category' type='string' value='{D2D1PixelShaderEffect.GetEffectCategory<T>()}'/>
|
||||
<Property name='Author' type='string' value='{D2D1PixelShaderEffect.GetEffectAuthor<T>()}'/>
|
||||
<Property name='DisplayName' type='string' value='{displayName}'/>
|
||||
<Property name='Description' type='string' value='{description}'/>
|
||||
<Property name='Category' type='string' value='{category}'/>
|
||||
<Property name='Author' type='string' value='{author}'/>
|
||||
<Inputs>
|
||||
""");
|
||||
|
||||
// Add the input nodes, if any
|
||||
for (int i = 0; i < D2D1PixelShader.GetInputCount<T>(); i++)
|
||||
for (int i = 0; i < inputCount; i++)
|
||||
{
|
||||
_ = builder.Append('\n');
|
||||
_ = builder.Append($" <Input name='Source{i}'/>");
|
||||
@@ -66,7 +74,7 @@ internal static unsafe class D2D1EffectXmlFactory
|
||||
""");
|
||||
|
||||
// Add the resource texture manager nodes, if any
|
||||
for (int i = 0; i < D2D1PixelShader.GetResourceTextureCount<T>(); i++)
|
||||
for (int i = 0; i < resourceTextureCount; i++)
|
||||
{
|
||||
_ = builder.Append('\n');
|
||||
_ = builder.Append($"""
|
||||
|
||||
@@ -4,7 +4,6 @@ using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using ComputeSharp.D2D1.Exceptions;
|
||||
using ComputeSharp.D2D1.Extensions;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace ComputeSharp.Exceptions;
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
/// A custom <see cref="Exception"/> type that indicates when a shader compilation with the DXC compiler has failed.
|
||||
@@ -24,15 +23,15 @@ public sealed class DxcCompilationException : Exception
|
||||
/// <returns>A formatted error message for a new <see cref="DxcCompilationException"/> instance.</returns>
|
||||
private static string GetExceptionMessage(string error)
|
||||
{
|
||||
StringBuilder builder = new(512);
|
||||
#if NET6_0_OR_GREATER
|
||||
ReadOnlySpan<char> message = error.AsSpan().Trim();
|
||||
#else
|
||||
string message = error.Trim();
|
||||
#endif
|
||||
|
||||
_ = builder.AppendLine("The DXC compiler encountered one or more errors while trying to compile the shader:");
|
||||
_ = builder.AppendLine();
|
||||
_ = builder.AppendLine(error.Trim());
|
||||
_ = builder.AppendLine();
|
||||
_ = builder.AppendLine("Make sure to only be using supported features by checking the README file in the ComputeSharp repository: https://github.com/Sergio0694/ComputeSharp.");
|
||||
_ = builder.Append("If you're sure that your C# shader code is valid, please open an issue an include a working repro and this error message.");
|
||||
|
||||
return builder.ToString();
|
||||
return
|
||||
$"""The DXC compiler encountered one or more errors while trying to compile the shader: "{message}". """ +
|
||||
$"""Make sure to only be using supported features by checking the README file in the ComputeSharp repository: https://github.com/Sergio0694/ComputeSharp. """ +
|
||||
$"""If you're sure that your C# shader code is valid, please open an issue an include a working repro and this error message.""";
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using ComputeSharp.Core.Extensions;
|
||||
using ComputeSharp.Exceptions;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
#if !NET6_0_OR_GREATER
|
||||
|
||||
@@ -8,7 +8,6 @@ using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Shaders.Translation;
|
||||
using ComputeSharp.SourceGeneration.Extensions;
|
||||
using ComputeSharp.SourceGeneration.Helpers;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
using ComputeSharp.Exceptions;
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
using ComputeSharp.Exceptions;
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
using ComputeSharp.Exceptions;
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
using ComputeSharp.Exceptions;
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
using ComputeSharp.Exceptions;
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <inheritdoc cref="ThreadIds"/>
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
using ComputeSharp.Exceptions;
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using ComputeSharp.Interop;
|
||||
using ComputeSharp.Resources;
|
||||
|
||||
namespace ComputeSharp.Exceptions;
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
/// A custom <see cref="InvalidOperationException"/> that indicates when mismatched devices are being used.
|
||||
@@ -32,15 +31,13 @@ public sealed class GraphicsDeviceMismatchException : InvalidOperationException
|
||||
/// </remarks>
|
||||
private static GraphicsDeviceMismatchException Create(IReferenceTrackedObject resource, GraphicsDevice sourceDevice, GraphicsDevice destinationDevice)
|
||||
{
|
||||
StringBuilder builder = new(512);
|
||||
string message =
|
||||
$"""Invalid pairing of graphics devices used to run a compute shader and allocate memory buffers. """ +
|
||||
$"""The target device to run the compute shader is "{destinationDevice}". """ +
|
||||
$"""The buffer of type {resource.GetType()} was allocated on device "{sourceDevice}". """ +
|
||||
$"""Make sure to always allocate buffers on the same device used to actually run the code that accesses them.""";
|
||||
|
||||
_ = builder.AppendLine("Invalid pairing of graphics devices used to run a compute shader and allocate memory buffers.");
|
||||
_ = builder.AppendLine($"The target device to run the compute shader is \"{destinationDevice}\".");
|
||||
_ = builder.AppendLine($"The buffer of type {resource.GetType()} was allocated on device \"{sourceDevice}\".");
|
||||
_ = builder.Append("Make sure to always allocate buffers on the same device used to actually run the code that accesses them.");
|
||||
_ = builder.ToString();
|
||||
|
||||
return new(builder.ToString());
|
||||
return new(message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace ComputeSharp.Exceptions;
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
/// A custom <see cref="NotSupportedException"/> that indicates when a resource was attempted to be created with an unsupported type.
|
||||
@@ -24,14 +23,12 @@ public sealed class UnsupportedDoubleOperationException : NotSupportedException
|
||||
/// <returns>A new <see cref="UnsupportedTextureTypeException"/> instance with a formatted error message.</returns>
|
||||
private static UnsupportedDoubleOperationException Create(Type type)
|
||||
{
|
||||
StringBuilder builder = new(256);
|
||||
string message =
|
||||
$"The device in use does not support creating resources of type {type}, as it does not support using double precision floating point numbers. " +
|
||||
$"As a possible workaround, consider replacing usage of the double type with single precision floating point numbers. " +
|
||||
$"Note that double precision operations are only partially supported on GPU devices, and are far slower than single precision ones.";
|
||||
|
||||
_ = builder.AppendLine($"The device in use does not support creating resources of type {type}, as it does not support using double precision floating point numbers.");
|
||||
_ = builder.AppendLine("As a possible workaround, consider replacing usage of the double type with single precision floating point numbers.");
|
||||
_ = builder.AppendLine("Note that double precision operations are only partially supported on GPU devices, and are far slower than single precision ones.");
|
||||
_ = builder.ToString();
|
||||
|
||||
return new(builder.ToString());
|
||||
return new(message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace ComputeSharp.Exceptions;
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
/// A custom <see cref="NotSupportedException"/> that indicates when a texture was attempted to be created with an unsupported type.
|
||||
@@ -25,22 +24,20 @@ public sealed class UnsupportedTextureTypeException : NotSupportedException
|
||||
/// <returns>A new <see cref="UnsupportedTextureTypeException"/> instance with a formatted error message.</returns>
|
||||
private static UnsupportedTextureTypeException Create(int rank, Type type)
|
||||
{
|
||||
StringBuilder builder = new(256);
|
||||
|
||||
_ = builder.AppendLine($"The device in use does not support creating {rank}D textures of type {type}.");
|
||||
_ = builder.Append($"Make sure to check the support at runtime by using {nameof(GraphicsDevice)}.");
|
||||
|
||||
_ = builder.AppendLine(rank switch
|
||||
string suggestedMethods = rank switch
|
||||
{
|
||||
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>().",
|
||||
1 => $"{nameof(GraphicsDevice)}.{nameof(GraphicsDevice.IsReadOnlyTexture1DSupportedForType)}<T>() or {nameof(GraphicsDevice)}.{nameof(GraphicsDevice.IsReadWriteTexture1DSupportedForType)}<T>()",
|
||||
2 => $"{nameof(GraphicsDevice)}.{nameof(GraphicsDevice.IsReadOnlyTexture2DSupportedForType)}<T>() or {nameof(GraphicsDevice)}.{nameof(GraphicsDevice.IsReadWriteTexture2DSupportedForType)}<T>()",
|
||||
3 => $"{nameof(GraphicsDevice)}.{nameof(GraphicsDevice.IsReadOnlyTexture3DSupportedForType)}<T>() or {nameof(GraphicsDevice)}.{nameof(GraphicsDevice.IsReadWriteTexture3DSupportedForType)}<T>()",
|
||||
_ => 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.");
|
||||
string message =
|
||||
$"The device in use does not support creating {rank}D textures of type {type}. " +
|
||||
$"Make sure to check the support at runtime by using {suggestedMethods}. " +
|
||||
$"As a possible workaround on older devices, consider using a texture type of lower rank, or a linear buffer.";
|
||||
|
||||
return new(builder.ToString());
|
||||
return new(message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Buffers;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.Core.Helpers;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Commands.Interop;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Commands;
|
||||
using ComputeSharp.Graphics.Commands.Interop;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Commands;
|
||||
using ComputeSharp.Graphics.Commands.Interop;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Commands;
|
||||
using ComputeSharp.Graphics.Commands.Interop;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
|
||||
@@ -2,7 +2,6 @@ using System;
|
||||
using System.Buffers;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
using ComputeSharp.Interop;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
using ComputeSharp.Interop;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
using ComputeSharp.Interop;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
using ComputeSharp.Interop;
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.Core.Helpers;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
using ComputeSharp.Graphics.Resources.Interop;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Resources.Enums;
|
||||
using ComputeSharp.Resources;
|
||||
using ComputeSharp.Resources.Debug;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Diagnostics;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Resources.Enums;
|
||||
using ComputeSharp.Resources;
|
||||
using ComputeSharp.Resources.Debug;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Diagnostics;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Resources.Enums;
|
||||
using ComputeSharp.Resources;
|
||||
using ComputeSharp.Resources.Debug;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Diagnostics;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Resources.Enums;
|
||||
using ComputeSharp.Resources;
|
||||
using ComputeSharp.Resources.Debug;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Diagnostics;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Resources.Enums;
|
||||
using ComputeSharp.Resources;
|
||||
using ComputeSharp.Resources.Debug;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Diagnostics;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Resources.Enums;
|
||||
using ComputeSharp.Resources;
|
||||
using ComputeSharp.Resources.Debug;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Diagnostics;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Resources.Enums;
|
||||
using ComputeSharp.Resources;
|
||||
using ComputeSharp.Resources.Debug;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Resources.Enums;
|
||||
using ComputeSharp.Resources;
|
||||
using ComputeSharp.Resources.Debug;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Commands.Interop;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Diagnostics;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Resources.Enums;
|
||||
using ComputeSharp.Resources;
|
||||
using ComputeSharp.Resources.Debug;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Commands.Interop;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Diagnostics;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Resources.Enums;
|
||||
using ComputeSharp.Resources;
|
||||
using ComputeSharp.Resources.Debug;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Commands.Interop;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Diagnostics;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Resources.Enums;
|
||||
using ComputeSharp.Resources;
|
||||
using ComputeSharp.Resources.Debug;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Commands.Interop;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Diagnostics;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Resources.Enums;
|
||||
using ComputeSharp.Resources;
|
||||
using ComputeSharp.Resources.Debug;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Commands.Interop;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Diagnostics;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Resources.Enums;
|
||||
using ComputeSharp.Resources;
|
||||
using ComputeSharp.Resources.Debug;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Commands.Interop;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Diagnostics;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Resources.Enums;
|
||||
using ComputeSharp.Resources;
|
||||
using ComputeSharp.Resources.Debug;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using ComputeSharp.D2D1.Exceptions;
|
||||
using ComputeSharp.D2D1.Interop;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle("ComputeSharp.D2D1.Uwp.Tests")]
|
||||
@@ -10,7 +9,7 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyCopyright("Copyright © 2023")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: AssemblyMetadata("TargetPlatform","UAP")]
|
||||
[assembly: AssemblyMetadata("TargetPlatform", "UAP")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: ComVisible(false)]
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Shaders.Translation;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using TerraFX.Interop.DirectX;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Resources;
|
||||
using ComputeSharp.Tests.Attributes;
|
||||
using ComputeSharp.Tests.Extensions;
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする