Switched matrix types to default returns where needed

このコミットが含まれているのは:
Sergio Pedri committed 2021-03-11 15:38:13 +01:00
1 親 5f990055b2
コミット 042d4c7bef
18ファイル変更
+2488 -1366

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

ファイル差分が大きすぎるため表示されません。 差分を読み込み
-1
ファイルの表示
@@ -1,5 +1,4 @@
using System.Diagnostics;
using ComputeSharp.Exceptions;
namespace ComputeSharp
{
-1
ファイルの表示
@@ -1,5 +1,4 @@
using System.Diagnostics;
using ComputeSharp.Exceptions;
namespace ComputeSharp
{
-1
ファイルの表示
@@ -1,5 +1,4 @@
using System.Diagnostics;
using ComputeSharp.Exceptions;
namespace ComputeSharp
{
ファイル差分が大きすぎるため表示されません。 差分を読み込み
-1
ファイルの表示
@@ -1,6 +1,5 @@
using System.Diagnostics;
using System.Numerics;
using ComputeSharp.Exceptions;
namespace ComputeSharp
{
-1
ファイルの表示
@@ -1,6 +1,5 @@
using System.Diagnostics;
using System.Numerics;
using ComputeSharp.Exceptions;
namespace ComputeSharp
{
-1
ファイルの表示
@@ -1,6 +1,5 @@
using System.Diagnostics;
using System.Numerics;
using ComputeSharp.Exceptions;
namespace ComputeSharp
{
ファイル差分が大きすぎるため表示されません。 差分を読み込み
-1
ファイルの表示
@@ -1,5 +1,4 @@
using System.Diagnostics;
using ComputeSharp.Exceptions;
namespace ComputeSharp
{
-1
ファイルの表示
@@ -1,5 +1,4 @@
using System.Diagnostics;
using ComputeSharp.Exceptions;
namespace ComputeSharp
{
-1
ファイルの表示
@@ -1,5 +1,4 @@
using System.Diagnostics;
using ComputeSharp.Exceptions;
namespace ComputeSharp
{
ファイル差分が大きすぎるため表示されません。 差分を読み込み
+28 -14
ファイルの表示
@@ -10,8 +10,8 @@
void GenerateAllMatrixProperties(string typeName, int elementSize)
{
#>
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using ComputeSharp.Exceptions;
namespace ComputeSharp
{
@@ -38,9 +38,14 @@ void GenerateMatrixProperties(string typeName, int rows, int columns, int elemen
#>
/// <inheritdoc cref="<#=fullTypeName#>"/>
[StructLayout(LayoutKind.Explicit, Size = <#=(elementSize * rows * columns)#>, Pack = <#=elementSize#>)]
public partial struct <#=fullTypeName#>
public unsafe partial struct <#=fullTypeName#>
{
/// <summary>
/// A private buffer to which the undefined properties will point to.
/// </summary>
private static readonly void* UndefinedData = (void*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(<#=fullTypeName#>), sizeof(<#=typeName#>4));
<#
WriteLine("");
PushIndent(" ");
PushIndent(" ");
@@ -121,14 +126,16 @@ void GenerateMatrixProperties(string typeName, int rows, int columns, int elemen
/// Gets a reference to a specific row in the current <see cref="<#=fullTypeName#>"/> instance.
/// </summary>
/// <param name="row">The row to access.</param>
public ref <#=rowTypeName#> this[int row] => throw new InvalidExecutionContextException($"{typeof(<#=fullTypeName#>)}[{typeof(int)}]");
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
public ref <#=rowTypeName#> this[int row] => ref *(<#=rowTypeName#>*)UndefinedData;
/// <summary>
/// Gets a swizzled reference to a specific sequence of items in the current <see cref="<#=fullTypeName#>"/> instance.
/// </summary>
/// <param name="xy0">The identifier of the first item to index.</param>
/// <param name="xy1">The identifier of the second item to index.</param>
public ref <#=typeName#>2 this[MatrixIndex xy0, MatrixIndex xy1] => throw new InvalidExecutionContextException($"{typeof(<#=fullTypeName#>)}[{typeof(MatrixIndex)}, {typeof(MatrixIndex)}]");
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
public ref <#=typeName#>2 this[MatrixIndex xy0, MatrixIndex xy1] => ref *(<#=typeName#>2*)UndefinedData;
/// <summary>
/// Gets a swizzled reference to a specific sequence of items in the current <see cref="<#=fullTypeName#>"/> instance.
@@ -136,7 +143,8 @@ void GenerateMatrixProperties(string typeName, int rows, int columns, int elemen
/// <param name="xy0">The identifier of the first item to index.</param>
/// <param name="xy1">The identifier of the second item to index.</param>
/// <param name="xy2">The identifier of the third item to index.</param>
public ref <#=typeName#>3 this[MatrixIndex xy0, MatrixIndex xy1, MatrixIndex xy2] => throw new InvalidExecutionContextException($"{typeof(<#=fullTypeName#>)}[{typeof(MatrixIndex)}, {typeof(MatrixIndex)}, {typeof(MatrixIndex)}]");
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
public ref <#=typeName#>3 this[MatrixIndex xy0, MatrixIndex xy1, MatrixIndex xy2] => ref *(<#=typeName#>3*)UndefinedData;
/// <summary>
/// Gets a swizzled reference to a specific sequence of items in the current <see cref="<#=fullTypeName#>"/> instance.
@@ -145,7 +153,8 @@ void GenerateMatrixProperties(string typeName, int rows, int columns, int elemen
/// <param name="xy1">The identifier of the second item to index.</param>
/// <param name="xy2">The identifier of the third item to index.</param>
/// <param name="xy3">The identifier of the fourth item to index.</param>
public ref <#=typeName#>4 this[MatrixIndex xy0, MatrixIndex xy1, MatrixIndex xy2, MatrixIndex xy3] => throw new InvalidExecutionContextException($"{typeof(<#=fullTypeName#>)}[{typeof(MatrixIndex)}, {typeof(MatrixIndex)}, {typeof(MatrixIndex)}, {typeof(MatrixIndex)}]");
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
public ref <#=typeName#>4 this[MatrixIndex xy0, MatrixIndex xy1, MatrixIndex xy2, MatrixIndex xy3] => ref *(<#=typeName#>4*)UndefinedData;
<#
for (int i = 1; i <= rows; i++)
for (int j = 1; j <= columns; j++)
@@ -155,7 +164,7 @@ void GenerateMatrixProperties(string typeName, int rows, int columns, int elemen
/// <summary>
/// Gets a reference to the <see cref="<#=elementTypeName#>"/> value representing the component at position [<#=i#>, <#=j#>].
/// </summary>
public ref <#=elementTypeName#> M<#=i#><#=j#> => throw new InvalidExecutionContextException($"{typeof(<#=fullTypeName#>)}.M<#=i#><#=j#>");
public ref <#=elementTypeName#> M<#=i#><#=j#> => ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref this.m<#=i#><#=j#>, 1));
<#
}
@@ -198,7 +207,8 @@ void GenerateMatrixProperties(string typeName, int rows, int columns, int elemen
/// Negates a <see cref="<#=fullTypeName#>"/> value.
/// </summary>
/// <param name="matrix">The <see cref="<#=fullTypeName#>"/> value to negate.</param>
public static <#=fullTypeName#> operator -(<#=fullTypeName#> matrix) => throw new InvalidExecutionContextException($"{typeof(<#=fullTypeName#>)}.-");
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
public static <#=fullTypeName#> operator -(<#=fullTypeName#> matrix) => default;
<#
}
@@ -212,28 +222,32 @@ void GenerateMatrixProperties(string typeName, int rows, int columns, int elemen
/// </summary>
/// <param name="left">The first <see cref="<#=fullTypeName#>"/> value to sum.</param>
/// <param name="right">The second <see cref="<#=fullTypeName#>"/> value to sum.</param>
public static <#=fullTypeName#> operator +(<#=fullTypeName#> left, <#=fullTypeName#> right) => throw new InvalidExecutionContextException($"{typeof(<#=fullTypeName#>)}.+");
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
public static <#=fullTypeName#> operator +(<#=fullTypeName#> left, <#=fullTypeName#> right) => default;
/// <summary>
/// Divides two <see cref="<#=fullTypeName#>"/> values (elementwise division).
/// </summary>
/// <param name="left">The first <see cref="<#=fullTypeName#>"/> value to divide.</param>
/// <param name="right">The second <see cref="<#=fullTypeName#>"/> value to divide.</param>
public static <#=fullTypeName#> operator /(<#=fullTypeName#> left, <#=fullTypeName#> right) => throw new InvalidExecutionContextException($"{typeof(<#=fullTypeName#>)}./");
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
public static <#=fullTypeName#> operator /(<#=fullTypeName#> left, <#=fullTypeName#> right) => default;
/// <summary>
/// Multiplies two <see cref="<#=fullTypeName#>"/> values (elementwise product).
/// </summary>
/// <param name="left">The first <see cref="<#=fullTypeName#>"/> value to multiply.</param>
/// <param name="right">The second <see cref="<#=fullTypeName#>"/> value to multiply.</param>
public static <#=fullTypeName#> operator *(<#=fullTypeName#> left, <#=fullTypeName#> right) => throw new InvalidExecutionContextException($"{typeof(<#=fullTypeName#>)}.*");
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
public static <#=fullTypeName#> operator *(<#=fullTypeName#> left, <#=fullTypeName#> right) => default;
/// <summary>
/// Subtracts two <see cref="<#=fullTypeName#>"/> values.
/// </summary>
/// <param name="left">The first <see cref="<#=fullTypeName#>"/> value to subtract.</param>
/// <param name="right">The second <see cref="<#=fullTypeName#>"/> value to subtract.</param>
public static <#=fullTypeName#> operator -(<#=fullTypeName#> left, <#=fullTypeName#> right) => throw new InvalidExecutionContextException($"{typeof(<#=fullTypeName#>)}.-");
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
public static <#=fullTypeName#> operator -(<#=fullTypeName#> left, <#=fullTypeName#> right) => default;
<#
}
@@ -246,7 +260,7 @@ void GenerateMatrixProperties(string typeName, int rows, int columns, int elemen
/// Casts a <see cref="<#=typeName#><#=columns#>"/> value to a <see cref="<#=fullTypeName#>"/> one.
/// </summary>
/// <param name="vector">The input <see cref="<#=typeName#><#=columns#>"/> value to cast.</param>
public static implicit operator <#=fullTypeName#>(<#=typeName#><#=columns#> vector) => throw new InvalidExecutionContextException($"{typeof(<#=fullTypeName#>)}.{typeof(<#=fullTypeName#>)}({typeof(<#=typeName#><#=columns#>)})");
public static implicit operator <#=fullTypeName#>(<#=typeName#><#=columns#> vector) => *(<#=fullTypeName#>*)&vector;
<#
}
@@ -258,7 +272,7 @@ void GenerateMatrixProperties(string typeName, int rows, int columns, int elemen
/// Casts a <see cref="<#=fullTypeName#>"/> value to a <see cref="<#=typeName#><#=rows#>"/> one.
/// </summary>
/// <param name="matrix">The input <see cref="<#=fullTypeName#>"/> value to cast.</param>
public static implicit operator <#=typeName#><#=rows#>(<#=fullTypeName#> matrix) => throw new InvalidExecutionContextException($"{typeof(<#=fullTypeName#>)}.{typeof(<#=typeName#><#=rows#>)}({typeof(<#=fullTypeName#>)})");
public static implicit operator <#=typeName#><#=rows#>(<#=fullTypeName#> matrix) => *(<#=typeName#><#=rows#>*)&matrix;
<#
}
#>
-1
ファイルの表示
@@ -1,5 +1,4 @@
using System.Diagnostics;
using ComputeSharp.Exceptions;
namespace ComputeSharp
{
-1
ファイルの表示
@@ -1,5 +1,4 @@
using System.Diagnostics;
using ComputeSharp.Exceptions;
namespace ComputeSharp
{
-1
ファイルの表示
@@ -1,5 +1,4 @@
using System.Diagnostics;
using ComputeSharp.Exceptions;
namespace ComputeSharp
{
ファイル差分が大きすぎるため表示されません。 差分を読み込み