Merge pull request #77 from Sergio0694/feature/texture3d

Added Texture3D<T> types
このコミットが含まれているのは:
Sergio Pedri authored and GitHub committed 2020-12-07 17:53:15 +01:00
コミット 8dd72da729
52ファイル変更
+3284 -970

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

+18 -6
ファイルの表示
@@ -20,16 +20,28 @@ namespace ComputeSharp
/// 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;
private Bool(bool value)
{
Value = value;
}
/// <inheritdoc/>
public override bool Equals(object? obj) => obj is Bool x && Value == x.Value;
public override bool Equals(object? obj)
{
return obj is Bool x && Value == x.Value;
}
/// <inheritdoc/>
public override int GetHashCode() => Value.GetHashCode();
public override int GetHashCode()
{
return Value.GetHashCode();
}
/// <inheritdoc/>
public override string ToString() => Value.ToString();
public override string ToString()
{
return Value.ToString();
}
/// <summary>
/// Checks whether or not two <see cref="Bool"/> instances represent the same <see cref="bool"/> value.
@@ -49,7 +61,7 @@ namespace ComputeSharp
/// 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 Bool(!x.Value);
public static Bool operator !(Bool x) => new(!x.Value);
/// <summary>
/// Converts a given <see cref="Bool"/> instance to its corresponding <see cref="bool"/> value.
@@ -61,6 +73,6 @@ namespace ComputeSharp
/// 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 Bool(x);
public static implicit operator Bool(bool x) => new(x);
}
}
+3 -3
ファイルの表示
@@ -24,12 +24,12 @@ namespace ComputeSharp
/// <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);
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 Bool2(false, true);
public static Bool2 TrueY => new(false, true);
/// <summary>
/// Creates a new <see cref="Bool2"/> instance with the specified parameters.
@@ -154,6 +154,6 @@ namespace ComputeSharp
/// 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);
public static implicit operator Bool2(bool x) => new(x, x);
}
}
+58 -58
ファイルの表示
@@ -24,17 +24,17 @@ namespace ComputeSharp
/// <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);
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 Bool3(false, true, false);
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 Bool3(false, false, true);
public static Bool3 TrueZ => new(false, false, true);
/// <summary>
/// Creates a new <see cref="Bool3"/> instance with the specified parameters.
@@ -263,32 +263,32 @@ namespace ComputeSharp
/// <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)}");
public Bool3 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)}");
public Bool3 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)}");
public Bool3 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)}");
public Bool3 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)}");
public Bool3 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
public Bool3 XYZ
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(XYZ)}");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(XYZ)}");
@@ -297,12 +297,12 @@ namespace ComputeSharp
/// <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)}");
public Bool3 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
public Bool3 XZY
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(XZY)}");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(XZY)}");
@@ -311,22 +311,22 @@ namespace ComputeSharp
/// <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)}");
public Bool3 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)}");
public Bool3 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)}");
public Bool3 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
public Bool3 YXZ
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(YXZ)}");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(YXZ)}");
@@ -335,22 +335,22 @@ namespace ComputeSharp
/// <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)}");
public Bool3 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)}");
public Bool3 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)}");
public Bool3 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
public Bool3 YZX
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(YZX)}");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(YZX)}");
@@ -359,22 +359,22 @@ namespace ComputeSharp
/// <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)}");
public Bool3 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)}");
public Bool3 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)}");
public Bool3 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
public Bool3 ZXY
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(ZXY)}");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(ZXY)}");
@@ -383,12 +383,12 @@ namespace ComputeSharp
/// <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)}");
public Bool3 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
public Bool3 ZYX
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(ZYX)}");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(ZYX)}");
@@ -397,57 +397,57 @@ namespace ComputeSharp
/// <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)}");
public Bool3 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)}");
public Bool3 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)}");
public Bool3 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)}");
public Bool3 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)}");
public Bool3 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)}");
public Bool3 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)}");
public Bool3 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)}");
public Bool3 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)}");
public Bool3 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)}");
public Bool3 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
public Bool3 RGB
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(RGB)}");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(RGB)}");
@@ -456,12 +456,12 @@ namespace ComputeSharp
/// <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)}");
public Bool3 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
public Bool3 RBG
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(RBG)}");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(RBG)}");
@@ -470,22 +470,22 @@ namespace ComputeSharp
/// <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)}");
public Bool3 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)}");
public Bool3 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)}");
public Bool3 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
public Bool3 GRB
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(GRB)}");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(GRB)}");
@@ -494,22 +494,22 @@ namespace ComputeSharp
/// <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)}");
public Bool3 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)}");
public Bool3 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)}");
public Bool3 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
public Bool3 GBR
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(GBR)}");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(GBR)}");
@@ -518,22 +518,22 @@ namespace ComputeSharp
/// <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)}");
public Bool3 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)}");
public Bool3 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)}");
public Bool3 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
public Bool3 BRG
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(BRG)}");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(BRG)}");
@@ -542,12 +542,12 @@ namespace ComputeSharp
/// <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)}");
public Bool3 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
public Bool3 BGR
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(BGR)}");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(BGR)}");
@@ -556,32 +556,32 @@ namespace ComputeSharp
/// <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)}");
public Bool3 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)}");
public Bool3 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)}");
public Bool3 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)}");
public Bool3 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)}");
public Bool3 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);
public static implicit operator Bool3(bool x) => new(x, x, x);
}
}
+5 -5
ファイルの表示
@@ -24,22 +24,22 @@ namespace ComputeSharp
/// <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 Bool4(true, false, false, false);
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 Bool4(false, true, false, false);
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 Bool4(false, false, true, false);
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 Bool4(false, false, false, true);
public static Bool4 TrueW => new(false, false, false, true);
/// <summary>
/// Creates a new <see cref="Bool4"/> instance with the specified parameters.
@@ -3994,6 +3994,6 @@ namespace ComputeSharp
/// 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 Bool4(x, x, x, x);
public static implicit operator Bool4(bool x) => new(x, x, x, x);
}
}
+3 -3
ファイルの表示
@@ -24,12 +24,12 @@ namespace ComputeSharp
/// <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 Double2(1, 0);
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 Double2(0, 1);
public static Double2 UnitY => new(0, 1);
/// <summary>
/// Creates a new <see cref="Double2"/> instance with the specified parameters.
@@ -140,7 +140,7 @@ namespace ComputeSharp
/// 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 Double2(x, x);
public static implicit operator Double2(double x) => new(x, x);
/// <summary>
/// Sums two <see cref="Double2"/> values.
+58 -58
ファイルの表示
@@ -24,17 +24,17 @@ namespace ComputeSharp
/// <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 Double3(1, 0, 0);
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 Double3(0, 1, 0);
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 Double3(0, 0, 1);
public static Double3 UnitZ => new(0, 0, 1);
/// <summary>
/// Creates a new <see cref="Double3"/> instance with the specified parameters.
@@ -242,32 +242,32 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="X"/> value for all components.
/// </summary>
public Double2 XXX => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(XXX)}");
public Double3 XXX => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(XXX)}");
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="X"/>, <see cref="X"/> and <see cref="Y"/> values.
/// </summary>
public Double2 XXY => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(XXY)}");
public Double3 XXY => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(XXY)}");
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="X"/>, <see cref="X"/> and <see cref="Z"/> values.
/// </summary>
public Double2 XXZ => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(XXZ)}");
public Double3 XXZ => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(XXZ)}");
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="X"/>, <see cref="Y"/> and <see cref="X"/> values.
/// </summary>
public Double2 XYX => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(XYX)}");
public Double3 XYX => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(XYX)}");
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="X"/>, <see cref="Y"/> and <see cref="Y"/> values.
/// </summary>
public Double2 XYY => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(XYY)}");
public Double3 XYY => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(XYY)}");
/// <summary>
/// Gets or sets an <see cref="Double3"/> value with the <see cref="X"/>, <see cref="Y"/> and <see cref="Z"/> values.
/// </summary>
public Double2 XYZ
public Double3 XYZ
{
get => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(XYZ)}");
set => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(XYZ)}");
@@ -276,12 +276,12 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="X"/>, <see cref="Z"/> and <see cref="X"/> values.
/// </summary>
public Double2 XZX => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(XZX)}");
public Double3 XZX => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(XZX)}");
/// <summary>
/// Gets or sets an <see cref="Double3"/> value with the <see cref="X"/>, <see cref="Z"/> and <see cref="Y"/> values.
/// </summary>
public Double2 XZY
public Double3 XZY
{
get => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(XZY)}");
set => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(XZY)}");
@@ -290,22 +290,22 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="X"/>, <see cref="Z"/> and <see cref="Z"/> values.
/// </summary>
public Double2 XZZ => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(XZZ)}");
public Double3 XZZ => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(XZZ)}");
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="Y"/>, <see cref="X"/> and <see cref="X"/> values.
/// </summary>
public Double2 YXX => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(YXX)}");
public Double3 YXX => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(YXX)}");
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="Y"/>, <see cref="X"/> and <see cref="Y"/> values.
/// </summary>
public Double2 YXY => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(YXY)}");
public Double3 YXY => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(YXY)}");
/// <summary>
/// Gets or sets an <see cref="Double3"/> value with the <see cref="Y"/>, <see cref="X"/> and <see cref="Z"/> values.
/// </summary>
public Double2 YXZ
public Double3 YXZ
{
get => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(YXZ)}");
set => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(YXZ)}");
@@ -314,22 +314,22 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="Y"/>, <see cref="Y"/> and <see cref="X"/> values.
/// </summary>
public Double2 YYX => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(YYX)}");
public Double3 YYX => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(YYX)}");
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="Y"/> value for all components.
/// </summary>
public Double2 YYY => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(YYY)}");
public Double3 YYY => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(YYY)}");
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="Y"/>, <see cref="Y"/> and <see cref="Z"/> values.
/// </summary>
public Double2 YYZ => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(YYZ)}");
public Double3 YYZ => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(YYZ)}");
/// <summary>
/// Gets or sets an <see cref="Double3"/> value with the <see cref="Y"/>, <see cref="Z"/> and <see cref="X"/> values.
/// </summary>
public Double2 YZX
public Double3 YZX
{
get => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(YZX)}");
set => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(YZX)}");
@@ -338,22 +338,22 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="Y"/>, <see cref="Z"/> and <see cref="Y"/> values.
/// </summary>
public Double2 YZY => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(YZY)}");
public Double3 YZY => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(YZY)}");
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="Y"/>, <see cref="Z"/> and <see cref="Z"/> values.
/// </summary>
public Double2 YZZ => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(YZZ)}");
public Double3 YZZ => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(YZZ)}");
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="Z"/>, <see cref="Z"/> and <see cref="Z"/> values.
/// </summary>
public Double2 ZXX => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(ZXX)}");
public Double3 ZXX => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(ZXX)}");
/// <summary>
/// Gets or sets an <see cref="Double3"/> value with the <see cref="Z"/>, <see cref="X"/> and <see cref="Y"/> values.
/// </summary>
public Double2 ZXY
public Double3 ZXY
{
get => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(ZXY)}");
set => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(ZXY)}");
@@ -362,12 +362,12 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="Z"/>, <see cref="X"/> and <see cref="Z"/> values.
/// </summary>
public Double2 ZXZ => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(ZXZ)}");
public Double3 ZXZ => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(ZXZ)}");
/// <summary>
/// Gets or sets an <see cref="Double3"/> value with the <see cref="Z"/>, <see cref="Y"/> and <see cref="X"/> values.
/// </summary>
public Double2 ZYX
public Double3 ZYX
{
get => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(ZYX)}");
set => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(ZYX)}");
@@ -376,57 +376,57 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="Z"/>, <see cref="Y"/> and <see cref="Y"/> values.
/// </summary>
public Double2 ZYY => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(ZYY)}");
public Double3 ZYY => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(ZYY)}");
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="Z"/>, <see cref="Y"/> and <see cref="Z"/> values.
/// </summary>
public Double2 ZYZ => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(ZYZ)}");
public Double3 ZYZ => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(ZYZ)}");
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="Z"/>, <see cref="Z"/> and <see cref="X"/> values.
/// </summary>
public Double2 ZZX => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(ZZX)}");
public Double3 ZZX => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(ZZX)}");
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="Z"/>, <see cref="Z"/> and <see cref="Y"/> values.
/// </summary>
public Double2 ZZY => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(ZZY)}");
public Double3 ZZY => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(ZZY)}");
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="Z"/> value for all components.
/// </summary>
public Double2 ZZZ => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(ZZZ)}");
public Double3 ZZZ => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(ZZZ)}");
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="R"/> value for all components.
/// </summary>
public Double2 RRR => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(RRR)}");
public Double3 RRR => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(RRR)}");
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="R"/>, <see cref="R"/> and <see cref="G"/> values.
/// </summary>
public Double2 RRG => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(RRG)}");
public Double3 RRG => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(RRG)}");
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="R"/>, <see cref="R"/> and <see cref="B"/> values.
/// </summary>
public Double2 RRB => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(RRB)}");
public Double3 RRB => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(RRB)}");
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="R"/>, <see cref="G"/> and <see cref="R"/> values.
/// </summary>
public Double2 RGR => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(RGR)}");
public Double3 RGR => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(RGR)}");
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="R"/>, <see cref="G"/> and <see cref="G"/> values.
/// </summary>
public Double2 RGG => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(RGG)}");
public Double3 RGG => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(RGG)}");
/// <summary>
/// Gets or sets an <see cref="Double3"/> value with the <see cref="R"/>, <see cref="G"/> and <see cref="B"/> values.
/// </summary>
public Double2 RGB
public Double3 RGB
{
get => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(RGB)}");
set => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(RGB)}");
@@ -435,12 +435,12 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="R"/>, <see cref="B"/> and <see cref="R"/> values.
/// </summary>
public Double2 RBR => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(RBR)}");
public Double3 RBR => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(RBR)}");
/// <summary>
/// Gets or sets an <see cref="Double3"/> value with the <see cref="R"/>, <see cref="B"/> and <see cref="G"/> values.
/// </summary>
public Double2 RBG
public Double3 RBG
{
get => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(RBG)}");
set => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(RBG)}");
@@ -449,22 +449,22 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="R"/>, <see cref="B"/> and <see cref="B"/> values.
/// </summary>
public Double2 RBB => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(RBB)}");
public Double3 RBB => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(RBB)}");
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="G"/>, <see cref="R"/> and <see cref="R"/> values.
/// </summary>
public Double2 GRR => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(GRR)}");
public Double3 GRR => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(GRR)}");
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="G"/>, <see cref="R"/> and <see cref="G"/> values.
/// </summary>
public Double2 GRG => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(GRG)}");
public Double3 GRG => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(GRG)}");
/// <summary>
/// Gets or sets an <see cref="Double3"/> value with the <see cref="G"/>, <see cref="R"/> and <see cref="B"/> values.
/// </summary>
public Double2 GRB
public Double3 GRB
{
get => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(GRB)}");
set => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(GRB)}");
@@ -473,22 +473,22 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="G"/>, <see cref="G"/> and <see cref="R"/> values.
/// </summary>
public Double2 GGR => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(GGR)}");
public Double3 GGR => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(GGR)}");
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="G"/> value for all components.
/// </summary>
public Double2 GGG => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(GGG)}");
public Double3 GGG => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(GGG)}");
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="G"/>, <see cref="G"/> and <see cref="B"/> values.
/// </summary>
public Double2 GGB => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(GGB)}");
public Double3 GGB => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(GGB)}");
/// <summary>
/// Gets or sets an <see cref="Double3"/> value with the <see cref="G"/>, <see cref="B"/> and <see cref="R"/> values.
/// </summary>
public Double2 GBR
public Double3 GBR
{
get => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(GBR)}");
set => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(GBR)}");
@@ -497,22 +497,22 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="G"/>, <see cref="B"/> and <see cref="G"/> values.
/// </summary>
public Double2 GBG => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(GBG)}");
public Double3 GBG => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(GBG)}");
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="G"/>, <see cref="B"/> and <see cref="B"/> values.
/// </summary>
public Double2 GBB => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(GBB)}");
public Double3 GBB => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(GBB)}");
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="B"/>, <see cref="B"/> and <see cref="B"/> values.
/// </summary>
public Double2 BRR => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(BRR)}");
public Double3 BRR => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(BRR)}");
/// <summary>
/// Gets or sets an <see cref="Double3"/> value with the <see cref="B"/>, <see cref="R"/> and <see cref="G"/> values.
/// </summary>
public Double2 BRG
public Double3 BRG
{
get => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(BRG)}");
set => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(BRG)}");
@@ -521,12 +521,12 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="B"/>, <see cref="R"/> and <see cref="B"/> values.
/// </summary>
public Double2 BRB => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(BRB)}");
public Double3 BRB => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(BRB)}");
/// <summary>
/// Gets or sets an <see cref="Double3"/> value with the <see cref="B"/>, <see cref="G"/> and <see cref="R"/> values.
/// </summary>
public Double2 BGR
public Double3 BGR
{
get => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(BGR)}");
set => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(BGR)}");
@@ -535,33 +535,33 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="B"/>, <see cref="G"/> and <see cref="G"/> values.
/// </summary>
public Double2 BGG => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(BGG)}");
public Double3 BGG => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(BGG)}");
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="B"/>, <see cref="G"/> and <see cref="B"/> values.
/// </summary>
public Double2 BGB => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(BGB)}");
public Double3 BGB => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(BGB)}");
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="B"/>, <see cref="B"/> and <see cref="R"/> values.
/// </summary>
public Double2 BBR => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(BBR)}");
public Double3 BBR => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(BBR)}");
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="B"/>, <see cref="B"/> and <see cref="G"/> values.
/// </summary>
public Double2 BBG => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(BBG)}");
public Double3 BBG => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(BBG)}");
/// <summary>
/// Gets an <see cref="Double3"/> value with the <see cref="B"/> value for all components.
/// </summary>
public Double2 BBB => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(BBB)}");
public Double3 BBB => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(BBB)}");
/// <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 Double3(x, x, x);
public static implicit operator Double3(double x) => new(x, x, x);
/// <summary>
/// Sums two <see cref="Double3"/> values.
+5 -5
ファイルの表示
@@ -24,22 +24,22 @@ namespace ComputeSharp
/// <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 Double4(1, 0, 0, 0);
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 Double4(0, 1, 0, 0);
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 Double4(0, 0, 1, 0);
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 Double4(0, 0, 0, 1);
public static Double4 UnitW => new(0, 0, 0, 1);
/// <summary>
/// Creates a new <see cref="Double4"/> instance with the specified parameters.
@@ -3966,7 +3966,7 @@ namespace ComputeSharp
/// 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 Double4(x, x, x, x);
public static implicit operator Double4(double x) => new(x, x, x, x);
/// <summary>
/// Sums two <see cref="Double4"/> values.
+3 -3
ファイルの表示
@@ -24,12 +24,12 @@ namespace ComputeSharp
/// <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 Float2(1, 0);
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 Float2(0, 1);
public static Float2 UnitY => new(0, 1);
/// <summary>
/// Creates a new <see cref="Float2"/> instance with the specified parameters.
@@ -140,7 +140,7 @@ namespace ComputeSharp
/// 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 Float2(x, x);
public static implicit operator Float2(float x) => new(x, x);
/// <summary>
/// Sums two <see cref="Float2"/> values.
+58 -58
ファイルの表示
@@ -24,17 +24,17 @@ namespace ComputeSharp
/// <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 Float3(1, 0, 0);
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 Float3(0, 1, 0);
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 Float3(0, 0, 1);
public static Float3 UnitZ => new(0, 0, 1);
/// <summary>
/// Creates a new <see cref="Float3"/> instance with the specified parameters.
@@ -242,32 +242,32 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="X"/> value for all components.
/// </summary>
public Float2 XXX => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(XXX)}");
public Float3 XXX => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(XXX)}");
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="X"/>, <see cref="X"/> and <see cref="Y"/> values.
/// </summary>
public Float2 XXY => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(XXY)}");
public Float3 XXY => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(XXY)}");
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="X"/>, <see cref="X"/> and <see cref="Z"/> values.
/// </summary>
public Float2 XXZ => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(XXZ)}");
public Float3 XXZ => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(XXZ)}");
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="X"/>, <see cref="Y"/> and <see cref="X"/> values.
/// </summary>
public Float2 XYX => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(XYX)}");
public Float3 XYX => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(XYX)}");
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="X"/>, <see cref="Y"/> and <see cref="Y"/> values.
/// </summary>
public Float2 XYY => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(XYY)}");
public Float3 XYY => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(XYY)}");
/// <summary>
/// Gets or sets an <see cref="Float3"/> value with the <see cref="X"/>, <see cref="Y"/> and <see cref="Z"/> values.
/// </summary>
public Float2 XYZ
public Float3 XYZ
{
get => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(XYZ)}");
set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(XYZ)}");
@@ -276,12 +276,12 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="X"/>, <see cref="Z"/> and <see cref="X"/> values.
/// </summary>
public Float2 XZX => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(XZX)}");
public Float3 XZX => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(XZX)}");
/// <summary>
/// Gets or sets an <see cref="Float3"/> value with the <see cref="X"/>, <see cref="Z"/> and <see cref="Y"/> values.
/// </summary>
public Float2 XZY
public Float3 XZY
{
get => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(XZY)}");
set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(XZY)}");
@@ -290,22 +290,22 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="X"/>, <see cref="Z"/> and <see cref="Z"/> values.
/// </summary>
public Float2 XZZ => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(XZZ)}");
public Float3 XZZ => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(XZZ)}");
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="Y"/>, <see cref="X"/> and <see cref="X"/> values.
/// </summary>
public Float2 YXX => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(YXX)}");
public Float3 YXX => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(YXX)}");
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="Y"/>, <see cref="X"/> and <see cref="Y"/> values.
/// </summary>
public Float2 YXY => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(YXY)}");
public Float3 YXY => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(YXY)}");
/// <summary>
/// Gets or sets an <see cref="Float3"/> value with the <see cref="Y"/>, <see cref="X"/> and <see cref="Z"/> values.
/// </summary>
public Float2 YXZ
public Float3 YXZ
{
get => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(YXZ)}");
set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(YXZ)}");
@@ -314,22 +314,22 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="Y"/>, <see cref="Y"/> and <see cref="X"/> values.
/// </summary>
public Float2 YYX => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(YYX)}");
public Float3 YYX => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(YYX)}");
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="Y"/> value for all components.
/// </summary>
public Float2 YYY => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(YYY)}");
public Float3 YYY => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(YYY)}");
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="Y"/>, <see cref="Y"/> and <see cref="Z"/> values.
/// </summary>
public Float2 YYZ => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(YYZ)}");
public Float3 YYZ => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(YYZ)}");
/// <summary>
/// Gets or sets an <see cref="Float3"/> value with the <see cref="Y"/>, <see cref="Z"/> and <see cref="X"/> values.
/// </summary>
public Float2 YZX
public Float3 YZX
{
get => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(YZX)}");
set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(YZX)}");
@@ -338,22 +338,22 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="Y"/>, <see cref="Z"/> and <see cref="Y"/> values.
/// </summary>
public Float2 YZY => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(YZY)}");
public Float3 YZY => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(YZY)}");
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="Y"/>, <see cref="Z"/> and <see cref="Z"/> values.
/// </summary>
public Float2 YZZ => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(YZZ)}");
public Float3 YZZ => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(YZZ)}");
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="Z"/>, <see cref="Z"/> and <see cref="Z"/> values.
/// </summary>
public Float2 ZXX => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(ZXX)}");
public Float3 ZXX => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(ZXX)}");
/// <summary>
/// Gets or sets an <see cref="Float3"/> value with the <see cref="Z"/>, <see cref="X"/> and <see cref="Y"/> values.
/// </summary>
public Float2 ZXY
public Float3 ZXY
{
get => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(ZXY)}");
set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(ZXY)}");
@@ -362,12 +362,12 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="Z"/>, <see cref="X"/> and <see cref="Z"/> values.
/// </summary>
public Float2 ZXZ => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(ZXZ)}");
public Float3 ZXZ => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(ZXZ)}");
/// <summary>
/// Gets or sets an <see cref="Float3"/> value with the <see cref="Z"/>, <see cref="Y"/> and <see cref="X"/> values.
/// </summary>
public Float2 ZYX
public Float3 ZYX
{
get => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(ZYX)}");
set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(ZYX)}");
@@ -376,57 +376,57 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="Z"/>, <see cref="Y"/> and <see cref="Y"/> values.
/// </summary>
public Float2 ZYY => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(ZYY)}");
public Float3 ZYY => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(ZYY)}");
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="Z"/>, <see cref="Y"/> and <see cref="Z"/> values.
/// </summary>
public Float2 ZYZ => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(ZYZ)}");
public Float3 ZYZ => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(ZYZ)}");
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="Z"/>, <see cref="Z"/> and <see cref="X"/> values.
/// </summary>
public Float2 ZZX => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(ZZX)}");
public Float3 ZZX => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(ZZX)}");
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="Z"/>, <see cref="Z"/> and <see cref="Y"/> values.
/// </summary>
public Float2 ZZY => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(ZZY)}");
public Float3 ZZY => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(ZZY)}");
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="Z"/> value for all components.
/// </summary>
public Float2 ZZZ => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(ZZZ)}");
public Float3 ZZZ => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(ZZZ)}");
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="R"/> value for all components.
/// </summary>
public Float2 RRR => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(RRR)}");
public Float3 RRR => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(RRR)}");
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="R"/>, <see cref="R"/> and <see cref="G"/> values.
/// </summary>
public Float2 RRG => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(RRG)}");
public Float3 RRG => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(RRG)}");
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="R"/>, <see cref="R"/> and <see cref="B"/> values.
/// </summary>
public Float2 RRB => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(RRB)}");
public Float3 RRB => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(RRB)}");
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="R"/>, <see cref="G"/> and <see cref="R"/> values.
/// </summary>
public Float2 RGR => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(RGR)}");
public Float3 RGR => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(RGR)}");
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="R"/>, <see cref="G"/> and <see cref="G"/> values.
/// </summary>
public Float2 RGG => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(RGG)}");
public Float3 RGG => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(RGG)}");
/// <summary>
/// Gets or sets an <see cref="Float3"/> value with the <see cref="R"/>, <see cref="G"/> and <see cref="B"/> values.
/// </summary>
public Float2 RGB
public Float3 RGB
{
get => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(RGB)}");
set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(RGB)}");
@@ -435,12 +435,12 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="R"/>, <see cref="B"/> and <see cref="R"/> values.
/// </summary>
public Float2 RBR => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(RBR)}");
public Float3 RBR => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(RBR)}");
/// <summary>
/// Gets or sets an <see cref="Float3"/> value with the <see cref="R"/>, <see cref="B"/> and <see cref="G"/> values.
/// </summary>
public Float2 RBG
public Float3 RBG
{
get => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(RBG)}");
set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(RBG)}");
@@ -449,22 +449,22 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="R"/>, <see cref="B"/> and <see cref="B"/> values.
/// </summary>
public Float2 RBB => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(RBB)}");
public Float3 RBB => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(RBB)}");
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="G"/>, <see cref="R"/> and <see cref="R"/> values.
/// </summary>
public Float2 GRR => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(GRR)}");
public Float3 GRR => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(GRR)}");
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="G"/>, <see cref="R"/> and <see cref="G"/> values.
/// </summary>
public Float2 GRG => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(GRG)}");
public Float3 GRG => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(GRG)}");
/// <summary>
/// Gets or sets an <see cref="Float3"/> value with the <see cref="G"/>, <see cref="R"/> and <see cref="B"/> values.
/// </summary>
public Float2 GRB
public Float3 GRB
{
get => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(GRB)}");
set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(GRB)}");
@@ -473,22 +473,22 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="G"/>, <see cref="G"/> and <see cref="R"/> values.
/// </summary>
public Float2 GGR => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(GGR)}");
public Float3 GGR => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(GGR)}");
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="G"/> value for all components.
/// </summary>
public Float2 GGG => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(GGG)}");
public Float3 GGG => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(GGG)}");
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="G"/>, <see cref="G"/> and <see cref="B"/> values.
/// </summary>
public Float2 GGB => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(GGB)}");
public Float3 GGB => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(GGB)}");
/// <summary>
/// Gets or sets an <see cref="Float3"/> value with the <see cref="G"/>, <see cref="B"/> and <see cref="R"/> values.
/// </summary>
public Float2 GBR
public Float3 GBR
{
get => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(GBR)}");
set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(GBR)}");
@@ -497,22 +497,22 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="G"/>, <see cref="B"/> and <see cref="G"/> values.
/// </summary>
public Float2 GBG => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(GBG)}");
public Float3 GBG => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(GBG)}");
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="G"/>, <see cref="B"/> and <see cref="B"/> values.
/// </summary>
public Float2 GBB => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(GBB)}");
public Float3 GBB => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(GBB)}");
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="B"/>, <see cref="B"/> and <see cref="B"/> values.
/// </summary>
public Float2 BRR => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(BRR)}");
public Float3 BRR => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(BRR)}");
/// <summary>
/// Gets or sets an <see cref="Float3"/> value with the <see cref="B"/>, <see cref="R"/> and <see cref="G"/> values.
/// </summary>
public Float2 BRG
public Float3 BRG
{
get => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(BRG)}");
set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(BRG)}");
@@ -521,12 +521,12 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="B"/>, <see cref="R"/> and <see cref="B"/> values.
/// </summary>
public Float2 BRB => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(BRB)}");
public Float3 BRB => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(BRB)}");
/// <summary>
/// Gets or sets an <see cref="Float3"/> value with the <see cref="B"/>, <see cref="G"/> and <see cref="R"/> values.
/// </summary>
public Float2 BGR
public Float3 BGR
{
get => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(BGR)}");
set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(BGR)}");
@@ -535,33 +535,33 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="B"/>, <see cref="G"/> and <see cref="G"/> values.
/// </summary>
public Float2 BGG => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(BGG)}");
public Float3 BGG => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(BGG)}");
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="B"/>, <see cref="G"/> and <see cref="B"/> values.
/// </summary>
public Float2 BGB => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(BGB)}");
public Float3 BGB => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(BGB)}");
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="B"/>, <see cref="B"/> and <see cref="R"/> values.
/// </summary>
public Float2 BBR => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(BBR)}");
public Float3 BBR => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(BBR)}");
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="B"/>, <see cref="B"/> and <see cref="G"/> values.
/// </summary>
public Float2 BBG => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(BBG)}");
public Float3 BBG => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(BBG)}");
/// <summary>
/// Gets an <see cref="Float3"/> value with the <see cref="B"/> value for all components.
/// </summary>
public Float2 BBB => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(BBB)}");
public Float3 BBB => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(BBB)}");
/// <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 Float3(x, x, x);
public static implicit operator Float3(float x) => new(x, x, x);
/// <summary>
/// Sums two <see cref="Float3"/> values.
+5 -5
ファイルの表示
@@ -24,22 +24,22 @@ namespace ComputeSharp
/// <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 Float4(1, 0, 0, 0);
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 Float4(0, 1, 0, 0);
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 Float4(0, 0, 1, 0);
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 Float4(0, 0, 0, 1);
public static Float4 UnitW => new(0, 0, 0, 1);
/// <summary>
/// Creates a new <see cref="Float4"/> instance with the specified parameters.
@@ -3966,7 +3966,7 @@ namespace ComputeSharp
/// 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 Float4(x, x, x, x);
public static implicit operator Float4(float x) => new(x, x, x, x);
/// <summary>
/// Sums two <see cref="Float4"/> values.
+3 -3
ファイルの表示
@@ -24,12 +24,12 @@ namespace ComputeSharp
/// <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 Int2(1, 0);
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 Int2(0, 1);
public static Int2 UnitY => new(0, 1);
/// <summary>
/// Creates a new <see cref="Int2"/> instance with the specified parameters.
@@ -140,7 +140,7 @@ namespace ComputeSharp
/// 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 Int2(x, x);
public static implicit operator Int2(int x) => new(x, x);
/// <summary>
/// Sums two <see cref="Int2"/> values.
+58 -58
ファイルの表示
@@ -24,17 +24,17 @@ namespace ComputeSharp
/// <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 Int3(1, 0, 0);
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 Int3(0, 1, 0);
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 Int3(0, 0, 1);
public static Int3 UnitZ => new(0, 0, 1);
/// <summary>
/// Creates a new <see cref="Int3"/> instance with the specified parameters.
@@ -242,32 +242,32 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="X"/> value for all components.
/// </summary>
public Int2 XXX => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(XXX)}");
public Int3 XXX => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(XXX)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="X"/> and <see cref="Y"/> values.
/// </summary>
public Int2 XXY => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(XXY)}");
public Int3 XXY => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(XXY)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="X"/> and <see cref="Z"/> values.
/// </summary>
public Int2 XXZ => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(XXZ)}");
public Int3 XXZ => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(XXZ)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="Y"/> and <see cref="X"/> values.
/// </summary>
public Int2 XYX => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(XYX)}");
public Int3 XYX => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(XYX)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="Y"/> and <see cref="Y"/> values.
/// </summary>
public Int2 XYY => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(XYY)}");
public Int3 XYY => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(XYY)}");
/// <summary>
/// Gets or sets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="Y"/> and <see cref="Z"/> values.
/// </summary>
public Int2 XYZ
public Int3 XYZ
{
get => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(XYZ)}");
set => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(XYZ)}");
@@ -276,12 +276,12 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="Z"/> and <see cref="X"/> values.
/// </summary>
public Int2 XZX => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(XZX)}");
public Int3 XZX => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(XZX)}");
/// <summary>
/// Gets or sets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="Z"/> and <see cref="Y"/> values.
/// </summary>
public Int2 XZY
public Int3 XZY
{
get => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(XZY)}");
set => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(XZY)}");
@@ -290,22 +290,22 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="Z"/> and <see cref="Z"/> values.
/// </summary>
public Int2 XZZ => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(XZZ)}");
public Int3 XZZ => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(XZZ)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="X"/> and <see cref="X"/> values.
/// </summary>
public Int2 YXX => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(YXX)}");
public Int3 YXX => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(YXX)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="X"/> and <see cref="Y"/> values.
/// </summary>
public Int2 YXY => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(YXY)}");
public Int3 YXY => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(YXY)}");
/// <summary>
/// Gets or sets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="X"/> and <see cref="Z"/> values.
/// </summary>
public Int2 YXZ
public Int3 YXZ
{
get => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(YXZ)}");
set => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(YXZ)}");
@@ -314,22 +314,22 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="Y"/> and <see cref="X"/> values.
/// </summary>
public Int2 YYX => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(YYX)}");
public Int3 YYX => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(YYX)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/> value for all components.
/// </summary>
public Int2 YYY => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(YYY)}");
public Int3 YYY => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(YYY)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="Y"/> and <see cref="Z"/> values.
/// </summary>
public Int2 YYZ => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(YYZ)}");
public Int3 YYZ => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(YYZ)}");
/// <summary>
/// Gets or sets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="Z"/> and <see cref="X"/> values.
/// </summary>
public Int2 YZX
public Int3 YZX
{
get => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(YZX)}");
set => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(YZX)}");
@@ -338,22 +338,22 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="Z"/> and <see cref="Y"/> values.
/// </summary>
public Int2 YZY => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(YZY)}");
public Int3 YZY => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(YZY)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="Z"/> and <see cref="Z"/> values.
/// </summary>
public Int2 YZZ => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(YZZ)}");
public Int3 YZZ => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(YZZ)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="Z"/> and <see cref="Z"/> values.
/// </summary>
public Int2 ZXX => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(ZXX)}");
public Int3 ZXX => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(ZXX)}");
/// <summary>
/// Gets or sets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="X"/> and <see cref="Y"/> values.
/// </summary>
public Int2 ZXY
public Int3 ZXY
{
get => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(ZXY)}");
set => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(ZXY)}");
@@ -362,12 +362,12 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="X"/> and <see cref="Z"/> values.
/// </summary>
public Int2 ZXZ => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(ZXZ)}");
public Int3 ZXZ => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(ZXZ)}");
/// <summary>
/// Gets or sets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="Y"/> and <see cref="X"/> values.
/// </summary>
public Int2 ZYX
public Int3 ZYX
{
get => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(ZYX)}");
set => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(ZYX)}");
@@ -376,57 +376,57 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="Y"/> and <see cref="Y"/> values.
/// </summary>
public Int2 ZYY => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(ZYY)}");
public Int3 ZYY => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(ZYY)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="Y"/> and <see cref="Z"/> values.
/// </summary>
public Int2 ZYZ => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(ZYZ)}");
public Int3 ZYZ => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(ZYZ)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="Z"/> and <see cref="X"/> values.
/// </summary>
public Int2 ZZX => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(ZZX)}");
public Int3 ZZX => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(ZZX)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="Z"/> and <see cref="Y"/> values.
/// </summary>
public Int2 ZZY => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(ZZY)}");
public Int3 ZZY => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(ZZY)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/> value for all components.
/// </summary>
public Int2 ZZZ => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(ZZZ)}");
public Int3 ZZZ => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(ZZZ)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="R"/> value for all components.
/// </summary>
public Int2 RRR => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(RRR)}");
public Int3 RRR => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(RRR)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="R"/>, <see cref="R"/> and <see cref="G"/> values.
/// </summary>
public Int2 RRG => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(RRG)}");
public Int3 RRG => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(RRG)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="R"/>, <see cref="R"/> and <see cref="B"/> values.
/// </summary>
public Int2 RRB => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(RRB)}");
public Int3 RRB => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(RRB)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="R"/>, <see cref="G"/> and <see cref="R"/> values.
/// </summary>
public Int2 RGR => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(RGR)}");
public Int3 RGR => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(RGR)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="R"/>, <see cref="G"/> and <see cref="G"/> values.
/// </summary>
public Int2 RGG => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(RGG)}");
public Int3 RGG => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(RGG)}");
/// <summary>
/// Gets or sets an <see cref="Int3"/> value with the <see cref="R"/>, <see cref="G"/> and <see cref="B"/> values.
/// </summary>
public Int2 RGB
public Int3 RGB
{
get => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(RGB)}");
set => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(RGB)}");
@@ -435,12 +435,12 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="R"/>, <see cref="B"/> and <see cref="R"/> values.
/// </summary>
public Int2 RBR => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(RBR)}");
public Int3 RBR => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(RBR)}");
/// <summary>
/// Gets or sets an <see cref="Int3"/> value with the <see cref="R"/>, <see cref="B"/> and <see cref="G"/> values.
/// </summary>
public Int2 RBG
public Int3 RBG
{
get => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(RBG)}");
set => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(RBG)}");
@@ -449,22 +449,22 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="R"/>, <see cref="B"/> and <see cref="B"/> values.
/// </summary>
public Int2 RBB => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(RBB)}");
public Int3 RBB => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(RBB)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="G"/>, <see cref="R"/> and <see cref="R"/> values.
/// </summary>
public Int2 GRR => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(GRR)}");
public Int3 GRR => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(GRR)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="G"/>, <see cref="R"/> and <see cref="G"/> values.
/// </summary>
public Int2 GRG => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(GRG)}");
public Int3 GRG => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(GRG)}");
/// <summary>
/// Gets or sets an <see cref="Int3"/> value with the <see cref="G"/>, <see cref="R"/> and <see cref="B"/> values.
/// </summary>
public Int2 GRB
public Int3 GRB
{
get => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(GRB)}");
set => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(GRB)}");
@@ -473,22 +473,22 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="G"/>, <see cref="G"/> and <see cref="R"/> values.
/// </summary>
public Int2 GGR => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(GGR)}");
public Int3 GGR => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(GGR)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="G"/> value for all components.
/// </summary>
public Int2 GGG => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(GGG)}");
public Int3 GGG => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(GGG)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="G"/>, <see cref="G"/> and <see cref="B"/> values.
/// </summary>
public Int2 GGB => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(GGB)}");
public Int3 GGB => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(GGB)}");
/// <summary>
/// Gets or sets an <see cref="Int3"/> value with the <see cref="G"/>, <see cref="B"/> and <see cref="R"/> values.
/// </summary>
public Int2 GBR
public Int3 GBR
{
get => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(GBR)}");
set => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(GBR)}");
@@ -497,22 +497,22 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="G"/>, <see cref="B"/> and <see cref="G"/> values.
/// </summary>
public Int2 GBG => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(GBG)}");
public Int3 GBG => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(GBG)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="G"/>, <see cref="B"/> and <see cref="B"/> values.
/// </summary>
public Int2 GBB => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(GBB)}");
public Int3 GBB => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(GBB)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="B"/>, <see cref="B"/> and <see cref="B"/> values.
/// </summary>
public Int2 BRR => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(BRR)}");
public Int3 BRR => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(BRR)}");
/// <summary>
/// Gets or sets an <see cref="Int3"/> value with the <see cref="B"/>, <see cref="R"/> and <see cref="G"/> values.
/// </summary>
public Int2 BRG
public Int3 BRG
{
get => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(BRG)}");
set => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(BRG)}");
@@ -521,12 +521,12 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="B"/>, <see cref="R"/> and <see cref="B"/> values.
/// </summary>
public Int2 BRB => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(BRB)}");
public Int3 BRB => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(BRB)}");
/// <summary>
/// Gets or sets an <see cref="Int3"/> value with the <see cref="B"/>, <see cref="G"/> and <see cref="R"/> values.
/// </summary>
public Int2 BGR
public Int3 BGR
{
get => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(BGR)}");
set => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(BGR)}");
@@ -535,33 +535,33 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="B"/>, <see cref="G"/> and <see cref="G"/> values.
/// </summary>
public Int2 BGG => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(BGG)}");
public Int3 BGG => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(BGG)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="B"/>, <see cref="G"/> and <see cref="B"/> values.
/// </summary>
public Int2 BGB => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(BGB)}");
public Int3 BGB => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(BGB)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="B"/>, <see cref="B"/> and <see cref="R"/> values.
/// </summary>
public Int2 BBR => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(BBR)}");
public Int3 BBR => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(BBR)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="B"/>, <see cref="B"/> and <see cref="G"/> values.
/// </summary>
public Int2 BBG => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(BBG)}");
public Int3 BBG => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(BBG)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="B"/> value for all components.
/// </summary>
public Int2 BBB => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(BBB)}");
public Int3 BBB => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(BBB)}");
/// <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 Int3(x, x, x);
public static implicit operator Int3(int x) => new(x, x, x);
/// <summary>
/// Sums two <see cref="Int3"/> values.
+5 -5
ファイルの表示
@@ -24,22 +24,22 @@ namespace ComputeSharp
/// <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 Int4(1, 0, 0, 0);
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 Int4(0, 1, 0, 0);
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 Int4(0, 0, 1, 0);
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 Int4(0, 0, 0, 1);
public static Int4 UnitW => new(0, 0, 0, 1);
/// <summary>
/// Creates a new <see cref="Int4"/> instance with the specified parameters.
@@ -3966,7 +3966,7 @@ namespace ComputeSharp
/// 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 Int4(x, x, x, x);
public static implicit operator Int4(int x) => new(x, x, x, x);
/// <summary>
/// Sums two <see cref="Int4"/> values.
+181 -1
ファイルの表示
@@ -5,7 +5,7 @@ namespace ComputeSharp
/// <summary>
/// A <see langword="struct"/> that indicates the ids of a given GPU thread running a compute shader.
/// </summary>
public readonly struct ThreadIds
public readonly ref struct ThreadIds
{
/// <summary>
/// Gets the X id of the current thread.
@@ -21,5 +21,185 @@ namespace ComputeSharp
/// Gets the Z id of the current thread.
/// </summary>
public int Z => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(Z)}");
/// <summary>
/// Gets an <see cref="Int2"/> value with the <see cref="X"/> value for all components.
/// </summary>
public Int2 XX => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(XX)}");
/// <summary>
/// Gets or sets an <see cref="Int2"/> value with the <see cref="X"/> and <see cref="Y"/> values.
/// </summary>
public Int2 XY => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(XY)}");
/// <summary>
/// Gets or sets an <see cref="Int2"/> value with the <see cref="X"/> and <see cref="Z"/> values.
/// </summary>
public Int2 XZ => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(XZ)}");
/// <summary>
/// Gets or sets an <see cref="Int2"/> value with the <see cref="Y"/> and <see cref="X"/> values.
/// </summary>
public Int2 YX => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(YX)}");
/// <summary>
/// Gets an <see cref="Int2"/> value with the <see cref="Y"/> value for all components.
/// </summary>
public Int2 YY => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(YY)}");
/// <summary>
/// Gets or sets an <see cref="Int2"/> value with the <see cref="Y"/> and <see cref="Z"/> values.
/// </summary>
public Int2 YZ => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(YZ)}");
/// <summary>
/// Gets or sets an <see cref="Int2"/> value with the <see cref="Z"/> and <see cref="X"/> values.
/// </summary>
public Int2 ZX => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(ZX)}");
/// <summary>
/// Gets or sets an <see cref="Int2"/> value with the <see cref="Z"/> and <see cref="Y"/> values.
/// </summary>
public Int2 ZY => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(ZY)}");
/// <summary>
/// Gets an <see cref="Int2"/> value with the <see cref="Z"/> value for all components.
/// </summary>
public Int2 ZZ => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(ZZ)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="X"/> value for all components.
/// </summary>
public Int3 XXX => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(XXX)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="X"/> and <see cref="Y"/> values.
/// </summary>
public Int3 XXY => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(XXY)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="X"/> and <see cref="Z"/> values.
/// </summary>
public Int3 XXZ => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(XXZ)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="Y"/> and <see cref="X"/> values.
/// </summary>
public Int3 XYX => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(XYX)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="Y"/> and <see cref="Y"/> values.
/// </summary>
public Int3 XYY => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(XYY)}");
/// <summary>
/// Gets or sets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="Y"/> and <see cref="Z"/> values.
/// </summary>
public Int3 XYZ => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(XYZ)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="Z"/> and <see cref="X"/> values.
/// </summary>
public Int3 XZX => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(XZX)}");
/// <summary>
/// Gets or sets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="Z"/> and <see cref="Y"/> values.
/// </summary>
public Int3 XZY => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(XZY)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="Z"/> and <see cref="Z"/> values.
/// </summary>
public Int3 XZZ => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(XZZ)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="X"/> and <see cref="X"/> values.
/// </summary>
public Int3 YXX => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(YXX)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="X"/> and <see cref="Y"/> values.
/// </summary>
public Int3 YXY => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(YXY)}");
/// <summary>
/// Gets or sets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="X"/> and <see cref="Z"/> values.
/// </summary>
public Int3 YXZ => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(YXZ)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="Y"/> and <see cref="X"/> values.
/// </summary>
public Int3 YYX => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(YYX)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/> value for all components.
/// </summary>
public Int3 YYY => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(YYY)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="Y"/> and <see cref="Z"/> values.
/// </summary>
public Int3 YYZ => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(YYZ)}");
/// <summary>
/// Gets or sets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="Z"/> and <see cref="X"/> values.
/// </summary>
public Int3 YZX => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(YZX)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="Z"/> and <see cref="Y"/> values.
/// </summary>
public Int3 YZY => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(YZY)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="Z"/> and <see cref="Z"/> values.
/// </summary>
public Int3 YZZ => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(YZZ)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="Z"/> and <see cref="Z"/> values.
/// </summary>
public Int3 ZXX => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(ZXX)}");
/// <summary>
/// Gets or sets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="X"/> and <see cref="Y"/> values.
/// </summary>
public Int3 ZXY => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(ZXY)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="X"/> and <see cref="Z"/> values.
/// </summary>
public Int3 ZXZ => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(ZXZ)}");
/// <summary>
/// Gets or sets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="Y"/> and <see cref="X"/> values.
/// </summary>
public Int3 ZYX => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(ZYX)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="Y"/> and <see cref="Y"/> values.
/// </summary>
public Int3 ZYY => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(ZYY)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="Y"/> and <see cref="Z"/> values.
/// </summary>
public Int3 ZYZ => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(ZYZ)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="Z"/> and <see cref="X"/> values.
/// </summary>
public Int3 ZZX => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(ZZX)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="Z"/> and <see cref="Y"/> values.
/// </summary>
public Int3 ZZY => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(ZZY)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/> value for all components.
/// </summary>
public Int3 ZZZ => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(ZZZ)}");
}
}
+3 -3
ファイルの表示
@@ -24,12 +24,12 @@ namespace ComputeSharp
/// <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 UInt2(1, 0);
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 UInt2(0, 1);
public static UInt2 UnitY => new(0, 1);
/// <summary>
/// Creates a new <see cref="UInt2"/> instance with the specified parameters.
@@ -140,7 +140,7 @@ namespace ComputeSharp
/// 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 UInt2(x, x);
public static implicit operator UInt2(uint x) => new(x, x);
/// <summary>
/// Sums two <see cref="UInt2"/> values.
+58 -58
ファイルの表示
@@ -24,17 +24,17 @@ namespace ComputeSharp
/// <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 UInt3(1, 0, 0);
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 UInt3(0, 1, 0);
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 UInt3(0, 0, 1);
public static UInt3 UnitZ => new(0, 0, 1);
/// <summary>
/// Creates a new <see cref="UInt3"/> instance with the specified parameters.
@@ -242,32 +242,32 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="X"/> value for all components.
/// </summary>
public UInt2 XXX => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(XXX)}");
public UInt3 XXX => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(XXX)}");
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="X"/>, <see cref="X"/> and <see cref="Y"/> values.
/// </summary>
public UInt2 XXY => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(XXY)}");
public UInt3 XXY => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(XXY)}");
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="X"/>, <see cref="X"/> and <see cref="Z"/> values.
/// </summary>
public UInt2 XXZ => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(XXZ)}");
public UInt3 XXZ => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(XXZ)}");
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="X"/>, <see cref="Y"/> and <see cref="X"/> values.
/// </summary>
public UInt2 XYX => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(XYX)}");
public UInt3 XYX => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(XYX)}");
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="X"/>, <see cref="Y"/> and <see cref="Y"/> values.
/// </summary>
public UInt2 XYY => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(XYY)}");
public UInt3 XYY => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(XYY)}");
/// <summary>
/// Gets or sets an <see cref="UInt3"/> value with the <see cref="X"/>, <see cref="Y"/> and <see cref="Z"/> values.
/// </summary>
public UInt2 XYZ
public UInt3 XYZ
{
get => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(XYZ)}");
set => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(XYZ)}");
@@ -276,12 +276,12 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="X"/>, <see cref="Z"/> and <see cref="X"/> values.
/// </summary>
public UInt2 XZX => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(XZX)}");
public UInt3 XZX => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(XZX)}");
/// <summary>
/// Gets or sets an <see cref="UInt3"/> value with the <see cref="X"/>, <see cref="Z"/> and <see cref="Y"/> values.
/// </summary>
public UInt2 XZY
public UInt3 XZY
{
get => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(XZY)}");
set => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(XZY)}");
@@ -290,22 +290,22 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="X"/>, <see cref="Z"/> and <see cref="Z"/> values.
/// </summary>
public UInt2 XZZ => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(XZZ)}");
public UInt3 XZZ => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(XZZ)}");
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="Y"/>, <see cref="X"/> and <see cref="X"/> values.
/// </summary>
public UInt2 YXX => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(YXX)}");
public UInt3 YXX => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(YXX)}");
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="Y"/>, <see cref="X"/> and <see cref="Y"/> values.
/// </summary>
public UInt2 YXY => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(YXY)}");
public UInt3 YXY => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(YXY)}");
/// <summary>
/// Gets or sets an <see cref="UInt3"/> value with the <see cref="Y"/>, <see cref="X"/> and <see cref="Z"/> values.
/// </summary>
public UInt2 YXZ
public UInt3 YXZ
{
get => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(YXZ)}");
set => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(YXZ)}");
@@ -314,22 +314,22 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="Y"/>, <see cref="Y"/> and <see cref="X"/> values.
/// </summary>
public UInt2 YYX => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(YYX)}");
public UInt3 YYX => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(YYX)}");
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="Y"/> value for all components.
/// </summary>
public UInt2 YYY => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(YYY)}");
public UInt3 YYY => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(YYY)}");
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="Y"/>, <see cref="Y"/> and <see cref="Z"/> values.
/// </summary>
public UInt2 YYZ => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(YYZ)}");
public UInt3 YYZ => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(YYZ)}");
/// <summary>
/// Gets or sets an <see cref="UInt3"/> value with the <see cref="Y"/>, <see cref="Z"/> and <see cref="X"/> values.
/// </summary>
public UInt2 YZX
public UInt3 YZX
{
get => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(YZX)}");
set => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(YZX)}");
@@ -338,22 +338,22 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="Y"/>, <see cref="Z"/> and <see cref="Y"/> values.
/// </summary>
public UInt2 YZY => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(YZY)}");
public UInt3 YZY => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(YZY)}");
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="Y"/>, <see cref="Z"/> and <see cref="Z"/> values.
/// </summary>
public UInt2 YZZ => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(YZZ)}");
public UInt3 YZZ => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(YZZ)}");
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="Z"/>, <see cref="Z"/> and <see cref="Z"/> values.
/// </summary>
public UInt2 ZXX => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(ZXX)}");
public UInt3 ZXX => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(ZXX)}");
/// <summary>
/// Gets or sets an <see cref="UInt3"/> value with the <see cref="Z"/>, <see cref="X"/> and <see cref="Y"/> values.
/// </summary>
public UInt2 ZXY
public UInt3 ZXY
{
get => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(ZXY)}");
set => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(ZXY)}");
@@ -362,12 +362,12 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="Z"/>, <see cref="X"/> and <see cref="Z"/> values.
/// </summary>
public UInt2 ZXZ => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(ZXZ)}");
public UInt3 ZXZ => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(ZXZ)}");
/// <summary>
/// Gets or sets an <see cref="UInt3"/> value with the <see cref="Z"/>, <see cref="Y"/> and <see cref="X"/> values.
/// </summary>
public UInt2 ZYX
public UInt3 ZYX
{
get => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(ZYX)}");
set => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(ZYX)}");
@@ -376,57 +376,57 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="Z"/>, <see cref="Y"/> and <see cref="Y"/> values.
/// </summary>
public UInt2 ZYY => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(ZYY)}");
public UInt3 ZYY => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(ZYY)}");
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="Z"/>, <see cref="Y"/> and <see cref="Z"/> values.
/// </summary>
public UInt2 ZYZ => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(ZYZ)}");
public UInt3 ZYZ => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(ZYZ)}");
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="Z"/>, <see cref="Z"/> and <see cref="X"/> values.
/// </summary>
public UInt2 ZZX => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(ZZX)}");
public UInt3 ZZX => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(ZZX)}");
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="Z"/>, <see cref="Z"/> and <see cref="Y"/> values.
/// </summary>
public UInt2 ZZY => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(ZZY)}");
public UInt3 ZZY => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(ZZY)}");
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="Z"/> value for all components.
/// </summary>
public UInt2 ZZZ => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(ZZZ)}");
public UInt3 ZZZ => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(ZZZ)}");
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="R"/> value for all components.
/// </summary>
public UInt2 RRR => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(RRR)}");
public UInt3 RRR => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(RRR)}");
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="R"/>, <see cref="R"/> and <see cref="G"/> values.
/// </summary>
public UInt2 RRG => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(RRG)}");
public UInt3 RRG => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(RRG)}");
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="R"/>, <see cref="R"/> and <see cref="B"/> values.
/// </summary>
public UInt2 RRB => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(RRB)}");
public UInt3 RRB => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(RRB)}");
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="R"/>, <see cref="G"/> and <see cref="R"/> values.
/// </summary>
public UInt2 RGR => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(RGR)}");
public UInt3 RGR => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(RGR)}");
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="R"/>, <see cref="G"/> and <see cref="G"/> values.
/// </summary>
public UInt2 RGG => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(RGG)}");
public UInt3 RGG => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(RGG)}");
/// <summary>
/// Gets or sets an <see cref="UInt3"/> value with the <see cref="R"/>, <see cref="G"/> and <see cref="B"/> values.
/// </summary>
public UInt2 RGB
public UInt3 RGB
{
get => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(RGB)}");
set => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(RGB)}");
@@ -435,12 +435,12 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="R"/>, <see cref="B"/> and <see cref="R"/> values.
/// </summary>
public UInt2 RBR => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(RBR)}");
public UInt3 RBR => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(RBR)}");
/// <summary>
/// Gets or sets an <see cref="UInt3"/> value with the <see cref="R"/>, <see cref="B"/> and <see cref="G"/> values.
/// </summary>
public UInt2 RBG
public UInt3 RBG
{
get => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(RBG)}");
set => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(RBG)}");
@@ -449,22 +449,22 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="R"/>, <see cref="B"/> and <see cref="B"/> values.
/// </summary>
public UInt2 RBB => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(RBB)}");
public UInt3 RBB => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(RBB)}");
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="G"/>, <see cref="R"/> and <see cref="R"/> values.
/// </summary>
public UInt2 GRR => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(GRR)}");
public UInt3 GRR => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(GRR)}");
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="G"/>, <see cref="R"/> and <see cref="G"/> values.
/// </summary>
public UInt2 GRG => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(GRG)}");
public UInt3 GRG => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(GRG)}");
/// <summary>
/// Gets or sets an <see cref="UInt3"/> value with the <see cref="G"/>, <see cref="R"/> and <see cref="B"/> values.
/// </summary>
public UInt2 GRB
public UInt3 GRB
{
get => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(GRB)}");
set => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(GRB)}");
@@ -473,22 +473,22 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="G"/>, <see cref="G"/> and <see cref="R"/> values.
/// </summary>
public UInt2 GGR => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(GGR)}");
public UInt3 GGR => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(GGR)}");
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="G"/> value for all components.
/// </summary>
public UInt2 GGG => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(GGG)}");
public UInt3 GGG => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(GGG)}");
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="G"/>, <see cref="G"/> and <see cref="B"/> values.
/// </summary>
public UInt2 GGB => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(GGB)}");
public UInt3 GGB => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(GGB)}");
/// <summary>
/// Gets or sets an <see cref="UInt3"/> value with the <see cref="G"/>, <see cref="B"/> and <see cref="R"/> values.
/// </summary>
public UInt2 GBR
public UInt3 GBR
{
get => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(GBR)}");
set => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(GBR)}");
@@ -497,22 +497,22 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="G"/>, <see cref="B"/> and <see cref="G"/> values.
/// </summary>
public UInt2 GBG => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(GBG)}");
public UInt3 GBG => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(GBG)}");
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="G"/>, <see cref="B"/> and <see cref="B"/> values.
/// </summary>
public UInt2 GBB => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(GBB)}");
public UInt3 GBB => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(GBB)}");
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="B"/>, <see cref="B"/> and <see cref="B"/> values.
/// </summary>
public UInt2 BRR => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(BRR)}");
public UInt3 BRR => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(BRR)}");
/// <summary>
/// Gets or sets an <see cref="UInt3"/> value with the <see cref="B"/>, <see cref="R"/> and <see cref="G"/> values.
/// </summary>
public UInt2 BRG
public UInt3 BRG
{
get => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(BRG)}");
set => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(BRG)}");
@@ -521,12 +521,12 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="B"/>, <see cref="R"/> and <see cref="B"/> values.
/// </summary>
public UInt2 BRB => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(BRB)}");
public UInt3 BRB => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(BRB)}");
/// <summary>
/// Gets or sets an <see cref="UInt3"/> value with the <see cref="B"/>, <see cref="G"/> and <see cref="R"/> values.
/// </summary>
public UInt2 BGR
public UInt3 BGR
{
get => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(BGR)}");
set => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(BGR)}");
@@ -535,33 +535,33 @@ namespace ComputeSharp
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="B"/>, <see cref="G"/> and <see cref="G"/> values.
/// </summary>
public UInt2 BGG => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(BGG)}");
public UInt3 BGG => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(BGG)}");
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="B"/>, <see cref="G"/> and <see cref="B"/> values.
/// </summary>
public UInt2 BGB => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(BGB)}");
public UInt3 BGB => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(BGB)}");
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="B"/>, <see cref="B"/> and <see cref="R"/> values.
/// </summary>
public UInt2 BBR => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(BBR)}");
public UInt3 BBR => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(BBR)}");
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="B"/>, <see cref="B"/> and <see cref="G"/> values.
/// </summary>
public UInt2 BBG => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(BBG)}");
public UInt3 BBG => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(BBG)}");
/// <summary>
/// Gets an <see cref="UInt3"/> value with the <see cref="B"/> value for all components.
/// </summary>
public UInt2 BBB => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(BBB)}");
public UInt3 BBB => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(BBB)}");
/// <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 UInt3(x, x, x);
public static implicit operator UInt3(uint x) => new(x, x, x);
/// <summary>
/// Sums two <see cref="UInt3"/> values.
+5 -5
ファイルの表示
@@ -24,22 +24,22 @@ namespace ComputeSharp
/// <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 UInt4(1, 0, 0, 0);
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 UInt4(0, 1, 0, 0);
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 UInt4(0, 0, 1, 0);
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 UInt4(0, 0, 0, 1);
public static UInt4 UnitW => new(0, 0, 0, 1);
/// <summary>
/// Creates a new <see cref="UInt4"/> instance with the specified parameters.
@@ -3966,7 +3966,7 @@ namespace ComputeSharp
/// 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 UInt4(x, x, x, x);
public static implicit operator UInt4(uint x) => new(x, x, x, x);
/// <summary>
/// Sums two <see cref="UInt4"/> values.
+23 -120
ファイルの表示
@@ -1,13 +1,13 @@
using System;
using System.Buffers;
using System.Diagnostics.Contracts;
using System.Buffers;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using ComputeSharp.Core.Interop;
using ComputeSharp.Exceptions;
using ComputeSharp.Graphics.Buffers.Enums;
using ComputeSharp.Graphics.Extensions;
using Microsoft.Toolkit.Diagnostics;
using TerraFX.Interop;
using FX = TerraFX.Interop.Windows;
namespace ComputeSharp.Graphics.Buffers.Abstract
{
@@ -45,7 +45,15 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
{
device.ThrowIfDisposed();
Guard.IsGreaterThanOrEqualTo(length, 0, nameof(length));
if (resourceType == ResourceType.Constant)
{
Guard.IsBetweenOrEqualTo(length, 1, FX.D3D12_REQ_CONSTANT_BUFFER_ELEMENT_COUNT, nameof(length));
}
else
{
// The maximum length is set such that the aligned buffer size can't exceed uint.MaxValue
Guard.IsBetweenOrEqualTo(length, 1, (uint.MaxValue / elementSizeInBytes) & ~255, nameof(length));
}
SizeInBytes = checked((nint)(length * elementSizeInBytes));
GraphicsDevice = device;
@@ -79,22 +87,13 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
/// </summary>
public int Length { get; }
/// <summary>
/// Gets the size in bytes of each <typeparamref name="T"/> value contained in the buffer.
/// </summary>
protected int ElementSizeInBytes
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => Unsafe.SizeOf<T>();
}
/// <summary>
/// Gets whether or not there is some padding between elements in the current buffer.
/// </summary>
internal bool IsPaddingPresent
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => SizeInBytes > Length * Unsafe.SizeOf<T>();
get => SizeInBytes > (nint)Length * sizeof(T);
}
/// <summary>
@@ -103,114 +102,20 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
internal ID3D12Resource* D3D12Resource => this.d3D12Resource;
/// <summary>
/// Reads the contents of the current <see cref="Buffer{T}"/> instance and returns an array.
/// </summary>
/// <returns>A <typeparamref name="T"/> array with the contents of the current buffer.</returns>
[Pure]
public T[] GetData()
{
return GetData(0, Length);
}
/// <summary>
/// Reads the contents of the current <see cref="Buffer{T}"/> instance in a given range and returns an array.
/// Reads the contents of the specified range from the current <see cref="Buffer{T}"/> instance and writes them into a target memory area.
/// </summary>
/// <param name="destination">The input memory area to write data to.</param>
/// <param name="size">The size of the memory area to write data to.</param>
/// <param name="offset">The offset to start reading data from.</param>
/// <param name="count">The number of items to read.</param>
/// <returns>A <typeparamref name="T"/> array with the contents of the specified range from the current buffer.</returns>
[Pure]
public T[] GetData(int offset, int count)
{
Guard.IsGreaterThanOrEqualTo(count, 0, nameof(count));
T[] data = GC.AllocateUninitializedArray<T>(count);
GetData(data.AsSpan(), offset);
return data;
}
internal abstract void GetData(ref T destination, nint size, int offset);
/// <summary>
/// Reads the contents of the current <see cref="Buffer{T}"/> instance and writes them into a target array.
/// Writes the contents of a given memory area to a specified area of the current <see cref="Buffer{T}"/> instance.
/// </summary>
/// <param name="destination">The input array to write data to.</param>
public void GetData(T[] destination)
{
GetData(destination.AsSpan(), 0);
}
/// <summary>
/// Reads the contents of the specified range from the current <see cref="Buffer{T}"/> instance and writes them into a target array.
/// </summary>
/// <param name="destination">The input array to write data to.</param>
/// <param name="destinationOffset">The starting offset within <paramref name="source"/> to write data to.</param>
/// <param name="bufferOffset">The offset to start reading data from.</param>
/// <param name="count">The number of items to read.</param>
public void GetData(T[] destination, int destinationOffset, int bufferOffset, int count)
{
Span<T> span = destination.AsSpan(destinationOffset, count);
GetData(span, bufferOffset);
}
/// <summary>
/// Reads the contents of the current <see cref="Buffer{T}"/> instance and writes them into a target <see cref="Span{T}"/>.
/// The input data will be read from the start of the buffer.
/// </summary>
/// <param name="destination">The input <see cref="Span{T}"/> to write data to.</param>
public void GetData(Span<T> destination)
{
GetData(destination, 0);
}
/// <summary>
/// Reads the contents of the specified range from the current <see cref="Buffer{T}"/> instance and writes them into a target <see cref="Span{T}"/>.
/// </summary>
/// <param name="destination">The input <see cref="Span{T}"/> to write data to.</param>
/// <param name="offset">The offset to start reading data from.</param>
public abstract void GetData(Span<T> destination, int offset);
/// <summary>
/// Writes the contents of a given <typeparamref name="T"/> array to the current <see cref="Buffer{T}"/> instance.
/// </summary>
/// <param name="source">The input <typeparamref name="T"/> array to read data from.</param>
public void SetData(T[] source)
{
SetData(source.AsSpan());
}
/// <summary>
/// Writes the contents of a given <typeparamref name="T"/> array to a specified area of the current <see cref="Buffer{T}"/> instance.
/// </summary>
/// <param name="source">The input <typeparamref name="T"/> array to read data from.</param>
/// <param name="sourceOffset">The starting offset within <paramref name="source"/> to read data from.</param>
/// <param name="bufferOffset">The offset to start writing data to.</param>
/// <param name="count">The number of items to write.</param>
public void SetData(T[] source, int sourceOffset, int bufferOffset, int count)
{
ReadOnlySpan<T> span = source.AsSpan(sourceOffset, count);
SetData(span, bufferOffset);
}
/// <summary>
/// Writes the contents of a given <see cref="ReadOnlySpan{T}"/> to the current <see cref="Buffer{T}"/> instance.
/// The input data will be written to the start of the buffer, and all input items will be copied.
/// </summary>
/// <param name="source">The input <see cref="ReadOnlySpan{T}"/> to read data from.</param>
public void SetData(ReadOnlySpan<T> source)
{
SetData(source, 0);
}
/// <summary>
/// Writes the contents of a given <see cref="ReadOnlySpan{T}"/> to a specified area of the current <see cref="Buffer{T}"/> instance.
/// The input data will be written into the buffer starting at the specified offset, and all input items will be copied.
/// </summary>
/// <param name="source">The input <see cref="ReadOnlySpan{T}"/> to read data from.</param>
/// <param name="source">The input memory area to read data from.</param>
/// <param name="size">The size of the input memory area to read data from.</param>
/// <param name="offset">The offset to start writing data to.</param>
/// <param name="count">The number of items to write.</param>
public abstract void SetData(ReadOnlySpan<T> source, int offset);
internal abstract void SetData(ref T source, nint size, int offset);
/// <summary>
/// Writes the contents of a given <see cref="Buffer{T}"/> to the current <see cref="Buffer{T}"/> instance.
@@ -228,11 +133,9 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
try
{
Span<T> span = array.AsSpan(0, source.Length);
source.GetData(ref MemoryMarshal.GetArrayDataReference(array), source.Length, 0);
source.GetData(span);
SetData(span);
SetData(ref MemoryMarshal.GetArrayDataReference(array), source.Length, 0);
}
finally
{
+27 -16
ファイルの表示
@@ -1,6 +1,4 @@
using System;
using System.Runtime.CompilerServices;
using ComputeSharp.Graphics.Buffers.Enums;
using ComputeSharp.Graphics.Buffers.Enums;
using ComputeSharp.Graphics.Buffers.Interop;
using ComputeSharp.Graphics.Commands;
using ComputeSharp.Graphics.Extensions;
@@ -24,24 +22,24 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
/// <param name="device">The <see cref="GraphicsDevice"/> associated with the current instance.</param>
/// <param name="length">The number of items to store in the current buffer.</param>
/// <param name="resourceType">The buffer type for the current buffer.</param>
private protected StructuredBuffer(GraphicsDevice device, int length, ResourceType resourceType)
: base(device, length, (uint)Unsafe.SizeOf<T>(), resourceType)
private protected unsafe StructuredBuffer(GraphicsDevice device, int length, ResourceType resourceType)
: base(device, length, (uint)sizeof(T), resourceType)
{
}
/// <inheritdoc/>
public override unsafe void GetData(Span<T> destination, int offset)
internal override unsafe void GetData(ref T destination, nint size, int offset)
{
GraphicsDevice.ThrowIfDisposed();
ThrowIfDisposed();
Guard.IsInRange(offset, 0, Length, nameof(offset));
Guard.IsLessThanOrEqualTo((uint)offset + destination.Length, (uint)Length, nameof(destination));
Guard.IsLessThanOrEqualTo(offset + size, Length, nameof(size));
nint
byteOffset = (nint)offset * ElementSizeInBytes,
byteSize = (nint)destination.Length * ElementSizeInBytes;
byteOffset = (nint)offset * sizeof(T),
byteSize = size * sizeof(T);
using ComPtr<ID3D12Resource> d3D12Resource = GraphicsDevice.D3D12Device->CreateCommittedResource(ResourceType.ReadBack, (ulong)byteSize);
@@ -52,29 +50,42 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
}
using ID3D12ResourceMap resource = d3D12Resource.Get()->Map();
MemoryHelper.Copy(resource.Pointer, 0, destination);
fixed (void* destinationPointer = &destination)
{
MemoryHelper.Copy(
resource.Pointer,
0u,
(uint)size,
(uint)sizeof(T),
destinationPointer);
}
}
/// <inheritdoc/>
public override unsafe void SetData(ReadOnlySpan<T> source, int offset)
internal override unsafe void SetData(ref T source, nint size, int offset)
{
GraphicsDevice.ThrowIfDisposed();
ThrowIfDisposed();
Guard.IsInRange(offset, 0, Length, nameof(offset));
Guard.IsLessThanOrEqualTo((uint)offset + source.Length, (uint)Length, nameof(source));
Guard.IsLessThanOrEqualTo(offset + size, Length, nameof(size));
nint
byteOffset = (nint)offset * ElementSizeInBytes,
byteSize = (nint)source.Length * ElementSizeInBytes;
byteOffset = (nint)offset * sizeof(T),
byteSize = size * sizeof(T);
using ComPtr<ID3D12Resource> d3D12Resource = GraphicsDevice.D3D12Device->CreateCommittedResource(ResourceType.Upload, (ulong)byteSize);
using (ID3D12ResourceMap resource = d3D12Resource.Get()->Map())
fixed (void* sourcePointer = &source)
{
MemoryHelper.Copy(source, resource.Pointer, 0);
MemoryHelper.Copy(
sourcePointer,
0u,
(uint)size,
(uint)sizeof(T),
resource.Pointer);
}
using CommandList copyCommandList = new(GraphicsDevice, D3D12_COMMAND_LIST_TYPE_COPY);
+105 -253
ファイルの表示
@@ -1,6 +1,4 @@
using System;
using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;
using System.Runtime.CompilerServices;
using ComputeSharp.Core.Interop;
using ComputeSharp.Exceptions;
using ComputeSharp.Graphics.Buffers.Enums;
@@ -12,6 +10,8 @@ using Microsoft.Toolkit.Diagnostics;
using TerraFX.Interop;
using static TerraFX.Interop.D3D12_COMMAND_LIST_TYPE;
using static TerraFX.Interop.D3D12_RESOURCE_STATES;
using static TerraFX.Interop.D3D12_SRV_DIMENSION;
using static TerraFX.Interop.D3D12_UAV_DIMENSION;
using FX = TerraFX.Interop.Windows;
namespace ComputeSharp.Graphics.Buffers.Abstract
@@ -37,7 +37,12 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
/// <summary>
/// The default <see cref="D3D12_RESOURCE_STATES"/> value for the current resource.
/// </summary>
private readonly D3D12_RESOURCE_STATES D3D12ResourceState;
private readonly D3D12_RESOURCE_STATES d3D12ResourceState;
/// <summary>
/// The <see cref="D3D12_COMMAND_LIST_TYPE"/> value to use for copy operations.
/// </summary>
private readonly D3D12_COMMAND_LIST_TYPE d3D12CommandListType;
/// <summary>
/// Creates a new <see cref="Texture2D{T}"/> instance with the specified parameters.
@@ -50,8 +55,8 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
{
device.ThrowIfDisposed();
Guard.IsGreaterThanOrEqualTo(width, 0, nameof(width));
Guard.IsGreaterThanOrEqualTo(height, 0, nameof(height));
Guard.IsBetweenOrEqualTo(width, 1, FX.D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION, nameof(width));
Guard.IsBetweenOrEqualTo(height, 1, FX.D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION, nameof(height));
GraphicsDevice = device;
Width = width;
@@ -62,17 +67,21 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
DXGIFormatHelper.GetForType<T>(),
(uint)width,
(uint)height,
out D3D12ResourceState);
out this.d3D12ResourceState);
this.d3D12CommandListType = this.d3D12ResourceState == D3D12_RESOURCE_STATE_COMMON
? D3D12_COMMAND_LIST_TYPE_COPY
: D3D12_COMMAND_LIST_TYPE_COMPUTE;
device.AllocateShaderResourceViewDescriptorHandles(out D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandle, out D3D12GpuDescriptorHandle);
switch (resourceType)
{
case ResourceType.ReadOnly:
device.D3D12Device->CreateShaderResourceView(this.d3D12Resource, DXGIFormatHelper.GetForType<T>(), d3D12CpuDescriptorHandle);
device.D3D12Device->CreateShaderResourceView(this.d3D12Resource, DXGIFormatHelper.GetForType<T>(), D3D12_SRV_DIMENSION_TEXTURE2D, d3D12CpuDescriptorHandle);
break;
case ResourceType.ReadWrite:
device.D3D12Device->CreateUnorderedAccessView(this.d3D12Resource, DXGIFormatHelper.GetForType<T>(), d3D12CpuDescriptorHandle);
device.D3D12Device->CreateUnorderedAccessView(this.d3D12Resource, DXGIFormatHelper.GetForType<T>(), D3D12_UAV_DIMENSION_TEXTURE2D, d3D12CpuDescriptorHandle);
break;
}
}
@@ -98,133 +107,15 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
internal ID3D12Resource* D3D12Resource => this.d3D12Resource;
/// <summary>
/// Reads the contents of the current <see cref="Texture2D{T}"/> instance and returns an array.
/// Reads the contents of the specified range from the current <see cref="Texture2D{T}"/> instance and writes them into a target memory area.
/// </summary>
/// <returns>A <typeparamref name="T"/> array with the contents of the current buffer.</returns>
[Pure]
public T[,] GetData()
{
T[,] data = new T[Height, Width];
GetData(data);
return data;
}
/// <summary>
/// Reads the contents of the current <see cref="Texture2D{T}"/> instance and writes them into a target array.
/// </summary>
/// <param name="destination">The input array to write data to.</param>
public void GetData(T[,] destination)
{
fixed (T* p = destination)
{
GetData(new Span<T>(p, destination.Length));
}
}
/// <summary>
/// Reads the contents of the specified range from the current <see cref="Texture2D{T}"/> instance and writes them into a target array.
/// </summary>
/// <param name="destination">The input array to write data to.</param>
public void GetData(T[] destination)
{
GetData(destination.AsSpan(), 0, 0, Width, Height);
}
/// <summary>
/// Reads the contents of the specified range from the current <see cref="Texture2D{T}"/> instance and writes them into a target array.
/// </summary>
/// <param name="destination">The input array to write data to.</param>
/// <param name="x">The horizontal range of items to copy.</param>
/// <param name="y">The vertical range of items to copy.</param>
public void GetData(T[] destination, Range x, Range y)
{
GetData(destination.AsSpan(), x, y);
}
/// <summary>
/// Reads the contents of the specified range from the current <see cref="Texture2D{T}"/> instance and writes them into a target array.
/// </summary>
/// <param name="destination">The input array to write data to.</param>
/// <param name="destination">The target memory area to write data to.</param>
/// <param name="size">The size of the target memory area to write data to.</param>
/// <param name="x">The horizontal offset in the source texture.</param>
/// <param name="y">The vertical offset in the source texture.</param>
/// <param name="width">The width of the memory area to copy.</param>
/// <param name="height">The height of the memory area to copy.</param>
public void GetData(T[] destination, int x, int y, int width, int height)
{
GetData(destination.AsSpan(), x, y, width, height);
}
/// <summary>
/// Reads the contents of the specified range from the current <see cref="Texture2D{T}"/> instance and writes them into a target array.
/// </summary>
/// <param name="destination">The input array to write data to.</param>
/// <param name="offset">The starting offset within <paramref name="source"/> to write data to.</param>
public void GetData(T[] destination, int offset)
{
GetData(destination.AsSpan(offset), 0, 0, Width, Height);
}
/// <summary>
/// Reads the contents of the specified range from the current <see cref="Texture2D{T}"/> instance and writes them into a target array.
/// </summary>
/// <param name="destination">The input array to write data to.</param>
/// <param name="offset">The starting offset within <paramref name="source"/> to write data to.</param>
/// <param name="x">The horizontal range of items to copy.</param>
/// <param name="y">The vertical range of items to copy.</param>
public void GetData(T[] destination, int offset, Range x, Range y)
{
GetData(destination.AsSpan(offset), x, y);
}
/// <summary>
/// Reads the contents of the specified range from the current <see cref="Texture2D{T}"/> instance and writes them into a target array.
/// </summary>
/// <param name="destination">The input array to write data to.</param>
/// <param name="offset">The starting offset within <paramref name="source"/> to write data to.</param>
/// <param name="x">The horizontal offset in the source texture.</param>
/// <param name="y">The vertical offset in the source texture.</param>
/// <param name="width">The width of the memory area to copy.</param>
/// <param name="height">The height of the memory area to copy.</param>
public void GetData(T[] destination, int offset, int x, int y, int width, int height)
{
GetData(destination.AsSpan(offset), x, y, width, height);
}
/// <summary>
/// Reads the contents of the current <see cref="Texture2D{T}"/> instance and writes them into a target <see cref="Span{T}"/>.
/// The input data will be read from the start of the texture.
/// </summary>
/// <param name="destination">The input <see cref="Span{T}"/> to write data to.</param>
public void GetData(Span<T> destination)
{
GetData(destination, 0, 0, Width, Height);
}
/// <summary>
/// Reads the contents of the specified range from the current <see cref="Texture2D{T}"/> instance and writes them into a target <see cref="Span{T}"/>.
/// </summary>
/// <param name="destination">The input <see cref="Span{T}"/> to write data to.</param>
/// <param name="x">The horizontal range of items to copy.</param>
/// <param name="y">The vertical range of items to copy.</param>
public void GetData(Span<T> destination, Range x, Range y)
{
var (offsetX, width) = x.GetOffsetAndLength(Width);
var (offsetY, height) = y.GetOffsetAndLength(Height);
GetData(destination, offsetX, offsetY, width, height);
}
/// <summary>
/// Reads the contents of the specified range from the current <see cref="Texture2D{T}"/> instance and writes them into a target <see cref="Span{T}"/>.
/// </summary>
/// <param name="destination">The input <see cref="Span{T}"/> to write data to.</param>
/// <param name="x">The horizontal offset in the source texture.</param>
/// <param name="y">The vertical offset in the source texture.</param>
/// <param name="width">The width of the memory area to copy.</param>
/// <param name="height">The height of the memory area to copy.</param>
public void GetData(Span<T> destination, int x, int y, int width, int height)
internal void GetData(ref T destination, nint size, int x, int y, int width, int height)
{
GraphicsDevice.ThrowIfDisposed();
@@ -232,136 +123,72 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
Guard.IsInRange(x, 0, Width, nameof(x));
Guard.IsInRange(y, 0, Height, nameof(y));
Guard.IsBetweenOrEqualTo(width, 0, Width, nameof(width));
Guard.IsBetweenOrEqualTo(height, 0, Height, nameof(height));
Guard.IsBetweenOrEqualTo(width, 1, Width, nameof(width));
Guard.IsBetweenOrEqualTo(height, 1, Height, nameof(height));
Guard.IsLessThanOrEqualTo(x + width, Width, nameof(x));
Guard.IsLessThanOrEqualTo(y + height, Height, nameof(y));
Guard.HasSizeGreaterThanOrEqualTo(destination, width * height, nameof(destination));
Guard.IsGreaterThanOrEqualTo(size, (nint)width * height, nameof(size));
ulong
rowByteSize = (ulong)((nint)width * Unsafe.SizeOf<T>()),
rowPitchSize = (rowByteSize + FX.D3D12_TEXTURE_DATA_PITCH_ALIGNMENT - 1) & ~((ulong)(FX.D3D12_TEXTURE_DATA_PITCH_ALIGNMENT - 1)),
resourceByteSize = rowPitchSize * (uint)height;
D3D12_RESOURCE_DESC d3D12ResourceDescription = D3D12_RESOURCE_DESC.Tex2D(DXGIFormatHelper.GetForType<T>(), (ulong)width, (uint)height);
using ComPtr<ID3D12Resource> d3D12Resource = GraphicsDevice.D3D12Device->CreateCommittedResource(ResourceType.ReadBack, resourceByteSize);
GraphicsDevice.D3D12Device->GetCopyableFootprint(
&d3D12ResourceDescription,
out D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprint,
out _,
out ulong rowSizeInBytes,
out ulong totalSizeInBytes);
using (CommandList copyCommandList = new(GraphicsDevice, D3D12_COMMAND_LIST_TYPE_COMPUTE))
using ComPtr<ID3D12Resource> d3D12Resource = GraphicsDevice.D3D12Device->CreateCommittedResource(ResourceType.ReadBack, totalSizeInBytes);
using (CommandList copyCommandList = new(GraphicsDevice, this.d3D12CommandListType))
{
copyCommandList.ResourceBarrier(D3D12Resource, D3D12ResourceState, D3D12_RESOURCE_STATE_COPY_SOURCE);
copyCommandList.CopyTextureRegion(d3D12Resource.Get(), (uint)Unsafe.SizeOf<T>(), D3D12Resource, DXGIFormatHelper.GetForType<T>(), (uint)x, (uint)y, (uint)width, (uint)height);
copyCommandList.ResourceBarrier(D3D12Resource, D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12ResourceState);
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
{
copyCommandList.ResourceBarrier(D3D12Resource, this.d3D12ResourceState, D3D12_RESOURCE_STATE_COPY_SOURCE);
}
copyCommandList.CopyTextureRegion(
d3D12Resource.Get(),
&d3D12PlacedSubresourceFootprint,
D3D12Resource,
(uint)x,
(uint)y,
0,
(uint)width,
(uint)height,
1);
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
{
copyCommandList.ResourceBarrier(D3D12Resource, D3D12_RESOURCE_STATE_COPY_SOURCE, this.d3D12ResourceState);
}
copyCommandList.ExecuteAndWaitForCompletion();
}
using ID3D12ResourceMap resource = d3D12Resource.Get()->Map();
MemoryHelper.Copy(resource.Pointer, width, height, rowByteSize, rowPitchSize, destination);
}
/// <summary>
/// Writes the contents of a given <typeparamref name="T"/> array to the current <see cref="Texture2D{T}"/> instance.
/// </summary>
/// <param name="source">The input <typeparamref name="T"/> array to read data from.</param>
public void SetData(T[,] source)
{
fixed (T* p = source)
fixed (void* destinationPointer = &destination)
{
SetData(new Span<T>(p, source.Length));
MemoryHelper.Copy(
resource.Pointer,
(uint)height,
rowSizeInBytes,
d3D12PlacedSubresourceFootprint.Footprint.RowPitch,
destinationPointer);
}
}
/// <summary>
/// Writes the contents of a given <typeparamref name="T"/> array to the current <see cref="Texture2D{T}"/> instance.
/// Writes the contents of a given memory area to a specified area of the current <see cref="Texture2D{T}"/> instance.
/// </summary>
/// <param name="source">The input <typeparamref name="T"/> array to read data from.</param>
public void SetData(T[] source)
{
SetData(source.AsSpan(), 0, 0, Width, Height);
}
/// <summary>
/// Writes the contents of a given <typeparamref name="T"/> array to a specified area of the current <see cref="Texture2D{T}"/> instance.
/// </summary>
/// <param name="source">The input <typeparamref name="T"/> array to read data from.</param>
/// <param name="x">The horizontal range of items to write.</param>
/// <param name="y">The vertical range of items to write.</param>
public void SetData(T[] source, Range x, Range y)
{
SetData(source.AsSpan(), x, y);
}
/// <summary>
/// Writes the contents of a given <typeparamref name="T"/> array to a specified area of the current <see cref="Texture2D{T}"/> instance.
/// </summary>
/// <param name="source">The input <typeparamref name="T"/> array to read data from.</param>
/// <param name="source">The input memory area to read data from.</param>
/// <param name="size">The size of the memory area to read data from.</param>
/// <param name="x">The horizontal offset in the destination texture.</param>
/// <param name="y">The vertical offset in the destination texture.</param>
/// <param name="width">The width of the memory area to write to.</param>
/// <param name="height">The height of the memory area to write to.</param>
public void SetData(T[] source, int x, int y, int width, int height)
{
SetData(source.AsSpan(), x, y, width, height);
}
/// <summary>
/// Writes the contents of a given <typeparamref name="T"/> array to a specified area of the current <see cref="Texture2D{T}"/> instance.
/// </summary>
/// <param name="source">The input <typeparamref name="T"/> array to read data from.</param>
/// <param name="offset">The starting offset within <paramref name="source"/> to read data from.</param>
/// <param name="x">The horizontal range of items to write.</param>
/// <param name="y">The vertical range of items to write.</param>
public void SetData(T[] source, int offset, Range x, Range y)
{
SetData(source.AsSpan(offset), x, y);
}
/// <summary>
/// Writes the contents of a given <typeparamref name="T"/> array to a specified area of the current <see cref="Texture2D{T}"/> instance.
/// </summary>
/// <param name="source">The input <typeparamref name="T"/> array to read data from.</param>
/// <param name="offset">The starting offset within <paramref name="source"/> to read data from.</param>
/// <param name="x">The horizontal offset in the destination texture.</param>
/// <param name="y">The vertical offset in the destination texture.</param>
/// <param name="width">The width of the memory area to write to.</param>
/// <param name="height">The height of the memory area to write to.</param>
public void SetData(T[] source, int offset, int x, int y, int width, int height)
{
SetData(source.AsSpan(offset), x, y, width, height);
}
/// <summary>
/// Writes the contents of a given <see cref="ReadOnlySpan{T}"/> to the current <see cref="Texture2D{T}"/> instance.
/// The input data will be written to the start of the texture, and all input items will be copied.
/// </summary>
/// <param name="source">The input <see cref="ReadOnlySpan{T}"/> to read data from.</param>
public void SetData(ReadOnlySpan<T> source)
{
SetData(source, 0, 0, Width, Height);
}
/// <summary>
/// Writes the contents of a given <see cref="ReadOnlySpan{T}"/> to a specified area of the current <see cref="Texture2D{T}"/> instance.
/// </summary>
/// <param name="source">The input <see cref="ReadOnlySpan{T}"/> to read data from.</param>
/// <param name="x">The horizontal range of items to write.</param>
/// <param name="y">The vertical range of items to write.</param>
public void SetData(ReadOnlySpan<T> source, Range x, Range y)
{
var (offsetX, width) = x.GetOffsetAndLength(Width);
var (offsetY, height) = y.GetOffsetAndLength(Height);
SetData(source, offsetX, offsetY, width, height);
}
/// <summary>
/// Writes the contents of a given <see cref="ReadOnlySpan{T}"/> to a specified area of the current <see cref="Texture2D{T}"/> instance.
/// </summary>
/// <param name="source">The input <see cref="ReadOnlySpan{T}"/> to read data from.</param>
/// <param name="x">The horizontal offset in the destination texture.</param>
/// <param name="y">The vertical offset in the destination texture.</param>
/// <param name="width">The width of the memory area to write to.</param>
/// <param name="height">The height of the memory area to write to.</param>
public void SetData(ReadOnlySpan<T> source, int x, int y, int width, int height)
internal void SetData(ref T source, nint size, int x, int y, int width, int height)
{
GraphicsDevice.ThrowIfDisposed();
@@ -369,29 +196,54 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
Guard.IsInRange(x, 0, Width, nameof(x));
Guard.IsInRange(y, 0, Height, nameof(y));
Guard.IsBetweenOrEqualTo(width, 0, Width, nameof(width));
Guard.IsBetweenOrEqualTo(height, 0, Height, nameof(height));
Guard.IsBetweenOrEqualTo(width, 1, Width, nameof(width));
Guard.IsBetweenOrEqualTo(height, 1, Height, nameof(height));
Guard.IsLessThanOrEqualTo(x + width, Width, nameof(x));
Guard.IsLessThanOrEqualTo(y + height, Height, nameof(y));
Guard.HasSizeGreaterThanOrEqualTo(source, width * height, nameof(source));
Guard.IsGreaterThanOrEqualTo(size, (nint)width * height, nameof(size));
ulong
rowByteSize = (ulong)((nint)width * Unsafe.SizeOf<T>()),
rowPitchSize = (rowByteSize + FX.D3D12_TEXTURE_DATA_PITCH_ALIGNMENT - 1) & ~((ulong)(FX.D3D12_TEXTURE_DATA_PITCH_ALIGNMENT - 1)),
resourceByteSize = rowPitchSize * (uint)height;
D3D12_RESOURCE_DESC d3D12ResourceDescription = D3D12_RESOURCE_DESC.Tex2D(DXGIFormatHelper.GetForType<T>(), (ulong)width, (uint)height);
using ComPtr<ID3D12Resource> d3D12Resource = GraphicsDevice.D3D12Device->CreateCommittedResource(ResourceType.Upload, resourceByteSize);
GraphicsDevice.D3D12Device->GetCopyableFootprint(
&d3D12ResourceDescription,
out D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprint,
out _,
out ulong rowSizeInBytes,
out ulong totalSizeInBytes);
using ComPtr<ID3D12Resource> d3D12Resource = GraphicsDevice.D3D12Device->CreateCommittedResource(ResourceType.Upload, totalSizeInBytes);
using (ID3D12ResourceMap resource = d3D12Resource.Get()->Map())
fixed (void* sourcePointer = &source)
{
MemoryHelper.Copy(source, resource.Pointer, width, height, rowByteSize, rowPitchSize);
MemoryHelper.Copy(
sourcePointer,
resource.Pointer,
(uint)height,
rowSizeInBytes,
d3D12PlacedSubresourceFootprint.Footprint.RowPitch);
}
using CommandList copyCommandList = new(GraphicsDevice, D3D12_COMMAND_LIST_TYPE_COMPUTE);
using CommandList copyCommandList = new(GraphicsDevice, this.d3D12CommandListType);
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
{
copyCommandList.ResourceBarrier(D3D12Resource, this.d3D12ResourceState, D3D12_RESOURCE_STATE_COPY_DEST);
}
copyCommandList.CopyTextureRegion(
D3D12Resource,
(uint)x,
(uint)y,
0,
d3D12Resource.Get(),
&d3D12PlacedSubresourceFootprint);
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
{
copyCommandList.ResourceBarrier(D3D12Resource, D3D12_RESOURCE_STATE_COPY_DEST, this.d3D12ResourceState);
}
copyCommandList.ResourceBarrier(D3D12Resource, D3D12ResourceState, D3D12_RESOURCE_STATE_COPY_DEST);
copyCommandList.CopyTextureRegion(D3D12Resource, DXGIFormatHelper.GetForType<T>(), (uint)x, (uint)y, d3D12Resource.Get(), (uint)width, (uint)height, (uint)Unsafe.SizeOf<T>());
copyCommandList.ResourceBarrier(D3D12Resource, D3D12_RESOURCE_STATE_COPY_DEST, D3D12ResourceState);
copyCommandList.ExecuteAndWaitForCompletion();
}
+291
ファイルの表示
@@ -0,0 +1,291 @@
using System.Runtime.CompilerServices;
using ComputeSharp.Core.Interop;
using ComputeSharp.Exceptions;
using ComputeSharp.Graphics.Buffers.Enums;
using ComputeSharp.Graphics.Buffers.Interop;
using ComputeSharp.Graphics.Commands;
using ComputeSharp.Graphics.Extensions;
using ComputeSharp.Graphics.Helpers;
using Microsoft.Toolkit.Diagnostics;
using TerraFX.Interop;
using static TerraFX.Interop.D3D12_COMMAND_LIST_TYPE;
using static TerraFX.Interop.D3D12_RESOURCE_STATES;
using static TerraFX.Interop.D3D12_SRV_DIMENSION;
using static TerraFX.Interop.D3D12_UAV_DIMENSION;
using FX = TerraFX.Interop.Windows;
namespace ComputeSharp.Graphics.Buffers.Abstract
{
/// <summary>
/// A <see langword="class"/> representing a typed 3D texture stored on GPU memory.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
public unsafe abstract class Texture3D<T> : NativeObject
where T : unmanaged
{
/// <summary>
/// The <see cref="ID3D12Resource"/> instance currently mapped.
/// </summary>
private ComPtr<ID3D12Resource> d3D12Resource;
/// <summary>
/// The <see cref="D3D12_GPU_DESCRIPTOR_HANDLE"/> instance for the current resource.
/// </summary>
/// <remarks>This field is dynamically accessed when loading shader dispatch data.</remarks>
internal readonly D3D12_GPU_DESCRIPTOR_HANDLE D3D12GpuDescriptorHandle;
/// <summary>
/// The default <see cref="D3D12_RESOURCE_STATES"/> value for the current resource.
/// </summary>
private readonly D3D12_RESOURCE_STATES d3D12ResourceState;
/// <summary>
/// The <see cref="D3D12_COMMAND_LIST_TYPE"/> value to use for copy operations.
/// </summary>
private readonly D3D12_COMMAND_LIST_TYPE d3D12CommandListType;
/// <summary>
/// Creates a new <see cref="Texture3D{T}"/> instance with the specified parameters.
/// </summary>
/// <param name="device">The <see cref="Graphics.GraphicsDevice"/> associated with the current instance.</param>
/// <param name="height">The height of the texture.</param>
/// <param name="width">The width of the texture.</param>
/// <param name="depth">The depth of the texture.</param>
/// <param name="resourceType">The resource type for the current texture.</param>
private protected Texture3D(GraphicsDevice device, int width, int height, int depth, ResourceType resourceType)
{
device.ThrowIfDisposed();
Guard.IsBetweenOrEqualTo(width, 1, FX.D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION, nameof(width));
Guard.IsBetweenOrEqualTo(height, 1, FX.D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION, nameof(height));
Guard.IsBetweenOrEqualTo(depth, 1, FX.D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION, nameof(depth));
GraphicsDevice = device;
Width = width;
Height = height;
Depth = depth;
this.d3D12Resource = device.D3D12Device->CreateCommittedResource(
resourceType,
DXGIFormatHelper.GetForType<T>(),
(uint)width,
(uint)height,
(ushort)depth,
out this.d3D12ResourceState);
this.d3D12CommandListType = this.d3D12ResourceState == D3D12_RESOURCE_STATE_COMMON
? D3D12_COMMAND_LIST_TYPE_COPY
: D3D12_COMMAND_LIST_TYPE_COMPUTE;
device.AllocateShaderResourceViewDescriptorHandles(out D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandle, out D3D12GpuDescriptorHandle);
switch (resourceType)
{
case ResourceType.ReadOnly:
device.D3D12Device->CreateShaderResourceView(this.d3D12Resource, DXGIFormatHelper.GetForType<T>(), D3D12_SRV_DIMENSION_TEXTURE3D, d3D12CpuDescriptorHandle);
break;
case ResourceType.ReadWrite:
device.D3D12Device->CreateUnorderedAccessView(this.d3D12Resource, DXGIFormatHelper.GetForType<T>(), D3D12_UAV_DIMENSION_TEXTURE3D, d3D12CpuDescriptorHandle);
break;
}
}
/// <summary>
/// Gets the <see cref="Graphics.GraphicsDevice"/> associated with the current instance.
/// </summary>
public GraphicsDevice GraphicsDevice { get; }
/// <summary>
/// Gets the width of the current texture.
/// </summary>
public int Width { get; }
/// <summary>
/// Gets the height of the current texture.
/// </summary>
public int Height { get; }
/// <summary>
/// Gets the depth of the current texture.
/// </summary>
public int Depth { get; }
/// <summary>
/// Gets the <see cref="ID3D12Resource"/> instance currently mapped.
/// </summary>
internal ID3D12Resource* D3D12Resource => this.d3D12Resource;
/// <summary>
/// Reads the contents of the specified range from the current <see cref="Texture3D{T}"/> instance and writes them into a target memory area.
/// </summary>
/// <param name="destination">The target memory area to write data to.</param>
/// <param name="size">The size of the memory area to write data to.</param>
/// <param name="x">The horizontal offset in the source texture.</param>
/// <param name="y">The vertical offset in the source texture.</param>
/// <param name="z">The depthwise offset in the source texture.</param>
/// <param name="width">The width of the memory area to copy.</param>
/// <param name="height">The height of the memory area to copy.</param>
/// <param name="depth">The depth of the memory area to copy.</param>
internal void GetData(ref T destination, nint size, int x, int y, int z, int width, int height, int depth)
{
GraphicsDevice.ThrowIfDisposed();
ThrowIfDisposed();
Guard.IsInRange(x, 0, Width, nameof(x));
Guard.IsInRange(y, 0, Height, nameof(y));
Guard.IsInRange(z, 0, Depth, nameof(z));
Guard.IsBetweenOrEqualTo(width, 1, Width, nameof(width));
Guard.IsBetweenOrEqualTo(height, 1, Height, nameof(height));
Guard.IsBetweenOrEqualTo(depth, 1, Depth, nameof(depth));
Guard.IsLessThanOrEqualTo(x + width, Width, nameof(x));
Guard.IsLessThanOrEqualTo(y + height, Height, nameof(y));
Guard.IsLessThanOrEqualTo(z + depth, Depth, nameof(z));
Guard.IsGreaterThanOrEqualTo(size, (nint)width * height * depth, nameof(size));
D3D12_RESOURCE_DESC d3D12ResourceDescription = D3D12_RESOURCE_DESC.Tex3D(DXGIFormatHelper.GetForType<T>(), (ulong)width, (uint)height, (ushort)depth);
GraphicsDevice.D3D12Device->GetCopyableFootprint(
&d3D12ResourceDescription,
out D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprint,
out _,
out ulong rowSizeInBytes,
out ulong totalSizeInBytes);
using ComPtr<ID3D12Resource> d3D12Resource = GraphicsDevice.D3D12Device->CreateCommittedResource(ResourceType.ReadBack, totalSizeInBytes);
using (CommandList copyCommandList = new(GraphicsDevice, this.d3D12CommandListType))
{
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
{
copyCommandList.ResourceBarrier(D3D12Resource, this.d3D12ResourceState, D3D12_RESOURCE_STATE_COPY_SOURCE);
}
copyCommandList.CopyTextureRegion(
d3D12Resource.Get(),
&d3D12PlacedSubresourceFootprint,
D3D12Resource,
(uint)x,
(uint)y,
(ushort)z,
(uint)width,
(uint)height,
(ushort)depth);
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
{
copyCommandList.ResourceBarrier(D3D12Resource, D3D12_RESOURCE_STATE_COPY_SOURCE, this.d3D12ResourceState);
}
copyCommandList.ExecuteAndWaitForCompletion();
}
using ID3D12ResourceMap resource = d3D12Resource.Get()->Map();
fixed (void* destinationPointer = &destination)
{
MemoryHelper.Copy(
resource.Pointer,
(uint)height,
(uint)depth,
rowSizeInBytes,
d3D12PlacedSubresourceFootprint.Footprint.RowPitch,
d3D12PlacedSubresourceFootprint.Footprint.RowPitch * (uint)height,
destinationPointer);
}
}
/// <summary>
/// Writes the contents of a given memory area to a specified area of the current <see cref="Texture3D{T}"/> instance.
/// </summary>
/// <param name="source">The input memory area to read data from.</param>
/// <param name="size">The size of the memory area to read data from.</param>
/// <param name="x">The horizontal offset in the destination texture.</param>
/// <param name="y">The vertical offset in the destination texture.</param>
/// <param name="z">The depthwise offseet in the destination texture.</param>
/// <param name="width">The width of the memory area to write to.</param>
/// <param name="height">The height of the memory area to write to.</param>
/// <param name="depth">The depth of the memory area to write to.</param>
internal void SetData(ref T source, nint size, int x, int y, int z, int width, int height, int depth)
{
GraphicsDevice.ThrowIfDisposed();
ThrowIfDisposed();
Guard.IsInRange(x, 0, Width, nameof(x));
Guard.IsInRange(y, 0, Height, nameof(y));
Guard.IsInRange(z, 0, Depth, nameof(z));
Guard.IsBetweenOrEqualTo(width, 1, Width, nameof(width));
Guard.IsBetweenOrEqualTo(height, 1, Height, nameof(height));
Guard.IsBetweenOrEqualTo(depth, 1, Depth, nameof(depth));
Guard.IsLessThanOrEqualTo(x + width, Width, nameof(x));
Guard.IsLessThanOrEqualTo(y + height, Height, nameof(y));
Guard.IsLessThanOrEqualTo(z + depth, Depth, nameof(z));
Guard.IsGreaterThanOrEqualTo(size, (nint)width * height * depth, nameof(size));
D3D12_RESOURCE_DESC d3D12ResourceDescription = D3D12_RESOURCE_DESC.Tex3D(DXGIFormatHelper.GetForType<T>(), (ulong)width, (uint)height, (ushort)depth);
GraphicsDevice.D3D12Device->GetCopyableFootprint(
&d3D12ResourceDescription,
out D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprint,
out _,
out ulong rowSizeInBytes,
out ulong totalSizeInBytes);
using ComPtr<ID3D12Resource> d3D12Resource = GraphicsDevice.D3D12Device->CreateCommittedResource(ResourceType.Upload, totalSizeInBytes);
using (ID3D12ResourceMap resource = d3D12Resource.Get()->Map())
fixed (void* sourcePointer = &source)
{
MemoryHelper.Copy(
sourcePointer,
resource.Pointer,
(uint)height,
(uint)depth,
rowSizeInBytes,
d3D12PlacedSubresourceFootprint.Footprint.RowPitch,
d3D12PlacedSubresourceFootprint.Footprint.RowPitch * (uint)height);
}
using CommandList copyCommandList = new(GraphicsDevice, this.d3D12CommandListType);
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
{
copyCommandList.ResourceBarrier(D3D12Resource, this.d3D12ResourceState, D3D12_RESOURCE_STATE_COPY_DEST);
}
copyCommandList.CopyTextureRegion(
D3D12Resource,
(uint)x,
(uint)y,
(ushort)z,
d3D12Resource.Get(),
&d3D12PlacedSubresourceFootprint);
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
{
copyCommandList.ResourceBarrier(D3D12Resource, D3D12_RESOURCE_STATE_COPY_DEST, this.d3D12ResourceState);
}
copyCommandList.ExecuteAndWaitForCompletion();
}
/// <inheritdoc/>
protected override void OnDispose()
{
this.d3D12Resource.Dispose();
}
/// <summary>
/// Throws a <see cref="GraphicsDeviceMismatchException"/> if the target device doesn't match the current one.
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ThrowIfDeviceMismatch(GraphicsDevice device)
{
if (GraphicsDevice != device)
{
GraphicsDeviceMismatchException.Throw(this, device);
}
}
}
}
+42 -38
ファイルの表示
@@ -1,8 +1,6 @@
using System;
using System.Diagnostics;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using ComputeSharp.Exceptions;
using ComputeSharp.Graphics;
using ComputeSharp.Graphics.Buffers.Abstract;
@@ -48,71 +46,77 @@ namespace ComputeSharp
/// </summary>
[Pure]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static int GetPaddedSize()
private static unsafe int GetPaddedSize()
{
return (Unsafe.SizeOf<T>() + 15) & ~15;
return (sizeof(T) + 15) & ~15;
}
/// <inheritdoc/>
public override unsafe void GetData(Span<T> destination, int offset)
internal override unsafe void GetData(ref T destination, nint size, int offset)
{
GraphicsDevice.ThrowIfDisposed();
ThrowIfDisposed();
Guard.IsInRange(offset, 0, Length, nameof(offset));
Guard.IsLessThanOrEqualTo((uint)offset + destination.Length, (uint)Length, nameof(destination));
Guard.IsLessThanOrEqualTo(offset + size, Length, nameof(size));
using ID3D12ResourceMap resource = D3D12Resource->Map();
if (IsPaddingPresent)
fixed (void* destinationPointer = &destination)
{
int count = destination.Length;
ref T spanRef = ref MemoryMarshal.GetReference(destination);
ref byte resourceRef = ref Unsafe.AsRef<byte>(resource.Pointer);
// Move to the initial ref
resourceRef = ref Unsafe.Add(ref resourceRef, offset * GetPaddedSize());
for (var i = 0; i < count; i++)
if (IsPaddingPresent)
{
ref byte targetRef = ref Unsafe.Add(ref resourceRef, i * GetPaddedSize());
Unsafe.Add(ref spanRef, i) = Unsafe.As<byte, T>(ref targetRef);
MemoryHelper.Copy<T>(
resource.Pointer,
(uint)offset,
(uint)size,
(uint)GetPaddedSize(),
destinationPointer);
}
else
{
MemoryHelper.Copy(
resource.Pointer,
(uint)offset,
(uint)size,
(uint)sizeof(T),
destinationPointer);
}
}
else MemoryHelper.Copy(resource.Pointer, offset, destination);
}
/// <inheritdoc/>
public override unsafe void SetData(ReadOnlySpan<T> source, int offset)
internal override unsafe void SetData(ref T source, nint size, int offset)
{
GraphicsDevice.ThrowIfDisposed();
ThrowIfDisposed();
Guard.IsInRange(offset, 0, Length, nameof(offset));
Guard.IsLessThanOrEqualTo((uint)offset + source.Length, (uint)Length, nameof(source));
Guard.IsLessThanOrEqualTo(offset + size, Length, nameof(size));
using ID3D12ResourceMap resource = D3D12Resource->Map();
if (IsPaddingPresent)
fixed (void* sourcePointer = &source)
{
int count = source.Length;
ref T spanRef = ref MemoryMarshal.GetReference(source);
ref byte resourceRef = ref Unsafe.AsRef<byte>(resource.Pointer);
// Move to the initial offset
resourceRef = ref Unsafe.Add(ref resourceRef, offset * GetPaddedSize());
for (var i = 0; i < count; i++)
if (IsPaddingPresent)
{
ref byte targetRef = ref Unsafe.Add(ref resourceRef, i * GetPaddedSize());
Unsafe.As<byte, T>(ref targetRef) = Unsafe.Add(ref spanRef, i);
MemoryHelper.Copy<T>(
sourcePointer,
resource.Pointer,
(uint)offset,
(uint)size,
(uint)GetPaddedSize());
}
else
{
MemoryHelper.Copy(
sourcePointer,
(uint)offset,
(uint)size,
(uint)sizeof(T),
resource.Pointer);
}
}
else MemoryHelper.Copy(source, resource.Pointer, offset);
}
/// <inheritdoc/>
@@ -128,7 +132,7 @@ namespace ComputeSharp
source.GraphicsDevice == GraphicsDevice)
{
// Directly copy the input buffer, if possible
using CommandList copyCommandList = new CommandList(GraphicsDevice, D3D12_COMMAND_LIST_TYPE_COPY);
using CommandList copyCommandList = new(GraphicsDevice, D3D12_COMMAND_LIST_TYPE_COPY);
copyCommandList.CopyBufferRegion(D3D12Resource, 0, source.D3D12Resource, 0,(ulong)SizeInBytes);
copyCommandList.ExecuteAndWaitForCompletion();
+10 -2
ファイルの表示
@@ -11,7 +11,7 @@ namespace ComputeSharp
/// A <see langword="class"/> representing a typed readonly 2D texture stored on GPU memory.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
[DebuggerTypeProxy(typeof(BufferDebugView2D<>))]
[DebuggerTypeProxy(typeof(Texture2DDebugView<>))]
[DebuggerDisplay("{ToString(),raw}")]
public sealed class ReadOnlyTexture2D<T> : Texture2D<T>
where T : unmanaged
@@ -27,12 +27,20 @@ namespace ComputeSharp
{
}
/// <summary>
/// Gets a single <typeparamref name="T"/> value from the current readonly texture.
/// </summary>
/// <param name="x">The horizontal offset of the value to get.</param>
/// <param name="y">The vertical offset of the value to get.</param>
/// <remarks>This API can only be used from a compute shader, and will always throw if used anywhere else.</remarks>
public T this[int x, int y] => throw new InvalidExecutionContextException($"{nameof(ReadOnlyTexture2D<T>)}<T>[int,int]");
/// <summary>
/// Gets a single <typeparamref name="T"/> value from the current readonly texture.
/// </summary>
/// <param name="xy">The coordinates of the value to get.</param>
/// <remarks>This API can only be used from a compute shader, and will always throw if used anywhere else.</remarks>
public T this[UInt2 xy] => throw new InvalidExecutionContextException($"{nameof(ReadOnlyTexture2D<T>)}<T>[UInt2]");
public T this[Int2 xy] => throw new InvalidExecutionContextException($"{nameof(ReadOnlyTexture2D<T>)}<T>[Int2]");
/// <inheritdoc/>
public override string ToString()
+53
ファイルの表示
@@ -0,0 +1,53 @@
using System.Diagnostics;
using ComputeSharp.Exceptions;
using ComputeSharp.Graphics;
using ComputeSharp.Graphics.Buffers.Abstract;
using ComputeSharp.Graphics.Buffers.Enums;
using ComputeSharp.Graphics.Buffers.Views;
namespace ComputeSharp
{
/// <summary>
/// A <see langword="class"/> representing a typed readonly 3D texture stored on GPU memory.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
[DebuggerTypeProxy(typeof(Texture3DDebugView<>))]
[DebuggerDisplay("{ToString(),raw}")]
public sealed class ReadOnlyTexture3D<T> : Texture3D<T>
where T : unmanaged
{
/// <summary>
/// Creates a new <see cref="ReadOnlyTexture3D{T}"/> instance with the specified parameters.
/// </summary>
/// <param name="device">The <see cref="GraphicsDevice"/> associated with the current instance.</param>
/// <param name="width">The width of the texture.</param>
/// <param name="height">The height of the texture.</param>
/// <param name="depth">The depth of the texture.</param>
internal ReadOnlyTexture3D(GraphicsDevice device, int width, int height, int depth)
: base(device, width, height, depth, ResourceType.ReadOnly)
{
}
/// <summary>
/// Gets a single <typeparamref name="T"/> value from the current readonly texture.
/// </summary>
/// <param name="x">The horizontal offset of the value to get.</param>
/// <param name="y">The vertical offset of the value to get.</param>
/// <param name="y">The depthwise offset of the value to get.</param>
/// <remarks>This API can only be used from a compute shader, and will always throw if used anywhere else.</remarks>
public T this[int x, int y, int z] => throw new InvalidExecutionContextException($"{nameof(ReadOnlyTexture3D<T>)}<T>[int,int,int]");
/// <summary>
/// Gets a single <typeparamref name="T"/> value from the current readonly texture.
/// </summary>
/// <param name="xyz">The coordinates of the value to get.</param>
/// <remarks>This API can only be used from a compute shader, and will always throw if used anywhere else.</remarks>
public T this[Int3 xyz] => throw new InvalidExecutionContextException($"{nameof(ReadOnlyTexture3D<T>)}<T>[Int3]");
/// <inheritdoc/>
public override string ToString()
{
return $"ComputeSharp.ReadOnlyTexture3D<{typeof(T)}>[{Width}, {Height}, {Depth}]";
}
}
}
+1 -1
ファイルの表示
@@ -27,7 +27,7 @@ namespace ComputeSharp
}
/// <summary>
/// Gets or sets a single <typeparamref name="T"/> value from the current read write buffer.
/// Gets or sets a single <typeparamref name="T"/> value from the current writeable buffer.
/// </summary>
/// <param name="i">The index of the value to get or set.</param>
/// <remarks>This API can only be used from a compute shader, and will always throw if used anywhere else.</remarks>
+11 -3
ファイルの表示
@@ -11,7 +11,7 @@ namespace ComputeSharp
/// A <see langword="class"/> representing a typed read write 2D texture stored on GPU memory.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
[DebuggerTypeProxy(typeof(BufferDebugView2D<>))]
[DebuggerTypeProxy(typeof(Texture2DDebugView<>))]
[DebuggerDisplay("{ToString(),raw}")]
public sealed class ReadWriteTexture2D<T> : Texture2D<T>
where T : unmanaged
@@ -28,11 +28,19 @@ namespace ComputeSharp
}
/// <summary>
/// Gets or sets a single <typeparamref name="T"/> value from the current readonly texture.
/// Gets a single <typeparamref name="T"/> value from the current writeable texture.
/// </summary>
/// <param name="x">The horizontal offset of the value to get.</param>
/// <param name="y">The vertical offset of the value to get.</param>
/// <remarks>This API can only be used from a compute shader, and will always throw if used anywhere else.</remarks>
public ref T this[int x, int y] => throw new InvalidExecutionContextException($"{nameof(ReadWriteTexture2D<T>)}<T>[int,int]");
/// <summary>
/// Gets or sets a single <typeparamref name="T"/> value from the current writeable texture.
/// </summary>
/// <param name="xy">The coordinates of the value to get.</param>
/// <remarks>This API can only be used from a compute shader, and will always throw if used anywhere else.</remarks>
public ref T this[UInt2 xy] => throw new InvalidExecutionContextException($"{nameof(ReadOnlyTexture2D<T>)}<T>[UInt2]");
public ref T this[Int2 xy] => throw new InvalidExecutionContextException($"{nameof(ReadWriteTexture2D<T>)}<T>[Int2]");
/// <inheritdoc/>
public override string ToString()
+53
ファイルの表示
@@ -0,0 +1,53 @@
using System.Diagnostics;
using ComputeSharp.Exceptions;
using ComputeSharp.Graphics;
using ComputeSharp.Graphics.Buffers.Abstract;
using ComputeSharp.Graphics.Buffers.Enums;
using ComputeSharp.Graphics.Buffers.Views;
namespace ComputeSharp
{
/// <summary>
/// A <see langword="class"/> representing a typed readonly 3D texture stored on GPU memory.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
[DebuggerTypeProxy(typeof(Texture3DDebugView<>))]
[DebuggerDisplay("{ToString(),raw}")]
public sealed class ReadWriteTexture3D<T> : Texture3D<T>
where T : unmanaged
{
/// <summary>
/// Creates a new <see cref="ReadOnlyTexture2D{T}"/> instance with the specified parameters.
/// </summary>
/// <param name="device">The <see cref="GraphicsDevice"/> associated with the current instance.</param>
/// <param name="width">The width of the texture.</param>
/// <param name="height">The height of the texture.</param>
/// <param name="depth">The depth of the texture.</param>
internal ReadWriteTexture3D(GraphicsDevice device, int width, int height, int depth)
: base(device, width, height, depth, ResourceType.ReadWrite)
{
}
/// <summary>
/// Gets a single <typeparamref name="T"/> value from the current writeable texture.
/// </summary>
/// <param name="x">The horizontal offset of the value to get.</param>
/// <param name="y">The vertical offset of the value to get.</param>
/// <param name="z">The depthwise offset of the value to get.</param>
/// <remarks>This API can only be used from a compute shader, and will always throw if used anywhere else.</remarks>
public ref T this[int x, int y, int z] => throw new InvalidExecutionContextException($"{nameof(ReadWriteTexture3D<T>)}<T>[int,int,int]");
/// <summary>
/// Gets a single <typeparamref name="T"/> value from the current writeable texture.
/// </summary>
/// <param name="xyz">The coordinates of the value to get.</param>
/// <remarks>This API can only be used from a compute shader, and will always throw if used anywhere else.</remarks>
public ref T this[Int3 xyz] => throw new InvalidExecutionContextException($"{nameof(ReadWriteTexture3D<T>)}<T>[Int3]");
/// <inheritdoc/>
public override string ToString()
{
return $"ComputeSharp.ReadWriteTexture3D<{typeof(T)}>[{Width}, {Height}, {Depth}]";
}
}
}
+10 -2
ファイルの表示
@@ -1,4 +1,5 @@
using System.Diagnostics;
using System;
using System.Diagnostics;
using ComputeSharp.Graphics.Buffers.Abstract;
namespace ComputeSharp.Graphics.Buffers.Views
@@ -16,7 +17,14 @@ namespace ComputeSharp.Graphics.Buffers.Views
/// <param name="buffer">The input <see cref="Buffer{T}"/> instance with the items to display.</param>
public BufferDebugView(Buffer<T>? buffer)
{
Items = buffer?.GetData();
if (buffer is not null)
{
var items = GC.AllocateUninitializedArray<T>(buffer.Length);
buffer.GetData(ref items[0], buffer.Length, 0);
Items = items;
}
}
/// <summary>
@@ -7,16 +7,23 @@ namespace ComputeSharp.Graphics.Buffers.Views
/// A debug proxy used to display items in a <see cref="Texture2D{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items to display.</typeparam>
internal sealed class BufferDebugView2D<T>
internal sealed class Texture2DDebugView<T>
where T : unmanaged
{
/// <summary>
/// Initializes a new instance of the <see cref="BufferDebugView2D{T}"/> class with the specified parameters.
/// Initializes a new instance of the <see cref="Texture2DDebugView{T}"/> class with the specified parameters.
/// </summary>
/// <param name="texture">The input <see cref="Texture2D{T}"/> instance with the items to display.</param>
public BufferDebugView2D(Texture2D<T>? texture)
public Texture2DDebugView(Texture2D<T>? texture)
{
Items = texture?.GetData();
if (texture is not null)
{
var items = new T[texture.Height, texture.Width];
texture.GetData(ref items[0, 0], items.Length, 0, 0, texture.Width, texture.Height);
Items = items;
}
}
/// <summary>
+35
ファイルの表示
@@ -0,0 +1,35 @@
using System.Diagnostics;
using ComputeSharp.Graphics.Buffers.Abstract;
namespace ComputeSharp.Graphics.Buffers.Views
{
/// <summary>
/// A debug proxy used to display items in a <see cref="Texture3D{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items to display.</typeparam>
internal sealed class Texture3DDebugView<T>
where T : unmanaged
{
/// <summary>
/// Initializes a new instance of the <see cref="Texture3DDebugView{T}"/> class with the specified parameters.
/// </summary>
/// <param name="texture">The input <see cref="Texture3D{T}"/> instance with the items to display.</param>
public Texture3DDebugView(Texture3D<T>? texture)
{
if (texture is not null)
{
var items = new T[texture.Depth, texture.Height, texture.Width];
texture.GetData(ref items[0, 0, 0], items.Length, 0, 0, 0, texture.Width, texture.Height, texture.Depth);
Items = items;
}
}
/// <summary>
/// Gets the items to display for the current instance.
/// </summary>
[DebuggerBrowsable(DebuggerBrowsableState.Collapsed)]
public T[,,]? Items { get; }
}
}
+15 -18
ファイルの表示
@@ -55,7 +55,7 @@ namespace ComputeSharp.Graphics.Commands
/// <summary>
/// Gets the command list type being used by the current instance.
/// </summary>
public readonly D3D12_COMMAND_LIST_TYPE D3d12CommandListType => this.d3D12CommandListType;
public readonly D3D12_COMMAND_LIST_TYPE D3D12CommandListType => this.d3D12CommandListType;
/// <summary>
/// Detaches the <see cref="ID3D12CommandAllocator"/> object in use by the current instance.
@@ -95,49 +95,46 @@ namespace ComputeSharp.Graphics.Commands
/// Copies a texture memory region from one resource (a buffer) to another (a texture).
/// </summary>
/// <param name="d3D12ResourceDestination">The destination <see cref="ID3D12Resource"/> (a texture) to write to.</param>
/// <param name="dxgiFormat">The <see cref="DXGI_FORMAT"/> parameter curreently in use by the texture.</param>
/// <param name="x">The horizontal offset in the destination texture.</param>
/// <param name="y">The vertical offset in the destination texture.</param>
/// <param name="z">The depthwise offset in the destination texture.</param>
/// <param name="d3D12ResourceSource">The source <see cref="ID3D12Resource"/> (a buffer) to read from.</param>
/// <param name="width">The width of the memory area to write to.</param>
/// <param name="height">The height of the memory area to write to.</param>
/// <param name="elementSizeInBytes">The size of each element to copy.</param>
/// <param name="d3D12PlacedSubresourceFootprintSource">The <see cref="D3D12_PLACED_SUBRESOURCE_FOOTPRINT"/> value describing <paramref name="d3D12ResourceSource"/>.</param>
public readonly void CopyTextureRegion(
ID3D12Resource* d3D12ResourceDestination,
DXGI_FORMAT dxgiFormat,
uint x,
uint y,
ushort z,
ID3D12Resource* d3D12ResourceSource,
uint width,
uint height,
uint elementSizeInBytes)
D3D12_PLACED_SUBRESOURCE_FOOTPRINT* d3D12PlacedSubresourceFootprintSource)
{
this.d3D12GraphicsCommandList.Get()->CopyTextureRegion(d3D12ResourceDestination, dxgiFormat, x, y, d3D12ResourceSource, width, height, elementSizeInBytes);
this.d3D12GraphicsCommandList.Get()->CopyTextureRegion(d3D12ResourceDestination, x, y, z, d3D12ResourceSource, d3D12PlacedSubresourceFootprintSource);
}
/// <summary>
/// Copies a texture memory region from one resource (a texture) to another (a buffer).
/// </summary>
/// <param name="d3D12ResourceDestination">The destination <see cref="ID3D12Resource"/> (a buffer) to write to.</param>
/// <param name="elementSizeInBytes">The size of each element to copy.</param>
/// <param name="d3D12PlacedSubresourceFootprintDestination">The <see cref="D3D12_PLACED_SUBRESOURCE_FOOTPRINT"/> value describing <paramref name="d3D12ResourceDestination"/>.</param>
/// <param name="d3D12ResourceSource">The source <see cref="ID3D12Resource"/> (a texture) to read from.</param>
/// <param name="dxgiFormat">The <see cref="DXGI_FORMAT"/> parameter curreently in use by the texture.</param>
/// <param name="x">The horizontal offset in the destination texture.</param>
/// <param name="y">The vertical offset in the destination texture.</param>
/// <param name="width">The width of the memory area to write to.</param>
/// <param name="height">The height of the memory area to write to.</param>
/// <param name="width">The width of the memory area to read from.</param>
/// <param name="height">The height of the memory area to read from.</param>
/// <param name="depth">The depth of the memory area to read from.</param>
public readonly void CopyTextureRegion(
ID3D12Resource* d3D12ResourceDestination,
uint elementSizeInBytes,
D3D12_PLACED_SUBRESOURCE_FOOTPRINT* d3D12PlacedSubresourceFootprintDestination,
ID3D12Resource* d3D12ResourceSource,
DXGI_FORMAT dxgiFormat,
uint x,
uint y,
ushort z,
uint width,
uint height)
uint height,
ushort depth)
{
this.d3D12GraphicsCommandList.Get()->CopyTextureRegion(d3D12ResourceDestination, elementSizeInBytes, d3D12ResourceSource, dxgiFormat, x, y, width, height);
this.d3D12GraphicsCommandList.Get()->CopyTextureRegion(d3D12ResourceDestination, d3D12PlacedSubresourceFootprintDestination, d3D12ResourceSource, x, y, z, width, height, depth);
}
/// <summary>
+13
ファイルの表示
@@ -71,5 +71,18 @@ namespace ComputeSharp.Exceptions
{
throw Create(texture, texture.GraphicsDevice, device);
}
/// <summary>
/// Throws a new <see cref="GraphicsDeviceMismatchException"/> instance from the specified parameters.
/// </summary>
/// <typeparam name="T">The type of values in the input buffer.</typeparam>
/// <param name="texture">The input <see cref="Texture3D{T}"/> that was used.</param>
/// <param name="device">The target <see cref="GraphicsDevice"/> instance that was used.</param>
[Pure]
internal static void Throw<T>(Texture3D<T> texture, GraphicsDevice device)
where T : unmanaged
{
throw Create(texture, texture.GraphicsDevice, device);
}
}
}
+89 -3
ファイルの表示
@@ -163,7 +163,7 @@ namespace ComputeSharp.Graphics.Extensions
(d3D12ResourceFlags, d3D12ResourceStates) = resourceType switch
{
ResourceType.ReadOnly => (D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE),
ResourceType.ReadOnly => (D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_COMMON),
ResourceType.ReadWrite => (D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_UNORDERED_ACCESS),
_ => ThrowHelper.ThrowArgumentException<(D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>()
};
@@ -190,6 +190,57 @@ namespace ComputeSharp.Graphics.Extensions
return d3D12Resource.Move();
}
/// <summary>
/// Creates a committed resource for a given 3D texture type.
/// </summary>
/// <param name="d3D12Device">The <see cref="ID3D12Device"/> instance in use.</param>
/// <param name="resourceType">The resource type currently in use.</param>
/// <param name="dxgiFormat">The <see cref="DXGI_FORMAT"/> value to use.</param>
/// <param name="width">The width of the texture resource.</param>
/// <param name="height">The height of the texture resource.</param>
/// <param name="depth">The depth of the texture resource.</param>
/// <param name="d3D12ResourceStates">The default <see cref="D3D12_RESOURCE_STATES"/> value for the resource.</param>
/// <returns>An <see cref="ID3D12Resource"/> reference for the current texture.</returns>
public static ComPtr<ID3D12Resource> CreateCommittedResource(
this ref ID3D12Device d3D12Device,
ResourceType resourceType,
DXGI_FORMAT dxgiFormat,
uint width,
uint height,
ushort depth,
out D3D12_RESOURCE_STATES d3D12ResourceStates)
{
D3D12_RESOURCE_FLAGS d3D12ResourceFlags;
(d3D12ResourceFlags, d3D12ResourceStates) = resourceType switch
{
ResourceType.ReadOnly => (D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_COMMON),
ResourceType.ReadWrite => (D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_UNORDERED_ACCESS),
_ => ThrowHelper.ThrowArgumentException<(D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>()
};
using ComPtr<ID3D12Resource> d3D12Resource = default;
D3D12_HEAP_PROPERTIES d3D12HeapProperties;
d3D12HeapProperties.Type = D3D12_HEAP_TYPE_DEFAULT;
d3D12HeapProperties.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN;
d3D12HeapProperties.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN;
d3D12HeapProperties.CreationNodeMask = 1;
d3D12HeapProperties.VisibleNodeMask = 1;
D3D12_RESOURCE_DESC d3D12ResourceDescription = D3D12_RESOURCE_DESC.Tex3D(dxgiFormat, width, height, depth, flags: d3D12ResourceFlags);
d3D12Device.CreateCommittedResource(
&d3D12HeapProperties,
D3D12_HEAP_FLAG_NONE,
&d3D12ResourceDescription,
d3D12ResourceStates,
null,
FX.__uuidof<ID3D12Resource>(),
d3D12Resource.GetVoidAddressOf()).Assert();
return d3D12Resource.Move();
}
/// <summary>
/// Creates a view for a constant buffer.
/// </summary>
@@ -242,15 +293,17 @@ namespace ComputeSharp.Graphics.Extensions
/// <param name="d3D12Device">The target <see cref="ID3D12Device"/> instance in use.</param>
/// <param name="d3D12Resource">The <see cref="ID3D12Resource"/> to create a view for.</param>
/// <param name="dxgiFormat">The <see cref="DXGI_FORMAT"/> value to use.</param>
/// <param name="d3D12SrvDimension">The <see cref="D3D12_SRV_DIMENSION"/> value for the view to create.</param>
/// <param name="d3D12CpuDescriptorHandle">The <see cref="D3D12_CPU_DESCRIPTOR_HANDLE"/> instance for the current resource.</param>
public static void CreateShaderResourceView(
this ref ID3D12Device d3D12Device,
ID3D12Resource* d3D12Resource,
DXGI_FORMAT dxgiFormat,
D3D12_SRV_DIMENSION d3D12SrvDimension,
D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandle)
{
D3D12_SHADER_RESOURCE_VIEW_DESC d3D12ShaderResourceViewDescription = default;
d3D12ShaderResourceViewDescription.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D;
d3D12ShaderResourceViewDescription.ViewDimension = d3D12SrvDimension;
d3D12ShaderResourceViewDescription.Format = dxgiFormat;
d3D12ShaderResourceViewDescription.Shader4ComponentMapping = FX.D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
d3D12ShaderResourceViewDescription.Texture2D.MipLevels = uint.MaxValue;
@@ -287,16 +340,19 @@ namespace ComputeSharp.Graphics.Extensions
/// <param name="d3D12Device">The target <see cref="ID3D12Device"/> instance in use.</param>
/// <param name="d3D12Resource">The <see cref="ID3D12Resource"/> to create a view for.</param>
/// <param name="dxgiFormat">The <see cref="DXGI_FORMAT"/> value to use.</param>
/// <param name="d3D12UavDimension">The <see cref="D3D12_UAV_DIMENSION"/> value for the view to create.</param>
/// <param name="d3D12CpuDescriptorHandle">The <see cref="D3D12_CPU_DESCRIPTOR_HANDLE"/> instance for the current resource.</param>
public static void CreateUnorderedAccessView(
this ref ID3D12Device d3D12Device,
ID3D12Resource* d3D12Resource,
DXGI_FORMAT dxgiFormat,
D3D12_UAV_DIMENSION d3D12UavDimension,
D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandle)
{
D3D12_UNORDERED_ACCESS_VIEW_DESC d3D12UnorderedAccessViewDescription = default;
d3D12UnorderedAccessViewDescription.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2D;
d3D12UnorderedAccessViewDescription.ViewDimension = d3D12UavDimension;
d3D12UnorderedAccessViewDescription.Format = dxgiFormat;
d3D12UnorderedAccessViewDescription.Texture3D.WSize = uint.MaxValue;
d3D12Device.CreateUnorderedAccessView(d3D12Resource, null, &d3D12UnorderedAccessViewDescription, d3D12CpuDescriptorHandle);
}
@@ -347,6 +403,36 @@ namespace ComputeSharp.Graphics.Extensions
return d3D12GraphicsCommandList.Move();
}
/// <summary>
/// Gets the layout data for a target resource.
/// </summary>
/// <param name="d3D12Device">The target <see cref="ID3D12Device"/> to use to get the layout info.</param>
/// <param name="d3D12ResourceDesc">The <see cref="D3D12_RESOURCE_DESC"/> value for the target resource.</param>
/// <param name="d3D12PlacedSubresourceFootprint">The resulting layout info for the resource.</param>
/// <param name="numRows">The number of rows in the resource.</param>
/// <param name="rowSizeInBytes">The size in bytes of each row in the resource.</param>
/// <param name="totalSizeInBytes">The total number of bytes for the resource.</param>
public static void GetCopyableFootprint(
this ref ID3D12Device d3D12Device,
D3D12_RESOURCE_DESC* d3D12ResourceDesc,
out D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprint,
out uint numRows,
out ulong rowSizeInBytes,
out ulong totalSizeInBytes)
{
uint a;
ulong b, c;
fixed (D3D12_PLACED_SUBRESOURCE_FOOTPRINT* p = &d3D12PlacedSubresourceFootprint)
{
d3D12Device.GetCopyableFootprints(d3D12ResourceDesc, 0, 1, 0, p, &a, &b, &c);
}
numRows = a;
rowSizeInBytes = b;
totalSizeInBytes = c;
}
/// <summary>
/// Checks the feature support of a given type for a given device.
/// </summary>
+19 -40
ファイルの表示
@@ -1,5 +1,4 @@
using TerraFX.Interop;
using FX = TerraFX.Interop.Windows;
namespace ComputeSharp.Graphics.Extensions
{
@@ -13,39 +12,26 @@ namespace ComputeSharp.Graphics.Extensions
/// </summary>
/// <param name="d3D12GraphicsCommandList">The <see cref="ID3D12GraphicsCommandList"/> instance in use.</param>
/// <param name="d3D12ResourceDestination">The destination <see cref="ID3D12Resource"/> (a texture) to write to.</param>
/// <param name="dxgiFormat">The <see cref="DXGI_FORMAT"/> parameter curreently in use by the texture.</param>
/// <param name="x">The horizontal offset in the destination texture.</param>
/// <param name="y">The vertical offset in the destination texture.</param>
/// <param name="z">The depthwise offset in the destination texture.</param>
/// <param name="d3D12ResourceSource">The source <see cref="ID3D12Resource"/> (a buffer) to read from.</param>
/// <param name="width">The width of the memory area to write to.</param>
/// <param name="height">The height of the memory area to write to.</param>
/// <param name="elementSizeInBytes">The size of each element to copy.</param>
/// <param name="d3D12PlacedSubresourceFootprintSource">The <see cref="D3D12_PLACED_SUBRESOURCE_FOOTPRINT"/> value describing <paramref name="d3D12ResourceSource"/>.</param>
public static void CopyTextureRegion(
this ref ID3D12GraphicsCommandList d3D12GraphicsCommandList,
ID3D12Resource* d3D12ResourceDestination,
DXGI_FORMAT dxgiFormat,
uint x,
uint y,
ushort z,
ID3D12Resource* d3D12ResourceSource,
uint width,
uint height,
uint elementSizeInBytes)
D3D12_PLACED_SUBRESOURCE_FOOTPRINT* d3D12PlacedSubresourceFootprintSource)
{
D3D12_SUBRESOURCE_FOOTPRINT d3D12SubresourceFootprint = new(
dxgiFormat,
width,
height,
1,
(elementSizeInBytes * width + FX.D3D12_TEXTURE_DATA_PITCH_ALIGNMENT - 1) & ~((uint)FX.D3D12_TEXTURE_DATA_PITCH_ALIGNMENT - 1));
D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprint;
d3D12PlacedSubresourceFootprint.Offset = 0;
d3D12PlacedSubresourceFootprint.Footprint = d3D12SubresourceFootprint;
D3D12_TEXTURE_COPY_LOCATION
d3D12TextureCopyLocationDestination = new(d3D12ResourceDestination, 0),
d3D12TextureCopyLocationSource = new(d3D12ResourceSource, d3D12PlacedSubresourceFootprint);
d3D12TextureCopyLocationSource = new(d3D12ResourceSource, in *d3D12PlacedSubresourceFootprintSource);
d3D12GraphicsCommandList.CopyTextureRegion(&d3D12TextureCopyLocationDestination, x, y, 0, &d3D12TextureCopyLocationSource, null);
d3D12GraphicsCommandList.CopyTextureRegion(&d3D12TextureCopyLocationDestination, x, y, z, &d3D12TextureCopyLocationSource, null);
}
/// <summary>
@@ -53,37 +39,30 @@ namespace ComputeSharp.Graphics.Extensions
/// </summary>
/// <param name="d3D12GraphicsCommandList">The <see cref="ID3D12GraphicsCommandList"/> instance in use.</param>
/// <param name="d3D12ResourceDestination">The destination <see cref="ID3D12Resource"/> (a buffer) to write to.</param>
/// <param name="elementSizeInBytes">The size of each element to copy.</param>
/// <param name="d3D12PlacedSubresourceFootprintDestination">The <see cref="D3D12_PLACED_SUBRESOURCE_FOOTPRINT"/> value describing <paramref name="d3D12ResourceDestination"/>.</param>
/// <param name="d3D12ResourceSource">The source <see cref="ID3D12Resource"/> (a texture) to read from.</param>
/// <param name="dxgiFormat">The <see cref="DXGI_FORMAT"/> parameter curreently in use by the texture.</param>
/// <param name="x">The horizontal offset in the destination texture.</param>
/// <param name="y">The vertical offset in the destination texture.</param>
/// <param name="width">The width of the memory area to write to.</param>
/// <param name="height">The height of the memory area to write to.</param>
/// <param name="x">The horizontal offset in the source texture.</param>
/// <param name="y">The vertical offset in the source texture.</param>
/// <param name="z">The depthwise offset in the source texture.</param>
/// <param name="width">The width of the memory area to read from.</param>
/// <param name="height">The height of the memory area to read from.</param>
/// <param name="depth">The depth of the memory area to read from.</param>
public static void CopyTextureRegion(
this ref ID3D12GraphicsCommandList d3D12GraphicsCommandList,
ID3D12Resource* d3D12ResourceDestination,
uint elementSizeInBytes,
D3D12_PLACED_SUBRESOURCE_FOOTPRINT* d3D12PlacedSubresourceFootprintDestination,
ID3D12Resource* d3D12ResourceSource,
DXGI_FORMAT dxgiFormat,
uint x,
uint y,
ushort z,
uint width,
uint height)
uint height,
ushort depth)
{
D3D12_SUBRESOURCE_FOOTPRINT d3D12SubresourceFootprint = new(
dxgiFormat,
width,
height,
1,
(elementSizeInBytes * width + FX.D3D12_TEXTURE_DATA_PITCH_ALIGNMENT - 1) & ~((uint)FX.D3D12_TEXTURE_DATA_PITCH_ALIGNMENT - 1));
D3D12_PLACED_SUBRESOURCE_FOOTPRINT d3D12PlacedSubresourceFootprint;
d3D12PlacedSubresourceFootprint.Offset = 0;
d3D12PlacedSubresourceFootprint.Footprint = d3D12SubresourceFootprint;
D3D12_TEXTURE_COPY_LOCATION
d3D12TextureCopyLocationDestination = new(d3D12ResourceDestination, d3D12PlacedSubresourceFootprint),
d3D12TextureCopyLocationDestination = new(d3D12ResourceDestination, in *d3D12PlacedSubresourceFootprintDestination),
d3D12TextureCopyLocationSource = new(d3D12ResourceSource, 0);
D3D12_BOX d3D12Box = new((int)x, (int)y, (int)(x + width), (int)(y + height));
D3D12_BOX d3D12Box = new((int)x, (int)y, z, (int)(x + width), (int)(y + height), z + depth);
d3D12GraphicsCommandList.CopyTextureRegion(&d3D12TextureCopyLocationDestination, 0, 0, 0, &d3D12TextureCopyLocationSource, &d3D12Box);
}
+1 -1
ファイルの表示
@@ -168,7 +168,7 @@ namespace ComputeSharp.Graphics
ulong d3D12FenceValue;
// Get the target command queue, fence and pool for the list type
switch (commandList.D3d12CommandListType)
switch (commandList.D3D12CommandListType)
{
case D3D12_COMMAND_LIST_TYPE_COMPUTE:
commandAllocatorPool = ref this.computeCommandAllocatorPool;
+197 -45
ファイルの表示
@@ -9,101 +9,253 @@ namespace ComputeSharp.Graphics.Helpers
internal static class MemoryHelper
{
/// <summary>
/// Copies the content of a <see cref="ReadOnlySpan{T}"/> to the area pointed by an input pointer.
/// Copies the content of a source memory area to a target one.
/// </summary>
/// <typeparam name="T">The type of values in the input <see cref="ReadOnlySpan{T}"/>.</typeparam>
/// <param name="source">The source <see cref="ReadOnlySpan{T}"/> to read.</param>
/// <param name="source">The source memory area to read from.</param>
/// <param name="destination">The pointer for the destination memory area.</param>
/// <param name="destinationOffset">The destination offset to start writing data to.</param>
/// <param name="offset">The destination offset to start writing data to.</param>
/// <param name="length">The number of items to copy.</param>
/// <param name="elementSizeInBytes">The size in bytes of each item to copy.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe void Copy<T>(ReadOnlySpan<T> source, void* destination, int destinationOffset)
where T : unmanaged
public static unsafe void Copy(
void* source,
void* destination,
uint offset,
uint length,
uint elementSizeInBytes)
{
source.CopyTo(new Span<T>((T*)destination + destinationOffset, source.Length));
Buffer.MemoryCopy(
source,
(byte*)destination + offset * elementSizeInBytes,
ulong.MaxValue,
elementSizeInBytes * length);
}
/// <summary>
/// Copies a memory area pointed by a pointer to a target <see cref="Span{T}"/>.
/// Copies the content of a source memory area to a target one, accounting for padding.
/// The destination memory area has padding for each element, while the source does not.
/// </summary>
/// <typeparam name="T">The type of values to read.</typeparam>
/// <param name="source">The pointer that indicates the memory area to read from.</param>
/// <param name="sourceOffset">The source offset to start reading data from.</param>
/// <param name="destination">The destination <see cref="Span{T}"/> to write.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe void Copy<T>(void* source, int sourceOffset, Span<T> destination)
/// <param name="source">The source memory area to read from.</param>
/// <param name="destination">The pointer for the destination memory area.</param>
/// <param name="offset">The destination offset to start writing data to.</param>
/// <param name="length">The number of items to copy.</param>
/// <param name="elementPitchInBytes">The padded size of each element.</param>
public static unsafe void Copy<T>(
void* source,
void* destination,
uint offset,
uint length,
uint elementPitchInBytes)
where T : unmanaged
{
new Span<T>((T*)source + sourceOffset, destination.Length).CopyTo(destination);
destination = (byte*)destination + offset * elementPitchInBytes;
for (int i = 0; i < length; i++)
{
*(T*)&((byte*)destination)[i * elementPitchInBytes] = ((T*)source)[i];
}
}
/// <summary>
/// Copies the content of a <see cref="ReadOnlySpan{T}"/> to the 2D area pointed by an input pointer.
/// Copies the content of a source memory area to a target one.
/// </summary>
/// <typeparam name="T">The type of values to read.</typeparam>
/// <param name="source">The destination <see cref="Span{T}"/> to read from.</param>
/// <param name="source">The source memory area to read from.</param>
/// <param name="offset">The source offset to start reading data from.</param>
/// <param name="length">The number of items to copy.</param>
/// <param name="elementSizeInBytes">The size in bytes of each item to copy.</param>
/// <param name="destination">The pointer for the destination memory area.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe void Copy(
void* source,
uint offset,
uint length,
uint elementSizeInBytes,
void* destination)
{
Buffer.MemoryCopy(
(byte*)source + offset * elementSizeInBytes,
destination,
ulong.MaxValue,
elementSizeInBytes * length);
}
/// <summary>
/// Copies the content of a source memory area to a target one, accounting for padding.
/// The source memory area has padding for each element, while the destination does not.
/// </summary>
/// <param name="source">The source memory area to read from.</param>
/// <param name="offset">The source offset to start reading data from.</param>
/// <param name="length">The number of items to copy.</param>
/// <param name="elementPitchInBytes">The padded size of each element.</param>
/// <param name="destination">The pointer for the destination memory area.</param>
public static unsafe void Copy<T>(
void* source,
uint offset,
uint length,
uint elementPitchInBytes,
void* destination)
where T : unmanaged
{
source = (byte*)source + offset * elementPitchInBytes;
for (int i = 0; i < length; i++)
{
((T*)destination)[i] = *(T*)&((byte*)source)[i * elementPitchInBytes];
}
}
/// <summary>
/// Copies the content of a source memory area to the 2D area pointed by an input pointer.
/// The destination memory area has padding in each row, while the source does not.
/// </summary>
/// <param name="source">The source pointer to read from.</param>
/// <param name="destination">The pointer that indicates the 2D memory area to write to.</param>
/// <param name="width">The width of the 2D memory area to read.</param>
/// <param name="height">The height of the 2D memory area to read.</param>
/// <param name="height">The height of the 2D memory area to write to.</param>
/// <param name="widthInBytes">The width of the memory area in bytes.</param>
/// <param name="pitchInBytes">The pitch (padded width) of the memory area in bytes.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe void Copy<T>(
ReadOnlySpan<T> source,
public static unsafe void Copy(
void* source,
void* destination,
int width,
int height,
uint height,
ulong widthInBytes,
ulong pitchInBytes)
where T : unmanaged
{
if (widthInBytes == pitchInBytes)
{
source.CopyTo(new Span<T>(destination, width * height));
Buffer.MemoryCopy(source, destination, ulong.MaxValue, widthInBytes * height);
}
else
{
for (int i = 0; i < height; i++)
{
ReadOnlySpan<T> sourceRow = source.Slice(i * width, width);
Span<T> destinationRow = new((byte*)destination + (uint)i * pitchInBytes, width);
sourceRow.CopyTo(destinationRow);
Buffer.MemoryCopy(
(byte*)source + (uint)i * widthInBytes,
(byte*)destination + (uint)i * pitchInBytes,
ulong.MaxValue,
widthInBytes);
}
}
}
/// <summary>
/// Copies a 2D memory area pointed by a pointer value to a target <see cref="Span{T}"/>.
/// Copies a 2D memory area pointed by a pointer value to a target memory area.
/// The source memory area has padding in each row, while the target does not.
/// </summary>
/// <typeparam name="T">The type of values to read.</typeparam>
/// <param name="source">The pointer that indicates the memory area to read from.</param>
/// <param name="width">The width of the 2D memory area to read.</param>
/// <param name="height">The height of the 2D memory area to read.</param>
/// <param name="widthInBytes">The width of the memory area in bytes.</param>
/// <param name="pitchInBytes">The pitch (padded width) of the memory area in bytes.</param>
/// <param name="destination">The destination <see cref="Span{T}"/> to write.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe void Copy<T>(
/// <param name="destination">The destination pointer to write to.</param>
public static unsafe void Copy(
void* source,
int width,
int height,
uint height,
ulong widthInBytes,
ulong pitchInBytes,
Span<T> destination)
where T : unmanaged
void* destination)
{
if (widthInBytes == pitchInBytes)
{
new Span<T>(source, width * height).CopyTo(destination);
Buffer.MemoryCopy(source, destination, ulong.MaxValue, widthInBytes * height);
}
else
{
for (int i = 0; i < height; i++)
{
ReadOnlySpan<T> sourceRow = new((byte*)source + (uint)i * pitchInBytes, width);
Span<T> destinationRow = destination.Slice(i * width, width);
Buffer.MemoryCopy(
(byte*)source + (uint)i * pitchInBytes,
(byte*)destination + (uint)i * widthInBytes,
ulong.MaxValue,
widthInBytes);
}
}
}
sourceRow.CopyTo(destinationRow);
/// <summary>
/// Copies the content of a source memory area to the 3D area pointed by an input pointer.
/// The destination memory area has padding in each row, while the source does not.
/// </summary>
/// <typeparam name="T">The type of values to read.</typeparam>
/// <param name="source">The source memory area to read from.</param>
/// <param name="destination">The pointer that indicates the 3D memory area to write to.</param>
/// <param name="height">The height of the 3D memory area to write to.</param>
/// <param name="depth">The depth of the 3D memory area to write to.</param>
/// <param name="widthInBytes">The width of the memory area in bytes.</param>
/// <param name="pitchInBytes">The pitch (padded width) of the memory area in bytes.</param>
/// <param name="sliceInBytes">The size in bytes of each 2D slice within the target 3D memory area.</param>
public static unsafe void Copy(
void* source,
void* destination,
uint height,
uint depth,
ulong widthInBytes,
ulong pitchInBytes,
ulong sliceInBytes)
{
if (widthInBytes == pitchInBytes)
{
Buffer.MemoryCopy(source, destination, ulong.MaxValue, widthInBytes * height * depth);
}
else
{
for (int z = 0; z < depth; z++)
{
ulong
sourceZOffset = (uint)z * widthInBytes * height,
destinationZOffset = (uint)z * sliceInBytes;
for (int i = 0; i < height; i++)
{
Buffer.MemoryCopy(
(byte*)source + sourceZOffset + (uint)i * widthInBytes,
(byte*)destination + destinationZOffset + (uint)i * pitchInBytes,
ulong.MaxValue,
widthInBytes);
}
}
}
}
/// <summary>
/// Copies a 3D memory area pointed by a pointer value to a target memory area.
/// The source memory area has padding in each row, while the target does not.
/// </summary>
/// <typeparam name="T">The type of values to read.</typeparam>
/// <param name="source">The pointer that indicates the memory area to read from.</param>
/// <param name="height">The height of the 3D memory area to read.</param>
/// <param name="depth">The depth of the 3D memory area to read.</param>
/// <param name="widthInBytes">The width of the memory area in bytes.</param>
/// <param name="pitchInBytes">The pitch (padded width) of the memory area in bytes.</param>
/// <param name="sliceInBytes">The size in bytes of each 2D slice within the source 3D memory area.</param>
/// <param name="destination">The destination pointer to write.</param>
public static unsafe void Copy(
void* source,
uint height,
uint depth,
ulong widthInBytes,
ulong pitchInBytes,
ulong sliceInBytes,
void* destination)
{
if (widthInBytes == pitchInBytes)
{
Buffer.MemoryCopy(source, destination, ulong.MaxValue, widthInBytes * height * depth);
}
else
{
for (int z = 0; z < depth; z++)
{
ulong
sourceZOffset = (uint)z * sliceInBytes,
destinationZOffset = (uint)z * widthInBytes * height;
for (int i = 0; i < height; i++)
{
Buffer.MemoryCopy(
(byte*)source + sourceZOffset + (uint)i * pitchInBytes,
(byte*)destination + destinationZOffset + (uint)i * widthInBytes,
ulong.MaxValue,
widthInBytes);
}
}
}
}
+3 -1
ファイルの表示
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using ComputeSharp.Core.Extensions;
using ComputeSharp.Graphics;
using ComputeSharp.Graphics.Commands;
@@ -136,8 +137,9 @@ namespace ComputeSharp.Shaders
// Initialize the loop targets and the captured values
ConstantBuffer<Int4> variablesBuffer = ShaderRunner.GetVariablesBuffer(device);
ReadOnlySpan<Int4> variables = dispatchData.Variables;
variablesBuffer.SetData(dispatchData.Variables);
variablesBuffer.SetData(ref MemoryMarshal.GetReference(variables), variables.Length, 0);
commandList.SetComputeRootDescriptorTable(0, variablesBuffer.D3D12GpuDescriptorHandle);
@@ -63,7 +63,7 @@ namespace ComputeSharp.Shaders.Mappings
type.GetGenericTypeDefinition() == typeof(ConstantBuffer<>);
/// <summary>
/// Checks whether or not the input type is a <see cref="ReadOnlyBuffer{T}"/> or <see cref="ReadOnlyTexture2D{T}"/> value.
/// Checks whether or not the input type is a known readonly resource type (buffer or texture).
/// </summary>
/// <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 a readonly resource type.</returns>
@@ -76,11 +76,12 @@ namespace ComputeSharp.Shaders.Mappings
return
genericType == typeof(ReadOnlyBuffer<>) ||
genericType == typeof(ReadOnlyTexture2D<>);
genericType == typeof(ReadOnlyTexture2D<>) ||
genericType == typeof(ReadOnlyTexture3D<>);
}
/// <summary>
/// Checks whether or not the input type is a <see cref="ReadWriteBuffer{T}"/> or <see cref="ReadWriteTexture2D{T}"/> value.
/// Checks whether or not the input type is a known writeable resource type (buffer or texture).
/// </summary>
/// <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 a writeable resource type.</returns>
@@ -93,7 +94,8 @@ namespace ComputeSharp.Shaders.Mappings
return
genericType == typeof(ReadWriteBuffer<>) ||
genericType == typeof(ReadWriteTexture2D<>);
genericType == typeof(ReadWriteTexture2D<>) ||
genericType == typeof(ReadWriteTexture3D<>);
}
}
}
+20
ファイルの表示
@@ -74,6 +74,26 @@ namespace ComputeSharp.SourceGenerators.Extensions
return symbol.ToDisplayString(FullyQualifiedWithoutGlobalAndParametersFormat);
}
/// <summary>
/// Gets the full metadata name for a given <see cref="IPropertySymbol"/> instance.
/// </summary>
/// <param name="symbol">The input <see cref="IPropertySymbol"/> instance.</param>
/// <returns>The full metadata name for <paramref name="symbol"/>.</returns>
[Pure]
public static string GetFullMetadataName(this IPropertySymbol symbol)
{
string declaringTypeName = symbol.ContainingType.GetFullMetadataName();
if (symbol.IsIndexer)
{
var parameters = string.Join(", ", symbol.Parameters.Select(static p => ((INamedTypeSymbol)p.Type).GetFullMetadataName()));
return $"{declaringTypeName}.this[{parameters}]";
}
return $"{declaringTypeName}.{symbol.Name}";
}
/// <summary>
/// Gets a valid filename for a target symbol and generator type.
/// </summary>
+23 -4
ファイルの表示
@@ -12,6 +12,17 @@ namespace ComputeSharp.SourceGenerators.Mappings
/// </summary>
internal static class HlslKnownMembers
{
/// <summary>
/// The mapping of supported known indexers to HLSL vector type names.
/// </summary>
private static readonly IReadOnlyDictionary<string, string> KnownIndexers = new Dictionary<string, string>
{
[$"ComputeSharp.ReadOnlyTexture2D`1.this[{typeof(int).FullName}, {typeof(int).FullName}]"] = "int2",
[$"ComputeSharp.ReadWriteTexture2D`1.this[{typeof(int).FullName}, {typeof(int).FullName}]"] = "int2",
[$"ComputeSharp.ReadOnlyTexture3D`1.this[{typeof(int).FullName}, {typeof(int).FullName}, {typeof(int).FullName}]"] = "int3",
[$"ComputeSharp.ReadWriteTexture3D`1.this[{typeof(int).FullName}, {typeof(int).FullName}, {typeof(int).FullName}]"] = "int3"
};
/// <summary>
/// The mapping of supported known members to HLSL names.
/// </summary>
@@ -25,10 +36,6 @@ namespace ComputeSharp.SourceGenerators.Mappings
{
Dictionary<string, string> knownMembers = new()
{
[$"{typeof(ThreadIds).FullName}.{nameof(ThreadIds.X)}"] = "x",
[$"{typeof(ThreadIds).FullName}.{nameof(ThreadIds.Y)}"] = "y",
[$"{typeof(ThreadIds).FullName}.{nameof(ThreadIds.Z)}"] = "z",
[$"{typeof(Vector2).FullName}.{nameof(Vector2.X)}"] = "x",
[$"{typeof(Vector2).FullName}.{nameof(Vector2.Y)}"] = "y",
[$"{typeof(Vector2).FullName}.{nameof(Vector2.Zero)}"] = "(float2)0",
@@ -166,5 +173,17 @@ namespace ComputeSharp.SourceGenerators.Mappings
{
return KnownMembers.TryGetValue(name, out mapped);
}
/// <summary>
/// Tries to get the mapped HLSL-compatible indexer vector type name for the input indexer name.
/// </summary>
/// <param name="name">The input fully qualified indexer name.</param>
/// <param name="mapped">The mapped type name, if one is found.</param>
/// <returns>The HLSL-compatible type name that can be used in an HLSL shader for the given indexer.</returns>
[Pure]
public static bool TryGetMappedIndexerTypeName(string name, out string? mapped)
{
return KnownIndexers.TryGetValue(name, out mapped);
}
}
}
+19 -8
ファイルの表示
@@ -41,20 +41,21 @@ namespace ComputeSharp.SourceGenerators.Mappings
[typeof(Double2).FullName] = "double2",
[typeof(Double3).FullName] = "double3",
[typeof(Double4).FullName] = "double4",
[typeof(ThreadIds).FullName] = "uint3"
[typeof(ThreadIds).FullName] = "int3"
};
/// <summary>
/// Gets the known HLSL vector types available as mapped types.
/// </summary>
public static IReadOnlyCollection<Type> HlslMappedVectorTypes { get; } = new HashSet<Type>(new[]
public static IReadOnlyCollection<Type> HlslMappedVectorTypes { get; } = new[]
{
typeof(ThreadIds),
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>
/// Checks whether or not a given type name matches a typed resource type.
@@ -63,11 +64,18 @@ namespace ComputeSharp.SourceGenerators.Mappings
/// <returns>Whether or not <paramref name="typeName"/> represents a typed resource type.</returns>
public static bool IsTypedResourceType(string typeName)
{
return
typeName == "ComputeSharp.ReadOnlyBuffer`1" ||
typeName == "ComputeSharp.ReadWriteBuffer`1" ||
typeName == "ComputeSharp.ReadOnlyTexture2D`1" ||
typeName == "ComputeSharp.ReadWriteTexture2D`1";
switch (typeName)
{
case "ComputeSharp.ConstantBuffer`1":
case "ComputeSharp.ReadOnlyBuffer`1":
case "ComputeSharp.ReadWriteBuffer`1":
case "ComputeSharp.ReadOnlyTexture2D`1":
case "ComputeSharp.ReadWriteTexture2D`1":
case "ComputeSharp.ReadOnlyTexture3D`1":
case "ComputeSharp.ReadWriteTexture3D`1":
return true;
default: return false;
};
}
/// <summary>
@@ -98,10 +106,13 @@ namespace ComputeSharp.SourceGenerators.Mappings
// Construct the HLSL type name
return typeName switch
{
"ComputeSharp.ConstantBuffer`1" => mapped,
"ComputeSharp.ReadOnlyBuffer`1" => $"StructuredBuffer<{mapped}>",
"ComputeSharp.ReadWriteBuffer`1" => $"RWStructuredBuffer<{mapped}>",
"ComputeSharp.ReadOnlyTexture2D`1" => $"Texture2D<{mapped}>",
"ComputeSharp.ReadWriteTexture2D`1" => $"RWTexture2D<{mapped}>",
"ComputeSharp.ReadOnlyTexture3D`1" => $"Texture3D<{mapped}>",
"ComputeSharp.ReadWriteTexture3D`1" => $"RWTexture3D<{mapped}>",
_ => throw new ArgumentException()
};
}
+17 -1
ファイルの表示
@@ -158,7 +158,7 @@ namespace ComputeSharp.SourceGenerators.SyntaxRewriters
{
var updatedNode = (ObjectCreationExpressionSyntax)base.VisitObjectCreationExpression(node)!;
updatedNode = updatedNode.ReplaceAndTrackType(updatedNode.Type, node.Type, this.semanticModel, this.discoveredTypes);
updatedNode = updatedNode.ReplaceAndTrackType(updatedNode.Type, node, this.semanticModel, this.discoveredTypes);
// New objects use the default HLSL cast syntax, eg. (float4)0
if (updatedNode.ArgumentList!.Arguments.Count == 0)
@@ -342,6 +342,22 @@ namespace ComputeSharp.SourceGenerators.SyntaxRewriters
return updatedNode;
}
/// <inheritdoc/>
public override SyntaxNode? VisitElementAccessExpression(ElementAccessExpressionSyntax node)
{
var updatedNode = (ElementAccessExpressionSyntax)base.VisitElementAccessExpression(node)!;
if (this.semanticModel.GetOperation(node) is IPropertyReferenceOperation operation &&
HlslKnownMembers.TryGetMappedIndexerTypeName(operation.Property.GetFullMetadataName(), out string? mapping))
{
var index = InvocationExpression(IdentifierName(mapping!), ArgumentList(updatedNode.ArgumentList.Arguments));
return updatedNode.WithArgumentList(BracketedArgumentList(SingletonSeparatedList(Argument(index))));
}
return updatedNode;
}
/// <inheritdoc/>
public override SyntaxNode? VisitArgument(ArgumentSyntax node)
{
+1
ファイルの表示
@@ -4,6 +4,7 @@
<TargetFramework>net5.0-windows10.0.19041.0</TargetFramework>
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
+156
ファイルの表示
@@ -0,0 +1,156 @@
using System;
using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
using ComputeSharp.Graphics.Buffers.Abstract;
using Microsoft.Toolkit.Diagnostics;
namespace ComputeSharp
{
/// <summary>
/// A <see langword="class"/> that contains extension methods for the <see cref="Buffer{T}"/> type.
/// </summary>
public static class BufferExtensions
{
/// <summary>
/// Reads the contents of a <see cref="Buffer{T}"/> instance and returns an array.
/// </summary>
/// <typeparam name="T">The type of items stored on the buffer.</typeparam>
/// <param name="buffer">The input <see cref="Buffer{T}"/> instance to read data from.</param>
/// <returns>A <typeparamref name="T"/> array with the contents of the input buffer.</returns>
[Pure]
public static T[] GetData<T>(this Buffer<T> buffer)
where T : unmanaged
{
return buffer.GetData(0, buffer.Length);
}
/// <summary>
/// Reads the contents of a <see cref="Buffer{T}"/> instance in a given range and returns an array.
/// </summary>
/// <typeparam name="T">The type of items stored on the buffer.</typeparam>
/// <param name="buffer">The input <see cref="Buffer{T}"/> instance to read data from.</param>
/// <param name="offset">The offset to start reading data from.</param>
/// <param name="count">The number of items to read.</param>
/// <returns>A <typeparamref name="T"/> array with the contents of the specified range from the current buffer.</returns>
[Pure]
public static T[] GetData<T>(this Buffer<T> buffer, int offset, int count)
where T : unmanaged
{
Guard.IsGreaterThanOrEqualTo(count, 0, nameof(count));
T[] data = GC.AllocateUninitializedArray<T>(count);
buffer.GetData(data.AsSpan(), offset);
return data;
}
/// <summary>
/// Reads the contents of s <see cref="Buffer{T}"/> instance and writes them into a target array.
/// </summary>
/// <typeparam name="T">The type of items stored on the buffer.</typeparam>
/// <param name="buffer">The input <see cref="Buffer{T}"/> instance to read data from.</param>
/// <param name="destination">The input array to write data to.</param>
public static void GetData<T>(this Buffer<T> buffer, T[] destination)
where T : unmanaged
{
buffer.GetData(destination.AsSpan(), 0);
}
/// <summary>
/// Reads the contents of the specified range from s <see cref="Buffer{T}"/> instance and writes them into a target array.
/// </summary>
/// <typeparam name="T">The type of items stored on the buffer.</typeparam>
/// <param name="buffer">The input <see cref="Buffer{T}"/> instance to read data from.</param>
/// <param name="destination">The input array to write data to.</param>
/// <param name="destinationOffset">The starting offset within <paramref name="source"/> to write data to.</param>
/// <param name="bufferOffset">The offset to start reading data from.</param>
/// <param name="count">The number of items to read.</param>
public static void GetData<T>(this Buffer<T> buffer, T[] destination, int destinationOffset, int bufferOffset, int count)
where T : unmanaged
{
Span<T> span = destination.AsSpan(destinationOffset, count);
buffer.GetData(span, bufferOffset);
}
/// <summary>
/// Reads the contents of a <see cref="Buffer{T}"/> instance and writes them into a target <see cref="Span{T}"/>.
/// </summary>
/// <typeparam name="T">The type of items stored on the buffer.</typeparam>
/// <param name="buffer">The input <see cref="Buffer{T}"/> instance to read data from.</param>
/// <param name="destination">The input <see cref="Span{T}"/> to write data to.</param>
public static void GetData<T>(this Buffer<T> buffer, Span<T> destination)
where T : unmanaged
{
buffer.GetData(destination, 0);
}
/// <summary>
/// Reads the contents of the specified range from a <see cref="Buffer{T}"/> instance and writes them into a target <see cref="Span{T}"/>.
/// </summary>
/// <typeparam name="T">The type of items stored on the buffer.</typeparam>
/// <param name="buffer">The input <see cref="Buffer{T}"/> instance to read data from.</param>
/// <param name="destination">The input <see cref="Span{T}"/> to write data to.</param>
/// <param name="offset">The offset to start reading data from.</param>
public static void GetData<T>(this Buffer<T> buffer, Span<T> destination, int offset)
where T : unmanaged
{
buffer.GetData(ref MemoryMarshal.GetReference(destination), destination.Length, offset);
}
/// <summary>
/// Writes the contents of a given <typeparamref name="T"/> array to a <see cref="Buffer{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items stored on the buffer.</typeparam>
/// <param name="buffer">The target <see cref="Buffer{T}"/> instance to write data to.</param>
/// <param name="source">The input <typeparamref name="T"/> array to read data from.</param>
public static void SetData<T>(this Buffer<T> buffer, T[] source)
where T : unmanaged
{
buffer.SetData(source.AsSpan(), 0);
}
/// <summary>
/// Writes the contents of a given <typeparamref name="T"/> array to a specified area of a <see cref="Buffer{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items stored on the buffer.</typeparam>
/// <param name="buffer">The target <see cref="Buffer{T}"/> instance to write data to.</param>
/// <param name="source">The input <typeparamref name="T"/> array to read data from.</param>
/// <param name="sourceOffset">The starting offset within <paramref name="source"/> to read data from.</param>
/// <param name="bufferOffset">The offset to start writing data to.</param>
/// <param name="count">The number of items to write.</param>
public static void SetData<T>(this Buffer<T> buffer, T[] source, int sourceOffset, int bufferOffset, int count)
where T : unmanaged
{
ReadOnlySpan<T> span = source.AsSpan(sourceOffset, count);
buffer.SetData(span, bufferOffset);
}
/// <summary>
/// Writes the contents of a given <see cref="ReadOnlySpan{T}"/> to a <see cref="Buffer{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items stored on the buffer.</typeparam>
/// <param name="buffer">The target <see cref="Buffer{T}"/> instance to write data to.</param>
/// <param name="source">The input <see cref="ReadOnlySpan{T}"/> to read data from.</param>
public static void SetData<T>(this Buffer<T> buffer, ReadOnlySpan<T> source)
where T : unmanaged
{
buffer.SetData(source, 0);
}
/// <summary>
/// Writes the contents of a given <see cref="ReadOnlySpan{T}"/> to a specified area of a <see cref="Buffer{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items stored on the buffer.</typeparam>
/// <param name="buffer">The target <see cref="Buffer{T}"/> instance to write data to.</param>
/// <param name="source">The input <see cref="ReadOnlySpan{T}"/> to read data from.</param>
/// <param name="offset">The offset to start writing data to.</param>
public static void SetData<T>(this Buffer<T> buffer, ReadOnlySpan<T> source, int offset)
where T : unmanaged
{
buffer.SetData(ref MemoryMarshal.GetReference(source), source.Length, offset);
}
}
}
+314
ファイルの表示
@@ -0,0 +1,314 @@
using System;
using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
using ComputeSharp.Graphics.Buffers.Abstract;
using Microsoft.Toolkit.Diagnostics;
namespace ComputeSharp
{
/// <summary>
/// A <see langword="class"/> that contains extension methods for the <see cref="Texture2D{T}"/> type.
/// </summary>
public static class Texture2DExtensions
{
/// <summary>
/// Reads the contents of the current <see cref="Texture2D{T}"/> instance and returns an array.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The input <see cref="Texture2D{T}"/> instance to read data from.</param>
/// <returns>A <typeparamref name="T"/> array with the contents of the current texture.</returns>
[Pure]
public static T[,] GetData<T>(this Texture2D<T> texture)
where T : unmanaged
{
T[,] data = new T[texture.Height, texture.Width];
texture.GetData(data);
return data;
}
/// <summary>
/// Reads the contents of the current <see cref="Texture2D{T}"/> instance and writes them into a target array.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The input <see cref="Texture2D{T}"/> instance to read data from.</param>
/// <param name="destination">The input array to write data to.</param>
public static void GetData<T>(this Texture2D<T> texture, T[,] destination)
where T : unmanaged
{
Guard.IsEqualTo(destination.GetLength(0), texture.Height, nameof(destination));
Guard.IsEqualTo(destination.GetLength(1), texture.Width, nameof(destination));
texture.GetData(ref destination[0, 0], destination.Length, 0, 0, texture.Width, texture.Height);
}
/// <summary>
/// Reads the contents of the specified range from the current <see cref="Texture2D{T}"/> instance and writes them into a target array.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The input <see cref="Texture2D{T}"/> instance to read data from.</param>
/// <param name="destination">The input array to write data to.</param>
public static void GetData<T>(this Texture2D<T> texture, T[] destination)
where T : unmanaged
{
texture.GetData(destination.AsSpan(), 0, 0, texture.Width, texture.Height);
}
/// <summary>
/// Reads the contents of the specified range from the current <see cref="Texture2D{T}"/> instance and writes them into a target array.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The input <see cref="Texture2D{T}"/> instance to read data from.</param>
/// <param name="destination">The input array to write data to.</param>
/// <param name="x">The horizontal range of items to copy.</param>
/// <param name="y">The vertical range of items to copy.</param>
public static void GetData<T>(this Texture2D<T> texture, T[] destination, Range x, Range y)
where T : unmanaged
{
texture.GetData(destination.AsSpan(), x, y);
}
/// <summary>
/// Reads the contents of the specified range from the current <see cref="Texture2D{T}"/> instance and writes them into a target array.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The input <see cref="Texture2D{T}"/> instance to read data from.</param>
/// <param name="destination">The input array to write data to.</param>
/// <param name="x">The horizontal offset in the source texture.</param>
/// <param name="y">The vertical offset in the source texture.</param>
/// <param name="width">The width of the memory area to copy.</param>
/// <param name="height">The height of the memory area to copy.</param>
public static void GetData<T>(this Texture2D<T> texture, T[] destination, int x, int y, int width, int height)
where T : unmanaged
{
texture.GetData(destination.AsSpan(), x, y, width, height);
}
/// <summary>
/// Reads the contents of the specified range from the current <see cref="Texture2D{T}"/> instance and writes them into a target array.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The input <see cref="Texture2D{T}"/> instance to read data from.</param>
/// <param name="destination">The input array to write data to.</param>
/// <param name="offset">The starting offset within <paramref name="source"/> to write data to.</param>
public static void GetData<T>(this Texture2D<T> texture, T[] destination, int offset)
where T : unmanaged
{
texture.GetData(destination.AsSpan(offset), 0, 0, texture.Width, texture.Height);
}
/// <summary>
/// Reads the contents of the specified range from the current <see cref="Texture2D{T}"/> instance and writes them into a target array.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The input <see cref="Texture2D{T}"/> instance to read data from.</param>
/// <param name="destination">The input array to write data to.</param>
/// <param name="offset">The starting offset within <paramref name="source"/> to write data to.</param>
/// <param name="x">The horizontal range of items to copy.</param>
/// <param name="y">The vertical range of items to copy.</param>
public static void GetData<T>(this Texture2D<T> texture, T[] destination, int offset, Range x, Range y)
where T : unmanaged
{
texture.GetData(destination.AsSpan(offset), x, y);
}
/// <summary>
/// Reads the contents of the specified range from the current <see cref="Texture2D{T}"/> instance and writes them into a target array.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The input <see cref="Texture2D{T}"/> instance to read data from.</param>
/// <param name="destination">The input array to write data to.</param>
/// <param name="offset">The starting offset within <paramref name="source"/> to write data to.</param>
/// <param name="x">The horizontal offset in the source texture.</param>
/// <param name="y">The vertical offset in the source texture.</param>
/// <param name="width">The width of the memory area to copy.</param>
/// <param name="height">The height of the memory area to copy.</param>
public static void GetData<T>(this Texture2D<T> texture, T[] destination, int offset, int x, int y, int width, int height)
where T : unmanaged
{
texture.GetData(destination.AsSpan(offset), x, y, width, height);
}
/// <summary>
/// Reads the contents of the current <see cref="Texture2D{T}"/> instance and writes them into a target <see cref="Span{T}"/>.
/// The input data will be read from the start of the texture.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The input <see cref="Texture2D{T}"/> instance to read data from.</param>
/// <param name="destination">The input <see cref="Span{T}"/> to write data to.</param>
public static void GetData<T>(this Texture2D<T> texture, Span<T> destination)
where T : unmanaged
{
texture.GetData(destination, 0, 0, texture.Width, texture.Height);
}
/// <summary>
/// Reads the contents of the specified range from the current <see cref="Texture2D{T}"/> instance and writes them into a target <see cref="Span{T}"/>.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The input <see cref="Texture2D{T}"/> instance to read data from.</param>
/// <param name="destination">The input <see cref="Span{T}"/> to write data to.</param>
/// <param name="x">The horizontal range of items to copy.</param>
/// <param name="y">The vertical range of items to copy.</param>
public static void GetData<T>(this Texture2D<T> texture, Span<T> destination, Range x, Range y)
where T : unmanaged
{
var (offsetX, width) = x.GetOffsetAndLength(texture.Width);
var (offsetY, height) = y.GetOffsetAndLength(texture.Height);
texture.GetData(destination, offsetX, offsetY, width, height);
}
/// <summary>
/// Reads the contents of the specified range from the current <see cref="Texture2D{T}"/> instance and writes them into a target <see cref="Span{T}"/>.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The input <see cref="Texture2D{T}"/> instance to read data from.</param>
/// <param name="destination">The input <see cref="Span{T}"/> to write data to.</param>
/// <param name="x">The horizontal offset in the source texture.</param>
/// <param name="y">The vertical offset in the source texture.</param>
/// <param name="width">The width of the memory area to copy.</param>
/// <param name="height">The height of the memory area to copy.</param>
public static void GetData<T>(this Texture2D<T> texture, Span<T> destination, int x, int y, int width, int height)
where T : unmanaged
{
texture.GetData(ref MemoryMarshal.GetReference(destination), destination.Length, x, y, width, height);
}
/// <summary>
/// Writes the contents of a given <typeparamref name="T"/> array to the current <see cref="Texture2D{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The target <see cref="Texture2D{T}"/> instance to write data to.</param>
/// <param name="source">The input <typeparamref name="T"/> array to read data from.</param>
public static unsafe void SetData<T>(this Texture2D<T> texture, T[,] source)
where T : unmanaged
{
Guard.IsEqualTo(source.GetLength(0), texture.Height, nameof(source));
Guard.IsEqualTo(source.GetLength(1), texture.Width, nameof(source));
texture.SetData(ref source[0, 0], source.Length, 0, 0, texture.Width, texture.Height);
}
/// <summary>
/// Writes the contents of a given <typeparamref name="T"/> array to the current <see cref="Texture2D{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The target <see cref="Texture2D{T}"/> instance to write data to.</param>
/// <param name="source">The input <typeparamref name="T"/> array to read data from.</param>
public static void SetData<T>(this Texture2D<T> texture, T[] source)
where T : unmanaged
{
texture.SetData(source.AsSpan(), 0, 0, texture.Width, texture.Height);
}
/// <summary>
/// Writes the contents of a given <typeparamref name="T"/> array to a specified area of the current <see cref="Texture2D{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The target <see cref="Texture2D{T}"/> instance to write data to.</param>
/// <param name="source">The input <typeparamref name="T"/> array to read data from.</param>
/// <param name="x">The horizontal range of items to write.</param>
/// <param name="y">The vertical range of items to write.</param>
public static void SetData<T>(this Texture2D<T> texture, T[] source, Range x, Range y)
where T : unmanaged
{
texture.SetData(source.AsSpan(), x, y);
}
/// <summary>
/// Writes the contents of a given <typeparamref name="T"/> array to a specified area of the current <see cref="Texture2D{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The target <see cref="Texture2D{T}"/> instance to write data to.</param>
/// <param name="source">The input <typeparamref name="T"/> array to read data from.</param>
/// <param name="x">The horizontal offset in the destination texture.</param>
/// <param name="y">The vertical offset in the destination texture.</param>
/// <param name="width">The width of the memory area to write to.</param>
/// <param name="height">The height of the memory area to write to.</param>
public static void SetData<T>(this Texture2D<T> texture, T[] source, int x, int y, int width, int height)
where T : unmanaged
{
texture.SetData(source.AsSpan(), x, y, width, height);
}
/// <summary>
/// Writes the contents of a given <typeparamref name="T"/> array to a specified area of the current <see cref="Texture2D{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The target <see cref="Texture2D{T}"/> instance to write data to.</param>
/// <param name="source">The input <typeparamref name="T"/> array to read data from.</param>
/// <param name="offset">The starting offset within <paramref name="source"/> to read data from.</param>
/// <param name="x">The horizontal range of items to write.</param>
/// <param name="y">The vertical range of items to write.</param>
public static void SetData<T>(this Texture2D<T> texture, T[] source, int offset, Range x, Range y)
where T : unmanaged
{
texture.SetData(source.AsSpan(offset), x, y);
}
/// <summary>
/// Writes the contents of a given <typeparamref name="T"/> array to a specified area of the current <see cref="Texture2D{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The target <see cref="Texture2D{T}"/> instance to write data to.</param>
/// <param name="source">The input <typeparamref name="T"/> array to read data from.</param>
/// <param name="offset">The starting offset within <paramref name="source"/> to read data from.</param>
/// <param name="x">The horizontal offset in the destination texture.</param>
/// <param name="y">The vertical offset in the destination texture.</param>
/// <param name="width">The width of the memory area to write to.</param>
/// <param name="height">The height of the memory area to write to.</param>
public static void SetData<T>(this Texture2D<T> texture, T[] source, int offset, int x, int y, int width, int height)
where T : unmanaged
{
texture.SetData(source.AsSpan(offset), x, y, width, height);
}
/// <summary>
/// Writes the contents of a given <see cref="ReadOnlySpan{T}"/> to the current <see cref="Texture2D{T}"/> instance.
/// The input data will be written to the start of the texture, and all input items will be copied.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The target <see cref="Texture2D{T}"/> instance to write data to.</param>
/// <param name="source">The input <see cref="ReadOnlySpan{T}"/> to read data from.</param>
public static void SetData<T>(this Texture2D<T> texture, ReadOnlySpan<T> source)
where T : unmanaged
{
texture.SetData(source, 0, 0, texture.Width, texture.Height);
}
/// <summary>
/// Writes the contents of a given <see cref="ReadOnlySpan{T}"/> to a specified area of the current <see cref="Texture2D{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The target <see cref="Texture2D{T}"/> instance to write data to.</param>
/// <param name="source">The input <see cref="ReadOnlySpan{T}"/> to read data from.</param>
/// <param name="x">The horizontal range of items to write.</param>
/// <param name="y">The vertical range of items to write.</param>
public static void SetData<T>(this Texture2D<T> texture, ReadOnlySpan<T> source, Range x, Range y)
where T : unmanaged
{
var (offsetX, width) = x.GetOffsetAndLength(texture.Width);
var (offsetY, height) = y.GetOffsetAndLength(texture.Height);
texture.SetData(source, offsetX, offsetY, width, height);
}
/// <summary>
/// Writes the contents of a given <see cref="ReadOnlySpan{T}"/> to a specified area of the current <see cref="Texture2D{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The target <see cref="Texture2D{T}"/> instance to write data to.</param>
/// <param name="source">The input <see cref="ReadOnlySpan{T}"/> to read data from.</param>
/// <param name="x">The horizontal offset in the destination texture.</param>
/// <param name="y">The vertical offset in the destination texture.</param>
/// <param name="width">The width of the memory area to write to.</param>
/// <param name="height">The height of the memory area to write to.</param>
public static void SetData<T>(this Texture2D<T> texture, ReadOnlySpan<T> source, int x, int y, int width, int height)
where T : unmanaged
{
texture.SetData(ref MemoryMarshal.GetReference(source), source.Length, x, y, width, height);
}
}
}
+303
ファイルの表示
@@ -0,0 +1,303 @@
using System;
using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
using ComputeSharp.Graphics.Buffers.Abstract;
using Microsoft.Toolkit.Diagnostics;
namespace ComputeSharp
{
/// <summary>
/// A <see langword="class"/> that contains extension methods for the <see cref="Texture3D{T}"/> type.
/// </summary>
public static class Texture3DExtensions
{
/// <summary>
/// Reads the contents of the current <see cref="Texture3D{T}"/> instance and returns an array.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The input <see cref="Texture3D{T}"/> instance to read data from.</param>
/// <returns>A <typeparamref name="T"/> array with the contents of the current buffer.</returns>
/// <remarks>
/// The returned array will be using the same memory layout as the texture, that is, each 2D plane
/// in the 3D volume represented by the texture is contiguous in memory, and planes are stacked in
/// the depth dimension. This means that the resulting 3D array will have a size of [D, H, W].
/// </remarks>
[Pure]
public static T[,,] GetData<T>(this Texture3D<T> texture)
where T : unmanaged
{
T[,,] data = new T[texture.Depth, texture.Height, texture.Width];
texture.GetData(data);
return data;
}
/// <summary>
/// Reads the contents of the current <see cref="Texture3D{T}"/> instance and writes them into a target array.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The input <see cref="Texture3D{T}"/> instance to read data from.</param>
/// <param name="destination">The input array to write data to.</param>
/// <remarks>
/// The input 3D array needs to have each 2D plane stacked on the depth axis. That is, the expected
/// layout of the input array has to be [<see cref="Depth"/>, <see cref="Height"/>, <see cref="Width"/>].
/// </remarks>
public static void GetData<T>(this Texture3D<T> texture, T[,,] destination)
where T : unmanaged
{
Guard.IsEqualTo(destination.GetLength(0), texture.Depth, nameof(destination));
Guard.IsEqualTo(destination.GetLength(1), texture.Height, nameof(destination));
Guard.IsEqualTo(destination.GetLength(2), texture.Width, nameof(destination));
texture.GetData(ref destination[0, 0, 0], destination.Length, 0, 0, 0, texture.Width, texture.Height, texture.Depth);
}
/// <summary>
/// Reads the contents of the specified range from the current <see cref="Texture3D{T}"/> instance and writes them into a target array.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The input <see cref="Texture3D{T}"/> instance to read data from.</param>
/// <param name="destination">The input array to write data to.</param>
/// <param name="offset">The starting offset within <paramref name="source"/> to write data to.</param>
public static void GetData<T>(this Texture3D<T> texture, T[] destination, int offset)
where T : unmanaged
{
texture.GetData(destination.AsSpan(offset), 0, 0, 0, texture.Width, texture.Height, texture.Depth);
}
/// <summary>
/// Reads the contents of the specified range from the current <see cref="Texture3D{T}"/> instance and writes them into a target array.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The input <see cref="Texture3D{T}"/> instance to read data from.</param>
/// <param name="destination">The input array to write data to.</param>
/// <param name="offset">The starting offset within <paramref name="source"/> to write data to.</param>
/// <param name="x">The horizontal range of items to copy.</param>
/// <param name="y">The vertical range of items to copy.</param>
/// <param name="z">The depthwise range of items to copy.</param>
public static void GetData<T>(this Texture3D<T> texture, T[] destination, int offset, Range x, Range y, Range z)
where T : unmanaged
{
texture.GetData(destination.AsSpan(offset), x, y, z);
}
/// <summary>
/// Reads the contents of the specified range from the current <see cref="Texture3D{T}"/> instance and writes them into a target array.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The input <see cref="Texture3D{T}"/> instance to read data from.</param>
/// <param name="destination">The input array to write data to.</param>
/// <param name="offset">The starting offset within <paramref name="source"/> to write data to.</param>
/// <param name="x">The horizontal offset in the source texture.</param>
/// <param name="y">The vertical offset in the source texture.</param>
/// <param name="z">The depthwise offset in the source texture.</param>
/// <param name="width">The width of the memory area to copy.</param>
/// <param name="height">The height of the memory area to copy.</param>
/// <param name="depth">The depth of the memory area to copy.</param>
public static void GetData<T>(this Texture3D<T> texture, T[] destination, int offset, int x, int y, int z, int width, int height, int depth)
where T : unmanaged
{
texture.GetData(destination.AsSpan(offset), x, y, z, width, height, depth);
}
/// <summary>
/// Reads the contents of the specified range from the current <see cref="Texture3D{T}"/> instance and writes them into a target <see cref="Span{T}"/>.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The input <see cref="Texture3D{T}"/> instance to read data from.</param>
/// <param name="destination">The input <see cref="Span{T}"/> to write data to.</param>
public static void GetData<T>(this Texture3D<T> texture, Span<T> destination)
where T : unmanaged
{
texture.GetData(destination, 0, 0, 0, texture.Width, texture.Height, texture.Depth);
}
/// <summary>
/// Reads the contents of the specified range from the current <see cref="Texture3D{T}"/> instance and writes them into a target <see cref="Span{T}"/>.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The input <see cref="Texture3D{T}"/> instance to read data from.</param>
/// <param name="destination">The input <see cref="Span{T}"/> to write data to.</param>
/// <param name="x">The horizontal range in the source texture.</param>
/// <param name="y">The vertical range in the source texture.</param>
/// <param name="z">The depthwise range in the source texture.</param>
public static void GetData<T>(this Texture3D<T> texture, Span<T> destination, Range x, Range y, Range z)
where T : unmanaged
{
var (offsetX, width) = x.GetOffsetAndLength(texture.Width);
var (offsetY, height) = y.GetOffsetAndLength(texture.Height);
var (offsetZ, depth) = z.GetOffsetAndLength(texture.Depth);
texture.GetData(destination, offsetX, offsetY, offsetZ, width, height, depth);
}
/// <summary>
/// Reads the contents of the specified range from the current <see cref="Texture3D{T}"/> instance and writes them into a target <see cref="Span{T}"/>.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The input <see cref="Texture3D{T}"/> instance to read data from.</param>
/// <param name="destination">The input <see cref="Span{T}"/> to write data to.</param>
/// <param name="x">The horizontal offset in the source texture.</param>
/// <param name="y">The vertical offset in the source texture.</param>
/// <param name="z">The depthwise offset in the source texture.</param>
/// <param name="width">The width of the memory area to copy.</param>
/// <param name="height">The height of the memory area to copy.</param>
/// <param name="depth">The depth of the memory area to copy.</param>
public static void GetData<T>(this Texture3D<T> texture, Span<T> destination, int x, int y, int z, int width, int height, int depth)
where T : unmanaged
{
texture.GetData(ref MemoryMarshal.GetReference(destination), destination.Length, x, y, z, width, height, depth);
}
/// <summary>
/// Writes the contents of a given <typeparamref name="T"/> array to the current <see cref="Texture3D{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The target <see cref="Texture3D{T}"/> instance to write data to.</param>
/// <param name="source">The input <typeparamref name="T"/> array to read data from.</param>
/// <remarks>
/// The source 3D array needs to have each 2D plane stacked on the depth axis. That is, the expected
/// layout of the input array has to be [<see cref="Depth"/>, <see cref="Height"/>, <see cref="Width"/>].
/// </remarks>
public static void SetData<T>(this Texture3D<T> texture, T[,,] source)
where T : unmanaged
{
Guard.IsEqualTo(source.GetLength(0), texture.Depth, nameof(source));
Guard.IsEqualTo(source.GetLength(1), texture.Height, nameof(source));
Guard.IsEqualTo(source.GetLength(2), texture.Width, nameof(source));
texture.SetData(ref source[0, 0, 0], source.Length, 0, 0, 0, texture.Width, texture.Height, texture.Depth);
}
/// <summary>
/// Writes the contents of a given <typeparamref name="T"/> array to the current <see cref="Texture3D{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The target <see cref="Texture3D{T}"/> instance to write data to.</param>
/// <param name="source">The input <typeparamref name="T"/> array to read data from.</param>
public static void SetData<T>(this Texture3D<T> texture, T[] source)
where T : unmanaged
{
texture.SetData(source.AsSpan(), 0, 0, 0, texture.Width, texture.Height, texture.Depth);
}
/// <summary>
/// Writes the contents of a given <typeparamref name="T"/> array to a specified area of the current <see cref="Texture3D{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The target <see cref="Texture3D{T}"/> instance to write data to.</param>
/// <param name="source">The input <typeparamref name="T"/> array to read data from.</param>
/// <param name="x">The horizontal range of items to write.</param>
/// <param name="y">The vertical range of items to write.</param>
/// <param name="z">The depthwise range of items to write.</param>
public static void SetData<T>(this Texture3D<T> texture, T[] source, Range x, Range y, Range z)
where T : unmanaged
{
texture.SetData(source.AsSpan(), x, y, z);
}
/// <summary>
/// Writes the contents of a given <typeparamref name="T"/> array to a specified area of the current <see cref="Texture3D{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The target <see cref="Texture3D{T}"/> instance to write data to.</param>
/// <param name="source">The input <typeparamref name="T"/> array to read data from.</param>
/// <param name="x">The horizontal offset in the destination texture.</param>
/// <param name="y">The vertical offset in the destination texture.</param>
/// <param name="z">The depthwise offset in the destination texture.</param>
/// <param name="width">The width of the memory area to write to.</param>
/// <param name="height">The height of the memory area to write to.</param>
/// <param name="depth">The depth of the memory area to write to.</param>
public static void SetData<T>(this Texture3D<T> texture, T[] source, int x, int y, int z, int width, int height, int depth)
where T : unmanaged
{
texture.SetData(source.AsSpan(), x, y, z, width, height, depth);
}
/// <summary>
/// Writes the contents of a given <typeparamref name="T"/> array to a specified area of the current <see cref="Texture3D{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The target <see cref="Texture3D{T}"/> instance to write data to.</param>
/// <param name="source">The input <typeparamref name="T"/> array to read data from.</param>
/// <param name="offset">The starting offset within <paramref name="source"/> to read data from.</param>
/// <param name="x">The horizontal range of items to write.</param>
/// <param name="y">The vertical range of items to write.</param>
/// <param name="z">The depthwise range of items to write.</param>
public static void SetData<T>(this Texture3D<T> texture, T[] source, int offset, Range x, Range y, Range z)
where T : unmanaged
{
texture.SetData(source.AsSpan(offset), x, y, z);
}
/// <summary>
/// Writes the contents of a given <typeparamref name="T"/> array to a specified area of the current <see cref="Texture3D{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The target <see cref="Texture3D{T}"/> instance to write data to.</param>
/// <param name="source">The input <typeparamref name="T"/> array to read data from.</param>
/// <param name="offset">The starting offset within <paramref name="source"/> to read data from.</param>
/// <param name="x">The horizontal offset in the destination texture.</param>
/// <param name="y">The vertical offset in the destination texture.</param>
/// <param name="z">The depthwise offset in the destination texture.</param>
/// <param name="width">The width of the memory area to write to.</param>
/// <param name="height">The height of the memory area to write to.</param>
/// <param name="depth">The depth of the memory area to write to.</param>
public static void SetData<T>(this Texture3D<T> texture, T[] source, int offset, int x, int y, int z, int width, int height, int depth)
where T : unmanaged
{
texture.SetData(source.AsSpan(offset), x, y, z, width, height, depth);
}
/// <summary>
/// Writes the contents of a given <see cref="ReadOnlySpan{T}"/> to the current <see cref="Texture3D{T}"/> instance.
/// The input data will be written to the start of the texture, and all input items will be copied.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The target <see cref="Texture3D{T}"/> instance to write data to.</param>
/// <param name="source">The input <see cref="ReadOnlySpan{T}"/> to read data from.</param>
public static void SetData<T>(this Texture3D<T> texture, ReadOnlySpan<T> source)
where T : unmanaged
{
texture.SetData(source, 0, 0, 0, texture.Width, texture.Height, texture.Depth);
}
/// <summary>
/// Writes the contents of a given <see cref="ReadOnlySpan{T}"/> to a specified area of the current <see cref="Texture3D{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The target <see cref="Texture3D{T}"/> instance to write data to.</param>
/// <param name="source">The input <see cref="ReadOnlySpan{T}"/> to read data from.</param>
/// <param name="x">The horizontal range of items to write.</param>
/// <param name="y">The vertical range of items to write.</param>
/// <param name="z">The depthwise range of items to write.</param>
public static void SetData<T>(this Texture3D<T> texture, ReadOnlySpan<T> source, Range x, Range y, Range z)
where T : unmanaged
{
var (offsetX, width) = x.GetOffsetAndLength(texture.Width);
var (offsetY, height) = y.GetOffsetAndLength(texture.Height);
var (offsetZ, depth) = z.GetOffsetAndLength(texture.Depth);
texture.SetData(source, offsetX, offsetY, offsetZ, width, height, depth);
}
/// <summary>
/// Writes the contents of a given <see cref="ReadOnlySpan{T}"/> to a specified area of the current <see cref="Texture3D{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The target <see cref="Texture3D{T}"/> instance to write data to.</param>
/// <param name="source">The input <see cref="ReadOnlySpan{T}"/> to read data from.</param>
/// <param name="x">The horizontal offset in the destination texture.</param>
/// <param name="y">The vertical offset in the destination texture.</param>
/// <param name="z">The depthwise offseet in the destination texture.</param>
/// <param name="width">The width of the memory area to write to.</param>
/// <param name="height">The height of the memory area to write to.</param>
/// <param name="depth">The depth of the memory area to write to.</param>
public static void SetData<T>(this Texture3D<T> texture, ReadOnlySpan<T> source, int x, int y, int z, int width, int height, int depth)
where T : unmanaged
{
texture.SetData(ref MemoryMarshal.GetReference(source), source.Length, x, y, z, width, height, depth);
}
}
}
+252 -64
ファイルの表示
@@ -139,70 +139,6 @@ namespace ComputeSharp
return readWriteBuffer;
}
/// <summary>
/// Allocates a new read write buffer with the specified parameters.
/// </summary>
/// <typeparam name="T">The type of items to store in the buffer.</typeparam>
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the buffer.</param>
/// <param name="length">The length of the buffer to allocate.</param>
/// <returns>A zeroed <see cref="ReadWriteBuffer{T}"/> instance of size <paramref name="length"/>.</returns>
[Pure]
public static ReadWriteBuffer<T> AllocateReadWriteBuffer<T>(this GraphicsDevice device, int length)
where T : unmanaged
{
return new(device, length);
}
/// <summary>
/// Allocates a new read write buffer with the specified parameters.
/// </summary>
/// <typeparam name="T">The type of items to store in the buffer.</typeparam>
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the buffer.</param>
/// <param name="array">The input <typeparamref name="T"/> array with the data to copy on the allocated buffer.</param>
/// <returns>A read write <see cref="ReadWriteBuffer{T}"/> instance with the contents of the input array.</returns>
[Pure]
public static ReadWriteBuffer<T> AllocateReadWriteBuffer<T>(this GraphicsDevice device, T[] array)
where T : unmanaged
{
return device.AllocateReadWriteBuffer<T>(array.AsSpan());
}
/// <summary>
/// Allocates a new read write buffer with the specified parameters.
/// </summary>
/// <typeparam name="T">The type of items to store in the buffer.</typeparam>
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the buffer.</param>
/// <param name="span">The input <see cref="ReadOnlySpan{T}"/> with the data to copy on the allocated buffer.</param>
/// <returns>A read write <see cref="ReadWriteBuffer{T}"/> instance with the contents of the input <see cref="ReadOnlySpan{T}"/>.</returns>
[Pure]
public static ReadWriteBuffer<T> AllocateReadWriteBuffer<T>(this GraphicsDevice device, ReadOnlySpan<T> span)
where T : unmanaged
{
ReadWriteBuffer<T> buffer = new(device, span.Length);
buffer.SetData(span);
return buffer;
}
/// <summary>
/// Allocates a new read write buffer with the specified parameters.
/// </summary>
/// <typeparam name="T">The type of items to store in the buffer.</typeparam>
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the buffer.</param>
/// <param name="buffer">The input <see cref="Buffer{T}"/> with the data to copy on the allocated buffer.</param>
/// <returns>A read write <see cref="ReadWriteBuffer{T}"/> instance with the contents of the input <see cref="Buffer{T}"/>.</returns>
[Pure]
public static ReadWriteBuffer<T> AllocateReadWriteBuffer<T>(this GraphicsDevice device, Buffer<T> buffer)
where T : unmanaged
{
ReadWriteBuffer<T> readWriteBuffer = new(device, buffer.Length);
readWriteBuffer.SetData(buffer);
return readWriteBuffer;
}
/// <summary>
/// Allocates a new readonly 2D texture with the specified parameters.
/// </summary>
@@ -289,6 +225,164 @@ namespace ComputeSharp
return texture;
}
/// <summary>
/// Allocates a new readonly 3D texture with the specified parameters.
/// </summary>
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
/// <param name="width">The width of the texture.</param>
/// <param name="height">The height of the texture.</param>
/// <param name="depth">The depth of the texture.</param>
/// <returns>A zeroed <see cref="ReadOnlyTexture3D{T}"/> instance of size [<paramref name="width"/>, <paramref name="height"/>, <paramref name="depth"/>].</returns>
[Pure]
public static ReadOnlyTexture3D<T> AllocateReadOnlyTexture3D<T>(this GraphicsDevice device, int width, int height, int depth)
where T : unmanaged
{
return new(device, width, height, depth);
}
/// <summary>
/// Allocates a new readonly 3D texture with the specified parameters.
/// </summary>
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
/// <param name="array">The input <typeparamref name="T"/> array with the data to copy on the allocated texture.</param>
/// <param name="width">The width of the texture.</param>
/// <param name="height">The height of the texture.</param>
/// <param name="depth">The depth of the texture.</param>
/// <returns>A <see cref="ReadOnlyTexture3D{T}"/> instance with the contents of the input array.</returns>
[Pure]
public static ReadOnlyTexture3D<T> AllocateReadOnlyTexture3D<T>(this GraphicsDevice device, T[] array, int width, int height, int depth)
where T : unmanaged
{
return device.AllocateReadOnlyTexture3D<T>(array.AsSpan(), width, height, depth);
}
/// <summary>
/// Allocates a new readonly 3D texture with the specified parameters.
/// </summary>
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
/// <param name="array">The input <typeparamref name="T"/> array with the data to copy on the allocated texture.</param>
/// <param name="offset">The starting offset within <paramref name="source"/> to read data from.</param>
/// <param name="width">The width of the texture.</param>
/// <param name="height">The height of the texture.</param>
/// <param name="depth">The depth of the texture.</param>
/// <returns>A <see cref="ReadOnlyTexture3D{T}"/> instance with the contents of the input array.</returns>
[Pure]
public static ReadOnlyTexture3D<T> AllocateReadOnlyTexture3D<T>(this GraphicsDevice device, T[] array, int offset, int width, int height, int depth)
where T : unmanaged
{
return device.AllocateReadOnlyTexture3D<T>(array.AsSpan(offset), width, height, depth);
}
/// <summary>
/// Allocates a new readonly 3D texture with the specified parameters.
/// </summary>
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
/// <param name="array">The input <typeparamref name="T"/> array with the data to copy on the allocated texture.</param>
/// <returns>A read write <see cref="ReadOnlyTexture3D{T}"/> instance with the contents of the input array.</returns>
/// <remarks>
/// The source 3D array needs to have each 2D plane stacked on the depth axis.
/// That is, the expected layout of the input array has to be [depth, height, width].
/// </remarks>
[Pure]
public static ReadOnlyTexture3D<T> AllocateReadOnlyTexture3D<T>(this GraphicsDevice device, T[,,] array)
where T : unmanaged
{
ReadOnlyTexture3D<T> texture = new(device, array.GetLength(2), array.GetLength(1), array.GetLength(0));
texture.SetData(array);
return texture;
}
/// <summary>
/// Allocates a new readonly 3D texture with the specified parameters.
/// </summary>
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
/// <param name="span">The input <see cref="ReadOnlySpan{T}"/> with the data to copy on the allocated texture.</param>
/// <param name="width">The width of the texture.</param>
/// <param name="height">The height of the texture.</param>
/// <param name="depth">The depth of the texture.</param>
/// <returns>A <see cref="ReadOnlyTexture3D{T}"/> instance with the contents of the input <see cref="ReadOnlySpan{T}"/>.</returns>
[Pure]
public static ReadOnlyTexture3D<T> AllocateReadOnlyTexture3D<T>(this GraphicsDevice device, ReadOnlySpan<T> span, int width, int height, int depth)
where T : unmanaged
{
ReadOnlyTexture3D<T> texture = new(device, width, height, depth);
texture.SetData(span);
return texture;
}
/// <summary>
/// Allocates a new read write buffer with the specified parameters.
/// </summary>
/// <typeparam name="T">The type of items to store in the buffer.</typeparam>
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the buffer.</param>
/// <param name="length">The length of the buffer to allocate.</param>
/// <returns>A zeroed <see cref="ReadWriteBuffer{T}"/> instance of size <paramref name="length"/>.</returns>
[Pure]
public static ReadWriteBuffer<T> AllocateReadWriteBuffer<T>(this GraphicsDevice device, int length)
where T : unmanaged
{
return new(device, length);
}
/// <summary>
/// Allocates a new read write buffer with the specified parameters.
/// </summary>
/// <typeparam name="T">The type of items to store in the buffer.</typeparam>
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the buffer.</param>
/// <param name="array">The input <typeparamref name="T"/> array with the data to copy on the allocated buffer.</param>
/// <returns>A read write <see cref="ReadWriteBuffer{T}"/> instance with the contents of the input array.</returns>
[Pure]
public static ReadWriteBuffer<T> AllocateReadWriteBuffer<T>(this GraphicsDevice device, T[] array)
where T : unmanaged
{
return device.AllocateReadWriteBuffer<T>(array.AsSpan());
}
/// <summary>
/// Allocates a new read write buffer with the specified parameters.
/// </summary>
/// <typeparam name="T">The type of items to store in the buffer.</typeparam>
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the buffer.</param>
/// <param name="span">The input <see cref="ReadOnlySpan{T}"/> with the data to copy on the allocated buffer.</param>
/// <returns>A read write <see cref="ReadWriteBuffer{T}"/> instance with the contents of the input <see cref="ReadOnlySpan{T}"/>.</returns>
[Pure]
public static ReadWriteBuffer<T> AllocateReadWriteBuffer<T>(this GraphicsDevice device, ReadOnlySpan<T> span)
where T : unmanaged
{
ReadWriteBuffer<T> buffer = new(device, span.Length);
buffer.SetData(span);
return buffer;
}
/// <summary>
/// Allocates a new read write buffer with the specified parameters.
/// </summary>
/// <typeparam name="T">The type of items to store in the buffer.</typeparam>
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the buffer.</param>
/// <param name="buffer">The input <see cref="Buffer{T}"/> with the data to copy on the allocated buffer.</param>
/// <returns>A read write <see cref="ReadWriteBuffer{T}"/> instance with the contents of the input <see cref="Buffer{T}"/>.</returns>
[Pure]
public static ReadWriteBuffer<T> AllocateReadWriteBuffer<T>(this GraphicsDevice device, Buffer<T> buffer)
where T : unmanaged
{
ReadWriteBuffer<T> readWriteBuffer = new(device, buffer.Length);
readWriteBuffer.SetData(buffer);
return readWriteBuffer;
}
/// <summary>
/// Allocates a new writeable 2D texture with the specified parameters.
/// </summary>
@@ -375,6 +469,100 @@ namespace ComputeSharp
return texture;
}
/// <summary>
/// Allocates a new writeable 3D texture with the specified parameters.
/// </summary>
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
/// <param name="width">The width of the texture.</param>
/// <param name="height">The height of the texture.</param>
/// <param name="depth">The depth of the texture.</param>
/// <returns>A zeroed <see cref="ReadWriteTexture3D{T}"/> instance of size [<paramref name="width"/>, <paramref name="height"/>].</returns>
[Pure]
public static ReadWriteTexture3D<T> AllocateReadWriteTexture3D<T>(this GraphicsDevice device, int width, int height, int depth)
where T : unmanaged
{
return new(device, width, height, depth);
}
/// <summary>
/// Allocates a new writeable 3D texture with the specified parameters.
/// </summary>
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
/// <param name="array">The input <typeparamref name="T"/> array with the data to copy on the allocated texture.</param>
/// <param name="width">The width of the texture.</param>
/// <param name="height">The height of the texture.</param>
/// <param name="depth">The depth of the texture.</param>
/// <returns>A <see cref="ReadWriteTexture3D{T}"/> instance with the contents of the input array.</returns>
[Pure]
public static ReadWriteTexture3D<T> AllocateReadWriteTexture3D<T>(this GraphicsDevice device, T[] array, int width, int height, int depth)
where T : unmanaged
{
return device.AllocateReadWriteTexture3D<T>(array.AsSpan(), width, height, depth);
}
/// <summary>
/// Allocates a new writeable 3D texture with the specified parameters.
/// </summary>
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
/// <param name="array">The input <typeparamref name="T"/> array with the data to copy on the allocated texture.</param>
/// <param name="offset">The starting offset within <paramref name="source"/> to read data from.</param>
/// <param name="width">The width of the texture.</param>
/// <param name="height">The height of the texture.</param>
/// <param name="depth">The depth of the texture.</param>
/// <returns>A <see cref="ReadWriteTexture3D{T}"/> instance with the contents of the input array.</returns>
[Pure]
public static ReadWriteTexture3D<T> AllocateReadWriteTexture3D<T>(this GraphicsDevice device, T[] array, int offset, int width, int height, int depth)
where T : unmanaged
{
return device.AllocateReadWriteTexture3D<T>(array.AsSpan(offset), width, height, depth);
}
/// <summary>
/// Allocates a new writeable 3D texture with the specified parameters.
/// </summary>
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
/// <param name="array">The input <typeparamref name="T"/> array with the data to copy on the allocated texture.</param>
/// <returns>A read write <see cref="ReadWriteTexture3D{T}"/> instance with the contents of the input array.</returns>
/// <remarks>
/// The source 3D array needs to have each 2D plane stacked on the depth axis.
/// That is, the expected layout of the input array has to be [depth, height, width].
/// </remarks>
[Pure]
public static ReadWriteTexture3D<T> AllocateReadWriteTexture3D<T>(this GraphicsDevice device, T[,,] array)
where T : unmanaged
{
ReadWriteTexture3D<T> texture = new(device, array.GetLength(2), array.GetLength(1), array.GetLength(0));
texture.SetData(array);
return texture;
}
/// <summary>
/// Allocates a new writeable 3D texture with the specified parameters.
/// </summary>
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
/// <param name="span">The input <see cref="ReadOnlySpan{T}"/> with the data to copy on the allocated texture.</param>
/// <param name="width">The width of the texture.</param>
/// <param name="height">The height of the texture.</param>
/// <param name="depth">The depth of the texture.</param>
/// <returns>A <see cref="ReadWriteTexture3D{T}"/> instance with the contents of the input <see cref="ReadOnlySpan{T}"/>.</returns>
[Pure]
public static ReadWriteTexture3D<T> AllocateReadWriteTexture3D<T>(this GraphicsDevice device, ReadOnlySpan<T> span, int width, int height, int depth)
where T : unmanaged
{
ReadWriteTexture3D<T> texture = new(device, width, height, depth);
texture.SetData(span);
return texture;
}
/// <summary>
/// Compiles and runs the input shader on a target <see cref="GraphicsDevice"/> instance, with the specified parameters.
/// </summary>
+99 -5
ファイルの表示
@@ -7,14 +7,14 @@ using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace ComputeSharp.Tests
{
[TestClass]
[TestCategory("Buffers")]
public class BufferTests
[TestCategory("Buffer")]
public partial class BufferTests
{
[TestMethod]
[DataRow(typeof(ConstantBuffer<>))]
[DataRow(typeof(ReadOnlyBuffer<>))]
[DataRow(typeof(ReadWriteBuffer<>))]
public void AllocateBuffer_Uninitialized(Type bufferType)
public void Allocate_Uninitialized_Ok(Type bufferType)
{
using Buffer<float> buffer = Gpu.Default.AllocateBuffer<float>(bufferType, 128);
@@ -23,11 +23,24 @@ namespace ComputeSharp.Tests
Assert.AreSame(buffer.GraphicsDevice, Gpu.Default);
}
[TestMethod]
[DataRow(typeof(ConstantBuffer<>), -247824)]
[DataRow(typeof(ConstantBuffer<>), -1)]
[DataRow(typeof(ConstantBuffer<>), -247824)]
[DataRow(typeof(ConstantBuffer<>), -1)]
[DataRow(typeof(ConstantBuffer<>), -247824)]
[DataRow(typeof(ConstantBuffer<>), -1)]
[ExpectedException(typeof(ArgumentOutOfRangeException))]
public void Allocate_Uninitialized_Fail(Type bufferType, int length)
{
using Buffer<float> buffer = Gpu.Default.AllocateBuffer<float>(bufferType, length);
}
[TestMethod]
[DataRow(typeof(ConstantBuffer<>))]
[DataRow(typeof(ReadOnlyBuffer<>))]
[DataRow(typeof(ReadWriteBuffer<>))]
public void AllocateBuffer_FromArray(Type bufferType)
public void Allocate_FromArray(Type bufferType)
{
float[] data = Enumerable.Range(0, 128).Select(static i => (float)i).ToArray();
@@ -54,7 +67,7 @@ namespace ComputeSharp.Tests
[DataRow(typeof(ReadWriteBuffer<>), typeof(ConstantBuffer<>))]
[DataRow(typeof(ReadWriteBuffer<>), typeof(ReadOnlyBuffer<>))]
[DataRow(typeof(ReadWriteBuffer<>), typeof(ReadWriteBuffer<>))]
public void AllocateBuffer_FromBuffer(Type sourceType, Type destinationType)
public void Allocate_FromBuffer(Type sourceType, Type destinationType)
{
float[] data = Enumerable.Range(0, 128).Select(static i => (float)i).ToArray();
@@ -188,5 +201,86 @@ namespace ComputeSharp.Tests
buffer.GetData(result, destinationOffset, bufferOffset, count);
}
[TestMethod]
public void Dispatch_ConstantBuffer()
{
int[] data = Enumerable.Range(0, 1024).ToArray();
using ConstantBuffer<int> source = Gpu.Default.AllocateConstantBuffer(data);
using ReadWriteBuffer<int> destination = Gpu.Default.AllocateReadWriteBuffer<int>(data.Length);
Gpu.Default.For(source.Length, new ConstantBufferKernel(source, destination));
int[] result = destination.GetData();
CollectionAssert.AreEqual(data, result);
}
[AutoConstructor]
private readonly partial struct ConstantBufferKernel : IComputeShader
{
public readonly ConstantBuffer<int> source;
public readonly ReadWriteBuffer<int> destination;
public void Execute(ThreadIds ids)
{
destination[ids.X] = source[ids.X];
}
}
[TestMethod]
public void Dispatch_ReadOnlyBuffer()
{
int[] data = Enumerable.Range(0, 1024).ToArray();
using ReadOnlyBuffer<int> source = Gpu.Default.AllocateReadOnlyBuffer(data);
using ReadWriteBuffer<int> destination = Gpu.Default.AllocateReadWriteBuffer<int>(data.Length);
Gpu.Default.For(source.Length, new ReadOnlyBufferKernel(source, destination));
int[] result = destination.GetData();
CollectionAssert.AreEqual(data, result);
}
[AutoConstructor]
private readonly partial struct ReadOnlyBufferKernel : IComputeShader
{
public readonly ReadOnlyBuffer<int> source;
public readonly ReadWriteBuffer<int> destination;
public void Execute(ThreadIds ids)
{
destination[ids.X] = source[ids.X];
}
}
[TestMethod]
public void Dispatch_ReadWriteBuffer()
{
int[] data = Enumerable.Range(0, 1024).ToArray();
using ReadWriteBuffer<int> source = Gpu.Default.AllocateReadWriteBuffer(data);
using ReadWriteBuffer<int> destination = Gpu.Default.AllocateReadWriteBuffer<int>(data.Length);
Gpu.Default.For(source.Length, new ReadWriteBufferKernel(source, destination));
int[] result = destination.GetData();
CollectionAssert.AreEqual(data, result);
}
[AutoConstructor]
private readonly partial struct ReadWriteBufferKernel : IComputeShader
{
public readonly ReadWriteBuffer<int> source;
public readonly ReadWriteBuffer<int> destination;
public void Execute(ThreadIds ids)
{
destination[ids.X] = source[ids.X];
}
}
}
}
+1
ファイルの表示
@@ -7,6 +7,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" />
<PackageReference Include="Microsoft.Toolkit.HighPerformance" Version="7.0.0-preview4" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
</ItemGroup>
+107
ファイルの表示
@@ -31,6 +31,49 @@ namespace ComputeSharp.Tests.Extensions
};
}
/// <summary>
/// Allocates a new <see cref="Texture2D{T}"/> instance of the specified type.
/// </summary>
/// <typeparam name="T">The type of items in the texture.</typeparam>
/// <param name="device">The target <see cref="GraphicsDevice"/> instance to allocate the texture for.</param>
/// <param name="type">The type of texture to allocate.</param>
/// <param name="width">The width of the texture to create.</param>
/// <param name="height">The height of the texture to create.</param>
/// <returns>A <see cref="Texture2D{T}"/> instance of the requested size.</returns>
[Pure]
public static Texture2D<T> AllocateTexture2D<T>(this GraphicsDevice device, Type type, int width, int height)
where T : unmanaged
{
return type switch
{
_ when type == typeof(ReadOnlyTexture2D<>) => device.AllocateReadOnlyTexture2D<T>(width, height),
_ when type == typeof(ReadWriteTexture2D<>) => device.AllocateReadWriteTexture2D<T>(width, height),
_ => throw new ArgumentException($"Invalid type: {type}", nameof(type))
};
}
/// <summary>
/// Allocates a new <see cref="Texture3D{T}"/> instance of the specified type.
/// </summary>
/// <typeparam name="T">The type of items in the texture.</typeparam>
/// <param name="device">The target <see cref="GraphicsDevice"/> instance to allocate the texture for.</param>
/// <param name="type">The type of texture to allocate.</param>
/// <param name="width">The width of the texture to create.</param>
/// <param name="height">The height of the texture to create.</param>
/// <param name="depth">The depth of the texture to create.</param>
/// <returns>A <see cref="Texture2D{T}"/> instance of the requested size.</returns>
[Pure]
public static Texture3D<T> AllocateTexture3D<T>(this GraphicsDevice device, Type type, int width, int height, int depth)
where T : unmanaged
{
return type switch
{
_ when type == typeof(ReadOnlyTexture3D<>) => device.AllocateReadOnlyTexture3D<T>(width, height, depth),
_ when type == typeof(ReadWriteTexture3D<>) => device.AllocateReadWriteTexture3D<T>(width, height, depth),
_ => throw new ArgumentException($"Invalid type: {type}", nameof(type))
};
}
/// <summary>
/// Allocates a new <see cref="Buffer{T}"/> instance of the specified type.
/// </summary>
@@ -52,6 +95,70 @@ namespace ComputeSharp.Tests.Extensions
};
}
/// <summary>
/// Allocates a new <see cref="Texture2D{T}"/> instance of the specified type.
/// </summary>
/// <typeparam name="T">The type of items in the texture.</typeparam>
/// <param name="device">The target <see cref="GraphicsDevice"/> instance to allocate the texture for.</param>
/// <param name="type">The type of buffer to allocate.</param>
/// <param name="data">The data to load on the texture.</param>
/// <param name="width">The width of the texture to create.</param>
/// <param name="height">The height of the texture to create.</param>
/// <returns>A <see cref="Texture2D{T}"/> instance of the requested type.</returns>
[Pure]
public static Texture2D<T> AllocateTexture2D<T>(this GraphicsDevice device, Type type, T[] data, int width, int height)
where T : unmanaged
{
return type switch
{
_ when type == typeof(ReadOnlyTexture2D<>) => device.AllocateReadOnlyTexture2D(data, width, height),
_ when type == typeof(ReadWriteTexture2D<>) => device.AllocateReadWriteTexture2D(data, width, height),
_ => throw new ArgumentException($"Invalid type: {type}", nameof(type))
};
}
/// <summary>
/// Allocates a new <see cref="Texture3D{T}"/> instance of the specified type.
/// </summary>
/// <typeparam name="T">The type of items in the texture.</typeparam>
/// <param name="device">The target <see cref="GraphicsDevice"/> instance to allocate the texture for.</param>
/// <param name="type">The type of buffer to allocate.</param>
/// <param name="data">The data to load on the texture.</param>
/// <param name="width">The width of the texture to create.</param>
/// <param name="height">The height of the texture to create.</param>
/// <param name="depth">The depth of the texture to create.</param>
/// <returns>A <see cref="Texture2D{T}"/> instance of the requested type.</returns>
[Pure]
public static Texture3D<T> AllocateTexture3D<T>(this GraphicsDevice device, Type type, T[] data, int width, int height, int depth)
where T : unmanaged
{
return type switch
{
_ when type == typeof(ReadOnlyTexture3D<>) => device.AllocateReadOnlyTexture3D(data, width, height, depth),
_ when type == typeof(ReadWriteTexture3D<>) => device.AllocateReadWriteTexture3D(data, width, height, depth),
_ => throw new ArgumentException($"Invalid type: {type}", nameof(type))
};
}
/// <summary>
/// Allocates a new <see cref="Texture3D{T}"/> instance of the specified type.
/// </summary>
/// <typeparam name="T">The type of items in the texture.</typeparam>
/// <param name="device">The target <see cref="GraphicsDevice"/> instance to allocate the texture for.</param>
/// <param name="type">The type of texture to allocate.</param>
/// <returns>A <see cref="Texture2D{T}"/> instance of the requested size.</returns>
[Pure]
public static Texture3D<T> AllocateTexture3D<T>(this GraphicsDevice device, Type type, T[,,] data)
where T : unmanaged
{
return type switch
{
_ when type == typeof(ReadOnlyTexture3D<>) => device.AllocateReadOnlyTexture3D<T>(data),
_ when type == typeof(ReadWriteTexture3D<>) => device.AllocateReadWriteTexture3D<T>(data),
_ => throw new ArgumentException($"Invalid type: {type}", nameof(type))
};
}
/// <summary>
/// Allocates a new <see cref="Buffer{T}"/> instance of the specified type.
/// </summary>
+197
ファイルの表示
@@ -0,0 +1,197 @@
using System;
using System.Linq;
using ComputeSharp.Graphics.Buffers.Abstract;
using ComputeSharp.Tests.Extensions;
using Microsoft.Toolkit.HighPerformance.Memory;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace ComputeSharp.Tests
{
[TestClass]
[TestCategory("Texture2D")]
public partial class Texture2DTests
{
[TestMethod]
[DataRow(typeof(ReadOnlyTexture2D<>))]
[DataRow(typeof(ReadWriteTexture2D<>))]
public void Allocate_Uninitialized_Ok(Type textureType)
{
using Texture2D<float> texture = Gpu.Default.AllocateTexture2D<float>(textureType, 128, 128);
Assert.IsNotNull(texture);
Assert.AreEqual(texture.Width, 128);
Assert.AreEqual(texture.Height, 128);
Assert.AreSame(texture.GraphicsDevice, Gpu.Default);
}
[TestMethod]
[DataRow(typeof(ReadOnlyTexture2D<>), 128, -14253)]
[DataRow(typeof(ReadOnlyTexture2D<>), 128, -1)]
[DataRow(typeof(ReadOnlyTexture2D<>), 0, -4314)]
[DataRow(typeof(ReadOnlyTexture2D<>), -14, -53)]
[DataRow(typeof(ReadWriteTexture2D<>), 128, -14253)]
[DataRow(typeof(ReadWriteTexture2D<>), 128, -1)]
[DataRow(typeof(ReadWriteTexture2D<>), 0, -4314)]
[DataRow(typeof(ReadWriteTexture2D<>), -14, -53)]
[ExpectedException(typeof(ArgumentOutOfRangeException))]
public void Allocate_Uninitialized_Fail(Type textureType, int width, int height)
{
using Texture2D<float> texture = Gpu.Default.AllocateTexture2D<float>(textureType, width, height);
}
[TestMethod]
[DataRow(typeof(ReadOnlyTexture2D<>))]
[DataRow(typeof(ReadWriteTexture2D<>))]
public void Allocate_FromArray(Type textureType)
{
float[] data = Enumerable.Range(0, 128 * 128).Select(static i => (float)i).ToArray();
using Texture2D<float> texture = Gpu.Default.AllocateTexture2D(textureType, data, 128, 128);
Assert.IsNotNull(texture);
Assert.AreEqual(texture.Width, 128);
Assert.AreEqual(texture.Height, 128);
Assert.AreSame(texture.GraphicsDevice, Gpu.Default);
float[,] result = texture.GetData();
Assert.IsNotNull(result);
Assert.AreEqual(data.Length, result.Length);
Assert.IsTrue(data.SequenceEqual(result.Cast<float>()));
}
[TestMethod]
[DataRow(typeof(ReadOnlyTexture2D<>))]
[DataRow(typeof(ReadWriteTexture2D<>))]
[ExpectedException(typeof(ObjectDisposedException))]
public void UsageAfterDispose(Type textureType)
{
using Texture2D<float> texture = Gpu.Default.AllocateTexture2D<float>(textureType, 10, 10);
texture.Dispose();
_ = texture.GetData();
}
[TestMethod]
[DataRow(typeof(ReadOnlyTexture2D<>), 0, 0, 64, 64)]
[DataRow(typeof(ReadOnlyTexture2D<>), 0, 14, 64, 50)]
[DataRow(typeof(ReadOnlyTexture2D<>), 14, 0, 50, 64)]
[DataRow(typeof(ReadOnlyTexture2D<>), 10, 10, 54, 54)]
[DataRow(typeof(ReadOnlyTexture2D<>), 20, 20, 32, 27)]
[DataRow(typeof(ReadOnlyTexture2D<>), 60, 0, 4, 64)]
[DataRow(typeof(ReadOnlyTexture2D<>), 0, 60, 64, 4)]
[DataRow(typeof(ReadOnlyTexture2D<>), 63, 2, 1, 60)]
[DataRow(typeof(ReadOnlyTexture2D<>), 2, 63, 60, 1)]
[DataRow(typeof(ReadWriteTexture2D<>), 0, 0, 64, 64)]
[DataRow(typeof(ReadWriteTexture2D<>), 0, 14, 64, 50)]
[DataRow(typeof(ReadWriteTexture2D<>), 14, 0, 50, 64)]
[DataRow(typeof(ReadWriteTexture2D<>), 10, 10, 54, 54)]
[DataRow(typeof(ReadWriteTexture2D<>), 20, 20, 32, 27)]
[DataRow(typeof(ReadWriteTexture2D<>), 60, 0, 4, 64)]
[DataRow(typeof(ReadWriteTexture2D<>), 0, 60, 64, 4)]
[DataRow(typeof(ReadWriteTexture2D<>), 63, 2, 1, 60)]
[DataRow(typeof(ReadWriteTexture2D<>), 2, 63, 60, 1)]
public void GetData_RangeToVoid_Ok(Type textureType, int x, int y, int width, int height)
{
float[] array = Enumerable.Range(0, 4096).Select(static i => (float)i).ToArray();
using Texture2D<float> texture = Gpu.Default.AllocateTexture2D(textureType, array, 64, 64);
float[] result = new float[width * height];
texture.GetData(result, x, y, width, height);
Span2D<float>
expected = new Span2D<float>(array, 64, 64).Slice(y, x, height, width),
data = new(result, height, width);
CollectionAssert.AreEqual(expected.ToArray(), data.ToArray());
}
[TestMethod]
[DataRow(typeof(ReadOnlyTexture2D<>), 0, -1, 50, 50)]
[DataRow(typeof(ReadOnlyTexture2D<>), -1, 0, 50, 50)]
[DataRow(typeof(ReadOnlyTexture2D<>), 12, 0, -1, 50)]
[DataRow(typeof(ReadOnlyTexture2D<>), 12, 0, 20, -1)]
[DataRow(typeof(ReadOnlyTexture2D<>), 12, 20, 20, 50)]
[DataRow(typeof(ReadOnlyTexture2D<>), 12, 20, 60, 20)]
[DataRow(typeof(ReadOnlyTexture2D<>), 80, 20, 40, 20)]
[DataRow(typeof(ReadOnlyTexture2D<>), 0, 80, 40, 20)]
[DataRow(typeof(ReadWriteTexture2D<>), 0, -1, 50, 50)]
[DataRow(typeof(ReadWriteTexture2D<>), -1, 0, 50, 50)]
[DataRow(typeof(ReadWriteTexture2D<>), 12, 0, -1, 50)]
[DataRow(typeof(ReadWriteTexture2D<>), 12, 0, 20, -1)]
[DataRow(typeof(ReadWriteTexture2D<>), 12, 20, 20, 50)]
[DataRow(typeof(ReadWriteTexture2D<>), 12, 20, 60, 20)]
[DataRow(typeof(ReadWriteTexture2D<>), 80, 20, 40, 20)]
[DataRow(typeof(ReadWriteTexture2D<>), 0, 80, 40, 20)]
[ExpectedException(typeof(ArgumentOutOfRangeException))]
public void GetData_RangeToVoid_Fail(Type textureType, int x, int y, int width, int height)
{
float[] array = Enumerable.Range(0, 4096).Select(static i => (float)i).ToArray();
using Texture2D<float> texture = Gpu.Default.AllocateTexture2D(textureType, array, 64, 64);
float[] result = new float[4096];
texture.GetData(result, x, y, width, height);
}
[TestMethod]
public void Dispatch_ReadOnlyTexture2D()
{
int[] data = Enumerable.Range(0, 32 * 32).ToArray();
using ReadOnlyTexture2D<int> source = Gpu.Default.AllocateReadOnlyTexture2D(data, 32, 32);
using ReadWriteBuffer<int> destination = Gpu.Default.AllocateReadWriteBuffer<int>(data.Length);
Gpu.Default.For(source.Width, source.Height, new ReadOnlyTexture2DKernel(source, destination));
int[] result = destination.GetData();
CollectionAssert.AreEqual(data, result);
}
[AutoConstructor]
private readonly partial struct ReadOnlyTexture2DKernel : IComputeShader
{
public readonly ReadOnlyTexture2D<int> source;
public readonly ReadWriteBuffer<int> destination;
public void Execute(ThreadIds ids)
{
destination[ids.Y * 32 + ids.X] = source[ids.XY];
}
}
[TestMethod]
public void Dispatch_ReadWriteTexture2D()
{
int[] data = Enumerable.Range(0, 32 * 32).ToArray();
using ReadWriteTexture2D<int> source = Gpu.Default.AllocateReadWriteTexture2D(data, 32, 32);
using ReadWriteTexture2D<int> destination = Gpu.Default.AllocateReadWriteTexture2D<int>(32, 32);
Gpu.Default.For(source.Width, source.Height, new ReadWriteTexture2DKernel(source, destination));
int[] result = new int[data.Length];
destination.GetData(result);
CollectionAssert.AreEqual(data, result);
}
[AutoConstructor]
private readonly partial struct ReadWriteTexture2DKernel : IComputeShader
{
public readonly ReadWriteTexture2D<int> source;
public readonly ReadWriteTexture2D<int> destination;
public void Execute(ThreadIds ids)
{
destination[ids.XY] = source[ids.XY];
}
}
}
}
+231
ファイルの表示
@@ -0,0 +1,231 @@
using System;
using System.Linq;
using ComputeSharp.Graphics.Buffers.Abstract;
using ComputeSharp.Tests.Extensions;
using Microsoft.Toolkit.HighPerformance.Extensions;
using Microsoft.Toolkit.HighPerformance.Memory;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace ComputeSharp.Tests
{
[TestClass]
[TestCategory("Texture3D")]
public partial class Texture3DTests
{
[TestMethod]
[DataRow(typeof(ReadOnlyTexture3D<>))]
[DataRow(typeof(ReadWriteTexture3D<>))]
public void Allocate_Uninitialized_Ok(Type textureType)
{
using Texture3D<float> texture = Gpu.Default.AllocateTexture3D<float>(textureType, 64, 64, 12);
Assert.IsNotNull(texture);
Assert.AreEqual(texture.Width, 64);
Assert.AreEqual(texture.Height, 64);
Assert.AreEqual(texture.Depth, 12);
Assert.AreSame(texture.GraphicsDevice, Gpu.Default);
}
[TestMethod]
[DataRow(typeof(ReadOnlyTexture3D<>), 128, -14253, 4)]
[DataRow(typeof(ReadOnlyTexture3D<>), 128, -1, 4)]
[DataRow(typeof(ReadOnlyTexture3D<>), 0, -4314, 4)]
[DataRow(typeof(ReadOnlyTexture3D<>), -14, -53, 4)]
[DataRow(typeof(ReadOnlyTexture3D<>), 12, 12, -1)]
[DataRow(typeof(ReadOnlyTexture3D<>), 2, 4, ushort.MaxValue + 1)]
[DataRow(typeof(ReadWriteTexture3D<>), 128, -14253, 4)]
[DataRow(typeof(ReadWriteTexture3D<>), 128, -1, 4)]
[DataRow(typeof(ReadWriteTexture3D<>), 0, -4314, 4)]
[DataRow(typeof(ReadWriteTexture3D<>), -14, -53, 4)]
[DataRow(typeof(ReadWriteTexture3D<>), 12, 12, -1)]
[DataRow(typeof(ReadWriteTexture3D<>), 2, 4, ushort.MaxValue + 1)]
[ExpectedException(typeof(ArgumentOutOfRangeException))]
public void Allocate_Uninitialized_Fail(Type textureType, int width, int height, int depth)
{
using Texture3D<float> texture = Gpu.Default.AllocateTexture3D<float>(textureType, width, height, depth);
}
[TestMethod]
[DataRow(typeof(ReadOnlyTexture3D<>), 12, 12, 4)]
[DataRow(typeof(ReadOnlyTexture3D<>), 2, 12, 4)]
[DataRow(typeof(ReadOnlyTexture3D<>), 64, 64, 1)]
[DataRow(typeof(ReadOnlyTexture3D<>), 64, 27, 3)]
[DataRow(typeof(ReadWriteTexture3D<>), 12, 12, 4)]
[DataRow(typeof(ReadWriteTexture3D<>), 2, 12, 4)]
[DataRow(typeof(ReadWriteTexture3D<>), 64, 64, 1)]
[DataRow(typeof(ReadWriteTexture3D<>), 64, 27, 3)]
public void Allocate_FromArray(Type textureType, int width, int height, int depth)
{
float[] data = Enumerable.Range(0, width * height * depth).Select(static i => (float)i).ToArray();
using Texture3D<float> texture = Gpu.Default.AllocateTexture3D(textureType, data, width, height, depth);
Assert.IsNotNull(texture);
Assert.AreEqual(texture.Width, width);
Assert.AreEqual(texture.Height, height);
Assert.AreEqual(texture.Depth, depth);
Assert.AreSame(texture.GraphicsDevice, Gpu.Default);
float[,,] result = texture.GetData();
Assert.IsNotNull(result);
Assert.AreEqual(result.GetLength(0), depth);
Assert.AreEqual(result.GetLength(1), height);
Assert.AreEqual(result.GetLength(2), width);
Assert.AreEqual(data.Length, result.Length);
Assert.IsTrue(data.SequenceEqual(result.Cast<float>()));
Array.Clear(result, 0, result.Length);
float[] flat = new float[result.Length];
texture.GetData(flat);
CollectionAssert.AreEqual(flat, data);
}
[TestMethod]
[DataRow(typeof(ReadOnlyTexture3D<>))]
[DataRow(typeof(ReadWriteTexture3D<>))]
[ExpectedException(typeof(ObjectDisposedException))]
public void UsageAfterDispose(Type textureType)
{
using Texture3D<float> texture = Gpu.Default.AllocateTexture3D<float>(textureType, 10, 10, 4);
texture.Dispose();
_ = texture.GetData();
}
[TestMethod]
[DataRow(typeof(ReadOnlyTexture3D<>), 0, 0, 0, 64, 64, 3)]
[DataRow(typeof(ReadOnlyTexture3D<>), 0, 14, 0, 64, 50, 3)]
[DataRow(typeof(ReadOnlyTexture3D<>), 0, 14, 1, 64, 50, 2)]
[DataRow(typeof(ReadOnlyTexture3D<>), 14, 0, 1, 50, 64, 2)]
[DataRow(typeof(ReadOnlyTexture3D<>), 10, 10, 2, 54, 54, 1)]
[DataRow(typeof(ReadOnlyTexture3D<>), 20, 20, 0, 32, 27, 3)]
[DataRow(typeof(ReadOnlyTexture3D<>), 60, 0, 0, 4, 64, 3)]
[DataRow(typeof(ReadOnlyTexture3D<>), 0, 60, 2, 64, 4, 1)]
[DataRow(typeof(ReadOnlyTexture3D<>), 63, 2, 0, 1, 60, 2)]
[DataRow(typeof(ReadOnlyTexture3D<>), 2, 63, 1, 60, 1, 2)]
[DataRow(typeof(ReadWriteTexture3D<>), 0, 0, 0, 64, 64, 3)]
[DataRow(typeof(ReadWriteTexture3D<>), 0, 14, 0, 64, 50, 3)]
[DataRow(typeof(ReadWriteTexture3D<>), 0, 14, 1, 64, 50, 2)]
[DataRow(typeof(ReadWriteTexture3D<>), 14, 0, 1, 50, 64, 2)]
[DataRow(typeof(ReadWriteTexture3D<>), 10, 10, 2, 54, 54, 1)]
[DataRow(typeof(ReadWriteTexture3D<>), 20, 20, 0, 32, 27, 3)]
[DataRow(typeof(ReadWriteTexture3D<>), 60, 0, 0, 4, 64, 3)]
[DataRow(typeof(ReadWriteTexture3D<>), 0, 60, 2, 64, 4, 1)]
[DataRow(typeof(ReadWriteTexture3D<>), 63, 2, 0, 1, 60, 2)]
[DataRow(typeof(ReadWriteTexture3D<>), 2, 63, 1, 60, 1, 2)]
public void GetData_RangeToVoid_Ok(Type textureType, int x, int y, int z, int width, int height, int depth)
{
int[,,] array = new int[3, 64, 64];
foreach (var item in array.AsSpan().Enumerate())
item.Value = item.Index;
using Texture3D<int> texture = Gpu.Default.AllocateTexture3D(textureType, array);
int[,,] result = new int[depth, height, width];
texture.GetData(result.AsSpan(), x, y, z, width, height, depth);
for (int k = 0; k < depth; k++)
{
Span2D<int>
source = array.AsSpan2D(z + k).Slice(y, x, height, width),
destination = result.AsSpan2D(k);
CollectionAssert.AreEqual(source.ToArray(), destination.ToArray());
}
}
[TestMethod]
[DataRow(typeof(ReadOnlyTexture3D<>), 0, -1, 0, 50, 50, 2)]
[DataRow(typeof(ReadOnlyTexture3D<>), -1, 0, 0, 50, 50, 3)]
[DataRow(typeof(ReadOnlyTexture3D<>), 12, 0, 0, -1, 50, 1)]
[DataRow(typeof(ReadOnlyTexture3D<>), 12, 0, 0, 20, 50, 0)]
[DataRow(typeof(ReadOnlyTexture3D<>), 12, 0, 1, 20, -1, 2)]
[DataRow(typeof(ReadOnlyTexture3D<>), 12, 20, 2, 20, 50, 1)]
[DataRow(typeof(ReadOnlyTexture3D<>), 12, 20, 0, 60, 20, 3)]
[DataRow(typeof(ReadOnlyTexture3D<>), 80, 20, 2, 40, 20, 1)]
[DataRow(typeof(ReadOnlyTexture3D<>), 0, 80, 2, 40, 20, 1)]
[DataRow(typeof(ReadWriteTexture3D<>), 0, -1, 0, 50, 50, 2)]
[DataRow(typeof(ReadWriteTexture3D<>), -1, 0, 0, 50, 50, 3)]
[DataRow(typeof(ReadWriteTexture3D<>), 12, 0, 0, -1, 50, 1)]
[DataRow(typeof(ReadWriteTexture3D<>), 12, 0, 0, 20, 50, 0)]
[DataRow(typeof(ReadWriteTexture3D<>), 12, 0, 1, 20, -1, 2)]
[DataRow(typeof(ReadWriteTexture3D<>), 12, 20, 2, 20, 50, 1)]
[DataRow(typeof(ReadWriteTexture3D<>), 12, 20, 0, 60, 20, 3)]
[DataRow(typeof(ReadWriteTexture3D<>), 80, 20, 2, 40, 20, 1)]
[DataRow(typeof(ReadWriteTexture3D<>), 0, 80, 2, 40, 20, 1)]
[ExpectedException(typeof(ArgumentOutOfRangeException))]
public void GetData_RangeToVoid_Fail(Type textureType, int x, int y, int z, int width, int height, int depth)
{
float[] array = Enumerable.Range(0, 64 * 64 * 3).Select(static i => (float)i).ToArray();
using Texture3D<float> texture = Gpu.Default.AllocateTexture3D(textureType, array, 64, 64, 3);
float[] result = new float[array.Length];
texture.GetData(result, x, y, z, width, height, depth);
}
[TestMethod]
public void Dispatch_ReadOnlyTexture3D()
{
int[] data = Enumerable.Range(0, 32 * 32 * 3).ToArray();
using ReadOnlyTexture3D<int> source = Gpu.Default.AllocateReadOnlyTexture3D(data, 32, 32, 3);
using ReadWriteBuffer<int> destination = Gpu.Default.AllocateReadWriteBuffer<int>(data.Length);
Gpu.Default.For(source.Width, source.Height, source.Depth, new ReadOnlyTexture3DKernel(source, destination));
int[] result = destination.GetData();
CollectionAssert.AreEqual(data, result);
}
[AutoConstructor]
private readonly partial struct ReadOnlyTexture3DKernel : IComputeShader
{
public readonly ReadOnlyTexture3D<int> source;
public readonly ReadWriteBuffer<int> destination;
public void Execute(ThreadIds ids)
{
destination[ids.Z * 32 * 32 + ids.Y * 32 + ids.X] = source[ids.XYZ];
}
}
[TestMethod]
public void Dispatch_ReadWriteTexture2D()
{
int[] data = Enumerable.Range(0, 32 * 32 * 3).ToArray();
using ReadWriteTexture3D<int> source = Gpu.Default.AllocateReadWriteTexture3D(data, 32, 32, 3);
using ReadWriteTexture3D<int> destination = Gpu.Default.AllocateReadWriteTexture3D<int>(32, 32, 3);
Gpu.Default.For(source.Width, source.Height, source.Depth, new ReadWriteTexture3DKernel(source, destination));
int[] result = new int[data.Length];
destination.GetData(result);
CollectionAssert.AreEqual(data, result);
}
[AutoConstructor]
private readonly partial struct ReadWriteTexture3DKernel : IComputeShader
{
public readonly ReadWriteTexture3D<int> source;
public readonly ReadWriteTexture3D<int> destination;
public void Execute(ThreadIds ids)
{
destination[ids.XYZ] = source[ids.XYZ];
}
}
}
}