Merge pull request #40 from Sergio0694/feature_bool-vectors

Bool vectors, bug fixes
このコミットが含まれているのは:
Sergio Pedri authored and GitHub committed 2019-08-29 03:26:37 +02:00
コミット f6124c647c
22ファイル変更
+4949 -115

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

+3 -3
ファイルの表示
@@ -45,11 +45,11 @@ float[] array = buffer.GetData();
If the shader in C# is capturing some local variable, those will be automatically copied over to the GPU, so that the HLSL shader will be able to access them just like you'd expect. Additionally, **ComputeSharp** can also resolve static fields being used in a shader. The captured variables need to be convertible to valid HLSL types: either scalar types (`int`, `uint`, `float`, etc.) or known HLSL structs (eg. `Vector3`). Here is a list of the variable types currently supported by the library:
✅ Local scalar types: `bool`, `int`, `uint`, `float`, `double`
✅ .NET scalar types: `bool`, `int`, `uint`, `float`, `double`
✅ Local vector types: `System.Numerics.Vector2`, `Vector3`, `Vector4`
✅ .NET vector types: `System.Numerics.Vector2`, `Vector3`, `Vector4`
✅ HLSL vector types: `Float2`, `Float3`, `Float4`, `Int2`, `Int3`, `Int4`, `UInt2`, `Uint3`, `UInt4`, `Double2`, `Double3`, `Double4`
✅ HLSL vector types: `Bool2`, `Bool3`, `Bool4`, `Float2`, `Float3`, `Float4`, `Int2`, `Int3`, `Int4`, `UInt2`, `Uint3`, etc.
✅ `static` fields of both scalar, vector or buffer types
+159
ファイルの表示
@@ -0,0 +1,159 @@
using System.Diagnostics;
using System.Runtime.InteropServices;
using ComputeSharp.Exceptions;
namespace ComputeSharp
{
/// <summary>
/// A <see langword="struct"/> that maps the bool2 HLSL type
/// </summary>
[DebuggerDisplay("({X}, {Y})")]
[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 => 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 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 => 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);
}
}
+587
ファイルの表示
@@ -0,0 +1,587 @@
using System.Diagnostics;
using System.Runtime.InteropServices;
using ComputeSharp.Exceptions;
namespace ComputeSharp
{
/// <summary>
/// A <see langword="struct"/> that maps the bool3 HLSL type
/// </summary>
[DebuggerDisplay("({X}, {Y}, {Z})")]
[StructLayout(LayoutKind.Explicit, Size = sizeof(int) * 3)]
public 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 Bool3(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 Bool3(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 Bool3(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)
{
_X = x;
_Y = y;
_Z = z;
}
[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;
}
[FieldOffset(8)]
private bool _Z;
/// <summary>
/// Gets or sets the value of the third vector component
/// </summary>
public bool Z
{
get => _Z;
set => _Z = value;
}
/// <summary>
/// Gets or sets the value of the first color component
/// </summary>
public bool R
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(R)}");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(R)}");
}
/// <summary>
/// Gets or sets the value of the second color component
/// </summary>
public bool G
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(G)}");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(G)}");
}
/// <summary>
/// Gets or sets the value of the third color component
/// </summary>
public bool B
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(B)}");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(B)}");
}
/// <summary>
/// Gets or sets a specific component in the current <see cref="Bool3"/> instance
/// </summary>
/// <param name="i">The index of the component to access</param>
public bool this[int i]
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}[int]");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}[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(Bool3)}.{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(Bool3)}.{nameof(XY)}");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(XY)}");
}
/// <summary>
/// Gets or sets an <see cref="Bool2"/> value with the <see cref="X"/> and <see cref="Z"/> values
/// </summary>
public Bool2 XZ
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(XZ)}");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(XZ)}");
}
/// <summary>
/// Gets or sets an <see cref="Bool2"/> value with the <see cref="Y"/> and <see cref="X"/> values
/// </summary>
public Bool2 YX
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(YX)}");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{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(Bool3)}.{nameof(YY)}");
/// <summary>
/// Gets or sets an <see cref="Bool2"/> value with the <see cref="Y"/> and <see cref="Z"/> values
/// </summary>
public Bool2 YZ
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(YZ)}");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(YZ)}");
}
/// <summary>
/// Gets or sets an <see cref="Bool2"/> value with the <see cref="Z"/> and <see cref="X"/> values
/// </summary>
public Bool2 ZX
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(ZX)}");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(ZX)}");
}
/// <summary>
/// Gets or sets an <see cref="Bool2"/> value with the <see cref="Z"/> and <see cref="Y"/> values
/// </summary>
public Bool2 ZY
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(ZY)}");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(ZY)}");
}
/// <summary>
/// Gets an <see cref="Bool2"/> value with the <see cref="Z"/> value for all components
/// </summary>
public Bool2 ZZ => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(ZZ)}");
/// <summary>
/// Gets an <see cref="Bool2"/> value with the <see cref="R"/> value for all components
/// </summary>
public Bool2 RR => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{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(Bool3)}.{nameof(RG)}");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(RG)}");
}
/// <summary>
/// Gets or sets an <see cref="Bool2"/> value with the <see cref="R"/> and <see cref="B"/> values
/// </summary>
public Bool2 RB
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(RB)}");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(RB)}");
}
/// <summary>
/// Gets or sets an <see cref="Bool2"/> value with the <see cref="G"/> and <see cref="R"/> values
/// </summary>
public Bool2 GR
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(GR)}");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{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(Bool3)}.{nameof(GG)}");
/// <summary>
/// Gets or sets an <see cref="Bool2"/> value with the <see cref="G"/> and <see cref="B"/> values
/// </summary>
public Bool2 GB
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(GB)}");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(GB)}");
}
/// <summary>
/// Gets or sets an <see cref="Bool2"/> value with the <see cref="B"/> and <see cref="R"/> values
/// </summary>
public Bool2 BR
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(BR)}");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(BR)}");
}
/// <summary>
/// Gets or sets an <see cref="Bool2"/> value with the <see cref="B"/> and <see cref="G"/> values
/// </summary>
public Bool2 BG
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(BG)}");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(BG)}");
}
/// <summary>
/// Gets an <see cref="Bool2"/> value with the <see cref="B"/> value for all components
/// </summary>
public Bool2 BB => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(BB)}");
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="X"/> value for all components
/// </summary>
public Bool2 XXX => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(XXX)}");
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="X"/>, <see cref="X"/> and <see cref="Y"/> values
/// </summary>
public Bool2 XXY => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(XXY)}");
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="X"/>, <see cref="X"/> and <see cref="Z"/> values
/// </summary>
public Bool2 XXZ => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(XXZ)}");
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="X"/>, <see cref="Y"/> and <see cref="X"/> values
/// </summary>
public Bool2 XYX => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(XYX)}");
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="X"/>, <see cref="Y"/> and <see cref="Y"/> values
/// </summary>
public Bool2 XYY => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(XYY)}");
/// <summary>
/// Gets or sets an <see cref="Bool3"/> value with the <see cref="X"/>, <see cref="Y"/> and <see cref="Z"/> values
/// </summary>
public Bool2 XYZ
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(XYZ)}");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(XYZ)}");
}
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="X"/>, <see cref="Z"/> and <see cref="X"/> values
/// </summary>
public Bool2 XZX => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(XZX)}");
/// <summary>
/// Gets or sets an <see cref="Bool3"/> value with the <see cref="X"/>, <see cref="Z"/> and <see cref="Y"/> values
/// </summary>
public Bool2 XZY
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(XZY)}");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(XZY)}");
}
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="X"/>, <see cref="Z"/> and <see cref="Z"/> values
/// </summary>
public Bool2 XZZ => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(XZZ)}");
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="Y"/>, <see cref="X"/> and <see cref="X"/> values
/// </summary>
public Bool2 YXX => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(YXX)}");
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="Y"/>, <see cref="X"/> and <see cref="Y"/> values
/// </summary>
public Bool2 YXY => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(YXY)}");
/// <summary>
/// Gets or sets an <see cref="Bool3"/> value with the <see cref="Y"/>, <see cref="X"/> and <see cref="Z"/> values
/// </summary>
public Bool2 YXZ
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(YXZ)}");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(YXZ)}");
}
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="Y"/>, <see cref="Y"/> and <see cref="X"/> values
/// </summary>
public Bool2 YYX => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(YYX)}");
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="Y"/> value for all components
/// </summary>
public Bool2 YYY => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(YYY)}");
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="Y"/>, <see cref="Y"/> and <see cref="Z"/> values
/// </summary>
public Bool2 YYZ => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(YYZ)}");
/// <summary>
/// Gets or sets an <see cref="Bool3"/> value with the <see cref="Y"/>, <see cref="Z"/> and <see cref="X"/> values
/// </summary>
public Bool2 YZX
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(YZX)}");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(YZX)}");
}
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="Y"/>, <see cref="Z"/> and <see cref="Y"/> values
/// </summary>
public Bool2 YZY => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(YZY)}");
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="Y"/>, <see cref="Z"/> and <see cref="Z"/> values
/// </summary>
public Bool2 YZZ => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(YZZ)}");
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="Z"/>, <see cref="Z"/> and <see cref="Z"/> values
/// </summary>
public Bool2 ZXX => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(ZXX)}");
/// <summary>
/// Gets or sets an <see cref="Bool3"/> value with the <see cref="Z"/>, <see cref="X"/> and <see cref="Y"/> values
/// </summary>
public Bool2 ZXY
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(ZXY)}");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(ZXY)}");
}
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="Z"/>, <see cref="X"/> and <see cref="Z"/> values
/// </summary>
public Bool2 ZXZ => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(ZXZ)}");
/// <summary>
/// Gets or sets an <see cref="Bool3"/> value with the <see cref="Z"/>, <see cref="Y"/> and <see cref="X"/> values
/// </summary>
public Bool2 ZYX
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(ZYX)}");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(ZYX)}");
}
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="Z"/>, <see cref="Y"/> and <see cref="Y"/> values
/// </summary>
public Bool2 ZYY => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(ZYY)}");
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="Z"/>, <see cref="Y"/> and <see cref="Z"/> values
/// </summary>
public Bool2 ZYZ => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(ZYZ)}");
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="Z"/>, <see cref="Z"/> and <see cref="X"/> values
/// </summary>
public Bool2 ZZX => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(ZZX)}");
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="Z"/>, <see cref="Z"/> and <see cref="Y"/> values
/// </summary>
public Bool2 ZZY => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(ZZY)}");
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="Z"/> value for all components
/// </summary>
public Bool2 ZZZ => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(ZZZ)}");
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="R"/> value for all components
/// </summary>
public Bool2 RRR => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(RRR)}");
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="R"/>, <see cref="R"/> and <see cref="G"/> values
/// </summary>
public Bool2 RRG => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(RRG)}");
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="R"/>, <see cref="R"/> and <see cref="B"/> values
/// </summary>
public Bool2 RRB => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(RRB)}");
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="R"/>, <see cref="G"/> and <see cref="R"/> values
/// </summary>
public Bool2 RGR => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(RGR)}");
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="R"/>, <see cref="G"/> and <see cref="G"/> values
/// </summary>
public Bool2 RGG => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(RGG)}");
/// <summary>
/// Gets or sets an <see cref="Bool3"/> value with the <see cref="R"/>, <see cref="G"/> and <see cref="B"/> values
/// </summary>
public Bool2 RGB
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(RGB)}");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(RGB)}");
}
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="R"/>, <see cref="B"/> and <see cref="R"/> values
/// </summary>
public Bool2 RBR => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(RBR)}");
/// <summary>
/// Gets or sets an <see cref="Bool3"/> value with the <see cref="R"/>, <see cref="B"/> and <see cref="G"/> values
/// </summary>
public Bool2 RBG
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(RBG)}");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(RBG)}");
}
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="R"/>, <see cref="B"/> and <see cref="B"/> values
/// </summary>
public Bool2 RBB => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(RBB)}");
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="G"/>, <see cref="R"/> and <see cref="R"/> values
/// </summary>
public Bool2 GRR => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(GRR)}");
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="G"/>, <see cref="R"/> and <see cref="G"/> values
/// </summary>
public Bool2 GRG => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(GRG)}");
/// <summary>
/// Gets or sets an <see cref="Bool3"/> value with the <see cref="G"/>, <see cref="R"/> and <see cref="B"/> values
/// </summary>
public Bool2 GRB
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(GRB)}");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(GRB)}");
}
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="G"/>, <see cref="G"/> and <see cref="R"/> values
/// </summary>
public Bool2 GGR => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(GGR)}");
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="G"/> value for all components
/// </summary>
public Bool2 GGG => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(GGG)}");
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="G"/>, <see cref="G"/> and <see cref="B"/> values
/// </summary>
public Bool2 GGB => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(GGB)}");
/// <summary>
/// Gets or sets an <see cref="Bool3"/> value with the <see cref="G"/>, <see cref="B"/> and <see cref="R"/> values
/// </summary>
public Bool2 GBR
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(GBR)}");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(GBR)}");
}
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="G"/>, <see cref="B"/> and <see cref="G"/> values
/// </summary>
public Bool2 GBG => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(GBG)}");
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="G"/>, <see cref="B"/> and <see cref="B"/> values
/// </summary>
public Bool2 GBB => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(GBB)}");
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="B"/>, <see cref="B"/> and <see cref="B"/> values
/// </summary>
public Bool2 BRR => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(BRR)}");
/// <summary>
/// Gets or sets an <see cref="Bool3"/> value with the <see cref="B"/>, <see cref="R"/> and <see cref="G"/> values
/// </summary>
public Bool2 BRG
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(BRG)}");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(BRG)}");
}
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="B"/>, <see cref="R"/> and <see cref="B"/> values
/// </summary>
public Bool2 BRB => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(BRB)}");
/// <summary>
/// Gets or sets an <see cref="Bool3"/> value with the <see cref="B"/>, <see cref="G"/> and <see cref="R"/> values
/// </summary>
public Bool2 BGR
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(BGR)}");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(BGR)}");
}
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="B"/>, <see cref="G"/> and <see cref="G"/> values
/// </summary>
public Bool2 BGG => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(BGG)}");
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="B"/>, <see cref="G"/> and <see cref="B"/> values
/// </summary>
public Bool2 BGB => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(BGB)}");
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="B"/>, <see cref="B"/> and <see cref="R"/> values
/// </summary>
public Bool2 BBR => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(BBR)}");
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="B"/>, <see cref="B"/> and <see cref="G"/> values
/// </summary>
public Bool2 BBG => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(BBG)}");
/// <summary>
/// Gets an <see cref="Bool3"/> value with the <see cref="B"/> value for all components
/// </summary>
public Bool2 BBB => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(BBB)}");
/// <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 Bool3(x, x, x);
}
}
ファイル差分が大きすぎるため表示されません。 差分を読み込み
+7 -5
ファイルの表示
@@ -1,4 +1,5 @@
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Runtime.InteropServices;
using ComputeSharp.Exceptions;
namespace ComputeSharp
@@ -6,28 +7,29 @@ namespace ComputeSharp
/// <summary>
/// A <see langword="struct"/> that maps the double2 HLSL type
/// </summary>
[DebuggerDisplay("({X}, {Y})")]
[StructLayout(LayoutKind.Sequential, Size = sizeof(double) * 2)]
public struct Double2
{
/// <summary>
/// Gets an <see cref="Double2"/> value with all components set to 0
/// </summary>
public static Double2 Zero { get; } = 0;
public static Double2 Zero => 0;
/// <summary>
/// Gets an <see cref="Double2"/> value with all components set to 1
/// </summary>
public static Double2 One { get; } = 1;
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 { get; } = new Double2(1, 0);
public static Double2 UnitX => new Double2(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 { get; } = new Double2(0, 1);
public static Double2 UnitY => new Double2(0, 1);
/// <summary>
/// Creates a new <see cref="Double2"/> instance with the specified parameters
+8 -6
ファイルの表示
@@ -1,4 +1,5 @@
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Runtime.InteropServices;
using ComputeSharp.Exceptions;
namespace ComputeSharp
@@ -6,33 +7,34 @@ namespace ComputeSharp
/// <summary>
/// A <see langword="struct"/> that maps the double3 HLSL type
/// </summary>
[DebuggerDisplay("({X}, {Y}, {Z})")]
[StructLayout(LayoutKind.Sequential, Size = sizeof(double) * 3)]
public struct Double3
{
/// <summary>
/// Gets an <see cref="Double3"/> value with all components set to 0
/// </summary>
public static Double3 Zero { get; } = 0;
public static Double3 Zero => 0;
/// <summary>
/// Gets an <see cref="Double3"/> value with all components set to 1
/// </summary>
public static Double3 One { get; } = 1;
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 { get; } = new Double3(1, 0, 0);
public static Double3 UnitX => new Double3(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 { get; } = new Double3(0, 1, 0);
public static Double3 UnitY => new Double3(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 { get; } = new Double3(0, 0, 1);
public static Double3 UnitZ => new Double3(0, 0, 1);
/// <summary>
/// Creates a new <see cref="Double3"/> instance with the specified parameters
+9 -7
ファイルの表示
@@ -1,4 +1,5 @@
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Runtime.InteropServices;
using ComputeSharp.Exceptions;
namespace ComputeSharp
@@ -6,38 +7,39 @@ namespace ComputeSharp
/// <summary>
/// A <see langword="struct"/> that maps the double4 HLSL type
/// </summary>
[DebuggerDisplay("({X}, {Y}, {Z}, {W})")]
[StructLayout(LayoutKind.Sequential, Size = sizeof(double) * 4)]
public struct Double4
{
/// <summary>
/// Gets an <see cref="Double4"/> value with all components set to 0
/// </summary>
public static Double4 Zero { get; } = 0;
public static Double4 Zero => 0;
/// <summary>
/// Gets an <see cref="Double4"/> value with all components set to 1
/// </summary>
public static Double4 One { get; } = 1;
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 { get; } = new Double4(1, 0, 0, 0);
public static Double4 UnitX => new Double4(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 { get; } = new Double4(0, 1, 0, 0);
public static Double4 UnitY => new Double4(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 { get; } = new Double4(0, 0, 1, 0);
public static Double4 UnitZ => new Double4(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 { get; } = new Double4(0, 0, 0, 1);
public static Double4 UnitW => new Double4(0, 0, 0, 1);
/// <summary>
/// Creates a new <see cref="Double4"/> instance with the specified parameters
+7 -5
ファイルの表示
@@ -1,4 +1,5 @@
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Runtime.InteropServices;
using ComputeSharp.Exceptions;
namespace ComputeSharp
@@ -6,28 +7,29 @@ namespace ComputeSharp
/// <summary>
/// A <see langword="struct"/> that maps the float2 HLSL type
/// </summary>
[DebuggerDisplay("({X}, {Y})")]
[StructLayout(LayoutKind.Sequential, Size = sizeof(float) * 2)]
public struct Float2
{
/// <summary>
/// Gets an <see cref="Float2"/> value with all components set to 0
/// </summary>
public static Float2 Zero { get; } = 0;
public static Float2 Zero => 0;
/// <summary>
/// Gets an <see cref="Float2"/> value with all components set to 1
/// </summary>
public static Float2 One { get; } = 1;
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 { get; } = new Float2(1, 0);
public static Float2 UnitX => new Float2(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 { get; } = new Float2(0, 1);
public static Float2 UnitY => new Float2(0, 1);
/// <summary>
/// Creates a new <see cref="Float2"/> instance with the specified parameters
+8 -6
ファイルの表示
@@ -1,4 +1,5 @@
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Runtime.InteropServices;
using ComputeSharp.Exceptions;
namespace ComputeSharp
@@ -6,33 +7,34 @@ namespace ComputeSharp
/// <summary>
/// A <see langword="struct"/> that maps the float3 HLSL type
/// </summary>
[DebuggerDisplay("({X}, {Y}, {Z})")]
[StructLayout(LayoutKind.Sequential, Size = sizeof(float) * 3)]
public struct Float3
{
/// <summary>
/// Gets an <see cref="Float3"/> value with all components set to 0
/// </summary>
public static Float3 Zero { get; } = 0;
public static Float3 Zero => 0;
/// <summary>
/// Gets an <see cref="Float3"/> value with all components set to 1
/// </summary>
public static Float3 One { get; } = 1;
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 { get; } = new Float3(1, 0, 0);
public static Float3 UnitX => new Float3(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 { get; } = new Float3(0, 1, 0);
public static Float3 UnitY => new Float3(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 { get; } = new Float3(0, 0, 1);
public static Float3 UnitZ => new Float3(0, 0, 1);
/// <summary>
/// Creates a new <see cref="Float3"/> instance with the specified parameters
+9 -7
ファイルの表示
@@ -1,4 +1,5 @@
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Runtime.InteropServices;
using ComputeSharp.Exceptions;
namespace ComputeSharp
@@ -6,38 +7,39 @@ namespace ComputeSharp
/// <summary>
/// A <see langword="struct"/> that maps the float4 HLSL type
/// </summary>
[DebuggerDisplay("({X}, {Y}, {Z}, {W})")]
[StructLayout(LayoutKind.Sequential, Size = sizeof(float) * 4)]
public struct Float4
{
/// <summary>
/// Gets an <see cref="Float4"/> value with all components set to 0
/// </summary>
public static Float4 Zero { get; } = 0;
public static Float4 Zero => 0;
/// <summary>
/// Gets an <see cref="Float4"/> value with all components set to 1
/// </summary>
public static Float4 One { get; } = 1;
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 { get; } = new Float4(1, 0, 0, 0);
public static Float4 UnitX => new Float4(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 { get; } = new Float4(0, 1, 0, 0);
public static Float4 UnitY => new Float4(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 { get; } = new Float4(0, 0, 1, 0);
public static Float4 UnitZ => new Float4(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 { get; } = new Float4(0, 0, 0, 1);
public static Float4 UnitW => new Float4(0, 0, 0, 1);
/// <summary>
/// Creates a new <see cref="Float4"/> instance with the specified parameters
+7 -5
ファイルの表示
@@ -1,4 +1,5 @@
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Runtime.InteropServices;
using ComputeSharp.Exceptions;
namespace ComputeSharp
@@ -6,28 +7,29 @@ namespace ComputeSharp
/// <summary>
/// A <see langword="struct"/> that maps the int2 HLSL type
/// </summary>
[DebuggerDisplay("({X}, {Y})")]
[StructLayout(LayoutKind.Sequential, Size = sizeof(int) * 2)]
public struct Int2
{
/// <summary>
/// Gets an <see cref="Int2"/> value with all components set to 0
/// </summary>
public static Int2 Zero { get; } = 0;
public static Int2 Zero => 0;
/// <summary>
/// Gets an <see cref="Int2"/> value with all components set to 1
/// </summary>
public static Int2 One { get; } = 1;
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 { get; } = new Int2(1, 0);
public static Int2 UnitX => new Int2(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 { get; } = new Int2(0, 1);
public static Int2 UnitY => new Int2(0, 1);
/// <summary>
/// Creates a new <see cref="Int2"/> instance with the specified parameters
+8 -6
ファイルの表示
@@ -1,4 +1,5 @@
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Runtime.InteropServices;
using ComputeSharp.Exceptions;
namespace ComputeSharp
@@ -6,33 +7,34 @@ namespace ComputeSharp
/// <summary>
/// A <see langword="struct"/> that maps the int3 HLSL type
/// </summary>
[DebuggerDisplay("({X}, {Y}, {Z})")]
[StructLayout(LayoutKind.Sequential, Size = sizeof(int) * 3)]
public struct Int3
{
/// <summary>
/// Gets an <see cref="Int3"/> value with all components set to 0
/// </summary>
public static Int3 Zero { get; } = 0;
public static Int3 Zero => 0;
/// <summary>
/// Gets an <see cref="Int3"/> value with all components set to 1
/// </summary>
public static Int3 One { get; } = 1;
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 { get; } = new Int3(1, 0, 0);
public static Int3 UnitX => new Int3(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 { get; } = new Int3(0, 1, 0);
public static Int3 UnitY => new Int3(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 { get; } = new Int3(0, 0, 1);
public static Int3 UnitZ => new Int3(0, 0, 1);
/// <summary>
/// Creates a new <see cref="Int3"/> instance with the specified parameters
+9 -7
ファイルの表示
@@ -1,4 +1,5 @@
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Runtime.InteropServices;
using ComputeSharp.Exceptions;
namespace ComputeSharp
@@ -6,38 +7,39 @@ namespace ComputeSharp
/// <summary>
/// A <see langword="struct"/> that maps the int4 HLSL type
/// </summary>
[DebuggerDisplay("({X}, {Y}, {Z}, {W})")]
[StructLayout(LayoutKind.Sequential, Size = sizeof(int) * 4)]
public struct Int4
{
/// <summary>
/// Gets an <see cref="Int4"/> value with all components set to 0
/// </summary>
public static Int4 Zero { get; } = 0;
public static Int4 Zero => 0;
/// <summary>
/// Gets an <see cref="Int4"/> value with all components set to 1
/// </summary>
public static Int4 One { get; } = 1;
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 { get; } = new Int4(1, 0, 0, 0);
public static Int4 UnitX => new Int4(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 { get; } = new Int4(0, 1, 0, 0);
public static Int4 UnitY => new Int4(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 { get; } = new Int4(0, 0, 1, 0);
public static Int4 UnitZ => new Int4(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 { get; } = new Int4(0, 0, 0, 1);
public static Int4 UnitW => new Int4(0, 0, 0, 1);
/// <summary>
/// Creates a new <see cref="Int4"/> instance with the specified parameters
+7 -5
ファイルの表示
@@ -1,4 +1,5 @@
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Runtime.InteropServices;
using ComputeSharp.Exceptions;
namespace ComputeSharp
@@ -6,28 +7,29 @@ namespace ComputeSharp
/// <summary>
/// A <see langword="struct"/> that maps the uint2 HLSL type
/// </summary>
[DebuggerDisplay("({X}, {Y})")]
[StructLayout(LayoutKind.Sequential, Size = sizeof(uint) * 2)]
public struct UInt2
{
/// <summary>
/// Gets an <see cref="UInt2"/> value with all components set to 0
/// </summary>
public static UInt2 Zero { get; } = 0;
public static UInt2 Zero => 0;
/// <summary>
/// Gets an <see cref="UInt2"/> value with all components set to 1
/// </summary>
public static UInt2 One { get; } = 1;
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 { get; } = new UInt2(1, 0);
public static UInt2 UnitX => new UInt2(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 { get; } = new UInt2(0, 1);
public static UInt2 UnitY => new UInt2(0, 1);
/// <summary>
/// Creates a new <see cref="UInt2"/> instance with the specified parameters
+8 -6
ファイルの表示
@@ -1,4 +1,5 @@
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Runtime.InteropServices;
using ComputeSharp.Exceptions;
namespace ComputeSharp
@@ -6,33 +7,34 @@ namespace ComputeSharp
/// <summary>
/// A <see langword="struct"/> that maps the uint3 HLSL type
/// </summary>
[DebuggerDisplay("({X}, {Y}, {Z})")]
[StructLayout(LayoutKind.Sequential, Size = sizeof(uint) * 3)]
public struct UInt3
{
/// <summary>
/// Gets an <see cref="UInt3"/> value with all components set to 0
/// </summary>
public static UInt3 Zero { get; } = 0;
public static UInt3 Zero => 0;
/// <summary>
/// Gets an <see cref="UInt3"/> value with all components set to 1
/// </summary>
public static UInt3 One { get; } = 1;
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 { get; } = new UInt3(1, 0, 0);
public static UInt3 UnitX => new UInt3(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 { get; } = new UInt3(0, 1, 0);
public static UInt3 UnitY => new UInt3(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 { get; } = new UInt3(0, 0, 1);
public static UInt3 UnitZ => new UInt3(0, 0, 1);
/// <summary>
/// Creates a new <see cref="UInt3"/> instance with the specified parameters
+9 -7
ファイルの表示
@@ -1,4 +1,5 @@
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Runtime.InteropServices;
using ComputeSharp.Exceptions;
namespace ComputeSharp
@@ -6,38 +7,39 @@ namespace ComputeSharp
/// <summary>
/// A <see langword="struct"/> that maps the uuint4 HLSL type
/// </summary>
[DebuggerDisplay("({X}, {Y}, {Z}, {W})")]
[StructLayout(LayoutKind.Sequential, Size = sizeof(uint) * 4)]
public struct UInt4
{
/// <summary>
/// Gets an <see cref="UInt4"/> value with all components set to 0
/// </summary>
public static UInt4 Zero { get; } = 0;
public static UInt4 Zero => 0;
/// <summary>
/// Gets an <see cref="UInt4"/> value with all components set to 1
/// </summary>
public static UInt4 One { get; } = 1;
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 { get; } = new UInt4(1, 0, 0, 0);
public static UInt4 UnitX => new UInt4(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 { get; } = new UInt4(0, 1, 0, 0);
public static UInt4 UnitY => new UInt4(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 { get; } = new UInt4(0, 0, 1, 0);
public static UInt4 UnitZ => new UInt4(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 { get; } = new UInt4(0, 0, 0, 1);
public static UInt4 UnitW => new UInt4(0, 0, 0, 1);
/// <summary>
/// Creates a new <see cref="UInt4"/> instance with the specified parameters
-1
ファイルの表示
@@ -1,7 +1,6 @@
using System;
using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using ComputeSharp.Core;
using ComputeSharp.Graphics;
using ComputeSharp.Graphics.Buffers.Abstract;
+3
ファイルの表示
@@ -44,6 +44,9 @@ 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 Bool3 b3: WriteValue(b3, ref r0); break;
case Bool4 b4: WriteValue(b4, 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;
+3 -2
ファイルの表示
@@ -109,9 +109,10 @@ namespace ComputeSharp.Shaders.Extensions
}
// Process the input node if it's a known method invocation
if (HlslKnownMethods.TryGetMappedName(containingMemberSymbolInfo.Symbol, memberSymbol) is string mappedName)
if (HlslKnownMethods.TryGetMappedName(containingMemberSymbolInfo.Symbol, memberSymbol, out string? mappedName))
{
return SyntaxFactory.IdentifierName(mappedName).WithLeadingTrivia(node.GetLeadingTrivia()).WithTrailingTrivia(node.GetTrailingTrivia());
string expression = memberSymbol.IsStatic ? mappedName : $"{node.Expression}{mappedName}";
return SyntaxFactory.IdentifierName(expression).WithLeadingTrivia(node.GetLeadingTrivia()).WithTrailingTrivia(node.GetTrailingTrivia());
}
// Handle static fields as a special case
+26 -10
ファイルの表示
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Reflection;
@@ -128,6 +129,27 @@ namespace ComputeSharp.Shaders.Mappings
["System.Numerics.Vector4.Zero"] = "(float4)0",
["System.Numerics.Vector4.One"] = "float4(1.0f, 1.0f, 1.0f, 1.0f)",
// Bool2
["ComputeSharp.Bool2.False"] = "(bool2)0",
["ComputeSharp.Bool2.True"] = "bool2(true, true)",
["ComputeSharp.Bool2.TrueX"] = "bool2(true, false)",
["ComputeSharp.Bool2.TrueY"] = "bool2(false, true)",
// Bool3
["ComputeSharp.Bool3.False"] = "(bool3)0",
["ComputeSharp.Bool3.True"] = "bool3(true, true, true)",
["ComputeSharp.Bool3.TrueX"] = "bool3(true, false, false)",
["ComputeSharp.Bool3.TrueY"] = "bool3(false, true, false)",
["ComputeSharp.Bool3.TrueZ"] = "bool3(false, false, true)",
// Bool4
["ComputeSharp.Bool4.False"] = "(bool4)0",
["ComputeSharp.Bool4.True"] = "bool4(true, true, true, true)",
["ComputeSharp.Bool4.TrueX"] = "bool4(true, false, false, false)",
["ComputeSharp.Bool4.TrueY"] = "bool4(false, true, false, false)",
["ComputeSharp.Bool4.TrueZ"] = "bool4(false, false, true, false)",
["ComputeSharp.Bool4.TrueW"] = "bool4(false, false, false, true)",
// Int2
["ComputeSharp.Int2.Zero"] = "(int2)0",
["ComputeSharp.Int2.One"] = "int2(1, 1)",
@@ -225,7 +247,7 @@ namespace ComputeSharp.Shaders.Mappings
// Programmatically load mappings for the vector types
foreach (var item in
from type in HlslKnownTypes.KnownVectorTypes
from type in HlslKnownTypes.HlslMappedVectorTypes
from property in type.GetProperties(BindingFlags.Public | BindingFlags.Instance)
select (Type: type, Property: property))
{
@@ -241,21 +263,15 @@ namespace ComputeSharp.Shaders.Mappings
/// </summary>
/// <param name="containingMemberSymbol">The containing member symbol for the method to check</param>
/// <param name="memberSymbol">The symbol for the method to check</param>
/// <param name="mapped">The mapped name, if one is found</param>
/// <returns>The HLSL-compatible method name that can be used in an HLSL shader</returns>
[Pure]
public static string? TryGetMappedName(ISymbol containingMemberSymbol, ISymbol memberSymbol)
public static bool TryGetMappedName(ISymbol containingMemberSymbol, ISymbol memberSymbol, [NotNullWhen(true)] out string? mapped)
{
string fullTypeName = containingMemberSymbol.IsStatic ? containingMemberSymbol.ToString() : memberSymbol.ContainingType.ToString();
// Check if the target method is a known method
if (KnownMethods.TryGetValue($"{fullTypeName}{Type.Delimiter}{memberSymbol.Name}", out string mapped))
{
// Return the static method if possible, otherwise access the parent instance
if (memberSymbol.IsStatic) return mapped;
return $"{containingMemberSymbol.Name}{mapped}";
}
return null;
return KnownMethods.TryGetValue($"{fullTypeName}{Type.Delimiter}{memberSymbol.Name}", out mapped);
}
}
}
+21 -26
ファイルの表示
@@ -17,40 +17,46 @@ namespace ComputeSharp.Shaders.Mappings
private static readonly IReadOnlyDictionary<string, string> KnownTypes = new Dictionary<string, string>
{
[typeof(bool).FullName] = "bool",
[typeof(Bool2).FullName] = "bool2",
[typeof(Bool3).FullName] = "bool3",
[typeof(Bool4).FullName] = "bool4",
[typeof(int).FullName] = "int",
[typeof(uint).FullName] = "uint",
[typeof(float).FullName] = "float",
[typeof(double).FullName] = "double",
[typeof(Vector2).FullName] = "float2",
[typeof(Vector3).FullName] = "float3",
[typeof(Vector4).FullName] = "float4",
[typeof(ThreadIds).FullName] = "uint3",
[typeof(Int2).FullName] = "int2",
[typeof(Int3).FullName] = "int3",
[typeof(Int4).FullName] = "int4",
[typeof(uint).FullName] = "uint",
[typeof(UInt2).FullName] = "uint2",
[typeof(UInt3).FullName] = "uint3",
[typeof(UInt4).FullName] = "uint4",
[typeof(float).FullName] = "float",
[typeof(Float2).FullName] = "float2",
[typeof(Float3).FullName] = "float3",
[typeof(Float4).FullName] = "float4",
[typeof(Vector2).FullName] = "float2",
[typeof(Vector3).FullName] = "float3",
[typeof(Vector4).FullName] = "float4",
[typeof(double).FullName] = "double",
[typeof(Double2).FullName] = "double2",
[typeof(Double3).FullName] = "double3",
[typeof(Double4).FullName] = "double4",
[typeof(ThreadIds).FullName] = "uint3",
[typeof(ReadOnlyBuffer<>).FullName] = "StructuredBuffer",
[typeof(ReadWriteBuffer<>).FullName] = "RWStructuredBuffer"
};
/// <summary>
/// Gets the known HLSL vector types available as mapped types
/// </summary>
public static IReadOnlyList<Type> KnownVectorTypes { get; } = new[]
private static HashSet<Type> _HlslMappedVectorTypes { get; } = new HashSet<Type>(new[]
{
typeof(Bool2), typeof(Bool3), typeof(Bool4),
typeof(Int2), typeof(Int3), typeof(Int4),
typeof(UInt2), typeof(UInt3), typeof(UInt4),
typeof(Float2), typeof(Float3), typeof(Float4),
typeof(Double2), typeof(Double3), typeof(Double4)
};
});
/// <summary>
/// Gets the known HLSL vector types available as mapped types
/// </summary>
public static IReadOnlyCollection<Type> HlslMappedVectorTypes => _HlslMappedVectorTypes;
/// <summary>
/// Checks whether or not the input type is a known scalar type
@@ -70,21 +76,10 @@ namespace ComputeSharp.Shaders.Mappings
/// <param name="type">The input <see cref="Type"/> instance to check</param>
/// <returns>A <see langword="bool"/> indicating whether the input <see cref="Type"/> is in fact a known HLSL vector type</returns>
[Pure]
public static bool IsKnownVectorType(Type type) => type == typeof(Vector2) ||
public static bool IsKnownVectorType(Type type) => _HlslMappedVectorTypes.Contains(type) ||
type == typeof(Vector2) ||
type == typeof(Vector3) ||
type == typeof(Vector4) ||
type == typeof(Int2) ||
type == typeof(Int3) ||
type == typeof(Int4) ||
type == typeof(UInt2) ||
type == typeof(UInt3) ||
type == typeof(UInt4) ||
type == typeof(Float2) ||
type == typeof(Float3) ||
type == typeof(Float4) ||
type == typeof(Double2) ||
type == typeof(Double3) ||
type == typeof(Double4);
type == typeof(Vector4);
/// <summary>
/// Checks whether or not the input type is a <see cref="ConstantBuffer{T}"/> value
+52 -1
ファイルの表示
@@ -8,7 +8,7 @@ namespace ComputeSharp.Tests
public class HlslVectorTypesTests
{
[TestMethod]
public void LocalScalarAssignToBuffer()
public void LocalFloatAssignToFloat2Buffer()
{
Float2 f2 = new Float2(1, 2);
using ReadWriteBuffer<Float2> buffer = Gpu.Default.AllocateReadWriteBuffer<Float2>(1);
@@ -22,5 +22,56 @@ namespace ComputeSharp.Tests
Assert.IsTrue(MathF.Abs(result[0].X - f2.Y) < 0.0001f);
Assert.IsTrue(MathF.Abs(result[0].Y - f2.X) < 0.0001f);
}
[TestMethod]
public void Int2Properties()
{
using ReadWriteBuffer<Int2> buffer = Gpu.Default.AllocateReadWriteBuffer<Int2>(1);
Action<ThreadIds> action = id => buffer[0].X = 1;
Gpu.Default.For(1, action);
Int2[] result = buffer.GetData();
Assert.IsTrue(result[0].X == 1);
}
[TestMethod]
public void LocalBoolAssignToBool2Buffer()
{
Bool2 b2 = Bool2.TrueY;
using ReadWriteBuffer<Bool2> buffer = Gpu.Default.AllocateReadWriteBuffer<Bool2>(1);
Action<ThreadIds> action = id => buffer[0] = b2;
Gpu.Default.For(1, action);
Bool2[] result = buffer.GetData();
Assert.IsTrue(result[0].X == b2.X);
Assert.IsTrue(result[0].Y == b2.Y);
}
[TestMethod]
public void Bool3Operations()
{
using ReadWriteBuffer<Bool3> buffer = Gpu.Default.AllocateReadWriteBuffer<Bool3>(3);
Action<ThreadIds> action = id =>
{
buffer[0] = Bool3.TrueX;
buffer[1] = Bool3.True;
buffer[2].YZ = Bool2.True;
};
Gpu.Default.For(1, action);
Bool3[] result = buffer.GetData();
Assert.IsTrue(result[0].X && !result[0].Y && !result[0].Z);
Assert.IsTrue(result[1].X && result[1].Y && result[1].Z);
Assert.IsTrue(!result[2].X && result[2].Y && result[2].Z);
}
}
}