Move primitives to ComputeSharp.Core
このコミットが含まれているのは:
1 親
cc298770ca
コミット
e48949cd48
78ファイル変更
+369
-245
検索条件に一致するファイルはありません
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
/// An attribute that indicates that a target shader type should get an automatic constructor for all fields.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Struct, AllowMultiple = false)]
|
||||
public sealed class AutoConstructorAttribute : Attribute
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,222 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<DocumentationFile>ComputeSharp.Core.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Enable trimming support on .NET 6 -->
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0'">
|
||||
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
|
||||
<IsTrimmable>true</IsTrimmable>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- .NET Standard 2.0 polyfill packages -->
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
|
||||
<PackageReference Include="System.Memory" Version="4.5.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- T4 template generation service -->
|
||||
<ItemGroup>
|
||||
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Intrinsics\Hlsl.g.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Hlsl.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Primitives\Bool\Bool2.g.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Bool2.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Primitives\Bool\Bool3.g.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Bool3.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Primitives\Bool\Bool4.g.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Bool4.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Primitives\Bool\BoolMxN.g.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>BoolMxN.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Primitives\Double\Double2.g.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Double2.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Primitives\Double\Double3.g.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Double3.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Primitives\Double\Double4.g.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Double4.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Primitives\Double\DoubleMxN.g.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>DoubleMxN.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Primitives\Float\Float2.g.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Float2.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Primitives\Float\Float3.g.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Float3.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Primitives\Float\Float4.g.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Float4.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Primitives\Float\FloatMxN.g.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>FloatMxN.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Primitives\Int\Int2.g.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Int2.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Primitives\Int\Int3.g.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Int3.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Primitives\Int\Int4.g.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Int4.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Primitives\Int\IntMxN.g.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>IntMxN.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Primitives\UInt\UInt2.g.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>UInt2.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Primitives\UInt\UInt3.g.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>UInt3.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Primitives\UInt\UInt4.g.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>UInt4.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Primitives\UInt\UIntMxN.g.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>UIntMxN.tt</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Intrinsics\Hlsl.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>Hlsl.g.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Update="Primitives\Bool\Bool2.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>Bool2.g.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Update="Primitives\Bool\Bool3.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>Bool3.g.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Update="Primitives\Bool\Bool4.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>Bool4.g.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Update="Primitives\Bool\BoolMxN.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>BoolMxN.g.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Update="Primitives\Double\Double2.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>Double2.g.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Update="Primitives\Double\Double3.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>Double3.g.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Update="Primitives\Double\Double4.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>Double4.g.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Update="Primitives\Double\DoubleMxN.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>DoubleMxN.g.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Update="Primitives\Float\Float2.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>Float2.g.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Update="Primitives\Float\Float3.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>Float3.g.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Update="Primitives\Float\Float4.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>Float4.g.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Update="Primitives\Float\FloatMxN.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>FloatMxN.g.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Update="Primitives\Int\Int2.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>Int2.g.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Update="Primitives\Int\Int3.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>Int3.g.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Update="Primitives\Int\Int4.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>Int4.g.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Update="Primitives\Int\IntMxN.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>IntMxN.g.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Update="Primitives\UInt\UInt2.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>UInt2.g.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Update="Primitives\UInt\UInt3.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>UInt3.g.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Update="Primitives\UInt\UInt4.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>UInt4.g.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Update="Primitives\UInt\UIntMxN.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>UIntMxN.g.cs</LastGenOutput>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Shared project with .NET Standard 2.0 polyfills -->
|
||||
<Import Condition="'$(TargetFramework)' == 'netstandard2.0'" Project="..\ComputeSharp.Core.NetStandard\ComputeSharp.Core.NetStandard.projitems" Label="Shared" />
|
||||
</Project>
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
|
||||
namespace ComputeSharp.Exceptions;
|
||||
|
||||
/// <summary>
|
||||
/// A custom <see cref="InvalidOperationException"/> that indicates when an HLSL-only API is called from C#
|
||||
/// </summary>
|
||||
public sealed class InvalidExecutionContextException : InvalidOperationException
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="InvalidExecutionContextException"/> instance.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the caller API.</param>
|
||||
internal InvalidExecutionContextException(string name)
|
||||
: base($"The API {name} can only be used from within an HLSL shader.")
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,315 @@
|
||||
// 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;
|
||||
characters = initialBuffer;
|
||||
arrayToReturnToPool = null;
|
||||
position = 0;
|
||||
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(characters.Slice(0, position));
|
||||
#else
|
||||
string result = characters.Slice(0, position).ToString();
|
||||
#endif
|
||||
char[]? toReturn = 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 = characters;
|
||||
int pos = position;
|
||||
|
||||
if ((uint)pos < (uint)chars.Length)
|
||||
{
|
||||
chars[pos] = value[0];
|
||||
|
||||
position = pos + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
GrowThenCopyString(value);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (value.Length == 2)
|
||||
{
|
||||
Span<char> chars = characters;
|
||||
int pos = 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
|
||||
|
||||
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(characters.Slice(position)))
|
||||
#else
|
||||
if (value.AsSpan().TryCopyTo(characters.Slice(position)))
|
||||
#endif
|
||||
{
|
||||
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 (hasCustomFormatter)
|
||||
{
|
||||
AppendCustomFormatter(value, format);
|
||||
return;
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
int charsWritten;
|
||||
|
||||
while (!value.TryFormat(characters.Slice(position), out charsWritten, format, formatProvider))
|
||||
{
|
||||
Grow();
|
||||
}
|
||||
|
||||
position += charsWritten;
|
||||
#else
|
||||
AppendStringDirect(value.ToString(format, 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?)formatProvider?.GetFormat(typeof(ICustomFormatter));
|
||||
|
||||
if (formatter is not null && formatter.Format(format, value, 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(characters.Slice(position));
|
||||
#else
|
||||
value.AsSpan().CopyTo(characters.Slice(position));
|
||||
#endif
|
||||
|
||||
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)position + (uint)additionalChars);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Grows the size of <see cref="characters"/>.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
private void Grow()
|
||||
{
|
||||
GrowCore((uint)characters.Length + 1);
|
||||
}
|
||||
|
||||
/// <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)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);
|
||||
|
||||
characters.Slice(0, position).CopyTo(newArray);
|
||||
|
||||
char[]? toReturn = arrayToReturnToPool;
|
||||
|
||||
characters = arrayToReturnToPool = newArray;
|
||||
|
||||
if (toReturn is not null)
|
||||
{
|
||||
ArrayPool<char>.Shared.Return(toReturn);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,258 @@
|
||||
// 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>
|
||||
internal int position;
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether all formatting operations have succeeded.
|
||||
/// </summary>
|
||||
internal 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;
|
||||
position = 0;
|
||||
success = shouldAppend = destination.Length >= literalLength;
|
||||
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 = position;
|
||||
|
||||
if ((uint)pos < (uint)destination.Length)
|
||||
{
|
||||
destination[pos] = value[0];
|
||||
|
||||
position = pos + 1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return Fail();
|
||||
}
|
||||
|
||||
if (value.Length == 2)
|
||||
{
|
||||
Span<char> destination = this.destination;
|
||||
int pos = 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
|
||||
|
||||
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(destination.Slice(position)))
|
||||
#else
|
||||
if (value.AsSpan().TryCopyTo(destination.Slice(position)))
|
||||
#endif
|
||||
{
|
||||
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 (hasCustomFormatter)
|
||||
{
|
||||
return AppendCustomFormatter(value, formatAsString ??= format.ToString());
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
int charsWritten;
|
||||
|
||||
if (value.TryFormat(destination.Slice(position), out charsWritten, format, formatProvider))
|
||||
{
|
||||
position += charsWritten;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return Fail();
|
||||
#else
|
||||
return AppendStringDirect(value.ToString(formatAsString ??= format.ToString(), 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 (hasCustomFormatter)
|
||||
{
|
||||
return AppendCustomFormatter(value, format: null);
|
||||
}
|
||||
|
||||
if (value is null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
if (value.TryCopyTo(destination.Slice(position)))
|
||||
#else
|
||||
if (value.AsSpan().TryCopyTo(destination.Slice(position)))
|
||||
#endif
|
||||
{
|
||||
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?)formatProvider?.GetFormat(typeof(ICustomFormatter));
|
||||
|
||||
if (formatter is not null && formatter.Format(format, value, formatProvider) is string customFormatted)
|
||||
{
|
||||
return AppendStringDirect(customFormatted);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Marks formatting as having failed and returns false.
|
||||
/// </summary>
|
||||
private bool Fail()
|
||||
{
|
||||
success = false;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace ComputeSharp.Core.Intrinsics.Attributes;
|
||||
|
||||
/// <summary>
|
||||
/// An attribute indicating the native member name of a given HLSL intrinsic.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
|
||||
[Conditional("SOURCE_GENERATOR")]
|
||||
internal sealed class HlslIntrinsicNameAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="HlslIntrinsicNameAttribute"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the HLSL intrinsic.</param>
|
||||
public HlslIntrinsicNameAttribute(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the HLSL intrinsic.
|
||||
/// </summary>
|
||||
public string Name { get; }
|
||||
}
|
||||
@@ -0,0 +1,319 @@
|
||||
using ComputeSharp.Exceptions;
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
/// A <see langword="class"/> that maps the supported HLSL intrinsic functions that can be used in compute shaders.
|
||||
/// </summary>
|
||||
public static partial class Hlsl
|
||||
{
|
||||
/// <summary>
|
||||
/// Blocks execution of all threads in a group until all memory accesses have been completed.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// A memory barrier guarantees that outstanding memory operations have completed.
|
||||
/// Threads are synchronized at GroupSync barriers.
|
||||
/// This may stall a thread or threads if memory operations are in progress.
|
||||
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
|
||||
/// </remarks>
|
||||
public static void AllMemoryBarrier() => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(AllMemoryBarrier)}()");
|
||||
|
||||
/// <summary>
|
||||
/// Blocks execution of all threads in a group until all memory accesses have been completed and all threads in the group have reached this call.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// A memory barrier guarantees that outstanding memory operations have completed.
|
||||
/// Threads are synchronized at GroupSync barriers.
|
||||
/// This may stall a thread or threads if memory operations are in progress.
|
||||
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
|
||||
/// </remarks>
|
||||
public static void AllMemoryBarrierWithGroupSync() => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(AllMemoryBarrierWithGroupSync)}()");
|
||||
|
||||
/// <summary>
|
||||
/// Blocks execution of all threads in a group until all device memory accesses have been completed.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static void DeviceMemoryBarrier() => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(DeviceMemoryBarrier)}()");
|
||||
|
||||
/// <summary>
|
||||
/// Blocks execution of all threads in a group until all device memory accesses have been completed and all threads in the group have reached this call.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static void DeviceMemoryBarrierWithGroupSync() => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(DeviceMemoryBarrierWithGroupSync)}()");
|
||||
|
||||
/// <summary>
|
||||
/// Blocks execution of all threads in a group until all group shared accesses have been completed.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static void GroupMemoryBarrier() => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(GroupMemoryBarrier)}()");
|
||||
|
||||
/// <summary>
|
||||
/// Blocks execution of all threads in a group until all group shared accesses have been completed and all threads in the group have reached this call.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static void GroupMemoryBarrierWithGroupSync() => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(GroupMemoryBarrierWithGroupSync)}()");
|
||||
|
||||
/// <summary>
|
||||
/// Performs a guaranteed atomic add of a value to a destination.
|
||||
/// </summary>
|
||||
/// <param name="destination">The destination value.</param>
|
||||
/// <param name="value">The input value.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static void InterlockedAdd(ref int destination, int value) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(InterlockedAdd)}({typeof(int)}, {typeof(int)})");
|
||||
|
||||
/// <summary>
|
||||
/// Performs a guaranteed atomic add of a value to a destination.
|
||||
/// </summary>
|
||||
/// <param name="destination">The destination value.</param>
|
||||
/// <param name="value">The input value.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static void InterlockedAdd(ref uint destination, uint value) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(InterlockedAdd)}({typeof(uint)}, {typeof(uint)})");
|
||||
|
||||
/// <summary>
|
||||
/// Performs a guaranteed atomic add of a value to a destination.
|
||||
/// </summary>
|
||||
/// <param name="destination">The destination value.</param>
|
||||
/// <param name="value">The input value.</param>
|
||||
/// <param name="original">The original input value.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static void InterlockedAdd(ref int destination, int value, out int original) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(InterlockedAdd)}({typeof(int)}, {typeof(int)}, {typeof(int)})");
|
||||
|
||||
/// <summary>
|
||||
/// Performs a guaranteed atomic add of a value to a destination.
|
||||
/// </summary>
|
||||
/// <param name="destination">The destination value.</param>
|
||||
/// <param name="value">The input value.</param>
|
||||
/// <param name="original">The original input value.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static void InterlockedAdd(ref uint destination, uint value, out uint original) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(InterlockedAdd)}({typeof(uint)}, {typeof(uint)}, {typeof(uint)})");
|
||||
|
||||
/// <summary>
|
||||
/// Performs a guaranteed atomic and of a value to a destination.
|
||||
/// </summary>
|
||||
/// <param name="destination">The destination value.</param>
|
||||
/// <param name="value">The input value.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static void InterlockedAnd(ref int destination, int value) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(InterlockedAnd)}({typeof(int)}, {typeof(int)})");
|
||||
|
||||
/// <summary>
|
||||
/// Performs a guaranteed atomic and of a value to a destination.
|
||||
/// </summary>
|
||||
/// <param name="destination">The destination value.</param>
|
||||
/// <param name="value">The input value.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static void InterlockedAnd(ref uint destination, uint value) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(InterlockedAnd)}({typeof(uint)}, {typeof(uint)})");
|
||||
|
||||
/// <summary>
|
||||
/// Performs a guaranteed atomic and of a value to a destination.
|
||||
/// </summary>
|
||||
/// <param name="destination">The destination value.</param>
|
||||
/// <param name="value">The input value.</param>
|
||||
/// <param name="original">The original input value.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static void InterlockedAnd(ref int destination, int value, out int original) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(InterlockedAnd)}({typeof(int)}, {typeof(int)}, {typeof(int)})");
|
||||
|
||||
/// <summary>
|
||||
/// Performs a guaranteed atomic and of a value to a destination.
|
||||
/// </summary>
|
||||
/// <param name="destination">The destination value.</param>
|
||||
/// <param name="value">The input value.</param>
|
||||
/// <param name="original">The original input value.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static void InterlockedAnd(ref uint destination, uint value, out uint original) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(InterlockedAnd)}({typeof(uint)}, {typeof(uint)}, {typeof(uint)})");
|
||||
|
||||
/// <summary>
|
||||
/// Atomically compares the destination with the comparison value. If they are identical, the destination
|
||||
/// is overwritten with the input value. The original value is set to the destination's original value.
|
||||
/// </summary>
|
||||
/// <param name="destination">The destination value.</param>
|
||||
/// <param name="comparison">The comparison value.</param>
|
||||
/// <param name="value">The input value.</param>
|
||||
/// <param name="original">The original value.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static void InterlockedCompareExchange(ref int destination, int comparison, int value, out int original) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(InterlockedCompareExchange)}({typeof(int)}, {typeof(int)}, {typeof(int)}, {typeof(int)})");
|
||||
|
||||
/// <summary>
|
||||
/// Atomically compares the destination with the comparison value. If they are identical, the destination
|
||||
/// is overwritten with the input value. The original value is set to the destination's original value.
|
||||
/// </summary>
|
||||
/// <param name="destination">The destination value.</param>
|
||||
/// <param name="comparison">The comparison value.</param>
|
||||
/// <param name="value">The input value.</param>
|
||||
/// <param name="original">The original value.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static void InterlockedCompareExchange(ref uint destination, uint comparison, uint value, out uint original) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(InterlockedCompareExchange)}({typeof(uint)}, {typeof(uint)}, {typeof(uint)}, {typeof(uint)})");
|
||||
|
||||
/// <summary>
|
||||
/// Atomically compares the destination to the comparison value. If they
|
||||
/// are identical, the destination is overwritten with the input value.
|
||||
/// </summary>
|
||||
/// <param name="destination">The destination value.</param>
|
||||
/// <param name="comparison">The comparison value.</param>
|
||||
/// <param name="value">The input value.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static void InterlockedCompareStore(ref int destination, int comparison, int value) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(InterlockedCompareStore)}({typeof(int)}, {typeof(int)}, {typeof(int)})");
|
||||
|
||||
/// <summary>
|
||||
/// Atomically compares the destination to the comparison value. If they
|
||||
/// are identical, the destination is overwritten with the input value.
|
||||
/// </summary>
|
||||
/// <param name="destination">The destination value.</param>
|
||||
/// <param name="comparison">The comparison value.</param>
|
||||
/// <param name="value">The input value.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static void InterlockedCompareStore(ref uint destination, uint comparison, uint value) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(InterlockedCompareStore)}({typeof(uint)}, {typeof(uint)}, {typeof(uint)})");
|
||||
|
||||
/// <summary>
|
||||
/// Assigns value to dest and returns the original value.
|
||||
/// </summary>
|
||||
/// <param name="destination">The destination value.</param>
|
||||
/// <param name="value">The input value.</param>
|
||||
/// <param name="original">The original value.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static void InterlockedExchange(ref int destination, int value, out int original) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(InterlockedExchange)}({typeof(int)}, {typeof(int)}, {typeof(int)})");
|
||||
|
||||
/// <summary>
|
||||
/// Assigns value to dest and returns the original value.
|
||||
/// </summary>
|
||||
/// <param name="destination">The destination value.</param>
|
||||
/// <param name="value">The input value.</param>
|
||||
/// <param name="original">The original value.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static void InterlockedExchange(ref uint destination, uint value, out uint original) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(InterlockedExchange)}({typeof(uint)}, {typeof(uint)}, {typeof(uint)})");
|
||||
|
||||
/// <summary>
|
||||
/// Performs a guaranteed atomic max.
|
||||
/// </summary>
|
||||
/// <param name="destination">The destination value.</param>
|
||||
/// <param name="value">The input value.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static void InterlockedMax(ref int destination, int value) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(InterlockedMax)}({typeof(int)}, {typeof(int)})");
|
||||
|
||||
/// <summary>
|
||||
/// Performs a guaranteed atomic max.
|
||||
/// </summary>
|
||||
/// <param name="destination">The destination value.</param>
|
||||
/// <param name="value">The input value.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static void InterlockedMax(ref uint destination, uint value) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(InterlockedMax)}({typeof(uint)}, {typeof(uint)})");
|
||||
|
||||
/// <summary>
|
||||
/// Performs a guaranteed atomic max.
|
||||
/// </summary>
|
||||
/// <param name="destination">The destination value.</param>
|
||||
/// <param name="value">The input value.</param>
|
||||
/// <param name="original">The original value.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static void InterlockedMax(ref int destination, int value, out int original) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(InterlockedMax)}({typeof(int)}, {typeof(int)}, {typeof(int)})");
|
||||
|
||||
/// <summary>
|
||||
/// Performs a guaranteed atomic max.
|
||||
/// </summary>
|
||||
/// <param name="destination">The destination value.</param>
|
||||
/// <param name="value">The input value.</param>
|
||||
/// <param name="original">The original value.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static void InterlockedMax(ref uint destination, uint value, out uint original) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(InterlockedMax)}({typeof(uint)}, {typeof(uint)}, {typeof(uint)})");
|
||||
|
||||
/// <summary>
|
||||
/// Performs a guaranteed atomic min.
|
||||
/// </summary>
|
||||
/// <param name="destination">The destination value.</param>
|
||||
/// <param name="value">The input value.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static void InterlockedMin(ref int destination, int value) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(InterlockedMin)}({typeof(int)}, {typeof(int)})");
|
||||
|
||||
/// <summary>
|
||||
/// Performs a guaranteed atomic min.
|
||||
/// </summary>
|
||||
/// <param name="destination">The destination value.</param>
|
||||
/// <param name="value">The input value.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static void InterlockedMin(ref uint destination, uint value) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(InterlockedMin)}({typeof(uint)}, {typeof(uint)})");
|
||||
|
||||
/// <summary>
|
||||
/// Performs a guaranteed atomic min.
|
||||
/// </summary>
|
||||
/// <param name="destination">The destination value.</param>
|
||||
/// <param name="value">The input value.</param>
|
||||
/// <param name="original">The original value.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static void InterlockedMin(ref int destination, int value, out int original) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(InterlockedMin)}({typeof(int)}, {typeof(int)}, {typeof(int)})");
|
||||
|
||||
/// <summary>
|
||||
/// Performs a guaranteed atomic min.
|
||||
/// </summary>
|
||||
/// <param name="destination">The destination value.</param>
|
||||
/// <param name="value">The input value.</param>
|
||||
/// <param name="original">The original value.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static void InterlockedMin(ref uint destination, uint value, out uint original) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(InterlockedMin)}({typeof(uint)}, {typeof(uint)}, {typeof(uint)})");
|
||||
|
||||
/// <summary>
|
||||
/// Performs a guaranteed atomic or.
|
||||
/// </summary>
|
||||
/// <param name="destination">The destination value.</param>
|
||||
/// <param name="value">The input value.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static void InterlockedOr(ref int destination, int value) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(InterlockedOr)}({typeof(int)}, {typeof(int)})");
|
||||
|
||||
/// <summary>
|
||||
/// Performs a guaranteed atomic or.
|
||||
/// </summary>
|
||||
/// <param name="destination">The destination value.</param>
|
||||
/// <param name="value">The input value.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static void InterlockedOr(ref uint destination, uint value) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(InterlockedOr)}({typeof(uint)}, {typeof(uint)})");
|
||||
|
||||
/// <summary>
|
||||
/// Performs a guaranteed atomic or.
|
||||
/// </summary>
|
||||
/// <param name="destination">The destination value.</param>
|
||||
/// <param name="value">The input value.</param>
|
||||
/// <param name="original">The original value.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static void InterlockedOr(ref int destination, int value, out int original) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(InterlockedOr)}({typeof(int)}, {typeof(int)}, {typeof(int)})");
|
||||
|
||||
/// <summary>
|
||||
/// Performs a guaranteed atomic or.
|
||||
/// </summary>
|
||||
/// <param name="destination">The destination value.</param>
|
||||
/// <param name="value">The input value.</param>
|
||||
/// <param name="original">The original value.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static void InterlockedOr(ref uint destination, uint value, out uint original) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(InterlockedOr)}({typeof(uint)}, {typeof(uint)}, {typeof(uint)})");
|
||||
|
||||
/// <summary>
|
||||
/// Performs a guaranteed atomic xor.
|
||||
/// </summary>
|
||||
/// <param name="destination">The destination value.</param>
|
||||
/// <param name="value">The input value.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static void InterlockedXor(ref int destination, int value) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(InterlockedXor)}({typeof(int)}, {typeof(int)})");
|
||||
|
||||
/// <summary>
|
||||
/// Performs a guaranteed atomic xor.
|
||||
/// </summary>
|
||||
/// <param name="destination">The destination value.</param>
|
||||
/// <param name="value">The input value.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static void InterlockedXor(ref uint destination, uint value) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(InterlockedXor)}({typeof(uint)}, {typeof(uint)})");
|
||||
|
||||
/// <summary>
|
||||
/// Performs a guaranteed atomic xor.
|
||||
/// </summary>
|
||||
/// <param name="destination">The destination value.</param>
|
||||
/// <param name="value">The input value.</param>
|
||||
/// <param name="original">The original value.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static void InterlockedXor(ref int destination, int value, out int original) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(InterlockedXor)}({typeof(int)}, {typeof(int)}, {typeof(int)})");
|
||||
|
||||
/// <summary>
|
||||
/// Performs a guaranteed atomic xor.
|
||||
/// </summary>
|
||||
/// <param name="destination">The destination value.</param>
|
||||
/// <param name="value">The input value.</param>
|
||||
/// <param name="original">The original value.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static void InterlockedXor(ref uint destination, uint value, out uint original) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(InterlockedXor)}({typeof(uint)}, {typeof(uint)}, {typeof(uint)})");
|
||||
}
|
||||
ファイル差分が大きすぎるため表示されません。
差分を読み込み
@@ -0,0 +1,63 @@
|
||||
<#@include file="Hlsl.ttinclude" #>
|
||||
using ComputeSharp.Core.Intrinsics.Attributes;
|
||||
using ComputeSharp.Exceptions;
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <inheritdoc cref="Hlsl"/>
|
||||
public static partial class Hlsl
|
||||
{
|
||||
<#
|
||||
PushIndent(" ");
|
||||
|
||||
bool isFirst = true;
|
||||
|
||||
foreach (var intrinsic in Intrinsics)
|
||||
{
|
||||
foreach (var overload in intrinsic.Overloads)
|
||||
{
|
||||
if (isFirst) isFirst = false;
|
||||
else WriteLine("");
|
||||
|
||||
WriteLine("/// <summary>");
|
||||
WriteLine($"/// {intrinsic.Summary}");
|
||||
WriteLine("/// </summary>");
|
||||
|
||||
foreach (var param in intrinsic.Parameters)
|
||||
{
|
||||
WriteLine($"/// <param name=\"{param.Name}\">{param.Info}</param>");
|
||||
}
|
||||
|
||||
if (intrinsic.Returns.Length > 0)
|
||||
{
|
||||
var returns = Regex.Replace(intrinsic.Returns, @"{(\w+)}", m => $"<paramref name=\"{m.Groups[1].Value}\"/>");
|
||||
|
||||
WriteLine($"/// <returns>{returns}</returns>");
|
||||
}
|
||||
|
||||
WriteLine("/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>");
|
||||
|
||||
WriteLine($"[HlslIntrinsicName(\"{intrinsic.HlslName}\")]");
|
||||
|
||||
Write($"public static {overload.Return} {intrinsic.Name}(");
|
||||
Write(string.Join(", ", intrinsic.Parameters.Zip(overload.Params, (a, b) => $"{(a.IsOut ? "out " : "")}{b} {a.Name}")));
|
||||
Write(")");
|
||||
|
||||
if (intrinsic.Parameters.Any(param => param.IsOut))
|
||||
{
|
||||
Write(" => throw new InvalidExecutionContextException(");
|
||||
|
||||
var parameters = string.Join(", ", overload.Params.Select(t => $"{{typeof({t})}}"));
|
||||
|
||||
WriteLine($"$\"{{typeof(Hlsl)}}.{{nameof({intrinsic.Name})}}({parameters})\");");
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLine(" => default;");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PopIndent();
|
||||
#>
|
||||
}
|
||||
ファイル差分が大きすぎるため表示されません。
差分を読み込み
@@ -0,0 +1,90 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
/// A <see langword="struct"/> that can be used in place of the <see cref="bool"/> type in HLSL shaders.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Explicit, Size = sizeof(int), Pack = 4)]
|
||||
public readonly struct Bool
|
||||
{
|
||||
/// <summary>
|
||||
/// The wrapped <see cref="bool"/> value for the current instance.
|
||||
/// </summary>
|
||||
[FieldOffset(0)]
|
||||
private readonly bool Value;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Bool"/> instance for a given <see cref="bool"/> value.
|
||||
/// </summary>
|
||||
/// <param name="value">.</param>
|
||||
private Bool(bool value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
return obj is Bool x && Value == x.Value;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Value.GetHashCode();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string ToString()
|
||||
{
|
||||
return Value.ToString();
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="bool.ToString(IFormatProvider?)"/>
|
||||
public string ToString(IFormatProvider? formatProvider)
|
||||
{
|
||||
return Value.ToString();
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <inheritdoc cref="bool.TryFormat(Span{char}, out int)"/>
|
||||
public bool TryFormat(Span<char> destination, out int charsWritten)
|
||||
{
|
||||
return Value.TryFormat(destination, out charsWritten);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether or not two <see cref="Bool"/> instances represent the same <see cref="bool"/> value.
|
||||
/// </summary>
|
||||
/// <param name="left">The left <see cref="Bool"/> instance.</param>
|
||||
/// <param name="right">The right <see cref="Bool"/> instance.</param>
|
||||
public static bool operator ==(Bool left, Bool right) => left.Value == right.Value;
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether or not two <see cref="Bool"/> instances represent a different <see cref="bool"/> value.
|
||||
/// </summary>
|
||||
/// <param name="left">The left <see cref="Bool"/> instance.</param>
|
||||
/// <param name="right">The right <see cref="Bool"/> instance.</param>
|
||||
public static bool operator !=(Bool left, Bool right) => left.Value != right.Value;
|
||||
|
||||
/// <summary>
|
||||
/// Inverts the <see cref="bool"/> value represented by a given <see cref="Bool"/> instance.
|
||||
/// </summary>
|
||||
/// <param name="x">The input <see cref="Bool"/> instance.</param>
|
||||
public static Bool operator !(Bool x) => new(!x.Value);
|
||||
|
||||
/// <summary>
|
||||
/// Converts a given <see cref="Bool"/> instance to its corresponding <see cref="bool"/> value.
|
||||
/// </summary>
|
||||
/// <param name="x">The input <see cref="Bool"/> instance.</param>
|
||||
public static implicit operator bool(Bool x) => x.Value;
|
||||
|
||||
/// <summary>
|
||||
/// Converts a <see cref="bool"/> value to a corresponding <see cref="Bool"/> instance.
|
||||
/// </summary>
|
||||
/// <param name="x">The input <see cref="bool"/> value.</param>
|
||||
public static implicit operator Bool(bool x) => new(x);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
/// A <see langword="struct"/> that maps the <see langword="bool2"/> HLSL type.
|
||||
/// </summary>
|
||||
public partial struct Bool2
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Bool2"/> value with all components set to <see langword="false"/>.
|
||||
/// </summary>
|
||||
public static Bool2 False => false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Bool2"/> value with all components set to <see langword="true"/>.
|
||||
/// </summary>
|
||||
public static Bool2 True => true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Bool2"/> value with the <see cref="X"/> component set to <see langword="true"/>, and the others to <see langword="false"/>.
|
||||
/// </summary>
|
||||
public static Bool2 TrueX => new(true, false);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Bool2"/> value with the <see cref="Y"/> component set to <see langword="true"/>, and the others to <see langword="false"/>.
|
||||
/// </summary>
|
||||
public static Bool2 TrueY => new(false, true);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Bool2"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to assign to the first vector component.</param>
|
||||
/// <param name="y">The value to assign to the second vector component.</param>
|
||||
public Bool2(bool x, bool y)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Bool2"/> value with the same value for all its components.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to use for the components of the new <see cref="Bool2"/> instance.</param>
|
||||
public static implicit operator Bool2(bool x) => new(x, x);
|
||||
}
|
||||
@@ -0,0 +1,410 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using RuntimeHelpers = ComputeSharp.Core.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.Core.NetStandard.System.Runtime.InteropServices.MemoryMarshal;
|
||||
#endif
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <inheritdoc cref="Bool2"/>
|
||||
[StructLayout(LayoutKind.Explicit, Size = 8, Pack = 4)]
|
||||
public unsafe partial struct Bool2
|
||||
{
|
||||
/// <summary>
|
||||
/// A private buffer to which the undefined properties will point to.
|
||||
/// </summary>
|
||||
private static readonly void* UndefinedData = (void*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(Bool2), sizeof(Bool4));
|
||||
|
||||
[FieldOffset(0)]
|
||||
private bool x;
|
||||
|
||||
[FieldOffset(4)]
|
||||
private bool y;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to a specific component in the current <see cref="Bool2"/> instance.
|
||||
/// </summary>
|
||||
/// <param name="i">The index of the component to access.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref bool this[int i] => ref *(bool*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="bool"/> value representing the <c>X</c> component.
|
||||
/// </summary>
|
||||
public readonly ref bool X => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.x), 1));
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="bool"/> value representing the <c>Y</c> component.
|
||||
/// </summary>
|
||||
public readonly ref bool Y => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.y), 1));
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool2"/> value with the components <see cref="X"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool2 XX => ref *(Bool2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="Bool2"/> value with the components <see cref="X"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref Bool2 XY => ref *(Bool2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="Bool2"/> value with the components <see cref="Y"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref Bool2 YX => ref *(Bool2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool2"/> value with the components <see cref="Y"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool2 YY => ref *(Bool2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool3"/> value with the components <see cref="X"/>, <see cref="X"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool3 XXX => ref *(Bool3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool3"/> value with the components <see cref="X"/>, <see cref="X"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool3 XXY => ref *(Bool3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool3"/> value with the components <see cref="X"/>, <see cref="Y"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool3 XYX => ref *(Bool3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool3"/> value with the components <see cref="X"/>, <see cref="Y"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool3 XYY => ref *(Bool3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool3"/> value with the components <see cref="Y"/>, <see cref="X"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool3 YXX => ref *(Bool3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool3"/> value with the components <see cref="Y"/>, <see cref="X"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool3 YXY => ref *(Bool3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool3"/> value with the components <see cref="Y"/>, <see cref="Y"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool3 YYX => ref *(Bool3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool3"/> value with the components <see cref="Y"/>, <see cref="Y"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool3 YYY => ref *(Bool3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool4"/> value with the components <see cref="X"/>, <see cref="X"/>, <see cref="X"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool4 XXXX => ref *(Bool4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool4"/> value with the components <see cref="X"/>, <see cref="X"/>, <see cref="X"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool4 XXXY => ref *(Bool4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool4"/> value with the components <see cref="X"/>, <see cref="X"/>, <see cref="Y"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool4 XXYX => ref *(Bool4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool4"/> value with the components <see cref="X"/>, <see cref="X"/>, <see cref="Y"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool4 XXYY => ref *(Bool4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool4"/> value with the components <see cref="X"/>, <see cref="Y"/>, <see cref="X"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool4 XYXX => ref *(Bool4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool4"/> value with the components <see cref="X"/>, <see cref="Y"/>, <see cref="X"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool4 XYXY => ref *(Bool4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool4"/> value with the components <see cref="X"/>, <see cref="Y"/>, <see cref="Y"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool4 XYYX => ref *(Bool4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool4"/> value with the components <see cref="X"/>, <see cref="Y"/>, <see cref="Y"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool4 XYYY => ref *(Bool4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool4"/> value with the components <see cref="Y"/>, <see cref="X"/>, <see cref="X"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool4 YXXX => ref *(Bool4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool4"/> value with the components <see cref="Y"/>, <see cref="X"/>, <see cref="X"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool4 YXXY => ref *(Bool4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool4"/> value with the components <see cref="Y"/>, <see cref="X"/>, <see cref="Y"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool4 YXYX => ref *(Bool4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool4"/> value with the components <see cref="Y"/>, <see cref="X"/>, <see cref="Y"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool4 YXYY => ref *(Bool4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool4"/> value with the components <see cref="Y"/>, <see cref="Y"/>, <see cref="X"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool4 YYXX => ref *(Bool4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool4"/> value with the components <see cref="Y"/>, <see cref="Y"/>, <see cref="X"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool4 YYXY => ref *(Bool4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool4"/> value with the components <see cref="Y"/>, <see cref="Y"/>, <see cref="Y"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool4 YYYX => ref *(Bool4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool4"/> value with the components <see cref="Y"/>, <see cref="Y"/>, <see cref="Y"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool4 YYYY => ref *(Bool4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="bool"/> value representing the <c>R</c> component.
|
||||
/// </summary>
|
||||
public readonly ref bool R => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.x), 1));
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="bool"/> value representing the <c>G</c> component.
|
||||
/// </summary>
|
||||
public readonly ref bool G => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.y), 1));
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool2"/> value with the components <see cref="R"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool2 RR => ref *(Bool2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="Bool2"/> value with the components <see cref="R"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref Bool2 RG => ref *(Bool2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="Bool2"/> value with the components <see cref="G"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref Bool2 GR => ref *(Bool2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool2"/> value with the components <see cref="G"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool2 GG => ref *(Bool2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool3"/> value with the components <see cref="R"/>, <see cref="R"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool3 RRR => ref *(Bool3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool3"/> value with the components <see cref="R"/>, <see cref="R"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool3 RRG => ref *(Bool3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool3"/> value with the components <see cref="R"/>, <see cref="G"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool3 RGR => ref *(Bool3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool3"/> value with the components <see cref="R"/>, <see cref="G"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool3 RGG => ref *(Bool3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool3"/> value with the components <see cref="G"/>, <see cref="R"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool3 GRR => ref *(Bool3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool3"/> value with the components <see cref="G"/>, <see cref="R"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool3 GRG => ref *(Bool3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool3"/> value with the components <see cref="G"/>, <see cref="G"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool3 GGR => ref *(Bool3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool3"/> value with the components <see cref="G"/>, <see cref="G"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool3 GGG => ref *(Bool3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool4"/> value with the components <see cref="R"/>, <see cref="R"/>, <see cref="R"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool4 RRRR => ref *(Bool4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool4"/> value with the components <see cref="R"/>, <see cref="R"/>, <see cref="R"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool4 RRRG => ref *(Bool4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool4"/> value with the components <see cref="R"/>, <see cref="R"/>, <see cref="G"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool4 RRGR => ref *(Bool4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool4"/> value with the components <see cref="R"/>, <see cref="R"/>, <see cref="G"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool4 RRGG => ref *(Bool4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool4"/> value with the components <see cref="R"/>, <see cref="G"/>, <see cref="R"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool4 RGRR => ref *(Bool4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool4"/> value with the components <see cref="R"/>, <see cref="G"/>, <see cref="R"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool4 RGRG => ref *(Bool4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool4"/> value with the components <see cref="R"/>, <see cref="G"/>, <see cref="G"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool4 RGGR => ref *(Bool4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool4"/> value with the components <see cref="R"/>, <see cref="G"/>, <see cref="G"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool4 RGGG => ref *(Bool4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool4"/> value with the components <see cref="G"/>, <see cref="R"/>, <see cref="R"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool4 GRRR => ref *(Bool4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool4"/> value with the components <see cref="G"/>, <see cref="R"/>, <see cref="R"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool4 GRRG => ref *(Bool4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool4"/> value with the components <see cref="G"/>, <see cref="R"/>, <see cref="G"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool4 GRGR => ref *(Bool4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool4"/> value with the components <see cref="G"/>, <see cref="R"/>, <see cref="G"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool4 GRGG => ref *(Bool4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool4"/> value with the components <see cref="G"/>, <see cref="G"/>, <see cref="R"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool4 GGRR => ref *(Bool4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool4"/> value with the components <see cref="G"/>, <see cref="G"/>, <see cref="R"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool4 GGRG => ref *(Bool4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool4"/> value with the components <see cref="G"/>, <see cref="G"/>, <see cref="G"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool4 GGGR => ref *(Bool4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Bool4"/> value with the components <see cref="G"/>, <see cref="G"/>, <see cref="G"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Bool4 GGGG => ref *(Bool4*)UndefinedData;
|
||||
|
||||
#if !SOURCE_GENERATOR
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override readonly string ToString()
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
return string.Create(null, stackalloc char[32], $"<{this.x}, {this.y}>");
|
||||
#else
|
||||
return $"<{this.x}, {this.y}>";
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Negates a <see cref="Bool2"/> value.
|
||||
/// </summary>
|
||||
/// <param name="xy">The <see cref="Bool2"/> value to negate.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static Bool2 operator !(Bool2 xy) => default;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<#@include file="..\VectorType.ttinclude" #>
|
||||
<#
|
||||
GenerateVectorProperties("Bool2", sizeof(int));
|
||||
#>
|
||||
@@ -0,0 +1,75 @@
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
/// A <see langword="struct"/> that maps the <see langword="bool3"/> HLSL type.
|
||||
/// </summary>
|
||||
public partial struct Bool3
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Bool3"/> value with all components set to <see langword="false"/>.
|
||||
/// </summary>
|
||||
public static Bool3 False => false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Bool3"/> value with all components set to <see langword="true"/>.
|
||||
/// </summary>
|
||||
public static Bool3 True => true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Bool3"/> value with the <see cref="X"/> component set to <see langword="true"/>, and the others to <see langword="false"/>.
|
||||
/// </summary>
|
||||
public static Bool3 TrueX => new(true, false, false);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Bool3"/> value with the <see cref="Y"/> component set to <see langword="true"/>, and the others to <see langword="false"/>.
|
||||
/// </summary>
|
||||
public static Bool3 TrueY => new(false, true, false);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Bool3"/> value with the <see cref="Z"/> component set to <see langword="true"/>, and the others to <see langword="false"/>.
|
||||
/// </summary>
|
||||
public static Bool3 TrueZ => new(false, false, true);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Bool3"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to assign to the first vector component.</param>
|
||||
/// <param name="y">The value to assign to the second vector component.</param>
|
||||
/// <param name="z">The value to assign to the third vector component.</param>
|
||||
public Bool3(bool x, bool y, bool z)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Bool3"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="xy">The value to assign to the first and second vector components.</param>
|
||||
/// <param name="z">The value to assign to the third vector component.</param>
|
||||
public Bool3(Bool2 xy, bool z)
|
||||
{
|
||||
this.x = xy.X;
|
||||
this.y = xy.Y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Bool3"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to assign to the first vector component.</param>
|
||||
/// <param name="yz">The value to assign to the second and thirt vector components.</param>
|
||||
public Bool3(bool x, Bool2 yz)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = yz.X;
|
||||
this.z = yz.Y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Bool3"/> value with the same value for all its components.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to use for the components of the new <see cref="Bool3"/> instance.</param>
|
||||
public static implicit operator Bool3(bool x) => new(x, x, x);
|
||||
}
|
||||
ファイル差分が大きすぎるため表示されません。
差分を読み込み
@@ -0,0 +1,4 @@
|
||||
<#@include file="..\VectorType.ttinclude" #>
|
||||
<#
|
||||
GenerateVectorProperties("Bool3", sizeof(int));
|
||||
#>
|
||||
@@ -0,0 +1,125 @@
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
/// A <see langword="struct"/> that maps the <see langword="bool4"/> HLSL type.
|
||||
/// </summary>
|
||||
public partial struct Bool4
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Bool4"/> value with all components set to <see langword="false"/>.
|
||||
/// </summary>
|
||||
public static Bool4 False => false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Bool4"/> value with all components set to <see langword="true"/>.
|
||||
/// </summary>
|
||||
public static Bool4 True => true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Bool4"/> value with the <see cref="X"/> component set to <see langword="true"/>, and the others to <see langword="false"/>.
|
||||
/// </summary>
|
||||
public static Bool4 TrueX => new(true, false, false, false);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Bool4"/> value with the <see cref="Y"/> component set to <see langword="true"/>, and the others to <see langword="false"/>.
|
||||
/// </summary>
|
||||
public static Bool4 TrueY => new(false, true, false, false);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Bool4"/> value with the <see cref="Z"/> component set to <see langword="true"/>, and the others to <see langword="false"/>.
|
||||
/// </summary>
|
||||
public static Bool4 TrueZ => new(false, false, true, false);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Bool4"/> value with the <see cref="W"/> component set to <see langword="true"/>, and the others to <see langword="false"/>.
|
||||
/// </summary>
|
||||
public static Bool4 TrueW => new(false, false, false, true);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Bool4"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to assign to the first vector component.</param>
|
||||
/// <param name="y">The value to assign to the second vector component.</param>
|
||||
/// <param name="z">The value to assign to the third vector component.</param>
|
||||
/// <param name="w">The value to assign to the fourth vector component.</param>
|
||||
public Bool4(bool x, bool y, bool z, bool w)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.w = w;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Bool4"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="xy">The value to assign to the first and second vector components.</param>
|
||||
/// <param name="z">The value to assign to the third vector component.</param>
|
||||
/// <param name="w">The value to assign to the fourth vector component.</param>
|
||||
public Bool4(Bool2 xy, bool z, bool w)
|
||||
{
|
||||
this.x = xy.X;
|
||||
this.y = xy.Y;
|
||||
this.z = z;
|
||||
this.w = w;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Bool4"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to assign to the first vector component.</param>
|
||||
/// <param name="y">The value to assign to the second vector component.</param>
|
||||
/// <param name="zw">The value to assign to the third and fourth vector components.</param>
|
||||
public Bool4(bool x, bool y, Bool2 zw)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = zw.X;
|
||||
this.w = zw.Y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Bool4"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="xy">The value to assign to the first and second vector components.</param>
|
||||
/// <param name="zw">The value to assign to the third and fourth vector components.</param>
|
||||
public Bool4(Bool2 xy, Bool2 zw)
|
||||
{
|
||||
this.x = xy.X;
|
||||
this.y = xy.Y;
|
||||
this.z = zw.X;
|
||||
this.w = zw.Y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Bool4"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="xyz">The value to assign to the first, second and third vector components.</param>
|
||||
/// <param name="w">The value to assign to the fourth vector component.</param>
|
||||
public Bool4(Bool3 xyz, bool w)
|
||||
{
|
||||
this.x = xyz.X;
|
||||
this.y = xyz.Y;
|
||||
this.z = xyz.Z;
|
||||
this.w = w;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Bool4"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to assign to the first vector component.</param>
|
||||
/// <param name="yzw">The value to assign to the second, third and fourth vector components.</param>
|
||||
public Bool4(bool x, Bool3 yzw)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = yzw.X;
|
||||
this.z = yzw.Y;
|
||||
this.w = yzw.Z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Bool4"/> value with the same value for all its components.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to use for the components of the new <see cref="Bool4"/> instance.</param>
|
||||
public static implicit operator Bool4(bool x) => new(x, x, x, x);
|
||||
}
|
||||
ファイル差分が大きすぎるため表示されません。
差分を読み込み
@@ -0,0 +1,4 @@
|
||||
<#@include file="..\VectorType.ttinclude" #>
|
||||
<#
|
||||
GenerateVectorProperties("Bool4", sizeof(int));
|
||||
#>
|
||||
ファイル差分が大きすぎるため表示されません。
差分を読み込み
@@ -0,0 +1,4 @@
|
||||
<#@include file="..\MatrixType.ttinclude" #>
|
||||
<#
|
||||
GenerateAllMatrixProperties("Bool", sizeof(int));
|
||||
#>
|
||||
@@ -0,0 +1,65 @@
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
/// A <see langword="struct"/> that maps the <see langword="double2"/> HLSL type.
|
||||
/// </summary>
|
||||
public partial struct Double2
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Double2"/> value with all components set to 0.
|
||||
/// </summary>
|
||||
public static Double2 Zero => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Double2"/> value with all components set to 1.
|
||||
/// </summary>
|
||||
public static Double2 One => 1;
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Double2"/> value with the <see cref="X"/> component set to 1, and the others to 0.
|
||||
/// </summary>
|
||||
public static Double2 UnitX => new(1, 0);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Double2"/> value with the <see cref="Y"/> component set to 1, and the others to 0.
|
||||
/// </summary>
|
||||
public static Double2 UnitY => new(0, 1);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Double2"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to assign to the first vector component.</param>
|
||||
/// <param name="y">The value to assign to the second vector component.</param>
|
||||
public Double2(double x, double y)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Double2"/> value with the same value for all its components.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to use for the components of the new <see cref="Double2"/> instance.</param>
|
||||
public static implicit operator Double2(double x) => new(x, x);
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="Double2"/> value to a <see cref="Int2"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xy">The input <see cref="Double2"/> value to cast.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static explicit operator Int2(Double2 xy) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="Double2"/> value to a <see cref="UInt2"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xy">The input <see cref="Double2"/> value to cast.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static explicit operator UInt2(Double2 xy) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="Double2"/> value to a <see cref="Float2"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xy">The input <see cref="Double2"/> value to cast.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static explicit operator Float2(Double2 xy) => default;
|
||||
}
|
||||
@@ -0,0 +1,474 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using RuntimeHelpers = ComputeSharp.Core.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.Core.NetStandard.System.Runtime.InteropServices.MemoryMarshal;
|
||||
#endif
|
||||
|
||||
#nullable enable
|
||||
|
||||
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.
|
||||
/// </summary>
|
||||
private static readonly void* UndefinedData = (void*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(Double2), sizeof(Double4));
|
||||
|
||||
[FieldOffset(0)]
|
||||
private double x;
|
||||
|
||||
[FieldOffset(8)]
|
||||
private double y;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to a specific component in the current <see cref="Double2"/> instance.
|
||||
/// </summary>
|
||||
/// <param name="i">The index of the component to access.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref double this[int i] => ref *(double*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="double"/> value representing the <c>X</c> component.
|
||||
/// </summary>
|
||||
public readonly ref double X => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.x), 1));
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="double"/> value representing the <c>Y</c> component.
|
||||
/// </summary>
|
||||
public readonly ref double Y => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.y), 1));
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double2"/> value with the components <see cref="X"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double2 XX => ref *(Double2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="Double2"/> value with the components <see cref="X"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref Double2 XY => ref *(Double2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="Double2"/> value with the components <see cref="Y"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref Double2 YX => ref *(Double2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double2"/> value with the components <see cref="Y"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double2 YY => ref *(Double2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double3"/> value with the components <see cref="X"/>, <see cref="X"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double3 XXX => ref *(Double3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double3"/> value with the components <see cref="X"/>, <see cref="X"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double3 XXY => ref *(Double3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double3"/> value with the components <see cref="X"/>, <see cref="Y"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double3 XYX => ref *(Double3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double3"/> value with the components <see cref="X"/>, <see cref="Y"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double3 XYY => ref *(Double3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double3"/> value with the components <see cref="Y"/>, <see cref="X"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double3 YXX => ref *(Double3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double3"/> value with the components <see cref="Y"/>, <see cref="X"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double3 YXY => ref *(Double3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double3"/> value with the components <see cref="Y"/>, <see cref="Y"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double3 YYX => ref *(Double3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double3"/> value with the components <see cref="Y"/>, <see cref="Y"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double3 YYY => ref *(Double3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double4"/> value with the components <see cref="X"/>, <see cref="X"/>, <see cref="X"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double4 XXXX => ref *(Double4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double4"/> value with the components <see cref="X"/>, <see cref="X"/>, <see cref="X"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double4 XXXY => ref *(Double4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double4"/> value with the components <see cref="X"/>, <see cref="X"/>, <see cref="Y"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double4 XXYX => ref *(Double4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double4"/> value with the components <see cref="X"/>, <see cref="X"/>, <see cref="Y"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double4 XXYY => ref *(Double4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double4"/> value with the components <see cref="X"/>, <see cref="Y"/>, <see cref="X"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double4 XYXX => ref *(Double4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double4"/> value with the components <see cref="X"/>, <see cref="Y"/>, <see cref="X"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double4 XYXY => ref *(Double4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double4"/> value with the components <see cref="X"/>, <see cref="Y"/>, <see cref="Y"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double4 XYYX => ref *(Double4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double4"/> value with the components <see cref="X"/>, <see cref="Y"/>, <see cref="Y"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double4 XYYY => ref *(Double4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double4"/> value with the components <see cref="Y"/>, <see cref="X"/>, <see cref="X"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double4 YXXX => ref *(Double4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double4"/> value with the components <see cref="Y"/>, <see cref="X"/>, <see cref="X"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double4 YXXY => ref *(Double4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double4"/> value with the components <see cref="Y"/>, <see cref="X"/>, <see cref="Y"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double4 YXYX => ref *(Double4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double4"/> value with the components <see cref="Y"/>, <see cref="X"/>, <see cref="Y"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double4 YXYY => ref *(Double4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double4"/> value with the components <see cref="Y"/>, <see cref="Y"/>, <see cref="X"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double4 YYXX => ref *(Double4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double4"/> value with the components <see cref="Y"/>, <see cref="Y"/>, <see cref="X"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double4 YYXY => ref *(Double4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double4"/> value with the components <see cref="Y"/>, <see cref="Y"/>, <see cref="Y"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double4 YYYX => ref *(Double4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double4"/> value with the components <see cref="Y"/>, <see cref="Y"/>, <see cref="Y"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double4 YYYY => ref *(Double4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="double"/> value representing the <c>R</c> component.
|
||||
/// </summary>
|
||||
public readonly ref double R => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.x), 1));
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="double"/> value representing the <c>G</c> component.
|
||||
/// </summary>
|
||||
public readonly ref double G => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.y), 1));
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double2"/> value with the components <see cref="R"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double2 RR => ref *(Double2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="Double2"/> value with the components <see cref="R"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref Double2 RG => ref *(Double2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="Double2"/> value with the components <see cref="G"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref Double2 GR => ref *(Double2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double2"/> value with the components <see cref="G"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double2 GG => ref *(Double2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double3"/> value with the components <see cref="R"/>, <see cref="R"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double3 RRR => ref *(Double3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double3"/> value with the components <see cref="R"/>, <see cref="R"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double3 RRG => ref *(Double3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double3"/> value with the components <see cref="R"/>, <see cref="G"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double3 RGR => ref *(Double3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double3"/> value with the components <see cref="R"/>, <see cref="G"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double3 RGG => ref *(Double3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double3"/> value with the components <see cref="G"/>, <see cref="R"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double3 GRR => ref *(Double3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double3"/> value with the components <see cref="G"/>, <see cref="R"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double3 GRG => ref *(Double3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double3"/> value with the components <see cref="G"/>, <see cref="G"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double3 GGR => ref *(Double3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double3"/> value with the components <see cref="G"/>, <see cref="G"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double3 GGG => ref *(Double3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double4"/> value with the components <see cref="R"/>, <see cref="R"/>, <see cref="R"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double4 RRRR => ref *(Double4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double4"/> value with the components <see cref="R"/>, <see cref="R"/>, <see cref="R"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double4 RRRG => ref *(Double4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double4"/> value with the components <see cref="R"/>, <see cref="R"/>, <see cref="G"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double4 RRGR => ref *(Double4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double4"/> value with the components <see cref="R"/>, <see cref="R"/>, <see cref="G"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double4 RRGG => ref *(Double4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double4"/> value with the components <see cref="R"/>, <see cref="G"/>, <see cref="R"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double4 RGRR => ref *(Double4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double4"/> value with the components <see cref="R"/>, <see cref="G"/>, <see cref="R"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double4 RGRG => ref *(Double4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double4"/> value with the components <see cref="R"/>, <see cref="G"/>, <see cref="G"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double4 RGGR => ref *(Double4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double4"/> value with the components <see cref="R"/>, <see cref="G"/>, <see cref="G"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double4 RGGG => ref *(Double4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double4"/> value with the components <see cref="G"/>, <see cref="R"/>, <see cref="R"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double4 GRRR => ref *(Double4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double4"/> value with the components <see cref="G"/>, <see cref="R"/>, <see cref="R"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double4 GRRG => ref *(Double4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double4"/> value with the components <see cref="G"/>, <see cref="R"/>, <see cref="G"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double4 GRGR => ref *(Double4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double4"/> value with the components <see cref="G"/>, <see cref="R"/>, <see cref="G"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double4 GRGG => ref *(Double4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double4"/> value with the components <see cref="G"/>, <see cref="G"/>, <see cref="R"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double4 GGRR => ref *(Double4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double4"/> value with the components <see cref="G"/>, <see cref="G"/>, <see cref="R"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double4 GGRG => ref *(Double4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double4"/> value with the components <see cref="G"/>, <see cref="G"/>, <see cref="G"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double4 GGGR => ref *(Double4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Double4"/> value with the components <see cref="G"/>, <see cref="G"/>, <see cref="G"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Double4 GGGG => ref *(Double4*)UndefinedData;
|
||||
|
||||
#if !SOURCE_GENERATOR
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override readonly string ToString()
|
||||
{
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// Negates a <see cref="Double2"/> value.
|
||||
/// </summary>
|
||||
/// <param name="xy">The <see cref="Double2"/> value to negate.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static Double2 operator -(Double2 xy) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Sums two <see cref="Double2"/> values.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="Double2"/> value to sum.</param>
|
||||
/// <param name="right">The second <see cref="Double2"/> value to sum.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static Double2 operator +(Double2 left, Double2 right) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Divides two <see cref="Double2"/> values.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="Double2"/> value to divide.</param>
|
||||
/// <param name="right">The second <see cref="Double2"/> value to divide.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static Double2 operator /(Double2 left, Double2 right) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Multiplies two <see cref="Double2"/> values.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="Double2"/> value to multiply.</param>
|
||||
/// <param name="right">The second <see cref="Double2"/> value to multiply.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static Double2 operator *(Double2 left, Double2 right) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Subtracts two <see cref="Double2"/> values.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="Double2"/> value to subtract.</param>
|
||||
/// <param name="right">The second <see cref="Double2"/> value to subtract.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static Double2 operator -(Double2 left, Double2 right) => default;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<#@include file="..\VectorType.ttinclude" #>
|
||||
<#
|
||||
GenerateVectorProperties("Double2", sizeof(double));
|
||||
#>
|
||||
@@ -0,0 +1,96 @@
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
/// A <see langword="struct"/> that maps the <see langword="double3"/> HLSL type.
|
||||
/// </summary>
|
||||
public partial struct Double3
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Double3"/> value with all components set to 0.
|
||||
/// </summary>
|
||||
public static Double3 Zero => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Double3"/> value with all components set to 1.
|
||||
/// </summary>
|
||||
public static Double3 One => 1;
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Double3"/> value with the <see cref="X"/> component set to 1, and the others to 0.
|
||||
/// </summary>
|
||||
public static Double3 UnitX => new(1, 0, 0);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Double3"/> value with the <see cref="Y"/> component set to 1, and the others to 0.
|
||||
/// </summary>
|
||||
public static Double3 UnitY => new(0, 1, 0);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Double3"/> value with the <see cref="Z"/> component set to 1, and the others to 0.
|
||||
/// </summary>
|
||||
public static Double3 UnitZ => new(0, 0, 1);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Double3"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to assign to the first vector component.</param>
|
||||
/// <param name="y">The value to assign to the second vector component.</param>
|
||||
/// <param name="z">The value to assign to the third vector component.</param>
|
||||
public Double3(double x, double y, double z)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Double3"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="xy">The value to assign to the first and second vector components.</param>
|
||||
/// <param name="z">The value to assign to the third vector component.</param>
|
||||
public Double3(Double2 xy, double z)
|
||||
{
|
||||
this.x = xy.X;
|
||||
this.y = xy.Y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Double3"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to assign to the first vector component.</param>
|
||||
/// <param name="yz">The value to assign to the second and thirt vector components.</param>
|
||||
public Double3(double x, Double2 yz)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = yz.X;
|
||||
this.z = yz.Y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Double3"/> value with the same value for all its components.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to use for the components of the new <see cref="Double3"/> instance.</param>
|
||||
public static implicit operator Double3(double x) => new(x, x, x);
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="Double3"/> value to a <see cref="Int3"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xyz">The input <see cref="Double3"/> value to cast.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static explicit operator Int3(Double3 xyz) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="Double3"/> value to a <see cref="UInt3"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xyz">The input <see cref="Double3"/> value to cast.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static explicit operator UInt3(Double3 xyz) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="Double3"/> value to a <see cref="Float3"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xyz">The input <see cref="Double3"/> value to cast.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static explicit operator Float3(Double3 xyz) => default;
|
||||
}
|
||||
ファイル差分が大きすぎるため表示されません。
差分を読み込み
@@ -0,0 +1,4 @@
|
||||
<#@include file="..\VectorType.ttinclude" #>
|
||||
<#
|
||||
GenerateVectorProperties("Double3", sizeof(double));
|
||||
#>
|
||||
@@ -0,0 +1,146 @@
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
/// A <see langword="struct"/> that maps the <see langword="double4"/> HLSL type.
|
||||
/// </summary>
|
||||
public partial struct Double4
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Double4"/> value with all components set to 0.
|
||||
/// </summary>
|
||||
public static Double4 Zero => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Double4"/> value with all components set to 1.
|
||||
/// </summary>
|
||||
public static Double4 One => 1;
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Double4"/> value with the <see cref="X"/> component set to 1, and the others to 0.
|
||||
/// </summary>
|
||||
public static Double4 UnitX => new(1, 0, 0, 0);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Double4"/> value with the <see cref="Y"/> component set to 1, and the others to 0.
|
||||
/// </summary>
|
||||
public static Double4 UnitY => new(0, 1, 0, 0);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Double4"/> value with the <see cref="Z"/> component set to 1, and the others to 0.
|
||||
/// </summary>
|
||||
public static Double4 UnitZ => new(0, 0, 1, 0);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Double4"/> value with the <see cref="W"/> component set to 1, and the others to 0.
|
||||
/// </summary>
|
||||
public static Double4 UnitW => new(0, 0, 0, 1);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Double4"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to assign to the first vector component.</param>
|
||||
/// <param name="y">The value to assign to the second vector component.</param>
|
||||
/// <param name="z">The value to assign to the third vector component.</param>
|
||||
/// <param name="w">The value to assign to the fourth vector component.</param>
|
||||
public Double4(double x, double y, double z, double w)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.w = w;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Double4"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="xy">The value to assign to the first and second vector components.</param>
|
||||
/// <param name="z">The value to assign to the third vector component.</param>
|
||||
/// <param name="w">The value to assign to the fourth vector component.</param>
|
||||
public Double4(Double2 xy, double z, double w)
|
||||
{
|
||||
this.x = xy.X;
|
||||
this.y = xy.Y;
|
||||
this.z = z;
|
||||
this.w = w;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Double4"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to assign to the first vector component.</param>
|
||||
/// <param name="y">The value to assign to the second vector component.</param>
|
||||
/// <param name="zw">The value to assign to the third and fourth vector components.</param>
|
||||
public Double4(double x, double y, Double2 zw)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = zw.X;
|
||||
this.w = zw.Y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Double4"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="xy">The value to assign to the first and second vector components.</param>
|
||||
/// <param name="zw">The value to assign to the third and fourth vector components.</param>
|
||||
public Double4(Double2 xy, Double2 zw)
|
||||
{
|
||||
this.x = xy.X;
|
||||
this.y = xy.Y;
|
||||
this.z = zw.X;
|
||||
this.w = zw.Y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Double4"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="xyz">The value to assign to the first, second and third vector components.</param>
|
||||
/// <param name="w">The value to assign to the fourth vector component.</param>
|
||||
public Double4(Double3 xyz, double w)
|
||||
{
|
||||
this.x = xyz.X;
|
||||
this.y = xyz.Y;
|
||||
this.z = xyz.Z;
|
||||
this.w = w;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Double4"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to assign to the first vector component.</param>
|
||||
/// <param name="yzw">The value to assign to the second, third and fourth vector components.</param>
|
||||
public Double4(double x, Double3 yzw)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = yzw.X;
|
||||
this.z = yzw.Y;
|
||||
this.w = yzw.Z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Double4"/> value with the same value for all its components.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to use for the components of the new <see cref="Double4"/> instance.</param>
|
||||
public static implicit operator Double4(double x) => new(x, x, x, x);
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="Double4"/> value to a <see cref="Int4"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xyzw">The input <see cref="Double4"/> value to cast.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static explicit operator Int4(Double4 xyzw) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="Double4"/> value to a <see cref="UInt4"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xyzw">The input <see cref="Double4"/> value to cast.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static explicit operator UInt4(Double4 xyzw) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="Double4"/> value to a <see cref="Float4"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xyzw">The input <see cref="Double4"/> value to cast.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static explicit operator Float4(Double4 xyzw) => default;
|
||||
}
|
||||
ファイル差分が大きすぎるため表示されません。
差分を読み込み
@@ -0,0 +1,4 @@
|
||||
<#@include file="..\VectorType.ttinclude" #>
|
||||
<#
|
||||
GenerateVectorProperties("Double4", sizeof(double));
|
||||
#>
|
||||
ファイル差分が大きすぎるため表示されません。
差分を読み込み
@@ -0,0 +1,4 @@
|
||||
<#@include file="..\MatrixType.ttinclude" #>
|
||||
<#
|
||||
GenerateAllMatrixProperties("Double", sizeof(double));
|
||||
#>
|
||||
@@ -0,0 +1,79 @@
|
||||
using System.Numerics;
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
/// A <see langword="struct"/> that maps the <see langword="float2"/> HLSL type.
|
||||
/// </summary>
|
||||
public partial struct Float2
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Float2"/> value with all components set to 0.
|
||||
/// </summary>
|
||||
public static Float2 Zero => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Float2"/> value with all components set to 1.
|
||||
/// </summary>
|
||||
public static Float2 One => 1;
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Float2"/> value with the <see cref="X"/> component set to 1, and the others to 0.
|
||||
/// </summary>
|
||||
public static Float2 UnitX => new(1, 0);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Float2"/> value with the <see cref="Y"/> component set to 1, and the others to 0.
|
||||
/// </summary>
|
||||
public static Float2 UnitY => new(0, 1);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Float2"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to assign to the first vector component.</param>
|
||||
/// <param name="y">The value to assign to the second vector component.</param>
|
||||
public Float2(float x, float y)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Float2"/> value with the same value for all its components.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to use for the components of the new <see cref="Float2"/> instance.</param>
|
||||
public static implicit operator Float2(float x) => new(x, x);
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="Float2"/> value to a <see cref="Vector2"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xy">The input <see cref="Float2"/> value to cast.</param>
|
||||
public static unsafe implicit operator Vector2(Float2 xy) => *(Vector2*)&xy;
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="Vector2"/> value to a <see cref="Float2"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xy">The input <see cref="Vector2"/> value to cast.</param>
|
||||
public static unsafe implicit operator Float2(Vector2 xy) => *(Float2*)&xy;
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="Float2"/> value to a <see cref="Double2"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xy">The input <see cref="Float2"/> value to cast.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static implicit operator Double2(Float2 xy) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="Float2"/> value to a <see cref="Int2"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xy">The input <see cref="Float2"/> value to cast.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static explicit operator Int2(Float2 xy) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="Float2"/> value to a <see cref="UInt2"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xy">The input <see cref="Float2"/> value to cast.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static explicit operator UInt2(Float2 xy) => default;
|
||||
}
|
||||
@@ -0,0 +1,474 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using RuntimeHelpers = ComputeSharp.Core.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.Core.NetStandard.System.Runtime.InteropServices.MemoryMarshal;
|
||||
#endif
|
||||
|
||||
#nullable enable
|
||||
|
||||
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.
|
||||
/// </summary>
|
||||
private static readonly void* UndefinedData = (void*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(Float2), sizeof(Float4));
|
||||
|
||||
[FieldOffset(0)]
|
||||
private float x;
|
||||
|
||||
[FieldOffset(4)]
|
||||
private float y;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to a specific component in the current <see cref="Float2"/> instance.
|
||||
/// </summary>
|
||||
/// <param name="i">The index of the component to access.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref float this[int i] => ref *(float*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="float"/> value representing the <c>X</c> component.
|
||||
/// </summary>
|
||||
public readonly ref float X => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.x), 1));
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="float"/> value representing the <c>Y</c> component.
|
||||
/// </summary>
|
||||
public readonly ref float Y => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.y), 1));
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float2"/> value with the components <see cref="X"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float2 XX => ref *(Float2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="Float2"/> value with the components <see cref="X"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref Float2 XY => ref *(Float2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="Float2"/> value with the components <see cref="Y"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref Float2 YX => ref *(Float2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float2"/> value with the components <see cref="Y"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float2 YY => ref *(Float2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float3"/> value with the components <see cref="X"/>, <see cref="X"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float3 XXX => ref *(Float3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float3"/> value with the components <see cref="X"/>, <see cref="X"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float3 XXY => ref *(Float3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float3"/> value with the components <see cref="X"/>, <see cref="Y"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float3 XYX => ref *(Float3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float3"/> value with the components <see cref="X"/>, <see cref="Y"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float3 XYY => ref *(Float3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float3"/> value with the components <see cref="Y"/>, <see cref="X"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float3 YXX => ref *(Float3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float3"/> value with the components <see cref="Y"/>, <see cref="X"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float3 YXY => ref *(Float3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float3"/> value with the components <see cref="Y"/>, <see cref="Y"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float3 YYX => ref *(Float3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float3"/> value with the components <see cref="Y"/>, <see cref="Y"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float3 YYY => ref *(Float3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float4"/> value with the components <see cref="X"/>, <see cref="X"/>, <see cref="X"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float4 XXXX => ref *(Float4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float4"/> value with the components <see cref="X"/>, <see cref="X"/>, <see cref="X"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float4 XXXY => ref *(Float4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float4"/> value with the components <see cref="X"/>, <see cref="X"/>, <see cref="Y"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float4 XXYX => ref *(Float4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float4"/> value with the components <see cref="X"/>, <see cref="X"/>, <see cref="Y"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float4 XXYY => ref *(Float4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float4"/> value with the components <see cref="X"/>, <see cref="Y"/>, <see cref="X"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float4 XYXX => ref *(Float4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float4"/> value with the components <see cref="X"/>, <see cref="Y"/>, <see cref="X"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float4 XYXY => ref *(Float4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float4"/> value with the components <see cref="X"/>, <see cref="Y"/>, <see cref="Y"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float4 XYYX => ref *(Float4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float4"/> value with the components <see cref="X"/>, <see cref="Y"/>, <see cref="Y"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float4 XYYY => ref *(Float4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float4"/> value with the components <see cref="Y"/>, <see cref="X"/>, <see cref="X"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float4 YXXX => ref *(Float4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float4"/> value with the components <see cref="Y"/>, <see cref="X"/>, <see cref="X"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float4 YXXY => ref *(Float4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float4"/> value with the components <see cref="Y"/>, <see cref="X"/>, <see cref="Y"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float4 YXYX => ref *(Float4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float4"/> value with the components <see cref="Y"/>, <see cref="X"/>, <see cref="Y"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float4 YXYY => ref *(Float4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float4"/> value with the components <see cref="Y"/>, <see cref="Y"/>, <see cref="X"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float4 YYXX => ref *(Float4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float4"/> value with the components <see cref="Y"/>, <see cref="Y"/>, <see cref="X"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float4 YYXY => ref *(Float4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float4"/> value with the components <see cref="Y"/>, <see cref="Y"/>, <see cref="Y"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float4 YYYX => ref *(Float4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float4"/> value with the components <see cref="Y"/>, <see cref="Y"/>, <see cref="Y"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float4 YYYY => ref *(Float4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="float"/> value representing the <c>R</c> component.
|
||||
/// </summary>
|
||||
public readonly ref float R => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.x), 1));
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="float"/> value representing the <c>G</c> component.
|
||||
/// </summary>
|
||||
public readonly ref float G => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.y), 1));
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float2"/> value with the components <see cref="R"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float2 RR => ref *(Float2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="Float2"/> value with the components <see cref="R"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref Float2 RG => ref *(Float2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="Float2"/> value with the components <see cref="G"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref Float2 GR => ref *(Float2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float2"/> value with the components <see cref="G"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float2 GG => ref *(Float2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float3"/> value with the components <see cref="R"/>, <see cref="R"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float3 RRR => ref *(Float3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float3"/> value with the components <see cref="R"/>, <see cref="R"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float3 RRG => ref *(Float3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float3"/> value with the components <see cref="R"/>, <see cref="G"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float3 RGR => ref *(Float3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float3"/> value with the components <see cref="R"/>, <see cref="G"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float3 RGG => ref *(Float3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float3"/> value with the components <see cref="G"/>, <see cref="R"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float3 GRR => ref *(Float3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float3"/> value with the components <see cref="G"/>, <see cref="R"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float3 GRG => ref *(Float3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float3"/> value with the components <see cref="G"/>, <see cref="G"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float3 GGR => ref *(Float3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float3"/> value with the components <see cref="G"/>, <see cref="G"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float3 GGG => ref *(Float3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float4"/> value with the components <see cref="R"/>, <see cref="R"/>, <see cref="R"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float4 RRRR => ref *(Float4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float4"/> value with the components <see cref="R"/>, <see cref="R"/>, <see cref="R"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float4 RRRG => ref *(Float4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float4"/> value with the components <see cref="R"/>, <see cref="R"/>, <see cref="G"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float4 RRGR => ref *(Float4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float4"/> value with the components <see cref="R"/>, <see cref="R"/>, <see cref="G"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float4 RRGG => ref *(Float4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float4"/> value with the components <see cref="R"/>, <see cref="G"/>, <see cref="R"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float4 RGRR => ref *(Float4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float4"/> value with the components <see cref="R"/>, <see cref="G"/>, <see cref="R"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float4 RGRG => ref *(Float4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float4"/> value with the components <see cref="R"/>, <see cref="G"/>, <see cref="G"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float4 RGGR => ref *(Float4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float4"/> value with the components <see cref="R"/>, <see cref="G"/>, <see cref="G"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float4 RGGG => ref *(Float4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float4"/> value with the components <see cref="G"/>, <see cref="R"/>, <see cref="R"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float4 GRRR => ref *(Float4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float4"/> value with the components <see cref="G"/>, <see cref="R"/>, <see cref="R"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float4 GRRG => ref *(Float4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float4"/> value with the components <see cref="G"/>, <see cref="R"/>, <see cref="G"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float4 GRGR => ref *(Float4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float4"/> value with the components <see cref="G"/>, <see cref="R"/>, <see cref="G"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float4 GRGG => ref *(Float4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float4"/> value with the components <see cref="G"/>, <see cref="G"/>, <see cref="R"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float4 GGRR => ref *(Float4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float4"/> value with the components <see cref="G"/>, <see cref="G"/>, <see cref="R"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float4 GGRG => ref *(Float4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float4"/> value with the components <see cref="G"/>, <see cref="G"/>, <see cref="G"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float4 GGGR => ref *(Float4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Float4"/> value with the components <see cref="G"/>, <see cref="G"/>, <see cref="G"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Float4 GGGG => ref *(Float4*)UndefinedData;
|
||||
|
||||
#if !SOURCE_GENERATOR
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override readonly string ToString()
|
||||
{
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// Negates a <see cref="Float2"/> value.
|
||||
/// </summary>
|
||||
/// <param name="xy">The <see cref="Float2"/> value to negate.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static Float2 operator -(Float2 xy) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Sums two <see cref="Float2"/> values.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="Float2"/> value to sum.</param>
|
||||
/// <param name="right">The second <see cref="Float2"/> value to sum.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static Float2 operator +(Float2 left, Float2 right) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Divides two <see cref="Float2"/> values.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="Float2"/> value to divide.</param>
|
||||
/// <param name="right">The second <see cref="Float2"/> value to divide.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static Float2 operator /(Float2 left, Float2 right) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Multiplies two <see cref="Float2"/> values.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="Float2"/> value to multiply.</param>
|
||||
/// <param name="right">The second <see cref="Float2"/> value to multiply.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static Float2 operator *(Float2 left, Float2 right) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Subtracts two <see cref="Float2"/> values.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="Float2"/> value to subtract.</param>
|
||||
/// <param name="right">The second <see cref="Float2"/> value to subtract.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static Float2 operator -(Float2 left, Float2 right) => default;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<#@include file="..\VectorType.ttinclude" #>
|
||||
<#
|
||||
GenerateVectorProperties("Float2", sizeof(float));
|
||||
#>
|
||||
@@ -0,0 +1,110 @@
|
||||
using System.Numerics;
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
/// A <see langword="struct"/> that maps the <see langword="float3"/> HLSL type.
|
||||
/// </summary>
|
||||
public partial struct Float3
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Float3"/> value with all components set to 0.
|
||||
/// </summary>
|
||||
public static Float3 Zero => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Float3"/> value with all components set to 1.
|
||||
/// </summary>
|
||||
public static Float3 One => 1;
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Float3"/> value with the <see cref="X"/> component set to 1, and the others to 0.
|
||||
/// </summary>
|
||||
public static Float3 UnitX => new(1, 0, 0);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Float3"/> value with the <see cref="Y"/> component set to 1, and the others to 0.
|
||||
/// </summary>
|
||||
public static Float3 UnitY => new(0, 1, 0);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Float3"/> value with the <see cref="Z"/> component set to 1, and the others to 0.
|
||||
/// </summary>
|
||||
public static Float3 UnitZ => new(0, 0, 1);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Float3"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to assign to the first vector component.</param>
|
||||
/// <param name="y">The value to assign to the second vector component.</param>
|
||||
/// <param name="z">The value to assign to the third vector component.</param>
|
||||
public Float3(float x, float y, float z)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Float3"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="xy">The value to assign to the first and second vector components.</param>
|
||||
/// <param name="z">The value to assign to the third vector component.</param>
|
||||
public Float3(Float2 xy, float z)
|
||||
{
|
||||
this.x = xy.X;
|
||||
this.y = xy.Y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Float3"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to assign to the first vector component.</param>
|
||||
/// <param name="yz">The value to assign to the second and thirt vector components.</param>
|
||||
public Float3(float x, Float2 yz)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = yz.X;
|
||||
this.z = yz.Y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Float3"/> value with the same value for all its components.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to use for the components of the new <see cref="Float3"/> instance.</param>
|
||||
public static implicit operator Float3(float x) => new(x, x, x);
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="Float3"/> value to a <see cref="Vector3"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xyz">The input <see cref="Float3"/> value to cast.</param>
|
||||
public static unsafe implicit operator Vector3(Float3 xyz) => *(Vector3*)&xyz;
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="Vector3"/> value to a <see cref="Float3"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xyz">The input <see cref="Vector3"/> value to cast.</param>
|
||||
public static unsafe implicit operator Float3(Vector3 xyz) => *(Float3*)&xyz;
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="Float3"/> value to a <see cref="Double3"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xyz">The input <see cref="Float3"/> value to cast.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static implicit operator Double3(Float3 xyz) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="Float3"/> value to a <see cref="Int3"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xyz">The input <see cref="Float3"/> value to cast.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static explicit operator Int3(Float3 xyz) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="Float3"/> value to a <see cref="UInt3"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xyz">The input <see cref="Float3"/> value to cast.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static explicit operator UInt3(Float3 xyz) => default;
|
||||
}
|
||||
ファイル差分が大きすぎるため表示されません。
差分を読み込み
@@ -0,0 +1,4 @@
|
||||
<#@include file="..\VectorType.ttinclude" #>
|
||||
<#
|
||||
GenerateVectorProperties("Float3", sizeof(float));
|
||||
#>
|
||||
@@ -0,0 +1,160 @@
|
||||
using System.Numerics;
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
/// A <see langword="struct"/> that maps the <see langword="float4"/> HLSL type.
|
||||
/// </summary>
|
||||
public partial struct Float4
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Float4"/> value with all components set to 0.
|
||||
/// </summary>
|
||||
public static Float4 Zero => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Float4"/> value with all components set to 1.
|
||||
/// </summary>
|
||||
public static Float4 One => 1;
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Float4"/> value with the <see cref="X"/> component set to 1, and the others to 0.
|
||||
/// </summary>
|
||||
public static Float4 UnitX => new(1, 0, 0, 0);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Float4"/> value with the <see cref="Y"/> component set to 1, and the others to 0.
|
||||
/// </summary>
|
||||
public static Float4 UnitY => new(0, 1, 0, 0);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Float4"/> value with the <see cref="Z"/> component set to 1, and the others to 0.
|
||||
/// </summary>
|
||||
public static Float4 UnitZ => new(0, 0, 1, 0);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Float4"/> value with the <see cref="W"/> component set to 1, and the others to 0.
|
||||
/// </summary>
|
||||
public static Float4 UnitW => new(0, 0, 0, 1);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Float4"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to assign to the first vector component.</param>
|
||||
/// <param name="y">The value to assign to the second vector component.</param>
|
||||
/// <param name="z">The value to assign to the third vector component.</param>
|
||||
/// <param name="w">The value to assign to the fourth vector component.</param>
|
||||
public Float4(float x, float y, float z, float w)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.w = w;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Float4"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="xy">The value to assign to the first and second vector components.</param>
|
||||
/// <param name="z">The value to assign to the third vector component.</param>
|
||||
/// <param name="w">The value to assign to the fourth vector component.</param>
|
||||
public Float4(Float2 xy, float z, float w)
|
||||
{
|
||||
this.x = xy.X;
|
||||
this.y = xy.Y;
|
||||
this.z = z;
|
||||
this.w = w;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Float4"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to assign to the first vector component.</param>
|
||||
/// <param name="y">The value to assign to the second vector component.</param>
|
||||
/// <param name="zw">The value to assign to the third and fourth vector components.</param>
|
||||
public Float4(float x, float y, Float2 zw)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = zw.X;
|
||||
this.w = zw.Y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Float4"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="xy">The value to assign to the first and second vector components.</param>
|
||||
/// <param name="zw">The value to assign to the third and fourth vector components.</param>
|
||||
public Float4(Float2 xy, Float2 zw)
|
||||
{
|
||||
this.x = xy.X;
|
||||
this.y = xy.Y;
|
||||
this.z = zw.X;
|
||||
this.w = zw.Y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Float4"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="xyz">The value to assign to the first, second and third vector components.</param>
|
||||
/// <param name="w">The value to assign to the fourth vector component.</param>
|
||||
public Float4(Float3 xyz, float w)
|
||||
{
|
||||
this.x = xyz.X;
|
||||
this.y = xyz.Y;
|
||||
this.z = xyz.Z;
|
||||
this.w = w;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Float4"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to assign to the first vector component.</param>
|
||||
/// <param name="yzw">The value to assign to the second, third and fourth vector components.</param>
|
||||
public Float4(float x, Float3 yzw)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = yzw.X;
|
||||
this.z = yzw.Y;
|
||||
this.w = yzw.Z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Float4"/> value with the same value for all its components.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to use for the components of the new <see cref="Float4"/> instance.</param>
|
||||
public static implicit operator Float4(float x) => new(x, x, x, x);
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="Float4"/> value to a <see cref="Vector4"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xyzw">The input <see cref="Float4"/> value to cast.</param>
|
||||
public static unsafe implicit operator Vector4(Float4 xyzw) => *(Vector4*)&xyzw;
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="Vector4"/> value to a <see cref="Float4"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xyzw">The input <see cref="Vector4"/> value to cast.</param>
|
||||
public static unsafe implicit operator Float4(Vector4 xyzw) => *(Float4*)&xyzw;
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="Float4"/> value to a <see cref="Double4"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xyzw">The input <see cref="Float4"/> value to cast.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static implicit operator Double4(Float4 xyzw) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="Float4"/> value to a <see cref="Int4"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xyzw">The input <see cref="Float4"/> value to cast.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static explicit operator Int4(Float4 xyzw) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="Float4"/> value to a <see cref="UInt4"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xyzw">The input <see cref="Float4"/> value to cast.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static explicit operator UInt4(Float4 xyzw) => default;
|
||||
}
|
||||
ファイル差分が大きすぎるため表示されません。
差分を読み込み
@@ -0,0 +1,4 @@
|
||||
<#@include file="..\VectorType.ttinclude" #>
|
||||
<#
|
||||
GenerateVectorProperties("Float4", sizeof(float));
|
||||
#>
|
||||
ファイル差分が大きすぎるため表示されません。
差分を読み込み
@@ -0,0 +1,4 @@
|
||||
<#@include file="..\MatrixType.ttinclude" #>
|
||||
<#
|
||||
GenerateAllMatrixProperties("Float", sizeof(float));
|
||||
#>
|
||||
@@ -0,0 +1,65 @@
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
/// A <see langword="struct"/> that maps the <see langword="int2"/> HLSL type.
|
||||
/// </summary>
|
||||
public partial struct Int2
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Int2"/> value with all components set to 0.
|
||||
/// </summary>
|
||||
public static Int2 Zero => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Int2"/> value with all components set to 1.
|
||||
/// </summary>
|
||||
public static Int2 One => 1;
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Int2"/> value with the <see cref="X"/> component set to 1, and the others to 0.
|
||||
/// </summary>
|
||||
public static Int2 UnitX => new(1, 0);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Int2"/> value with the <see cref="Y"/> component set to 1, and the others to 0.
|
||||
/// </summary>
|
||||
public static Int2 UnitY => new(0, 1);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Int2"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to assign to the first vector component.</param>
|
||||
/// <param name="y">The value to assign to the second vector component.</param>
|
||||
public Int2(int x, int y)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Int2"/> value with the same value for all its components.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to use for the components of the new <see cref="Int2"/> instance.</param>
|
||||
public static implicit operator Int2(int x) => new(x, x);
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="Int2"/> value to a <see cref="UInt2"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xy">The input <see cref="Int2"/> value to cast.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static explicit operator UInt2(Int2 xy) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="Int2"/> value to a <see cref="Float2"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xy">The input <see cref="Int2"/> value to cast.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static implicit operator Float2(Int2 xy) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="Int2"/> value to a <see cref="Double2"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xy">The input <see cref="Int2"/> value to cast.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static implicit operator Double2(Int2 xy) => default;
|
||||
}
|
||||
@@ -0,0 +1,474 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using RuntimeHelpers = ComputeSharp.Core.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.Core.NetStandard.System.Runtime.InteropServices.MemoryMarshal;
|
||||
#endif
|
||||
|
||||
#nullable enable
|
||||
|
||||
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.
|
||||
/// </summary>
|
||||
private static readonly void* UndefinedData = (void*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(Int2), sizeof(Int4));
|
||||
|
||||
[FieldOffset(0)]
|
||||
private int x;
|
||||
|
||||
[FieldOffset(4)]
|
||||
private int y;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to a specific component in the current <see cref="Int2"/> instance.
|
||||
/// </summary>
|
||||
/// <param name="i">The index of the component to access.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref int this[int i] => ref *(int*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="int"/> value representing the <c>X</c> component.
|
||||
/// </summary>
|
||||
public readonly ref int X => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.x), 1));
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="int"/> value representing the <c>Y</c> component.
|
||||
/// </summary>
|
||||
public readonly ref int Y => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.y), 1));
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int2"/> value with the components <see cref="X"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int2 XX => ref *(Int2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="Int2"/> value with the components <see cref="X"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref Int2 XY => ref *(Int2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="Int2"/> value with the components <see cref="Y"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref Int2 YX => ref *(Int2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int2"/> value with the components <see cref="Y"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int2 YY => ref *(Int2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int3"/> value with the components <see cref="X"/>, <see cref="X"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int3 XXX => ref *(Int3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int3"/> value with the components <see cref="X"/>, <see cref="X"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int3 XXY => ref *(Int3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int3"/> value with the components <see cref="X"/>, <see cref="Y"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int3 XYX => ref *(Int3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int3"/> value with the components <see cref="X"/>, <see cref="Y"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int3 XYY => ref *(Int3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int3"/> value with the components <see cref="Y"/>, <see cref="X"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int3 YXX => ref *(Int3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int3"/> value with the components <see cref="Y"/>, <see cref="X"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int3 YXY => ref *(Int3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int3"/> value with the components <see cref="Y"/>, <see cref="Y"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int3 YYX => ref *(Int3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int3"/> value with the components <see cref="Y"/>, <see cref="Y"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int3 YYY => ref *(Int3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int4"/> value with the components <see cref="X"/>, <see cref="X"/>, <see cref="X"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int4 XXXX => ref *(Int4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int4"/> value with the components <see cref="X"/>, <see cref="X"/>, <see cref="X"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int4 XXXY => ref *(Int4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int4"/> value with the components <see cref="X"/>, <see cref="X"/>, <see cref="Y"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int4 XXYX => ref *(Int4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int4"/> value with the components <see cref="X"/>, <see cref="X"/>, <see cref="Y"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int4 XXYY => ref *(Int4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int4"/> value with the components <see cref="X"/>, <see cref="Y"/>, <see cref="X"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int4 XYXX => ref *(Int4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int4"/> value with the components <see cref="X"/>, <see cref="Y"/>, <see cref="X"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int4 XYXY => ref *(Int4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int4"/> value with the components <see cref="X"/>, <see cref="Y"/>, <see cref="Y"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int4 XYYX => ref *(Int4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int4"/> value with the components <see cref="X"/>, <see cref="Y"/>, <see cref="Y"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int4 XYYY => ref *(Int4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int4"/> value with the components <see cref="Y"/>, <see cref="X"/>, <see cref="X"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int4 YXXX => ref *(Int4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int4"/> value with the components <see cref="Y"/>, <see cref="X"/>, <see cref="X"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int4 YXXY => ref *(Int4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int4"/> value with the components <see cref="Y"/>, <see cref="X"/>, <see cref="Y"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int4 YXYX => ref *(Int4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int4"/> value with the components <see cref="Y"/>, <see cref="X"/>, <see cref="Y"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int4 YXYY => ref *(Int4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int4"/> value with the components <see cref="Y"/>, <see cref="Y"/>, <see cref="X"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int4 YYXX => ref *(Int4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int4"/> value with the components <see cref="Y"/>, <see cref="Y"/>, <see cref="X"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int4 YYXY => ref *(Int4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int4"/> value with the components <see cref="Y"/>, <see cref="Y"/>, <see cref="Y"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int4 YYYX => ref *(Int4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int4"/> value with the components <see cref="Y"/>, <see cref="Y"/>, <see cref="Y"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int4 YYYY => ref *(Int4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="int"/> value representing the <c>R</c> component.
|
||||
/// </summary>
|
||||
public readonly ref int R => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.x), 1));
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="int"/> value representing the <c>G</c> component.
|
||||
/// </summary>
|
||||
public readonly ref int G => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.y), 1));
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int2"/> value with the components <see cref="R"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int2 RR => ref *(Int2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="Int2"/> value with the components <see cref="R"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref Int2 RG => ref *(Int2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="Int2"/> value with the components <see cref="G"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref Int2 GR => ref *(Int2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int2"/> value with the components <see cref="G"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int2 GG => ref *(Int2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int3"/> value with the components <see cref="R"/>, <see cref="R"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int3 RRR => ref *(Int3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int3"/> value with the components <see cref="R"/>, <see cref="R"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int3 RRG => ref *(Int3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int3"/> value with the components <see cref="R"/>, <see cref="G"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int3 RGR => ref *(Int3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int3"/> value with the components <see cref="R"/>, <see cref="G"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int3 RGG => ref *(Int3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int3"/> value with the components <see cref="G"/>, <see cref="R"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int3 GRR => ref *(Int3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int3"/> value with the components <see cref="G"/>, <see cref="R"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int3 GRG => ref *(Int3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int3"/> value with the components <see cref="G"/>, <see cref="G"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int3 GGR => ref *(Int3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int3"/> value with the components <see cref="G"/>, <see cref="G"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int3 GGG => ref *(Int3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int4"/> value with the components <see cref="R"/>, <see cref="R"/>, <see cref="R"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int4 RRRR => ref *(Int4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int4"/> value with the components <see cref="R"/>, <see cref="R"/>, <see cref="R"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int4 RRRG => ref *(Int4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int4"/> value with the components <see cref="R"/>, <see cref="R"/>, <see cref="G"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int4 RRGR => ref *(Int4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int4"/> value with the components <see cref="R"/>, <see cref="R"/>, <see cref="G"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int4 RRGG => ref *(Int4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int4"/> value with the components <see cref="R"/>, <see cref="G"/>, <see cref="R"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int4 RGRR => ref *(Int4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int4"/> value with the components <see cref="R"/>, <see cref="G"/>, <see cref="R"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int4 RGRG => ref *(Int4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int4"/> value with the components <see cref="R"/>, <see cref="G"/>, <see cref="G"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int4 RGGR => ref *(Int4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int4"/> value with the components <see cref="R"/>, <see cref="G"/>, <see cref="G"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int4 RGGG => ref *(Int4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int4"/> value with the components <see cref="G"/>, <see cref="R"/>, <see cref="R"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int4 GRRR => ref *(Int4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int4"/> value with the components <see cref="G"/>, <see cref="R"/>, <see cref="R"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int4 GRRG => ref *(Int4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int4"/> value with the components <see cref="G"/>, <see cref="R"/>, <see cref="G"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int4 GRGR => ref *(Int4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int4"/> value with the components <see cref="G"/>, <see cref="R"/>, <see cref="G"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int4 GRGG => ref *(Int4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int4"/> value with the components <see cref="G"/>, <see cref="G"/>, <see cref="R"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int4 GGRR => ref *(Int4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int4"/> value with the components <see cref="G"/>, <see cref="G"/>, <see cref="R"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int4 GGRG => ref *(Int4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int4"/> value with the components <see cref="G"/>, <see cref="G"/>, <see cref="G"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int4 GGGR => ref *(Int4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="Int4"/> value with the components <see cref="G"/>, <see cref="G"/>, <see cref="G"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly Int4 GGGG => ref *(Int4*)UndefinedData;
|
||||
|
||||
#if !SOURCE_GENERATOR
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override readonly string ToString()
|
||||
{
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// Negates a <see cref="Int2"/> value.
|
||||
/// </summary>
|
||||
/// <param name="xy">The <see cref="Int2"/> value to negate.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static Int2 operator -(Int2 xy) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Sums two <see cref="Int2"/> values.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="Int2"/> value to sum.</param>
|
||||
/// <param name="right">The second <see cref="Int2"/> value to sum.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static Int2 operator +(Int2 left, Int2 right) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Divides two <see cref="Int2"/> values.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="Int2"/> value to divide.</param>
|
||||
/// <param name="right">The second <see cref="Int2"/> value to divide.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static Int2 operator /(Int2 left, Int2 right) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Multiplies two <see cref="Int2"/> values.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="Int2"/> value to multiply.</param>
|
||||
/// <param name="right">The second <see cref="Int2"/> value to multiply.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static Int2 operator *(Int2 left, Int2 right) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Subtracts two <see cref="Int2"/> values.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="Int2"/> value to subtract.</param>
|
||||
/// <param name="right">The second <see cref="Int2"/> value to subtract.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static Int2 operator -(Int2 left, Int2 right) => default;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<#@include file="..\VectorType.ttinclude" #>
|
||||
<#
|
||||
GenerateVectorProperties("Int2", sizeof(int));
|
||||
#>
|
||||
@@ -0,0 +1,96 @@
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
/// A <see langword="struct"/> that maps the <see langword="int3"/> HLSL type.
|
||||
/// </summary>
|
||||
public partial struct Int3
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Int3"/> value with all components set to 0.
|
||||
/// </summary>
|
||||
public static Int3 Zero => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Int3"/> value with all components set to 1.
|
||||
/// </summary>
|
||||
public static Int3 One => 1;
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Int3"/> value with the <see cref="X"/> component set to 1, and the others to 0.
|
||||
/// </summary>
|
||||
public static Int3 UnitX => new(1, 0, 0);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/> component set to 1, and the others to 0.
|
||||
/// </summary>
|
||||
public static Int3 UnitY => new(0, 1, 0);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/> component set to 1, and the others to 0.
|
||||
/// </summary>
|
||||
public static Int3 UnitZ => new(0, 0, 1);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Int3"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to assign to the first vector component.</param>
|
||||
/// <param name="y">The value to assign to the second vector component.</param>
|
||||
/// <param name="z">The value to assign to the third vector component.</param>
|
||||
public Int3(int x, int y, int z)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Int3"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="xy">The value to assign to the first and second vector components.</param>
|
||||
/// <param name="z">The value to assign to the third vector component.</param>
|
||||
public Int3(Int2 xy, int z)
|
||||
{
|
||||
this.x = xy.X;
|
||||
this.y = xy.Y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Int3"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to assign to the first vector component.</param>
|
||||
/// <param name="yz">The value to assign to the second and thirt vector components.</param>
|
||||
public Int3(int x, Int2 yz)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = yz.X;
|
||||
this.z = yz.Y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Int3"/> value with the same value for all its components.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to use for the components of the new <see cref="Int3"/> instance.</param>
|
||||
public static implicit operator Int3(int x) => new(x, x, x);
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="Int3"/> value to a <see cref="UInt3"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xyz">The input <see cref="Int3"/> value to cast.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static explicit operator UInt3(Int3 xyz) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="Int3"/> value to a <see cref="Float3"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xyz">The input <see cref="Int3"/> value to cast.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static implicit operator Float3(Int3 xyz) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="Int3"/> value to a <see cref="Double3"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xyz">The input <see cref="Int3"/> value to cast.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static implicit operator Double3(Int3 xyz) => default;
|
||||
}
|
||||
ファイル差分が大きすぎるため表示されません。
差分を読み込み
@@ -0,0 +1,4 @@
|
||||
<#@include file="..\VectorType.ttinclude" #>
|
||||
<#
|
||||
GenerateVectorProperties("Int3", sizeof(int));
|
||||
#>
|
||||
@@ -0,0 +1,146 @@
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
/// A <see langword="struct"/> that maps the <see langword="int4"/> HLSL type.
|
||||
/// </summary>
|
||||
public partial struct Int4
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Int4"/> value with all components set to 0.
|
||||
/// </summary>
|
||||
public static Int4 Zero => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Int4"/> value with all components set to 1.
|
||||
/// </summary>
|
||||
public static Int4 One => 1;
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Int4"/> value with the <see cref="X"/> component set to 1, and the others to 0.
|
||||
/// </summary>
|
||||
public static Int4 UnitX => new(1, 0, 0, 0);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Int4"/> value with the <see cref="Y"/> component set to 1, and the others to 0.
|
||||
/// </summary>
|
||||
public static Int4 UnitY => new(0, 1, 0, 0);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Int4"/> value with the <see cref="Z"/> component set to 1, and the others to 0.
|
||||
/// </summary>
|
||||
public static Int4 UnitZ => new(0, 0, 1, 0);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Int4"/> value with the <see cref="W"/> component set to 1, and the others to 0.
|
||||
/// </summary>
|
||||
public static Int4 UnitW => new(0, 0, 0, 1);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Int4"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to assign to the first vector component.</param>
|
||||
/// <param name="y">The value to assign to the second vector component.</param>
|
||||
/// <param name="z">The value to assign to the third vector component.</param>
|
||||
/// <param name="w">The value to assign to the fourth vector component.</param>
|
||||
public Int4(int x, int y, int z, int w)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.w = w;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Int4"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="xy">The value to assign to the first and second vector components.</param>
|
||||
/// <param name="z">The value to assign to the third vector component.</param>
|
||||
/// <param name="w">The value to assign to the fourth vector component.</param>
|
||||
public Int4(Int2 xy, int z, int w)
|
||||
{
|
||||
this.x = xy.X;
|
||||
this.y = xy.Y;
|
||||
this.z = z;
|
||||
this.w = w;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Int4"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to assign to the first vector component.</param>
|
||||
/// <param name="y">The value to assign to the second vector component.</param>
|
||||
/// <param name="zw">The value to assign to the third and fourth vector components.</param>
|
||||
public Int4(int x, int y, Int2 zw)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = zw.X;
|
||||
this.w = zw.Y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Int4"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="xy">The value to assign to the first and second vector components.</param>
|
||||
/// <param name="zw">The value to assign to the third and fourth vector components.</param>
|
||||
public Int4(Int2 xy, Int2 zw)
|
||||
{
|
||||
this.x = xy.X;
|
||||
this.y = xy.Y;
|
||||
this.z = zw.X;
|
||||
this.w = zw.Y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Int4"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="xyz">The value to assign to the first, second and third vector components.</param>
|
||||
/// <param name="w">The value to assign to the fourth vector component.</param>
|
||||
public Int4(Int3 xyz, int w)
|
||||
{
|
||||
this.x = xyz.X;
|
||||
this.y = xyz.Y;
|
||||
this.z = xyz.Z;
|
||||
this.w = w;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Int4"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to assign to the first vector component.</param>
|
||||
/// <param name="yzw">The value to assign to the second, third and fourth vector components.</param>
|
||||
public Int4(int x, Int3 yzw)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = yzw.X;
|
||||
this.z = yzw.Y;
|
||||
this.w = yzw.Z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Int4"/> value with the same value for all its components.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to use for the components of the new <see cref="Int4"/> instance.</param>
|
||||
public static implicit operator Int4(int x) => new(x, x, x, x);
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="Int4"/> value to a <see cref="UInt4"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xyzw">The input <see cref="Int4"/> value to cast.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static explicit operator UInt4(Int4 xyzw) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="Int4"/> value to a <see cref="Float4"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xyzw">The input <see cref="Int4"/> value to cast.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static implicit operator Float4(Int4 xyzw) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="Int4"/> value to a <see cref="Double4"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xyzw">The input <see cref="Int4"/> value to cast.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static implicit operator Double4(Int4 xyzw) => default;
|
||||
}
|
||||
ファイル差分が大きすぎるため表示されません。
差分を読み込み
@@ -0,0 +1,4 @@
|
||||
<#@include file="..\VectorType.ttinclude" #>
|
||||
<#
|
||||
GenerateVectorProperties("Int4", sizeof(int));
|
||||
#>
|
||||
ファイル差分が大きすぎるため表示されません。
差分を読み込み
@@ -0,0 +1,4 @@
|
||||
<#@include file="..\MatrixType.ttinclude" #>
|
||||
<#
|
||||
GenerateAllMatrixProperties("Int", sizeof(int));
|
||||
#>
|
||||
@@ -0,0 +1,96 @@
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
/// A type indicating a base-1 index into a matrix type. This can be used to extract references to swizzled vectors within a given matrix value.
|
||||
/// For more info, see <see href="https://docs.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-per-component-math"/>.
|
||||
/// <para>This type is meant to be used within a <see langword="using static"/> directive to simplify the code:</para>
|
||||
/// <para>
|
||||
/// <c>
|
||||
/// using static ComputeSharp.MatrixIndex;
|
||||
/// Float2x2 matrix = 0;
|
||||
/// Float2 row = matrix[M11, M12];
|
||||
/// </c>
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public enum MatrixIndex
|
||||
{
|
||||
/// <summary>
|
||||
/// The first item in the first row.
|
||||
/// </summary>
|
||||
M11,
|
||||
|
||||
/// <summary>
|
||||
/// The second item in the first row.
|
||||
/// </summary>
|
||||
M12,
|
||||
|
||||
/// <summary>
|
||||
/// The third item in the first row.
|
||||
/// </summary>
|
||||
M13,
|
||||
|
||||
/// <summary>
|
||||
/// The fourth item in the first row.
|
||||
/// </summary>
|
||||
M14,
|
||||
|
||||
/// <summary>
|
||||
/// The first item in the second row.
|
||||
/// </summary>
|
||||
M21,
|
||||
|
||||
/// <summary>
|
||||
/// The second item in the second row.
|
||||
/// </summary>
|
||||
M22,
|
||||
|
||||
/// <summary>
|
||||
/// The third item in the second row.
|
||||
/// </summary>
|
||||
M23,
|
||||
|
||||
/// <summary>
|
||||
/// The fourth item in the second row.
|
||||
/// </summary>
|
||||
M24,
|
||||
|
||||
/// <summary>
|
||||
/// The first item in the third row.
|
||||
/// </summary>
|
||||
M31,
|
||||
|
||||
/// <summary>
|
||||
/// The second item in the third row.
|
||||
/// </summary>
|
||||
M32,
|
||||
|
||||
/// <summary>
|
||||
/// The third item in the third row.
|
||||
/// </summary>
|
||||
M33,
|
||||
|
||||
/// <summary>
|
||||
/// The fourth item in the third row.
|
||||
/// </summary>
|
||||
M34,
|
||||
|
||||
/// <summary>
|
||||
/// The first item in the fourth row.
|
||||
/// </summary>
|
||||
M41,
|
||||
|
||||
/// <summary>
|
||||
/// The second item in the fourth row.
|
||||
/// </summary>
|
||||
M42,
|
||||
|
||||
/// <summary>
|
||||
/// The third item in the fourth row.
|
||||
/// </summary>
|
||||
M43,
|
||||
|
||||
/// <summary>
|
||||
/// The fourth item in the fourth row.
|
||||
/// </summary>
|
||||
M44
|
||||
}
|
||||
@@ -0,0 +1,281 @@
|
||||
<#@ template debug="false" hostspecific="false" language="C#" #>
|
||||
<#@ assembly name="System.Core" #>
|
||||
<#@ import namespace="System.Linq" #>
|
||||
<#@ import namespace="System.Text" #>
|
||||
<#@ import namespace="System.Text.RegularExpressions" #>
|
||||
<#@ import namespace="System.Collections.Generic" #>
|
||||
<#@ output extension=".g.cs"#>
|
||||
<#
|
||||
// Generates all matrix members and types for a given HLSL type
|
||||
void GenerateAllMatrixProperties(string typeName, int elementSize)
|
||||
{
|
||||
#>
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using RuntimeHelpers = ComputeSharp.Core.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.Core.NetStandard.System.Runtime.InteropServices.MemoryMarshal;
|
||||
#endif
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
<#
|
||||
for (int rows = 1; rows <= 4; rows++)
|
||||
for (int columns = 1; columns <= 4; columns++)
|
||||
{
|
||||
if (rows > 1 || columns > 1) WriteLine("");
|
||||
|
||||
GenerateMatrixProperties(typeName, rows, columns, elementSize);
|
||||
}
|
||||
}
|
||||
|
||||
// Generates all vector access properties for a specified type
|
||||
void GenerateMatrixProperties(string typeName, int rows, int columns, int elementSize)
|
||||
{
|
||||
string elementTypeName = typeName.ToLower();
|
||||
string fullTypeName = $"{typeName}{rows}x{columns}";
|
||||
string rowTypeName = columns > 1 ? $"{typeName}{columns}" : elementTypeName;
|
||||
List<string> fieldNames = new List<string>();
|
||||
#>
|
||||
/// <inheritdoc cref="<#=fullTypeName#>"/>
|
||||
[StructLayout(LayoutKind.Explicit, Size = <#=(elementSize * rows * columns)#>, Pack = <#=elementSize#>)]
|
||||
public unsafe partial struct <#=fullTypeName#>
|
||||
{
|
||||
/// <summary>
|
||||
/// A private buffer to which the undefined properties will point to.
|
||||
/// </summary>
|
||||
private static readonly void* UndefinedData = (void*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(<#=fullTypeName#>), sizeof(<#=typeName#>4));
|
||||
<#
|
||||
WriteLine("");
|
||||
PushIndent(" ");
|
||||
|
||||
// Generate the private fields
|
||||
for (int i = 1; i <= rows; i++)
|
||||
for (int j = 1; j <= columns; j++)
|
||||
{
|
||||
WriteLine($"[FieldOffset({((i - 1) * columns + j - 1) * elementSize})]");
|
||||
WriteLine($"private {elementTypeName} m{i}{j};");
|
||||
WriteLine("");
|
||||
|
||||
fieldNames.Add($"m{i}{j}");
|
||||
}
|
||||
|
||||
// Generate the elementwise constructor
|
||||
WriteLine("/// <summary>");
|
||||
WriteLine($"/// Creates a new <see cref=\"{fullTypeName}\"/> instance with the specified parameters.");
|
||||
WriteLine("/// </summary>");
|
||||
|
||||
for (int i = 1; i <= rows; i++)
|
||||
for (int j = 1; j <= columns; j++)
|
||||
{
|
||||
WriteLine($"/// <param name=\"m{i}{j}\">The value to assign to the component at position [{i}, {j}].</param>");
|
||||
}
|
||||
|
||||
WriteLine($"public {fullTypeName}({string.Join(", ", fieldNames.Select(n => $"{elementTypeName} {n}"))})");
|
||||
WriteLine("{");
|
||||
PushIndent(" ");
|
||||
|
||||
foreach (string fieldName in fieldNames)
|
||||
{
|
||||
WriteLine($"this.{fieldName} = {fieldName};");
|
||||
}
|
||||
|
||||
PopIndent();
|
||||
WriteLine("}");
|
||||
WriteLine("");
|
||||
|
||||
// Generate the row-wise constructor, if needed
|
||||
if (rows > 1 && columns > 1)
|
||||
{
|
||||
WriteLine("/// <summary>");
|
||||
WriteLine($"/// Creates a new <see cref=\"{fullTypeName}\"/> instance with the specified parameters.");
|
||||
WriteLine("/// </summary>");
|
||||
|
||||
for (int i = 1; i <= rows; i++)
|
||||
{
|
||||
WriteLine($"/// <param name=\"row{i}\">The value to assign to the row at position [{i}].</param>");
|
||||
}
|
||||
|
||||
Write($"public {fullTypeName}(");
|
||||
|
||||
for (int i = 1; i <= rows; i++)
|
||||
{
|
||||
if (i > 1) Write(", ");
|
||||
Write($"{rowTypeName} row{i}");
|
||||
}
|
||||
|
||||
WriteLine(")");
|
||||
WriteLine("{");
|
||||
PushIndent(" ");
|
||||
|
||||
for (int i = 1; i <= rows; i++)
|
||||
for (int j = 1; j <= columns; j++)
|
||||
{
|
||||
WriteLine($"this.m{i}{j} = row{i}.{"XYZW"[j - 1]};");
|
||||
}
|
||||
|
||||
PopIndent();
|
||||
WriteLine("}");
|
||||
WriteLine("");
|
||||
}
|
||||
|
||||
PopIndent();
|
||||
#>
|
||||
/// <summary>
|
||||
/// Gets a reference to a specific row in the current <see cref="<#=fullTypeName#>"/> instance.
|
||||
/// </summary>
|
||||
/// <param name="row">The row to access.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref <#=rowTypeName#> this[int row] => ref *(<#=rowTypeName#>*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a swizzled reference to a specific sequence of items in the current <see cref="<#=fullTypeName#>"/> instance.
|
||||
/// </summary>
|
||||
/// <param name="xy0">The identifier of the first item to index.</param>
|
||||
/// <param name="xy1">The identifier of the second item to index.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref <#=typeName#>2 this[MatrixIndex xy0, MatrixIndex xy1] => ref *(<#=typeName#>2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a swizzled reference to a specific sequence of items in the current <see cref="<#=fullTypeName#>"/> instance.
|
||||
/// </summary>
|
||||
/// <param name="xy0">The identifier of the first item to index.</param>
|
||||
/// <param name="xy1">The identifier of the second item to index.</param>
|
||||
/// <param name="xy2">The identifier of the third item to index.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref <#=typeName#>3 this[MatrixIndex xy0, MatrixIndex xy1, MatrixIndex xy2] => ref *(<#=typeName#>3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a swizzled reference to a specific sequence of items in the current <see cref="<#=fullTypeName#>"/> instance.
|
||||
/// </summary>
|
||||
/// <param name="xy0">The identifier of the first item to index.</param>
|
||||
/// <param name="xy1">The identifier of the second item to index.</param>
|
||||
/// <param name="xy2">The identifier of the third item to index.</param>
|
||||
/// <param name="xy3">The identifier of the fourth item to index.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref <#=typeName#>4 this[MatrixIndex xy0, MatrixIndex xy1, MatrixIndex xy2, MatrixIndex xy3] => ref *(<#=typeName#>4*)UndefinedData;
|
||||
<#
|
||||
for (int i = 1; i <= rows; i++)
|
||||
for (int j = 1; j <= columns; j++)
|
||||
{
|
||||
WriteLine("");
|
||||
#>
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="<#=elementTypeName#>"/> value representing the component at position [<#=i#>, <#=j#>].
|
||||
/// </summary>
|
||||
public readonly ref <#=elementTypeName#> M<#=i#><#=j#> => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.m<#=i#><#=j#>), 1));
|
||||
<#
|
||||
}
|
||||
|
||||
WriteLine("");
|
||||
#>
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="<#=fullTypeName#>"/> value with the same value for all its components.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to use for the components of the new <see cref="<#=fullTypeName#>"/> instance.</param>
|
||||
public static implicit operator <#=fullTypeName#>(<#=elementTypeName#> x)
|
||||
<#
|
||||
// Complete the conversion operator above
|
||||
PushIndent(" ");
|
||||
WriteLine("{");
|
||||
PushIndent(" ");
|
||||
WriteLine($"{fullTypeName} matrix;");
|
||||
WriteLine("");
|
||||
|
||||
for (int i = 1; i <= rows; i++)
|
||||
for (int j = 1; j <= columns; j++)
|
||||
{
|
||||
WriteLine($"matrix.m{i}{j} = x;");
|
||||
}
|
||||
|
||||
WriteLine("");
|
||||
WriteLine("return matrix;");
|
||||
|
||||
PopIndent();
|
||||
WriteLine("}");
|
||||
PopIndent();
|
||||
|
||||
// Generate the negation operator
|
||||
if (typeName != "UInt")
|
||||
{
|
||||
WriteLine("");
|
||||
|
||||
string operatorName = typeName == "Bool" ? "!" : "-";
|
||||
#>
|
||||
/// <summary>
|
||||
/// Negates a <see cref="<#=fullTypeName#>"/> value.
|
||||
/// </summary>
|
||||
/// <param name="matrix">The <see cref="<#=fullTypeName#>"/> value to negate.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static <#=fullTypeName#> operator <#=operatorName#>(<#=fullTypeName#> matrix) => default;
|
||||
<#
|
||||
}
|
||||
|
||||
// Generate the numerical operators
|
||||
if (typeName != "Bool")
|
||||
{
|
||||
WriteLine("");
|
||||
#>
|
||||
/// <summary>
|
||||
/// Sums two <see cref="<#=fullTypeName#>"/> values.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="<#=fullTypeName#>"/> value to sum.</param>
|
||||
/// <param name="right">The second <see cref="<#=fullTypeName#>"/> value to sum.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static <#=fullTypeName#> operator +(<#=fullTypeName#> left, <#=fullTypeName#> right) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Divides two <see cref="<#=fullTypeName#>"/> values (elementwise division).
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="<#=fullTypeName#>"/> value to divide.</param>
|
||||
/// <param name="right">The second <see cref="<#=fullTypeName#>"/> value to divide.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static <#=fullTypeName#> operator /(<#=fullTypeName#> left, <#=fullTypeName#> right) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Multiplies two <see cref="<#=fullTypeName#>"/> values (elementwise product).
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="<#=fullTypeName#>"/> value to multiply.</param>
|
||||
/// <param name="right">The second <see cref="<#=fullTypeName#>"/> value to multiply.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static <#=fullTypeName#> operator *(<#=fullTypeName#> left, <#=fullTypeName#> right) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Subtracts two <see cref="<#=fullTypeName#>"/> values.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="<#=fullTypeName#>"/> value to subtract.</param>
|
||||
/// <param name="right">The second <see cref="<#=fullTypeName#>"/> value to subtract.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static <#=fullTypeName#> operator -(<#=fullTypeName#> left, <#=fullTypeName#> right) => default;
|
||||
<#
|
||||
}
|
||||
|
||||
// Generate the casting operators for row/column vectors
|
||||
if (rows == 1 && columns > 1)
|
||||
{
|
||||
WriteLine("");
|
||||
#>
|
||||
/// <summary>
|
||||
/// Casts a <see cref="<#=typeName#><#=columns#>"/> value to a <see cref="<#=fullTypeName#>"/> one.
|
||||
/// </summary>
|
||||
/// <param name="vector">The input <see cref="<#=typeName#><#=columns#>"/> value to cast.</param>
|
||||
public static implicit operator <#=fullTypeName#>(<#=typeName#><#=columns#> vector) => *(<#=fullTypeName#>*)&vector;
|
||||
<#
|
||||
}
|
||||
|
||||
if (columns == 1 && rows > 1)
|
||||
{
|
||||
WriteLine("");
|
||||
#>
|
||||
/// <summary>
|
||||
/// Casts a <see cref="<#=fullTypeName#>"/> value to a <see cref="<#=typeName#><#=rows#>"/> one.
|
||||
/// </summary>
|
||||
/// <param name="matrix">The input <see cref="<#=fullTypeName#>"/> value to cast.</param>
|
||||
public static implicit operator <#=typeName#><#=rows#>(<#=fullTypeName#> matrix) => *(<#=typeName#><#=rows#>*)&matrix;
|
||||
<#
|
||||
}
|
||||
#>
|
||||
}
|
||||
<#
|
||||
}
|
||||
#>
|
||||
@@ -0,0 +1,65 @@
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
/// A <see langword="struct"/> that maps the <see langword="uint2"/> HLSL type.
|
||||
/// </summary>
|
||||
public partial struct UInt2
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets an <see cref="UInt2"/> value with all components set to 0.
|
||||
/// </summary>
|
||||
public static UInt2 Zero => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="UInt2"/> value with all components set to 1.
|
||||
/// </summary>
|
||||
public static UInt2 One => 1;
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="UInt2"/> value with the <see cref="X"/> component set to 1, and the others to 0.
|
||||
/// </summary>
|
||||
public static UInt2 UnitX => new(1, 0);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="UInt2"/> value with the <see cref="Y"/> component set to 1, and the others to 0.
|
||||
/// </summary>
|
||||
public static UInt2 UnitY => new(0, 1);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="UInt2"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to assign to the first vector component.</param>
|
||||
/// <param name="y">The value to assign to the second vector component.</param>
|
||||
public UInt2(uint x, uint y)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="UInt2"/> value with the same value for all its components.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to use for the components of the new <see cref="UInt2"/> instance.</param>
|
||||
public static implicit operator UInt2(uint x) => new(x, x);
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="UInt2"/> value to a <see cref="Int2"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xy">The input <see cref="UInt2"/> value to cast.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static explicit operator Int2(UInt2 xy) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="UInt2"/> value to a <see cref="Float2"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xy">The input <see cref="UInt2"/> value to cast.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static implicit operator Float2(UInt2 xy) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="UInt2"/> value to a <see cref="Double2"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xy">The input <see cref="UInt2"/> value to cast.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static implicit operator Double2(UInt2 xy) => default;
|
||||
}
|
||||
@@ -0,0 +1,467 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using RuntimeHelpers = ComputeSharp.Core.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.Core.NetStandard.System.Runtime.InteropServices.MemoryMarshal;
|
||||
#endif
|
||||
|
||||
#nullable enable
|
||||
|
||||
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.
|
||||
/// </summary>
|
||||
private static readonly void* UndefinedData = (void*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(UInt2), sizeof(UInt4));
|
||||
|
||||
[FieldOffset(0)]
|
||||
private uint x;
|
||||
|
||||
[FieldOffset(4)]
|
||||
private uint y;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to a specific component in the current <see cref="UInt2"/> instance.
|
||||
/// </summary>
|
||||
/// <param name="i">The index of the component to access.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref uint this[int i] => ref *(uint*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="uint"/> value representing the <c>X</c> component.
|
||||
/// </summary>
|
||||
public readonly ref uint X => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.x), 1));
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="uint"/> value representing the <c>Y</c> component.
|
||||
/// </summary>
|
||||
public readonly ref uint Y => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.y), 1));
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt2"/> value with the components <see cref="X"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt2 XX => ref *(UInt2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="UInt2"/> value with the components <see cref="X"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref UInt2 XY => ref *(UInt2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="UInt2"/> value with the components <see cref="Y"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref UInt2 YX => ref *(UInt2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt2"/> value with the components <see cref="Y"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt2 YY => ref *(UInt2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt3"/> value with the components <see cref="X"/>, <see cref="X"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt3 XXX => ref *(UInt3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt3"/> value with the components <see cref="X"/>, <see cref="X"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt3 XXY => ref *(UInt3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt3"/> value with the components <see cref="X"/>, <see cref="Y"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt3 XYX => ref *(UInt3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt3"/> value with the components <see cref="X"/>, <see cref="Y"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt3 XYY => ref *(UInt3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt3"/> value with the components <see cref="Y"/>, <see cref="X"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt3 YXX => ref *(UInt3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt3"/> value with the components <see cref="Y"/>, <see cref="X"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt3 YXY => ref *(UInt3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt3"/> value with the components <see cref="Y"/>, <see cref="Y"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt3 YYX => ref *(UInt3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt3"/> value with the components <see cref="Y"/>, <see cref="Y"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt3 YYY => ref *(UInt3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt4"/> value with the components <see cref="X"/>, <see cref="X"/>, <see cref="X"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt4 XXXX => ref *(UInt4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt4"/> value with the components <see cref="X"/>, <see cref="X"/>, <see cref="X"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt4 XXXY => ref *(UInt4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt4"/> value with the components <see cref="X"/>, <see cref="X"/>, <see cref="Y"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt4 XXYX => ref *(UInt4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt4"/> value with the components <see cref="X"/>, <see cref="X"/>, <see cref="Y"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt4 XXYY => ref *(UInt4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt4"/> value with the components <see cref="X"/>, <see cref="Y"/>, <see cref="X"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt4 XYXX => ref *(UInt4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt4"/> value with the components <see cref="X"/>, <see cref="Y"/>, <see cref="X"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt4 XYXY => ref *(UInt4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt4"/> value with the components <see cref="X"/>, <see cref="Y"/>, <see cref="Y"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt4 XYYX => ref *(UInt4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt4"/> value with the components <see cref="X"/>, <see cref="Y"/>, <see cref="Y"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt4 XYYY => ref *(UInt4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt4"/> value with the components <see cref="Y"/>, <see cref="X"/>, <see cref="X"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt4 YXXX => ref *(UInt4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt4"/> value with the components <see cref="Y"/>, <see cref="X"/>, <see cref="X"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt4 YXXY => ref *(UInt4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt4"/> value with the components <see cref="Y"/>, <see cref="X"/>, <see cref="Y"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt4 YXYX => ref *(UInt4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt4"/> value with the components <see cref="Y"/>, <see cref="X"/>, <see cref="Y"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt4 YXYY => ref *(UInt4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt4"/> value with the components <see cref="Y"/>, <see cref="Y"/>, <see cref="X"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt4 YYXX => ref *(UInt4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt4"/> value with the components <see cref="Y"/>, <see cref="Y"/>, <see cref="X"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt4 YYXY => ref *(UInt4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt4"/> value with the components <see cref="Y"/>, <see cref="Y"/>, <see cref="Y"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt4 YYYX => ref *(UInt4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt4"/> value with the components <see cref="Y"/>, <see cref="Y"/>, <see cref="Y"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt4 YYYY => ref *(UInt4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="uint"/> value representing the <c>R</c> component.
|
||||
/// </summary>
|
||||
public readonly ref uint R => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.x), 1));
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="uint"/> value representing the <c>G</c> component.
|
||||
/// </summary>
|
||||
public readonly ref uint G => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.y), 1));
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt2"/> value with the components <see cref="R"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt2 RR => ref *(UInt2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="UInt2"/> value with the components <see cref="R"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref UInt2 RG => ref *(UInt2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="UInt2"/> value with the components <see cref="G"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref UInt2 GR => ref *(UInt2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt2"/> value with the components <see cref="G"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt2 GG => ref *(UInt2*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt3"/> value with the components <see cref="R"/>, <see cref="R"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt3 RRR => ref *(UInt3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt3"/> value with the components <see cref="R"/>, <see cref="R"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt3 RRG => ref *(UInt3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt3"/> value with the components <see cref="R"/>, <see cref="G"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt3 RGR => ref *(UInt3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt3"/> value with the components <see cref="R"/>, <see cref="G"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt3 RGG => ref *(UInt3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt3"/> value with the components <see cref="G"/>, <see cref="R"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt3 GRR => ref *(UInt3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt3"/> value with the components <see cref="G"/>, <see cref="R"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt3 GRG => ref *(UInt3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt3"/> value with the components <see cref="G"/>, <see cref="G"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt3 GGR => ref *(UInt3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt3"/> value with the components <see cref="G"/>, <see cref="G"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt3 GGG => ref *(UInt3*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt4"/> value with the components <see cref="R"/>, <see cref="R"/>, <see cref="R"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt4 RRRR => ref *(UInt4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt4"/> value with the components <see cref="R"/>, <see cref="R"/>, <see cref="R"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt4 RRRG => ref *(UInt4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt4"/> value with the components <see cref="R"/>, <see cref="R"/>, <see cref="G"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt4 RRGR => ref *(UInt4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt4"/> value with the components <see cref="R"/>, <see cref="R"/>, <see cref="G"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt4 RRGG => ref *(UInt4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt4"/> value with the components <see cref="R"/>, <see cref="G"/>, <see cref="R"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt4 RGRR => ref *(UInt4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt4"/> value with the components <see cref="R"/>, <see cref="G"/>, <see cref="R"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt4 RGRG => ref *(UInt4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt4"/> value with the components <see cref="R"/>, <see cref="G"/>, <see cref="G"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt4 RGGR => ref *(UInt4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt4"/> value with the components <see cref="R"/>, <see cref="G"/>, <see cref="G"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt4 RGGG => ref *(UInt4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt4"/> value with the components <see cref="G"/>, <see cref="R"/>, <see cref="R"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt4 GRRR => ref *(UInt4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt4"/> value with the components <see cref="G"/>, <see cref="R"/>, <see cref="R"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt4 GRRG => ref *(UInt4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt4"/> value with the components <see cref="G"/>, <see cref="R"/>, <see cref="G"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt4 GRGR => ref *(UInt4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt4"/> value with the components <see cref="G"/>, <see cref="R"/>, <see cref="G"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt4 GRGG => ref *(UInt4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt4"/> value with the components <see cref="G"/>, <see cref="G"/>, <see cref="R"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt4 GGRR => ref *(UInt4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt4"/> value with the components <see cref="G"/>, <see cref="G"/>, <see cref="R"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt4 GGRG => ref *(UInt4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt4"/> value with the components <see cref="G"/>, <see cref="G"/>, <see cref="G"/>, <see cref="R"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt4 GGGR => ref *(UInt4*)UndefinedData;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a readonly reference to the <see cref="UInt4"/> value with the components <see cref="G"/>, <see cref="G"/>, <see cref="G"/>, <see cref="G"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref readonly UInt4 GGGG => ref *(UInt4*)UndefinedData;
|
||||
|
||||
#if !SOURCE_GENERATOR
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override readonly string ToString()
|
||||
{
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// Sums two <see cref="UInt2"/> values.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="UInt2"/> value to sum.</param>
|
||||
/// <param name="right">The second <see cref="UInt2"/> value to sum.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static UInt2 operator +(UInt2 left, UInt2 right) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Divides two <see cref="UInt2"/> values.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="UInt2"/> value to divide.</param>
|
||||
/// <param name="right">The second <see cref="UInt2"/> value to divide.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static UInt2 operator /(UInt2 left, UInt2 right) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Multiplies two <see cref="UInt2"/> values.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="UInt2"/> value to multiply.</param>
|
||||
/// <param name="right">The second <see cref="UInt2"/> value to multiply.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static UInt2 operator *(UInt2 left, UInt2 right) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Subtracts two <see cref="UInt2"/> values.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="UInt2"/> value to subtract.</param>
|
||||
/// <param name="right">The second <see cref="UInt2"/> value to subtract.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static UInt2 operator -(UInt2 left, UInt2 right) => default;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<#@include file="..\VectorType.ttinclude" #>
|
||||
<#
|
||||
GenerateVectorProperties("UInt2", sizeof(uint));
|
||||
#>
|
||||
@@ -0,0 +1,96 @@
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
/// A <see langword="struct"/> that maps the <see langword="uint3"/> HLSL type.
|
||||
/// </summary>
|
||||
public partial struct UInt3
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets an <see cref="UInt3"/> value with all components set to 0.
|
||||
/// </summary>
|
||||
public static UInt3 Zero => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="UInt3"/> value with all components set to 1.
|
||||
/// </summary>
|
||||
public static UInt3 One => 1;
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="UInt3"/> value with the <see cref="X"/> component set to 1, and the others to 0.
|
||||
/// </summary>
|
||||
public static UInt3 UnitX => new(1, 0, 0);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="UInt3"/> value with the <see cref="Y"/> component set to 1, and the others to 0.
|
||||
/// </summary>
|
||||
public static UInt3 UnitY => new(0, 1, 0);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="UInt3"/> value with the <see cref="Z"/> component set to 1, and the others to 0.
|
||||
/// </summary>
|
||||
public static UInt3 UnitZ => new(0, 0, 1);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="UInt3"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to assign to the first vector component.</param>
|
||||
/// <param name="y">The value to assign to the second vector component.</param>
|
||||
/// <param name="z">The value to assign to the third vector component.</param>
|
||||
public UInt3(uint x, uint y, uint z)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="UInt3"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="xy">The value to assign to the first and second vector components.</param>
|
||||
/// <param name="z">The value to assign to the third vector component.</param>
|
||||
public UInt3(UInt2 xy, uint z)
|
||||
{
|
||||
this.x = xy.X;
|
||||
this.y = xy.Y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="UInt3"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to assign to the first vector component.</param>
|
||||
/// <param name="yz">The value to assign to the second and thirt vector components.</param>
|
||||
public UInt3(uint x, UInt2 yz)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = yz.X;
|
||||
this.z = yz.Y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="UInt3"/> value with the same value for all its components.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to use for the components of the new <see cref="UInt3"/> instance.</param>
|
||||
public static implicit operator UInt3(uint x) => new(x, x, x);
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="UInt3"/> value to a <see cref="Int3"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xyz">The input <see cref="UInt3"/> value to cast.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static explicit operator Int3(UInt3 xyz) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="UInt3"/> value to a <see cref="Float3"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xyz">The input <see cref="UInt3"/> value to cast.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static implicit operator Float3(UInt3 xyz) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="UInt3"/> value to a <see cref="Double3"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xyz">The input <see cref="UInt3"/> value to cast.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static implicit operator Double3(UInt3 xyz) => default;
|
||||
}
|
||||
ファイル差分が大きすぎるため表示されません。
差分を読み込み
@@ -0,0 +1,4 @@
|
||||
<#@include file="..\VectorType.ttinclude" #>
|
||||
<#
|
||||
GenerateVectorProperties("UInt3", sizeof(uint));
|
||||
#>
|
||||
@@ -0,0 +1,146 @@
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
/// A <see langword="struct"/> that maps the <see langword="uint4"/> HLSL type.
|
||||
/// </summary>
|
||||
public partial struct UInt4
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets an <see cref="UInt4"/> value with all components set to 0.
|
||||
/// </summary>
|
||||
public static UInt4 Zero => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="UInt4"/> value with all components set to 1.
|
||||
/// </summary>
|
||||
public static UInt4 One => 1;
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="UInt4"/> value with the <see cref="X"/> component set to 1, and the others to 0.
|
||||
/// </summary>
|
||||
public static UInt4 UnitX => new(1, 0, 0, 0);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="UInt4"/> value with the <see cref="Y"/> component set to 1, and the others to 0.
|
||||
/// </summary>
|
||||
public static UInt4 UnitY => new(0, 1, 0, 0);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="UInt4"/> value with the <see cref="Z"/> component set to 1, and the others to 0.
|
||||
/// </summary>
|
||||
public static UInt4 UnitZ => new(0, 0, 1, 0);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="UInt4"/> value with the <see cref="W"/> component set to 1, and the others to 0.
|
||||
/// </summary>
|
||||
public static UInt4 UnitW => new(0, 0, 0, 1);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="UInt4"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to assign to the first vector component.</param>
|
||||
/// <param name="y">The value to assign to the second vector component.</param>
|
||||
/// <param name="z">The value to assign to the third vector component.</param>
|
||||
/// <param name="w">The value to assign to the fourth vector component.</param>
|
||||
public UInt4(uint x, uint y, uint z, uint w)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.w = w;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="UInt4"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="xy">The value to assign to the first and second vector components.</param>
|
||||
/// <param name="z">The value to assign to the third vector component.</param>
|
||||
/// <param name="w">The value to assign to the fourth vector component.</param>
|
||||
public UInt4(UInt2 xy, uint z, uint w)
|
||||
{
|
||||
this.x = xy.X;
|
||||
this.y = xy.Y;
|
||||
this.z = z;
|
||||
this.w = w;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="UInt4"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to assign to the first vector component.</param>
|
||||
/// <param name="y">The value to assign to the second vector component.</param>
|
||||
/// <param name="zw">The value to assign to the third and fourth vector components.</param>
|
||||
public UInt4(uint x, uint y, UInt2 zw)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = zw.X;
|
||||
this.w = zw.Y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="UInt4"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="xy">The value to assign to the first and second vector components.</param>
|
||||
/// <param name="zw">The value to assign to the third and fourth vector components.</param>
|
||||
public UInt4(UInt2 xy, UInt2 zw)
|
||||
{
|
||||
this.x = xy.X;
|
||||
this.y = xy.Y;
|
||||
this.z = zw.X;
|
||||
this.w = zw.Y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="UInt4"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="xyz">The value to assign to the first, second and third vector components.</param>
|
||||
/// <param name="w">The value to assign to the fourth vector component.</param>
|
||||
public UInt4(UInt3 xyz, uint w)
|
||||
{
|
||||
this.x = xyz.X;
|
||||
this.y = xyz.Y;
|
||||
this.z = xyz.Z;
|
||||
this.w = w;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="UInt4"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to assign to the first vector component.</param>
|
||||
/// <param name="yzw">The value to assign to the second, third and fourth vector components.</param>
|
||||
public UInt4(uint x, UInt3 yzw)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = yzw.X;
|
||||
this.z = yzw.Y;
|
||||
this.w = yzw.Z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="UInt4"/> value with the same value for all its components.
|
||||
/// </summary>
|
||||
/// <param name="x">The value to use for the components of the new <see cref="UInt4"/> instance.</param>
|
||||
public static implicit operator UInt4(uint x) => new(x, x, x, x);
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="UInt4"/> value to a <see cref="Int4"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xyzw">The input <see cref="UInt4"/> value to cast.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static explicit operator Int4(UInt4 xyzw) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="UInt4"/> value to a <see cref="Float4"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xyzw">The input <see cref="UInt4"/> value to cast.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static implicit operator Float4(UInt4 xyzw) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="UInt4"/> value to a <see cref="Double4"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xyzw">The input <see cref="UInt4"/> value to cast.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static implicit operator Double4(UInt4 xyzw) => default;
|
||||
}
|
||||
ファイル差分が大きすぎるため表示されません。
差分を読み込み
@@ -0,0 +1,4 @@
|
||||
<#@include file="..\VectorType.ttinclude" #>
|
||||
<#
|
||||
GenerateVectorProperties("UInt4", sizeof(uint));
|
||||
#>
|
||||
ファイル差分が大きすぎるため表示されません。
差分を読み込み
@@ -0,0 +1,4 @@
|
||||
<#@include file="..\MatrixType.ttinclude" #>
|
||||
<#
|
||||
GenerateAllMatrixProperties("UInt", sizeof(uint));
|
||||
#>
|
||||
@@ -0,0 +1,284 @@
|
||||
<#@ template debug="false" hostspecific="false" language="C#" #>
|
||||
<#@ assembly name="System.Core" #>
|
||||
<#@ import namespace="System.Linq" #>
|
||||
<#@ import namespace="System.Text" #>
|
||||
<#@ import namespace="System.Text.RegularExpressions" #>
|
||||
<#@ import namespace="System.Collections.Generic" #>
|
||||
<#@ output extension=".g.cs"#>
|
||||
<#
|
||||
IEnumerable<string> EnumeratePropertyNames(string characters)
|
||||
{
|
||||
static IEnumerable<string> EnumeratePropertyNames(
|
||||
string characters,
|
||||
StringBuilder builder,
|
||||
int remainingCount)
|
||||
{
|
||||
foreach (char c in characters)
|
||||
{
|
||||
builder.Append(c);
|
||||
|
||||
if (remainingCount == 1)
|
||||
{
|
||||
yield return builder.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (string name in EnumeratePropertyNames(characters, builder, remainingCount - 1))
|
||||
{
|
||||
yield return name;
|
||||
}
|
||||
}
|
||||
|
||||
builder.Remove(builder.Length - 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder builder = new StringBuilder(4);
|
||||
|
||||
for (int length = 1; length <= 4; length++)
|
||||
{
|
||||
foreach (string name in EnumeratePropertyNames(characters, builder, length))
|
||||
{
|
||||
yield return name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Generates all vector access properties for a specified type
|
||||
void GenerateVectorProperties(string typeName, int elementSize)
|
||||
{
|
||||
string elementTypeName = Regex.Match(typeName, @"^[A-Za-z]+").Value;
|
||||
string hlslElementTypeName = elementTypeName.ToLower();
|
||||
int i = int.Parse(Regex.Match(typeName, @"\d+$").Value);
|
||||
string formattable = elementTypeName == "Bool" ? "" : "ISpanFormattable";
|
||||
|
||||
if (elementTypeName != "Bool")
|
||||
{
|
||||
WriteLine("using System;");
|
||||
WriteLine("using System.Globalization;");
|
||||
}
|
||||
#>
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using RuntimeHelpers = ComputeSharp.Core.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.Core.NetStandard.System.Runtime.InteropServices.MemoryMarshal;
|
||||
#endif
|
||||
|
||||
#nullable enable
|
||||
|
||||
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.
|
||||
/// </summary>
|
||||
private static readonly void* UndefinedData = (void*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(<#=typeName#>), sizeof(<#=elementTypeName#>4));
|
||||
<#
|
||||
WriteLine("");
|
||||
PushIndent(" ");
|
||||
|
||||
// Generate the private fields
|
||||
foreach (char name in "xyzw".Substring(0, i))
|
||||
{
|
||||
WriteLine($"[FieldOffset({"xyzw".IndexOf(name) * elementSize})]");
|
||||
WriteLine($"private {hlslElementTypeName} {name};");
|
||||
WriteLine("");
|
||||
}
|
||||
|
||||
PopIndent();
|
||||
#>
|
||||
/// <summary>
|
||||
/// Gets a reference to a specific component in the current <see cref="<#=typeName#>"/> instance.
|
||||
/// </summary>
|
||||
/// <param name="i">The index of the component to access.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public readonly ref <#=hlslElementTypeName#> this[int i] => ref *(<#=hlslElementTypeName#>*)UndefinedData;
|
||||
<#
|
||||
PushIndent(" ");
|
||||
|
||||
// Generate the combinatorial swizzling properties
|
||||
foreach (
|
||||
var propertyName in
|
||||
from source in new[] { "XYZW", "RGBA" }
|
||||
let range = source.Substring(0, i)
|
||||
from name in EnumeratePropertyNames(range)
|
||||
select name)
|
||||
{
|
||||
WriteLine("");
|
||||
|
||||
string propertyType = propertyName.Length == 1 ? hlslElementTypeName : $"{elementTypeName}{propertyName.Length}";
|
||||
bool isReadonly = propertyName.Distinct().Count() < propertyName.Length;
|
||||
string refType = isReadonly ? "ref readonly" : "ref";
|
||||
|
||||
// XML docs
|
||||
WriteLine("/// <summary>");
|
||||
if (propertyName.Length == 1)
|
||||
{
|
||||
WriteLine($"/// Gets a reference to the <see cref=\"{propertyType}\"/> value representing the <c>{propertyName}</c> component.");
|
||||
WriteLine("/// </summary>");
|
||||
|
||||
char fieldName = "xyzw"["xyzwrgba".IndexOf(propertyName.ToLower()) % 4];
|
||||
|
||||
// Property
|
||||
Write($"public readonly {refType} {propertyType} {propertyName} ");
|
||||
WriteLine($"=> ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.{fieldName}), 1));");
|
||||
}
|
||||
else
|
||||
{
|
||||
Write("/// Gets a ");
|
||||
if (isReadonly) Write("readonly ");
|
||||
Write($"reference to the <see cref=\"{propertyType}\"/> value with the components ");
|
||||
Write(string.Join(", ", propertyName.Select(c => $"<see cref=\"{c}\"/>")));
|
||||
WriteLine(".");
|
||||
WriteLine("/// </summary>");
|
||||
WriteLine("/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>");
|
||||
|
||||
// Property
|
||||
Write($"public readonly {refType} {propertyType} {propertyName} ");
|
||||
WriteLine($"=> ref *({propertyType}*)UndefinedData;");
|
||||
}
|
||||
}
|
||||
|
||||
PopIndent();
|
||||
WriteLine("");
|
||||
|
||||
#>
|
||||
#if !SOURCE_GENERATOR
|
||||
|
||||
<#
|
||||
|
||||
if (elementTypeName == "Bool")
|
||||
{
|
||||
#>
|
||||
/// <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}}}"))#>>");
|
||||
#else
|
||||
return $"<<#=string.Join(", ", "xyzw".Take(i).Select(c => $"{{this.{c}}}"))#>>";
|
||||
#endif
|
||||
}
|
||||
<#
|
||||
}
|
||||
else
|
||||
{
|
||||
#>
|
||||
/// <inheritdoc/>
|
||||
public override readonly string ToString()
|
||||
{
|
||||
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);
|
||||
}
|
||||
<#
|
||||
}
|
||||
|
||||
#>
|
||||
|
||||
#endif
|
||||
<#
|
||||
|
||||
// Generate the negation operator
|
||||
if (elementTypeName != "UInt")
|
||||
{
|
||||
WriteLine("");
|
||||
|
||||
string argumentName = "xyzw".Substring(0, i);
|
||||
string operatorName = elementTypeName == "Bool" ? "!" : "-";
|
||||
#>
|
||||
/// <summary>
|
||||
/// Negates a <see cref="<#=typeName#>"/> value.
|
||||
/// </summary>
|
||||
/// <param name="<#=argumentName#>">The <see cref="<#=typeName#>"/> value to negate.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static <#=typeName#> operator <#=operatorName#>(<#=typeName#> <#=argumentName#>) => default;
|
||||
<#
|
||||
}
|
||||
|
||||
// Generate the numerical operators
|
||||
if (elementTypeName != "Bool")
|
||||
{
|
||||
WriteLine("");
|
||||
#>
|
||||
/// <summary>
|
||||
/// Sums two <see cref="<#=typeName#>"/> values.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="<#=typeName#>"/> value to sum.</param>
|
||||
/// <param name="right">The second <see cref="<#=typeName#>"/> value to sum.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static <#=typeName#> operator +(<#=typeName#> left, <#=typeName#> right) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Divides two <see cref="<#=typeName#>"/> values.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="<#=typeName#>"/> value to divide.</param>
|
||||
/// <param name="right">The second <see cref="<#=typeName#>"/> value to divide.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static <#=typeName#> operator /(<#=typeName#> left, <#=typeName#> right) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Multiplies two <see cref="<#=typeName#>"/> values.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="<#=typeName#>"/> value to multiply.</param>
|
||||
/// <param name="right">The second <see cref="<#=typeName#>"/> value to multiply.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static <#=typeName#> operator *(<#=typeName#> left, <#=typeName#> right) => default;
|
||||
|
||||
/// <summary>
|
||||
/// Subtracts two <see cref="<#=typeName#>"/> values.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="<#=typeName#>"/> value to subtract.</param>
|
||||
/// <param name="right">The second <see cref="<#=typeName#>"/> value to subtract.</param>
|
||||
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
|
||||
public static <#=typeName#> operator -(<#=typeName#> left, <#=typeName#> right) => default;
|
||||
<#
|
||||
}
|
||||
#>
|
||||
}
|
||||
<#
|
||||
}
|
||||
#>
|
||||
新しいイシューから参照
ユーザーをブロックする