Refactored vector type indexers, switched to ref

このコミットが含まれているのは:
Sergio Pedri committed 2021-02-24 17:47:58 +01:00
1 親 c0bc242c7a
コミット e9e1b6e974
31ファイル変更
+150 -157

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

-10
ファイルの表示
@@ -84,16 +84,6 @@ namespace ComputeSharp
set => throw new InvalidExecutionContextException($"{nameof(Bool2)}.{nameof(G)}");
}
/// <summary>
/// Gets or sets a specific component in the current <see cref="Bool2"/> instance.
/// </summary>
/// <param name="i">The index of the component to access.</param>
public bool this[int i]
{
get => throw new InvalidExecutionContextException($"{nameof(Bool2)}[int]");
set => throw new InvalidExecutionContextException($"{nameof(Bool2)}[int]");
}
/// <summary>
/// Creates a new <see cref="Bool2"/> value with the same value for all its components.
/// </summary>
+9
ファイルの表示
@@ -5,6 +5,15 @@ namespace ComputeSharp
/// <inheritdoc cref="Bool2"/>
public partial struct Bool2
{
/// <summary>
/// Gets or sets a specific component in the current <see cref="Bool2"/> instance.
/// </summary>
/// <param name="i">The index of the component to access.</param>
public ref bool this[int i]
{
get => throw new InvalidExecutionContextException($"{nameof(Bool2)}[int]");
}
/// <summary>
/// Gets a <see cref="Bool2"/> value with the values <see cref="X"/>, <see cref="X"/>.
/// </summary>
-10
ファイルの表示
@@ -112,16 +112,6 @@ namespace ComputeSharp
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}.{nameof(B)}");
}
/// <summary>
/// Gets or sets a specific component in the current <see cref="Bool3"/> instance.
/// </summary>
/// <param name="i">The index of the component to access.</param>
public bool this[int i]
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}[int]");
set => throw new InvalidExecutionContextException($"{nameof(Bool3)}[int]");
}
/// <summary>
/// Creates a new <see cref="Bool3"/> value with the same value for all its components.
/// </summary>
+9
ファイルの表示
@@ -5,6 +5,15 @@ namespace ComputeSharp
/// <inheritdoc cref="Bool3"/>
public partial struct Bool3
{
/// <summary>
/// Gets or sets a specific component in the current <see cref="Bool3"/> instance.
/// </summary>
/// <param name="i">The index of the component to access.</param>
public ref bool this[int i]
{
get => throw new InvalidExecutionContextException($"{nameof(Bool3)}[int]");
}
/// <summary>
/// Gets a <see cref="Bool2"/> value with the values <see cref="X"/>, <see cref="X"/>.
/// </summary>
-10
ファイルの表示
@@ -140,16 +140,6 @@ namespace ComputeSharp
set => throw new InvalidExecutionContextException($"{nameof(Bool4)}.{nameof(A)}");
}
/// <summary>
/// Gets or sets a specific component in the current <see cref="Bool4"/> instance.
/// </summary>
/// <param name="i">The index of the component to access.</param>
public bool this[int i]
{
get => throw new InvalidExecutionContextException($"{nameof(Bool4)}[int]");
set => throw new InvalidExecutionContextException($"{nameof(Bool4)}[int]");
}
/// <summary>
/// Creates a new <see cref="Bool4"/> value with the same value for all its components.
/// </summary>
+9
ファイルの表示
@@ -5,6 +5,15 @@ namespace ComputeSharp
/// <inheritdoc cref="Bool4"/>
public partial struct Bool4
{
/// <summary>
/// Gets or sets a specific component in the current <see cref="Bool4"/> instance.
/// </summary>
/// <param name="i">The index of the component to access.</param>
public ref bool this[int i]
{
get => throw new InvalidExecutionContextException($"{nameof(Bool4)}[int]");
}
/// <summary>
/// Gets a <see cref="Bool2"/> value with the values <see cref="X"/>, <see cref="X"/>.
/// </summary>
-10
ファイルの表示
@@ -70,16 +70,6 @@ namespace ComputeSharp
set => throw new InvalidExecutionContextException($"{nameof(Double2)}.{nameof(G)}");
}
/// <summary>
/// Gets or sets a specific component in the current <see cref="Double2"/> instance.
/// </summary>
/// <param name="i">The index of the component to access.</param>
public double this[int i]
{
get => throw new InvalidExecutionContextException($"{nameof(Double2)}[int]");
set => throw new InvalidExecutionContextException($"{nameof(Double2)}[int]");
}
/// <summary>
/// Creates a new <see cref="Double2"/> value with the same value for all its components.
/// </summary>
+9
ファイルの表示
@@ -5,6 +5,15 @@ namespace ComputeSharp
/// <inheritdoc cref="Double2"/>
public partial struct Double2
{
/// <summary>
/// Gets or sets a specific component in the current <see cref="Double2"/> instance.
/// </summary>
/// <param name="i">The index of the component to access.</param>
public ref double this[int i]
{
get => throw new InvalidExecutionContextException($"{nameof(Double2)}[int]");
}
/// <summary>
/// Gets a <see cref="Double2"/> value with the values <see cref="X"/>, <see cref="X"/>.
/// </summary>
-10
ファイルの表示
@@ -91,16 +91,6 @@ namespace ComputeSharp
set => throw new InvalidExecutionContextException($"{nameof(Double3)}.{nameof(B)}");
}
/// <summary>
/// Gets or sets a specific component in the current <see cref="Double3"/> instance.
/// </summary>
/// <param name="i">The index of the component to access.</param>
public double this[int i]
{
get => throw new InvalidExecutionContextException($"{nameof(Double3)}[int]");
set => throw new InvalidExecutionContextException($"{nameof(Double3)}[int]");
}
/// <summary>
/// Creates a new <see cref="Double3"/> value with the same value for all its components.
/// </summary>
+9
ファイルの表示
@@ -5,6 +5,15 @@ namespace ComputeSharp
/// <inheritdoc cref="Double3"/>
public partial struct Double3
{
/// <summary>
/// Gets or sets a specific component in the current <see cref="Double3"/> instance.
/// </summary>
/// <param name="i">The index of the component to access.</param>
public ref double this[int i]
{
get => throw new InvalidExecutionContextException($"{nameof(Double3)}[int]");
}
/// <summary>
/// Gets a <see cref="Double2"/> value with the values <see cref="X"/>, <see cref="X"/>.
/// </summary>
-10
ファイルの表示
@@ -112,16 +112,6 @@ namespace ComputeSharp
set => throw new InvalidExecutionContextException($"{nameof(Double4)}.{nameof(A)}");
}
/// <summary>
/// Gets or sets a specific component in the current <see cref="Double4"/> instance.
/// </summary>
/// <param name="i">The index of the component to access.</param>
public double this[int i]
{
get => throw new InvalidExecutionContextException($"{nameof(Double4)}[int]");
set => throw new InvalidExecutionContextException($"{nameof(Double4)}[int]");
}
/// <summary>
/// Creates a new <see cref="Double4"/> value with the same value for all its components.
/// </summary>
+9
ファイルの表示
@@ -5,6 +5,15 @@ namespace ComputeSharp
/// <inheritdoc cref="Double4"/>
public partial struct Double4
{
/// <summary>
/// Gets or sets a specific component in the current <see cref="Double4"/> instance.
/// </summary>
/// <param name="i">The index of the component to access.</param>
public ref double this[int i]
{
get => throw new InvalidExecutionContextException($"{nameof(Double4)}[int]");
}
/// <summary>
/// Gets a <see cref="Double2"/> value with the values <see cref="X"/>, <see cref="X"/>.
/// </summary>
-10
ファイルの表示
@@ -71,16 +71,6 @@ namespace ComputeSharp
set => throw new InvalidExecutionContextException($"{nameof(Float2)}.{nameof(G)}");
}
/// <summary>
/// Gets or sets a specific component in the current <see cref="Float2"/> instance.
/// </summary>
/// <param name="i">The index of the component to access.</param>
public float this[int i]
{
get => throw new InvalidExecutionContextException($"{nameof(Float2)}[int]");
set => throw new InvalidExecutionContextException($"{nameof(Float2)}[int]");
}
/// <summary>
/// Creates a new <see cref="Float2"/> value with the same value for all its components.
/// </summary>
+9
ファイルの表示
@@ -5,6 +5,15 @@ namespace ComputeSharp
/// <inheritdoc cref="Float2"/>
public partial struct Float2
{
/// <summary>
/// Gets or sets a specific component in the current <see cref="Float2"/> instance.
/// </summary>
/// <param name="i">The index of the component to access.</param>
public ref float this[int i]
{
get => throw new InvalidExecutionContextException($"{nameof(Float2)}[int]");
}
/// <summary>
/// Gets a <see cref="Float2"/> value with the values <see cref="X"/>, <see cref="X"/>.
/// </summary>
-10
ファイルの表示
@@ -92,16 +92,6 @@ namespace ComputeSharp
set => throw new InvalidExecutionContextException($"{nameof(Float3)}.{nameof(B)}");
}
/// <summary>
/// Gets or sets a specific component in the current <see cref="Float3"/> instance.
/// </summary>
/// <param name="i">The index of the component to access.</param>
public float this[int i]
{
get => throw new InvalidExecutionContextException($"{nameof(Float3)}[int]");
set => throw new InvalidExecutionContextException($"{nameof(Float3)}[int]");
}
/// <summary>
/// Creates a new <see cref="Float3"/> value with the same value for all its components.
/// </summary>
+9
ファイルの表示
@@ -5,6 +5,15 @@ namespace ComputeSharp
/// <inheritdoc cref="Float3"/>
public partial struct Float3
{
/// <summary>
/// Gets or sets a specific component in the current <see cref="Float3"/> instance.
/// </summary>
/// <param name="i">The index of the component to access.</param>
public ref float this[int i]
{
get => throw new InvalidExecutionContextException($"{nameof(Float3)}[int]");
}
/// <summary>
/// Gets a <see cref="Float2"/> value with the values <see cref="X"/>, <see cref="X"/>.
/// </summary>
-10
ファイルの表示
@@ -113,16 +113,6 @@ namespace ComputeSharp
set => throw new InvalidExecutionContextException($"{nameof(Float4)}.{nameof(A)}");
}
/// <summary>
/// Gets or sets a specific component in the current <see cref="Float4"/> instance.
/// </summary>
/// <param name="i">The index of the component to access.</param>
public float this[int i]
{
get => throw new InvalidExecutionContextException($"{nameof(Float4)}[int]");
set => throw new InvalidExecutionContextException($"{nameof(Float4)}[int]");
}
/// <summary>
/// Creates a new <see cref="Float4"/> value with the same value for all its components.
/// </summary>
+9
ファイルの表示
@@ -5,6 +5,15 @@ namespace ComputeSharp
/// <inheritdoc cref="Float4"/>
public partial struct Float4
{
/// <summary>
/// Gets or sets a specific component in the current <see cref="Float4"/> instance.
/// </summary>
/// <param name="i">The index of the component to access.</param>
public ref float this[int i]
{
get => throw new InvalidExecutionContextException($"{nameof(Float4)}[int]");
}
/// <summary>
/// Gets a <see cref="Float2"/> value with the values <see cref="X"/>, <see cref="X"/>.
/// </summary>
-10
ファイルの表示
@@ -70,16 +70,6 @@ namespace ComputeSharp
set => throw new InvalidExecutionContextException($"{nameof(Int2)}.{nameof(G)}");
}
/// <summary>
/// Gets or sets a specific component in the current <see cref="Int2"/> instance.
/// </summary>
/// <param name="i">The index of the component to access.</param>
public int this[int i]
{
get => throw new InvalidExecutionContextException($"{nameof(Int2)}[int]");
set => throw new InvalidExecutionContextException($"{nameof(Int2)}[int]");
}
/// <summary>
/// Creates a new <see cref="Int2"/> value with the same value for all its components.
/// </summary>
+9
ファイルの表示
@@ -5,6 +5,15 @@ namespace ComputeSharp
/// <inheritdoc cref="Int2"/>
public partial struct Int2
{
/// <summary>
/// Gets or sets a specific component in the current <see cref="Int2"/> instance.
/// </summary>
/// <param name="i">The index of the component to access.</param>
public ref int this[int i]
{
get => throw new InvalidExecutionContextException($"{nameof(Int2)}[int]");
}
/// <summary>
/// Gets a <see cref="Int2"/> value with the values <see cref="X"/>, <see cref="X"/>.
/// </summary>
-10
ファイルの表示
@@ -91,16 +91,6 @@ namespace ComputeSharp
set => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(B)}");
}
/// <summary>
/// Gets or sets a specific component in the current <see cref="Int3"/> instance.
/// </summary>
/// <param name="i">The index of the component to access.</param>
public int this[int i]
{
get => throw new InvalidExecutionContextException($"{nameof(Int3)}[int]");
set => throw new InvalidExecutionContextException($"{nameof(Int3)}[int]");
}
/// <summary>
/// Creates a new <see cref="Int3"/> value with the same value for all its components.
/// </summary>
+9
ファイルの表示
@@ -5,6 +5,15 @@ namespace ComputeSharp
/// <inheritdoc cref="Int3"/>
public partial struct Int3
{
/// <summary>
/// Gets or sets a specific component in the current <see cref="Int3"/> instance.
/// </summary>
/// <param name="i">The index of the component to access.</param>
public ref int this[int i]
{
get => throw new InvalidExecutionContextException($"{nameof(Int3)}[int]");
}
/// <summary>
/// Gets a <see cref="Int2"/> value with the values <see cref="X"/>, <see cref="X"/>.
/// </summary>
-10
ファイルの表示
@@ -112,16 +112,6 @@ namespace ComputeSharp
set => throw new InvalidExecutionContextException($"{nameof(Int4)}.{nameof(A)}");
}
/// <summary>
/// Gets or sets a specific component in the current <see cref="Int4"/> instance.
/// </summary>
/// <param name="i">The index of the component to access.</param>
public int this[int i]
{
get => throw new InvalidExecutionContextException($"{nameof(Int4)}[int]");
set => throw new InvalidExecutionContextException($"{nameof(Int4)}[int]");
}
/// <summary>
/// Creates a new <see cref="Int4"/> value with the same value for all its components.
/// </summary>
+9
ファイルの表示
@@ -5,6 +5,15 @@ namespace ComputeSharp
/// <inheritdoc cref="Int4"/>
public partial struct Int4
{
/// <summary>
/// Gets or sets a specific component in the current <see cref="Int4"/> instance.
/// </summary>
/// <param name="i">The index of the component to access.</param>
public ref int this[int i]
{
get => throw new InvalidExecutionContextException($"{nameof(Int4)}[int]");
}
/// <summary>
/// Gets a <see cref="Int2"/> value with the values <see cref="X"/>, <see cref="X"/>.
/// </summary>
-10
ファイルの表示
@@ -70,16 +70,6 @@ namespace ComputeSharp
set => throw new InvalidExecutionContextException($"{nameof(UInt2)}.{nameof(G)}");
}
/// <summary>
/// Gets or sets a specific component in the current <see cref="UInt2"/> instance.
/// </summary>
/// <param name="i">The index of the component to access.</param>
public float this[int i]
{
get => throw new InvalidExecutionContextException($"{nameof(UInt2)}[int]");
set => throw new InvalidExecutionContextException($"{nameof(UInt2)}[int]");
}
/// <summary>
/// Creates a new <see cref="UInt2"/> value with the same value for all its components.
/// </summary>
+9
ファイルの表示
@@ -5,6 +5,15 @@ namespace ComputeSharp
/// <inheritdoc cref="UInt2"/>
public partial struct UInt2
{
/// <summary>
/// Gets or sets a specific component in the current <see cref="UInt2"/> instance.
/// </summary>
/// <param name="i">The index of the component to access.</param>
public ref uint this[int i]
{
get => throw new InvalidExecutionContextException($"{nameof(UInt2)}[int]");
}
/// <summary>
/// Gets a <see cref="UInt2"/> value with the values <see cref="X"/>, <see cref="X"/>.
/// </summary>
-10
ファイルの表示
@@ -91,16 +91,6 @@ namespace ComputeSharp
set => throw new InvalidExecutionContextException($"{nameof(UInt3)}.{nameof(B)}");
}
/// <summary>
/// Gets or sets a specific component in the current <see cref="UInt3"/> instance.
/// </summary>
/// <param name="i">The index of the component to access.</param>
public uint this[int i]
{
get => throw new InvalidExecutionContextException($"{nameof(UInt3)}[int]");
set => throw new InvalidExecutionContextException($"{nameof(UInt3)}[int]");
}
/// <summary>
/// Creates a new <see cref="UInt3"/> value with the same value for all its components.
/// </summary>
+9
ファイルの表示
@@ -5,6 +5,15 @@ namespace ComputeSharp
/// <inheritdoc cref="UInt3"/>
public partial struct UInt3
{
/// <summary>
/// Gets or sets a specific component in the current <see cref="UInt3"/> instance.
/// </summary>
/// <param name="i">The index of the component to access.</param>
public ref uint this[int i]
{
get => throw new InvalidExecutionContextException($"{nameof(UInt3)}[int]");
}
/// <summary>
/// Gets a <see cref="UInt2"/> value with the values <see cref="X"/>, <see cref="X"/>.
/// </summary>
-10
ファイルの表示
@@ -112,16 +112,6 @@ namespace ComputeSharp
set => throw new InvalidExecutionContextException($"{nameof(UInt4)}.{nameof(A)}");
}
/// <summary>
/// Gets or sets a specific component in the current <see cref="UInt4"/> instance.
/// </summary>
/// <param name="i">The index of the component to access.</param>
public uint this[int i]
{
get => throw new InvalidExecutionContextException($"{nameof(UInt4)}[uint]");
set => throw new InvalidExecutionContextException($"{nameof(UInt4)}[uint]");
}
/// <summary>
/// Creates a new <see cref="UInt4"/> value with the same value for all its components.
/// </summary>
+9
ファイルの表示
@@ -5,6 +5,15 @@ namespace ComputeSharp
/// <inheritdoc cref="UInt4"/>
public partial struct UInt4
{
/// <summary>
/// Gets or sets a specific component in the current <see cref="UInt4"/> instance.
/// </summary>
/// <param name="i">The index of the component to access.</param>
public ref uint this[int i]
{
get => throw new InvalidExecutionContextException($"{nameof(UInt4)}[int]");
}
/// <summary>
/// Gets a <see cref="UInt2"/> value with the values <see cref="X"/>, <see cref="X"/>.
/// </summary>
+15 -7
ファイルの表示
@@ -33,19 +33,29 @@ namespace ComputeSharp
/// <inheritdoc cref="<#=typeName#>"/>
public partial struct <#=typeName#>
{
/// <summary>
/// Gets or sets a specific component in the current <see cref="<#=typeName#>"/> instance.
/// </summary>
/// <param name="i">The index of the component to access.</param>
public ref <#=hlslElementTypeName#> this[int i]
{
get => throw new InvalidExecutionContextException($"{nameof(<#=typeName#>)}[int]");
}
<#
PushIndent(" ");
PushIndent(" ");
var properties = (
// Generate the combinatorial swizzling properties
foreach (
var property in
from j in Enumerable.Range(2, i - 1)
from source in new[] { "XYZW", "RGBA" }
from name in EnumerateCombinations(source.Substring(0, j))
select (Name: name, Length: j)).ToArray();
for (int j = 0; j < properties.Length; j++)
select (Name: name, Length: j))
{
var property = properties[j];
WriteLine("");
string propertyType = property.Length == 1 ? hlslElementTypeName : $"{elementTypeName}{property.Length}";
bool isReadonly = property.Name.Distinct().Count() < property.Name.Length;
@@ -73,8 +83,6 @@ namespace ComputeSharp
PopIndent();
WriteLine("}");
if (j < properties.Length - 1) WriteLine("");
}
PopIndent();