Added Bool2 struct
このコミットが含まれているのは:
1 親
37424c3692
コミット
51bfe59ef7
2ファイル変更
+158
検索条件に一致するファイルはありません
@@ -0,0 +1,157 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using ComputeSharp.Exceptions;
|
||||
|
||||
namespace ComputeSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see langword="struct"/> that maps the bool2 HLSL type
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Explicit, Size = sizeof(int) * 2)]
|
||||
public struct Bool2
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Bool2"/> value with all components set to <see langword="false"/>
|
||||
/// </summary>
|
||||
public static Bool2 False { get; } = new Bool2(false, false);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Bool2"/> value with all components set to <see langword="true"/>
|
||||
/// </summary>
|
||||
public static Bool2 True { get; } = new 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 { get; } = new Bool2(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 { get; } = new Bool2(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)
|
||||
{
|
||||
_X = x;
|
||||
_Y = y;
|
||||
}
|
||||
|
||||
[FieldOffset(0)]
|
||||
private bool _X;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the first vector component
|
||||
/// </summary>
|
||||
public bool X
|
||||
{
|
||||
get => _X;
|
||||
set => _X = value;
|
||||
}
|
||||
|
||||
[FieldOffset(4)]
|
||||
private bool _Y;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the second vector component
|
||||
/// </summary>
|
||||
public bool Y
|
||||
{
|
||||
get => _Y;
|
||||
set => _Y = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the first color component
|
||||
/// </summary>
|
||||
public uint R
|
||||
{
|
||||
get => throw new InvalidExecutionContextException($"{nameof(Bool2)}.{nameof(R)}");
|
||||
set => throw new InvalidExecutionContextException($"{nameof(Bool2)}.{nameof(R)}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the second color component
|
||||
/// </summary>
|
||||
public uint G
|
||||
{
|
||||
get => throw new InvalidExecutionContextException($"{nameof(Bool2)}.{nameof(G)}");
|
||||
set => throw new InvalidExecutionContextException($"{nameof(Bool2)}.{nameof(G)}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a specific component in the current <see cref="Bool2"/> instance
|
||||
/// </summary>
|
||||
/// <param name="i">The index of the component to access</param>
|
||||
public float this[int i]
|
||||
{
|
||||
get => throw new InvalidExecutionContextException($"{nameof(Bool2)}[int]");
|
||||
set => throw new InvalidExecutionContextException($"{nameof(Bool2)}[int]");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Bool2"/> value with the <see cref="X"/> value for all components
|
||||
/// </summary>
|
||||
public Bool2 XX => throw new InvalidExecutionContextException($"{nameof(Bool2)}.{nameof(XX)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets an <see cref="Bool2"/> value with the <see cref="X"/> and <see cref="Y"/> values
|
||||
/// </summary>
|
||||
public Bool2 XY
|
||||
{
|
||||
get => throw new InvalidExecutionContextException($"{nameof(Bool2)}.{nameof(XY)}");
|
||||
set => throw new InvalidExecutionContextException($"{nameof(Bool2)}.{nameof(XY)}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Bool2"/> value with the <see cref="Y"/> and <see cref="X"/> values
|
||||
/// </summary>
|
||||
public Bool2 YX
|
||||
{
|
||||
get => throw new InvalidExecutionContextException($"{nameof(Bool2)}.{nameof(YX)}");
|
||||
set => throw new InvalidExecutionContextException($"{nameof(Bool2)}.{nameof(YX)}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Bool2"/> value with the <see cref="Y"/> value for all components
|
||||
/// </summary>
|
||||
public Bool2 YY => throw new InvalidExecutionContextException($"{nameof(Bool2)}.{nameof(YY)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Bool2"/> value with the <see cref="R"/> value for all components
|
||||
/// </summary>
|
||||
public Bool2 RR => throw new InvalidExecutionContextException($"{nameof(Bool2)}.{nameof(RR)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets an <see cref="Bool2"/> value with the <see cref="R"/> and <see cref="G"/> values
|
||||
/// </summary>
|
||||
public Bool2 RG
|
||||
{
|
||||
get => throw new InvalidExecutionContextException($"{nameof(Bool2)}.{nameof(RG)}");
|
||||
set => throw new InvalidExecutionContextException($"{nameof(Bool2)}.{nameof(RG)}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Bool2"/> value with the <see cref="G"/> and <see cref="R"/> values
|
||||
/// </summary>
|
||||
public Bool2 GR
|
||||
{
|
||||
get => throw new InvalidExecutionContextException($"{nameof(Bool2)}.{nameof(GR)}");
|
||||
set => throw new InvalidExecutionContextException($"{nameof(Bool2)}.{nameof(GR)}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Bool2"/> value with the <see cref="G"/> value for all components
|
||||
/// </summary>
|
||||
public Bool2 GG => throw new InvalidExecutionContextException($"{nameof(Bool2)}.{nameof(GG)}");
|
||||
|
||||
/// <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 Bool2(x, x);
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,7 @@ namespace ComputeSharp.Graphics.Buffers.Extensions
|
||||
Unsafe.As<uint, bool>(ref ub) = b;
|
||||
WriteValue(ub, ref r0);
|
||||
break;
|
||||
case Bool2 b2: WriteValue(b2, ref r0); break;
|
||||
case int i: WriteValue(i, ref r0); break;
|
||||
case Int2 i2: WriteValue(i2, ref r0); break;
|
||||
case Int3 i3: WriteValue(i3, ref r0); break;
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする