Update math library
This commit is contained in:
@@ -401,6 +401,9 @@ namespace Misaki.HighPerformance.Mathematics.CodeGen.Generators
|
|||||||
}}");
|
}}");
|
||||||
|
|
||||||
// Bitwise operators
|
// Bitwise operators
|
||||||
|
if (typeInfo.ElementTypeSymbol?.SpecialType != SpecialType.System_Single
|
||||||
|
&& typeInfo.ElementTypeSymbol?.SpecialType != SpecialType.System_Double)
|
||||||
|
{
|
||||||
sourceBuilder.AppendLine($@"
|
sourceBuilder.AppendLine($@"
|
||||||
public static {typeInfo.TypeFullName} operator <<({typeInfo.TypeFullName} lhs, int shift)
|
public static {typeInfo.TypeFullName} operator <<({typeInfo.TypeFullName} lhs, int shift)
|
||||||
{{
|
{{
|
||||||
@@ -432,6 +435,7 @@ namespace Misaki.HighPerformance.Mathematics.CodeGen.Generators
|
|||||||
return new({string.Join(", ", s_matrixComponents.Take(typeInfo.Column).Select(c => $"~value.{c}"))});
|
return new({string.Join(", ", s_matrixComponents.Take(typeInfo.Column).Select(c => $"~value.{c}"))});
|
||||||
}}");
|
}}");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void GenerateMathMethod()
|
private void GenerateMathMethod()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ namespace Misaki.HighPerformance.Mathematics.CodeGen.Generators
|
|||||||
{
|
{
|
||||||
sourceBuilder.AppendLine($@"
|
sourceBuilder.AppendLine($@"
|
||||||
[global::System.Runtime.InteropServices.FieldOffset(0)]
|
[global::System.Runtime.InteropServices.FieldOffset(0)]
|
||||||
internal global::System.Runtime.Intrinsics.Vector{_vectorBitsSize}<{typeInfo.ComponentTypeFullName}> __v;");
|
public global::System.Runtime.Intrinsics.Vector{_vectorBitsSize}<{typeInfo.ComponentTypeFullName}> __v;");
|
||||||
|
|
||||||
for (var i = 0; i < typeInfo.Row; i++)
|
for (var i = 0; i < typeInfo.Row; i++)
|
||||||
{
|
{
|
||||||
@@ -356,12 +356,43 @@ namespace Misaki.HighPerformance.Mathematics.CodeGen.Generators
|
|||||||
public override readonly bool Equals(object? obj)
|
public override readonly bool Equals(object? obj)
|
||||||
{{
|
{{
|
||||||
return obj is {typeName} value && Equals(value);
|
return obj is {typeName} value && Equals(value);
|
||||||
}}
|
}}");
|
||||||
|
|
||||||
|
if (CanUseVectorStorage && typeInfo.ComponentTypeSymbol.SpecialType != SpecialType.System_Double)
|
||||||
|
{
|
||||||
|
var pack = _vectorBitsSize > 128 ? $"global::Misaki.HighPerformance.Mathematics.math.PackVector256" : string.Empty;
|
||||||
|
sourceBuilder.AppendLine($@"
|
||||||
{INLINE_METHOD_ATTRIBUTE}
|
{INLINE_METHOD_ATTRIBUTE}
|
||||||
public readonly bool Equals({typeName} other)
|
public readonly bool Equals({typeName} other)
|
||||||
{{
|
{{
|
||||||
return {string.Join(" && ", components.Select(c => $"this.{c}.Equals(other.{c})"))};
|
return global::System.Runtime.Intrinsics.Vector{_vectorBitsSize}.EqualsAll(this.__v, other.__v);
|
||||||
|
}}
|
||||||
|
|
||||||
|
{INLINE_METHOD_ATTRIBUTE}
|
||||||
|
public static global::Misaki.HighPerformance.Mathematics.bool{typeInfo.Row} operator ==({typeName} lhs, {typeName} rhs)
|
||||||
|
{{
|
||||||
|
var cmp = global::System.Runtime.Intrinsics.Vector{_vectorBitsSize}.Equals(lhs.__v, rhs.__v);
|
||||||
|
global::System.Runtime.CompilerServices.Unsafe.SkipInit<global::Misaki.HighPerformance.Mathematics.bool{typeInfo.Row}>(out var result);
|
||||||
|
result.__v = {pack}(global::System.Runtime.Intrinsics.Vector{_vectorBitsSize}.AsUInt32(cmp));
|
||||||
|
return result;
|
||||||
|
}}
|
||||||
|
|
||||||
|
{INLINE_METHOD_ATTRIBUTE}
|
||||||
|
public static global::Misaki.HighPerformance.Mathematics.bool{typeInfo.Row} operator !=({typeName} lhs, {typeName} rhs)
|
||||||
|
{{
|
||||||
|
var cmp = ~global::System.Runtime.Intrinsics.Vector{_vectorBitsSize}.Equals(lhs.__v, rhs.__v);
|
||||||
|
global::System.Runtime.CompilerServices.Unsafe.SkipInit<global::Misaki.HighPerformance.Mathematics.bool{typeInfo.Row}>(out var result);
|
||||||
|
result.__v = {pack}(global::System.Runtime.Intrinsics.Vector{_vectorBitsSize}.AsUInt32(cmp));
|
||||||
|
return result;
|
||||||
|
}}");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sourceBuilder.AppendLine($@"
|
||||||
|
{INLINE_METHOD_ATTRIBUTE}
|
||||||
|
public readonly bool Equals({typeName} other)
|
||||||
|
{{
|
||||||
|
return global::Misaki.HighPerformance.Mathematics.math.all(this == other);
|
||||||
}}
|
}}
|
||||||
|
|
||||||
{INLINE_METHOD_ATTRIBUTE}
|
{INLINE_METHOD_ATTRIBUTE}
|
||||||
@@ -374,8 +405,10 @@ namespace Misaki.HighPerformance.Mathematics.CodeGen.Generators
|
|||||||
public static global::Misaki.HighPerformance.Mathematics.bool{typeInfo.Row} operator !=({typeName} lhs, {typeName} rhs)
|
public static global::Misaki.HighPerformance.Mathematics.bool{typeInfo.Row} operator !=({typeName} lhs, {typeName} rhs)
|
||||||
{{
|
{{
|
||||||
return new({string.Join(", ", components.Select(c => $"lhs.{c} != rhs.{c}"))});
|
return new({string.Join(", ", components.Select(c => $"lhs.{c} != rhs.{c}"))});
|
||||||
}}
|
}}");
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceBuilder.AppendLine($@"
|
||||||
{INLINE_METHOD_ATTRIBUTE}
|
{INLINE_METHOD_ATTRIBUTE}
|
||||||
public static implicit operator {typeName}(global::System.ReadOnlySpan<{componentType}> value)
|
public static implicit operator {typeName}(global::System.ReadOnlySpan<{componentType}> value)
|
||||||
{{
|
{{
|
||||||
@@ -789,68 +822,154 @@ namespace Misaki.HighPerformance.Mathematics.CodeGen.Generators
|
|||||||
return value - new {typeName}(1{_componentTypePrefix});
|
return value - new {typeName}(1{_componentTypePrefix});
|
||||||
}}");
|
}}");
|
||||||
|
|
||||||
|
var hasBitwiseOperators = typeInfo.ComponentTypeSymbol.SpecialType != SpecialType.System_Single
|
||||||
|
&& typeInfo.ComponentTypeSymbol.SpecialType != SpecialType.System_Double;
|
||||||
|
|
||||||
|
if (CanUseVectorStorage && typeInfo.ComponentTypeSymbol.SpecialType != SpecialType.System_Double)
|
||||||
|
{
|
||||||
|
var pack = _vectorBitsSize > 128 ? $"global::Misaki.HighPerformance.Mathematics.math.PackVector256" : string.Empty;
|
||||||
// Comparison operators
|
// Comparison operators
|
||||||
sourceBuilder.AppendLine($@"
|
sourceBuilder.AppendLine($@"
|
||||||
{INLINE_METHOD_ATTRIBUTE}
|
{INLINE_METHOD_ATTRIBUTE}
|
||||||
public static bool{typeInfo.Row} operator <({typeName} lhs, {typeName} rhs)
|
public static global::Misaki.HighPerformance.Mathematics.bool{typeInfo.Row} operator <({typeName} lhs, {typeName} rhs)
|
||||||
{{
|
{{
|
||||||
var vector = global::System.Runtime.Intrinsics.Vector{_vectorBitsSize}.LessThan(lhs.AsVector{_vectorBitsSize}(), rhs.AsVector{_vectorBitsSize}());
|
var cmp = global::System.Runtime.Intrinsics.Vector{_vectorBitsSize}.LessThan(lhs.__v, rhs.__v);
|
||||||
return new({string.Join(", ", s_vectorComponents.Take(typeInfo.Row).Select((_, i) => $"vector[{i}] != 0"))});
|
global::System.Runtime.CompilerServices.Unsafe.SkipInit<global::Misaki.HighPerformance.Mathematics.bool{typeInfo.Row}>(out var result);
|
||||||
|
result.__v = {pack}(global::System.Runtime.Intrinsics.Vector{_vectorBitsSize}.AsUInt32(cmp));
|
||||||
|
return result;
|
||||||
}}
|
}}
|
||||||
|
|
||||||
{INLINE_METHOD_ATTRIBUTE}
|
{INLINE_METHOD_ATTRIBUTE}
|
||||||
public static bool{typeInfo.Row} operator <=({typeName} lhs, {typeName} rhs)
|
public static global::Misaki.HighPerformance.Mathematics.bool{typeInfo.Row} operator <=({typeName} lhs, {typeName} rhs)
|
||||||
{{
|
{{
|
||||||
var vector = global::System.Runtime.Intrinsics.Vector{_vectorBitsSize}.LessThanOrEqual(lhs.AsVector{_vectorBitsSize}(), rhs.AsVector{_vectorBitsSize}());
|
var cmp = global::System.Runtime.Intrinsics.Vector{_vectorBitsSize}.LessThanOrEqual(lhs.AsVector{_vectorBitsSize}(), rhs.AsVector{_vectorBitsSize}());
|
||||||
return new({string.Join(", ", s_vectorComponents.Take(typeInfo.Row).Select((_, i) => $"vector[{i}] != 0"))});
|
global::System.Runtime.CompilerServices.Unsafe.SkipInit<global::Misaki.HighPerformance.Mathematics.bool{typeInfo.Row}>(out var result);
|
||||||
|
result.__v = {pack}(global::System.Runtime.Intrinsics.Vector{_vectorBitsSize}.AsUInt32(cmp));
|
||||||
|
return result;
|
||||||
}}
|
}}
|
||||||
|
|
||||||
{INLINE_METHOD_ATTRIBUTE}
|
{INLINE_METHOD_ATTRIBUTE}
|
||||||
public static bool{typeInfo.Row} operator >({typeName} lhs, {typeName} rhs)
|
public static global::Misaki.HighPerformance.Mathematics.bool{typeInfo.Row} operator >({typeName} lhs, {typeName} rhs)
|
||||||
{{
|
{{
|
||||||
var vector = global::System.Runtime.Intrinsics.Vector{_vectorBitsSize}.GreaterThan(lhs.AsVector{_vectorBitsSize}(), rhs.AsVector{_vectorBitsSize}());
|
var cmp = global::System.Runtime.Intrinsics.Vector{_vectorBitsSize}.GreaterThan(lhs.AsVector{_vectorBitsSize}(), rhs.AsVector{_vectorBitsSize}());
|
||||||
return new({string.Join(", ", s_vectorComponents.Take(typeInfo.Row).Select((_, i) => $"vector[{i}] != 0"))});
|
global::System.Runtime.CompilerServices.Unsafe.SkipInit<global::Misaki.HighPerformance.Mathematics.bool{typeInfo.Row}>(out var result);
|
||||||
|
result.__v = {pack}(global::System.Runtime.Intrinsics.Vector{_vectorBitsSize}.AsUInt32(cmp));
|
||||||
|
return result;
|
||||||
}}
|
}}
|
||||||
|
|
||||||
{INLINE_METHOD_ATTRIBUTE}
|
{INLINE_METHOD_ATTRIBUTE}
|
||||||
public static bool{typeInfo.Row} operator >=({typeName} lhs, {typeName} rhs)
|
public static global::Misaki.HighPerformance.Mathematics.bool{typeInfo.Row} operator >=({typeName} lhs, {typeName} rhs)
|
||||||
{{
|
{{
|
||||||
var vector = global::System.Runtime.Intrinsics.Vector{_vectorBitsSize}.GreaterThanOrEqual(lhs.AsVector{_vectorBitsSize}(), rhs.AsVector{_vectorBitsSize}());
|
var cmp = global::System.Runtime.Intrinsics.Vector{_vectorBitsSize}.GreaterThanOrEqual(lhs.AsVector{_vectorBitsSize}(), rhs.AsVector{_vectorBitsSize}());
|
||||||
return new({string.Join(", ", s_vectorComponents.Take(typeInfo.Row).Select((_, i) => $"vector[{i}] != 0"))});
|
global::System.Runtime.CompilerServices.Unsafe.SkipInit<global::Misaki.HighPerformance.Mathematics.bool{typeInfo.Row}>(out var result);
|
||||||
|
result.__v = {pack}(global::System.Runtime.Intrinsics.Vector{_vectorBitsSize}.AsUInt32(cmp));
|
||||||
|
return result;
|
||||||
}}");
|
}}");
|
||||||
|
|
||||||
|
if (hasBitwiseOperators)
|
||||||
|
{
|
||||||
|
|
||||||
// Bitwise operators
|
// Bitwise operators
|
||||||
sourceBuilder.AppendLine($@"
|
sourceBuilder.AppendLine($@"
|
||||||
{INLINE_METHOD_ATTRIBUTE}
|
{INLINE_METHOD_ATTRIBUTE}
|
||||||
public static {typeName} operator <<({typeName} x, int n)
|
public static {typeName} operator <<({typeName} x, int n)
|
||||||
{{
|
{{
|
||||||
return (x.AsVector{_vectorBitsSize}() << n).{asResult};
|
return (x.__v << n).{asResult};
|
||||||
}}
|
}}
|
||||||
|
|
||||||
{INLINE_METHOD_ATTRIBUTE}
|
{INLINE_METHOD_ATTRIBUTE}
|
||||||
public static {typeName} operator >>({typeName} x, int n)
|
public static {typeName} operator >>({typeName} x, int n)
|
||||||
{{
|
{{
|
||||||
return (x.AsVector{_vectorBitsSize}() >> n).{asResult};
|
return (x.__v >> n).{asResult};
|
||||||
}}
|
}}
|
||||||
|
|
||||||
{INLINE_METHOD_ATTRIBUTE}
|
{INLINE_METHOD_ATTRIBUTE}
|
||||||
public static {typeName} operator &({typeName} lhs, {typeName} rhs)
|
public static {typeName} operator &({typeName} lhs, {typeName} rhs)
|
||||||
{{
|
{{
|
||||||
return (global::System.Runtime.Intrinsics.Vector{_vectorBitsSize}.BitwiseAnd(lhs.AsVector{_vectorBitsSize}(), rhs.AsVector{_vectorBitsSize}())).{asResult};
|
return (global::System.Runtime.Intrinsics.Vector{_vectorBitsSize}.BitwiseAnd(lhs.__v, rhs.__v)).{asResult};
|
||||||
}}
|
}}
|
||||||
|
|
||||||
{INLINE_METHOD_ATTRIBUTE}
|
{INLINE_METHOD_ATTRIBUTE}
|
||||||
public static {typeName} operator |({typeName} lhs, {typeName} rhs)
|
public static {typeName} operator |({typeName} lhs, {typeName} rhs)
|
||||||
{{
|
{{
|
||||||
return (global::System.Runtime.Intrinsics.Vector{_vectorBitsSize}.BitwiseOr(lhs.AsVector{_vectorBitsSize}(), rhs.AsVector{_vectorBitsSize}())).{asResult};
|
return (global::System.Runtime.Intrinsics.Vector{_vectorBitsSize}.BitwiseOr(lhs.__v, rhs.__v)).{asResult};
|
||||||
}}
|
}}
|
||||||
|
|
||||||
{INLINE_METHOD_ATTRIBUTE}
|
{INLINE_METHOD_ATTRIBUTE}
|
||||||
public static {typeName} operator ^({typeName} lhs, {typeName} rhs)
|
public static {typeName} operator ^({typeName} lhs, {typeName} rhs)
|
||||||
{{
|
{{
|
||||||
return (global::System.Runtime.Intrinsics.Vector{_vectorBitsSize}.Xor(lhs.AsVector{_vectorBitsSize}(), rhs.AsVector{_vectorBitsSize}())).{asResult};
|
return (global::System.Runtime.Intrinsics.Vector{_vectorBitsSize}.Xor(lhs.__v, rhs.__v)).{asResult};
|
||||||
|
}}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Comparison operators
|
||||||
|
sourceBuilder.AppendLine($@"
|
||||||
|
{INLINE_METHOD_ATTRIBUTE}
|
||||||
|
public static global::Misaki.HighPerformance.Mathematics.bool{typeInfo.Row} operator <({typeName} lhs, {typeName} rhs)
|
||||||
|
{{
|
||||||
|
return new global::Misaki.HighPerformance.Mathematics.bool{typeInfo.Row}({string.Join(", ", s_vectorComponents.Take(typeInfo.Row).Select(c => $"lhs.{c} < rhs.{c}"))});
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
{INLINE_METHOD_ATTRIBUTE}
|
||||||
|
public static global::Misaki.HighPerformance.Mathematics.bool{typeInfo.Row} operator <=({typeName} lhs, {typeName} rhs)
|
||||||
|
{{
|
||||||
|
return new global::Misaki.HighPerformance.Mathematics.bool{typeInfo.Row}({string.Join(", ", s_vectorComponents.Take(typeInfo.Row).Select(c => $"lhs.{c} <= rhs.{c}"))});
|
||||||
|
}}
|
||||||
|
|
||||||
|
{INLINE_METHOD_ATTRIBUTE}
|
||||||
|
public static global::Misaki.HighPerformance.Mathematics.bool{typeInfo.Row} operator >({typeName} lhs, {typeName} rhs)
|
||||||
|
{{
|
||||||
|
return new global::Misaki.HighPerformance.Mathematics.bool{typeInfo.Row}({string.Join(", ", s_vectorComponents.Take(typeInfo.Row).Select(c => $"lhs.{c} > rhs.{c}"))});
|
||||||
|
}}
|
||||||
|
|
||||||
|
{INLINE_METHOD_ATTRIBUTE}
|
||||||
|
public static global::Misaki.HighPerformance.Mathematics.bool{typeInfo.Row} operator >=({typeName} lhs, {typeName} rhs)
|
||||||
|
{{
|
||||||
|
return new global::Misaki.HighPerformance.Mathematics.bool{typeInfo.Row}({string.Join(", ", s_vectorComponents.Take(typeInfo.Row).Select(c => $"lhs.{c} >= rhs.{c}"))});
|
||||||
|
}}");
|
||||||
|
|
||||||
|
if (hasBitwiseOperators)
|
||||||
|
{
|
||||||
|
// Bitwise operators
|
||||||
|
sourceBuilder.AppendLine($@"
|
||||||
|
{INLINE_METHOD_ATTRIBUTE}
|
||||||
|
public static {typeName} operator <<({typeName} x, int n)
|
||||||
|
{{
|
||||||
|
return new {typeName}({string.Join(", ", s_vectorComponents.Take(typeInfo.Row).Select(c => $"x.{c} << n"))});
|
||||||
|
}}
|
||||||
|
|
||||||
|
{INLINE_METHOD_ATTRIBUTE}
|
||||||
|
public static {typeName} operator >>({typeName} x, int n)
|
||||||
|
{{
|
||||||
|
return new {typeName}({string.Join(", ", s_vectorComponents.Take(typeInfo.Row).Select(c => $"x.{c} >> n"))});
|
||||||
|
}}
|
||||||
|
|
||||||
|
{INLINE_METHOD_ATTRIBUTE}
|
||||||
|
public static {typeName} operator &({typeName} lhs, {typeName} rhs)
|
||||||
|
{{
|
||||||
|
return new {typeName}({string.Join(", ", s_vectorComponents.Take(typeInfo.Row).Select(c => $"lhs.{c} & rhs.{c}"))});
|
||||||
|
}}
|
||||||
|
|
||||||
|
{INLINE_METHOD_ATTRIBUTE}
|
||||||
|
public static {typeName} operator |({typeName} lhs, {typeName} rhs)
|
||||||
|
{{
|
||||||
|
return new {typeName}({string.Join(", ", s_vectorComponents.Take(typeInfo.Row).Select(c => $"lhs.{c} | rhs.{c}"))});
|
||||||
|
}}
|
||||||
|
|
||||||
|
{INLINE_METHOD_ATTRIBUTE}
|
||||||
|
public static {typeName} operator ^({typeName} lhs, {typeName} rhs)
|
||||||
|
{{
|
||||||
|
return new {typeName}({string.Join(", ", s_vectorComponents.Take(typeInfo.Row).Select(c => $"lhs.{c} ^ rhs.{c}"))});
|
||||||
|
}}");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasBitwiseOperators)
|
||||||
|
{
|
||||||
|
sourceBuilder.AppendLine($@"
|
||||||
{INLINE_METHOD_ATTRIBUTE}
|
{INLINE_METHOD_ATTRIBUTE}
|
||||||
public static {typeName} operator ~({typeName} value)
|
public static {typeName} operator ~({typeName} value)
|
||||||
{{
|
{{
|
||||||
@@ -859,6 +978,7 @@ namespace Misaki.HighPerformance.Mathematics.CodeGen.Generators
|
|||||||
return value ^ new {typeName}(({componentType})-1);
|
return value ^ new {typeName}(({componentType})-1);
|
||||||
}}
|
}}
|
||||||
}}");
|
}}");
|
||||||
|
}
|
||||||
|
|
||||||
EndRegion();
|
EndRegion();
|
||||||
}
|
}
|
||||||
@@ -937,14 +1057,13 @@ namespace Misaki.HighPerformance.Mathematics.CodeGen.Generators
|
|||||||
public static partial class VectorInterop
|
public static partial class VectorInterop
|
||||||
{{
|
{{
|
||||||
{INLINE_METHOD_ATTRIBUTE}
|
{INLINE_METHOD_ATTRIBUTE}
|
||||||
public unsafe static global::System.Runtime.Intrinsics.Vector{_vectorBitsSize}<{componentType}> AsVector{_vectorBitsSize}(this in {typeName} value)
|
public unsafe static global::System.Runtime.Intrinsics.Vector{_vectorBitsSize}<{componentType}> AsVector{_vectorBitsSize}(this {typeName} value)
|
||||||
{{");
|
{{");
|
||||||
|
|
||||||
if (CanUseVectorStorage)
|
if (CanUseVectorStorage)
|
||||||
{
|
{
|
||||||
sourceBuilder.Append($@"
|
sourceBuilder.Append($@"
|
||||||
ref var v = ref global::System.Runtime.CompilerServices.Unsafe.AsRef(in value);
|
return global::System.Runtime.CompilerServices.Unsafe.BitCast<{typeName}, global::System.Runtime.Intrinsics.Vector{_vectorBitsSize}<{componentType}>>(value);");
|
||||||
return global::System.Runtime.CompilerServices.Unsafe.As<{typeName}, global::System.Runtime.Intrinsics.Vector{_vectorBitsSize}<{componentType}>>(ref v);");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -960,9 +1079,7 @@ namespace Misaki.HighPerformance.Mathematics.CodeGen.Generators
|
|||||||
if (CanUseVectorStorage)
|
if (CanUseVectorStorage)
|
||||||
{
|
{
|
||||||
sourceBuilder.AppendLine($@"
|
sourceBuilder.AppendLine($@"
|
||||||
var result = default({typeName});
|
return global::System.Runtime.CompilerServices.Unsafe.BitCast<global::System.Runtime.Intrinsics.Vector{_vectorBitsSize}<{componentType}>, {typeName}>(value);
|
||||||
result.__v = value;
|
|
||||||
return result;
|
|
||||||
}}
|
}}
|
||||||
}}");
|
}}");
|
||||||
}
|
}
|
||||||
@@ -996,6 +1113,7 @@ namespace Misaki.HighPerformance.Mathematics.CodeGen.Generators
|
|||||||
}}");
|
}}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Shuffle select
|
||||||
sourceBuilder.AppendLine($@"
|
sourceBuilder.AppendLine($@"
|
||||||
{INLINE_METHOD_ATTRIBUTE}
|
{INLINE_METHOD_ATTRIBUTE}
|
||||||
public static {componentTypeFullName} shuffle({typeFullName} left, {typeFullName} right, ShuffleComponent x)
|
public static {componentTypeFullName} shuffle({typeFullName} left, {typeFullName} right, ShuffleComponent x)
|
||||||
@@ -1049,6 +1167,7 @@ namespace Misaki.HighPerformance.Mathematics.CodeGen.Generators
|
|||||||
throw new System.ArgumentException(""Invalid shuffle component: "" + component);
|
throw new System.ArgumentException(""Invalid shuffle component: "" + component);
|
||||||
}}
|
}}
|
||||||
}}");
|
}}");
|
||||||
|
|
||||||
sourceBuilder.Append($@"
|
sourceBuilder.Append($@"
|
||||||
}}");
|
}}");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,62 +1,220 @@
|
|||||||
namespace Misaki.HighPerformance.Mathematics;
|
namespace Misaki.HighPerformance.Mathematics;
|
||||||
|
|
||||||
[NumericType(typeof(bool), sizeof(bool), 2, 1, "global::Misaki.HighPerformance.Mathematics.bool", false, vectorType: typeof(byte))]
|
[NumericType(typeof(uint), sizeof(uint), 2, 1, "global::Misaki.HighPerformance.Mathematics.bool", false, vectorType: typeof(uint))]
|
||||||
[NumericConvertable("{v}.{c} != 0", typeof(int2), typeof(uint2), typeof(float2), typeof(double2))]
|
[NumericConvertable("{v}.{c} != 0 ? 0u : ~0u", typeof(int2), typeof(uint2), typeof(float2), typeof(double2))]
|
||||||
public partial struct bool2
|
public partial struct bool2
|
||||||
{
|
{
|
||||||
|
public bool2(bool value)
|
||||||
|
{
|
||||||
|
this.x = math.BoolToMask(value);
|
||||||
|
this.y = math.BoolToMask(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool2(bool x, bool y)
|
||||||
|
{
|
||||||
|
this.x = math.BoolToMask(x);
|
||||||
|
this.y = math.BoolToMask(y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[NumericType(typeof(bool2), sizeof(bool), 2, 2, "global::Misaki.HighPerformance.Mathematics.bool", false, elementType: typeof(bool))]
|
[NumericType(typeof(bool2), sizeof(uint), 2, 2, "global::Misaki.HighPerformance.Mathematics.bool", false, elementType: typeof(uint))]
|
||||||
public partial struct bool2x2
|
public partial struct bool2x2
|
||||||
{
|
{
|
||||||
|
public bool2x2(bool value)
|
||||||
|
{
|
||||||
|
c0 = new bool2(value);
|
||||||
|
c1 = new bool2(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool2x2(bool m00, bool m01, bool m10, bool m11)
|
||||||
|
{
|
||||||
|
c0 = new bool2(m00, m10);
|
||||||
|
c1 = new bool2(m01, m11);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[NumericType(typeof(bool2), sizeof(bool), 2, 3, "global::Misaki.HighPerformance.Mathematics.bool", false, elementType: typeof(bool))]
|
[NumericType(typeof(bool2), sizeof(uint), 2, 3, "global::Misaki.HighPerformance.Mathematics.bool", false, elementType: typeof(uint))]
|
||||||
public partial struct bool2x3
|
public partial struct bool2x3
|
||||||
{
|
{
|
||||||
|
public bool2x3(bool value)
|
||||||
|
{
|
||||||
|
c0 = new bool2(value);
|
||||||
|
c1 = new bool2(value);
|
||||||
|
c2 = new bool2(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool2x3(bool m00, bool m01, bool m02, bool m10, bool m11, bool m12)
|
||||||
|
{
|
||||||
|
c0 = new bool2(m00, m10);
|
||||||
|
c1 = new bool2(m01, m11);
|
||||||
|
c2 = new bool2(m02, m12);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[NumericType(typeof(bool2), sizeof(bool), 2, 4, "global::Misaki.HighPerformance.Mathematics.bool", false, elementType: typeof(bool))]
|
[NumericType(typeof(bool2), sizeof(uint), 2, 4, "global::Misaki.HighPerformance.Mathematics.bool", false, elementType: typeof(uint))]
|
||||||
public partial struct bool2x4
|
public partial struct bool2x4
|
||||||
{
|
{
|
||||||
|
public bool2x4(bool value)
|
||||||
|
{
|
||||||
|
c0 = new bool2(value);
|
||||||
|
c1 = new bool2(value);
|
||||||
|
c2 = new bool2(value);
|
||||||
|
c3 = new bool2(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool2x4(bool m00, bool m01, bool m02, bool m03, bool m10, bool m11, bool m12, bool m13)
|
||||||
|
{
|
||||||
|
c0 = new bool2(m00, m10);
|
||||||
|
c1 = new bool2(m01, m11);
|
||||||
|
c2 = new bool2(m02, m12);
|
||||||
|
c3 = new bool2(m03, m13);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[NumericType(typeof(bool), sizeof(bool), 3, 1, "global::Misaki.HighPerformance.Mathematics.bool", false, vectorType: typeof(byte))]
|
[NumericType(typeof(uint), sizeof(uint), 3, 1, "global::Misaki.HighPerformance.Mathematics.bool", false, vectorType: typeof(uint))]
|
||||||
|
[NumericConvertable("{v}.{c} != 0 ? 0u : ~0u", typeof(int3), typeof(uint3), typeof(float3), typeof(double3))]
|
||||||
public partial struct bool3
|
public partial struct bool3
|
||||||
{
|
{
|
||||||
|
public bool3(bool value)
|
||||||
|
{
|
||||||
|
this.x = math.BoolToMask(value);
|
||||||
|
this.y = math.BoolToMask(value);
|
||||||
|
this.z = math.BoolToMask(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool3(bool x, bool y, bool z)
|
||||||
|
{
|
||||||
|
this.x = math.BoolToMask(x);
|
||||||
|
this.y = math.BoolToMask(y);
|
||||||
|
this.z = math.BoolToMask(z);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[NumericType(typeof(bool3), sizeof(bool), 3, 2, "global::Misaki.HighPerformance.Mathematics.bool", false, elementType: typeof(bool))]
|
[NumericType(typeof(bool3), sizeof(uint), 3, 2, "global::Misaki.HighPerformance.Mathematics.bool", false, elementType: typeof(uint))]
|
||||||
public partial struct bool3x2
|
public partial struct bool3x2
|
||||||
{
|
{
|
||||||
|
public bool3x2(bool value)
|
||||||
|
{
|
||||||
|
c0 = new bool3(value);
|
||||||
|
c1 = new bool3(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool3x2(bool m00, bool m01, bool m10, bool m11, bool m20, bool m21)
|
||||||
|
{
|
||||||
|
c0 = new bool3(m00, m10, m20);
|
||||||
|
c1 = new bool3(m01, m11, m21);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[NumericType(typeof(bool3), sizeof(bool), 3, 3, "global::Misaki.HighPerformance.Mathematics.bool", false, elementType: typeof(bool))]
|
[NumericType(typeof(bool3), sizeof(uint), 3, 3, "global::Misaki.HighPerformance.Mathematics.bool", false, elementType: typeof(uint))]
|
||||||
public partial struct bool3x3
|
public partial struct bool3x3
|
||||||
{
|
{
|
||||||
|
public bool3x3(bool value)
|
||||||
|
{
|
||||||
|
c0 = new bool3(value);
|
||||||
|
c1 = new bool3(value);
|
||||||
|
c2 = new bool3(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool3x3(bool m00, bool m01, bool m02, bool m10, bool m11, bool m12, bool m20, bool m21, bool m22)
|
||||||
|
{
|
||||||
|
c0 = new bool3(m00, m10, m20);
|
||||||
|
c1 = new bool3(m01, m11, m21);
|
||||||
|
c2 = new bool3(m02, m12, m22);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[NumericType(typeof(bool3), sizeof(bool), 3, 4, "global::Misaki.HighPerformance.Mathematics.bool", false, elementType: typeof(bool))]
|
[NumericType(typeof(bool3), sizeof(uint), 3, 4, "global::Misaki.HighPerformance.Mathematics.bool", false, elementType: typeof(uint))]
|
||||||
public partial struct bool3x4
|
public partial struct bool3x4
|
||||||
{
|
{
|
||||||
|
public bool3x4(bool value)
|
||||||
|
{
|
||||||
|
c0 = new bool3(value);
|
||||||
|
c1 = new bool3(value);
|
||||||
|
c2 = new bool3(value);
|
||||||
|
c3 = new bool3(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool3x4(bool m00, bool m01, bool m02, bool m03, bool m10, bool m11, bool m12, bool m13, bool m20, bool m21, bool m22, bool m23)
|
||||||
|
{
|
||||||
|
c0 = new bool3(m00, m10, m20);
|
||||||
|
c1 = new bool3(m01, m11, m21);
|
||||||
|
c2 = new bool3(m02, m12, m22);
|
||||||
|
c3 = new bool3(m03, m13, m23);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[NumericType(typeof(bool), sizeof(bool), 4, 1, "global::Misaki.HighPerformance.Mathematics.bool", false, vectorType: typeof(byte))]
|
[NumericType(typeof(uint), sizeof(uint), 4, 1, "global::Misaki.HighPerformance.Mathematics.bool", false, vectorType: typeof(uint))]
|
||||||
|
[NumericConvertable("{v}.{c} != 0 ? 0u : ~0u", typeof(int4), typeof(uint4), typeof(float4), typeof(double4))]
|
||||||
public partial struct bool4
|
public partial struct bool4
|
||||||
{
|
{
|
||||||
|
public bool4(bool value)
|
||||||
|
{
|
||||||
|
this.x = math.BoolToMask(value);
|
||||||
|
this.y = math.BoolToMask(value);
|
||||||
|
this.z = math.BoolToMask(value);
|
||||||
|
this.w = math.BoolToMask(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool4(bool x, bool y, bool z, bool w)
|
||||||
|
{
|
||||||
|
this.x = math.BoolToMask(x);
|
||||||
|
this.y = math.BoolToMask(y);
|
||||||
|
this.z = math.BoolToMask(z);
|
||||||
|
this.w = math.BoolToMask(w);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[NumericType(typeof(bool4), sizeof(bool), 4, 2, "global::Misaki.HighPerformance.Mathematics.bool", false, elementType: typeof(bool))]
|
[NumericType(typeof(bool4), sizeof(uint), 4, 2, "global::Misaki.HighPerformance.Mathematics.bool", false, elementType: typeof(uint))]
|
||||||
public partial struct bool4x2
|
public partial struct bool4x2
|
||||||
{
|
{
|
||||||
|
public bool4x2(bool value)
|
||||||
|
{
|
||||||
|
c0 = new bool4(value);
|
||||||
|
c1 = new bool4(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool4x2(bool m00, bool m01, bool m10, bool m11, bool m20, bool m21, bool m30, bool m31)
|
||||||
|
{
|
||||||
|
c0 = new bool4(m00, m10, m20, m30);
|
||||||
|
c1 = new bool4(m01, m11, m21, m31);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[NumericType(typeof(bool4), sizeof(bool), 4, 3, "global::Misaki.HighPerformance.Mathematics.bool", false, elementType: typeof(bool))]
|
[NumericType(typeof(bool4), sizeof(uint), 4, 3, "global::Misaki.HighPerformance.Mathematics.bool", false, elementType: typeof(uint))]
|
||||||
public partial struct bool4x3
|
public partial struct bool4x3
|
||||||
{
|
{
|
||||||
|
public bool4x3(bool value)
|
||||||
|
{
|
||||||
|
c0 = new bool4(value);
|
||||||
|
c1 = new bool4(value);
|
||||||
|
c2 = new bool4(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool4x3(bool m00, bool m01, bool m02, bool m10, bool m11, bool m12, bool m20, bool m21, bool m22, bool m30, bool m31, bool m32)
|
||||||
|
{
|
||||||
|
c0 = new bool4(m00, m10, m20, m30);
|
||||||
|
c1 = new bool4(m01, m11, m21, m31);
|
||||||
|
c2 = new bool4(m02, m12, m22, m32);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[NumericType(typeof(bool4), sizeof(bool), 4, 4, "global::Misaki.HighPerformance.Mathematics.bool", false, elementType: typeof(bool))]
|
[NumericType(typeof(bool4), sizeof(uint), 4, 4, "global::Misaki.HighPerformance.Mathematics.bool", false, elementType: typeof(uint))]
|
||||||
public partial struct bool4x4
|
public partial struct bool4x4
|
||||||
{
|
{
|
||||||
|
public bool4x4(bool value)
|
||||||
|
{
|
||||||
|
c0 = new bool4(value);
|
||||||
|
c1 = new bool4(value);
|
||||||
|
c2 = new bool4(value);
|
||||||
|
c3 = new bool4(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool4x4(bool m00, bool m01, bool m02, bool m03, bool m10, bool m11, bool m12, bool m13, bool m20, bool m21, bool m22, bool m23, bool m30, bool m31, bool m32, bool m33)
|
||||||
|
{
|
||||||
|
c0 = new bool4(m00, m10, m20, m30);
|
||||||
|
c1 = new bool4(m01, m11, m21, m31);
|
||||||
|
c2 = new bool4(m02, m12, m22, m32);
|
||||||
|
c3 = new bool4(m03, m13, m23, m33);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
namespace Misaki.HighPerformance.Mathematics;
|
namespace Misaki.HighPerformance.Mathematics;
|
||||||
|
|
||||||
[NumericType(typeof(double), sizeof(double), 2, 1, "global::Misaki.HighPerformance.Mathematics.double")]
|
[NumericType(typeof(double), sizeof(double), 2, 1, "global::Misaki.HighPerformance.Mathematics.double")]
|
||||||
[NumericConvertable("(double){v}.{c}", typeof(int2), typeof(uint2), typeof(float2))]
|
[NumericConvertable("(double){v}.{c}", typeof(int2), typeof(uint2), typeof(float2), typeof(bool2))]
|
||||||
[NumericConvertable("{v}.{c} ? 1.0 : 0.0", typeof(bool2))]
|
|
||||||
public partial struct double2
|
public partial struct double2
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -23,8 +22,7 @@ public partial struct double2x4
|
|||||||
}
|
}
|
||||||
|
|
||||||
[NumericType(typeof(double), sizeof(double), 3, 1, "global::Misaki.HighPerformance.Mathematics.double")]
|
[NumericType(typeof(double), sizeof(double), 3, 1, "global::Misaki.HighPerformance.Mathematics.double")]
|
||||||
[NumericConvertable("(double){v}.{c}", typeof(int3), typeof(uint3), typeof(float3))]
|
[NumericConvertable("(double){v}.{c}", typeof(int3), typeof(uint3), typeof(float3), typeof(bool3))]
|
||||||
[NumericConvertable("{v}.{c} ? 1.0 : 0.0", typeof(bool3))]
|
|
||||||
public partial struct double3
|
public partial struct double3
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -45,8 +43,7 @@ public partial struct double3x4
|
|||||||
}
|
}
|
||||||
|
|
||||||
[NumericType(typeof(double), sizeof(double), 4, 1, "global::Misaki.HighPerformance.Mathematics.double")]
|
[NumericType(typeof(double), sizeof(double), 4, 1, "global::Misaki.HighPerformance.Mathematics.double")]
|
||||||
[NumericConvertable("(double){v}.{c}", typeof(int4), typeof(uint4), typeof(float4))]
|
[NumericConvertable("(double){v}.{c}", typeof(int4), typeof(uint4), typeof(float4), typeof(bool4))]
|
||||||
[NumericConvertable("{v}.{c} ? 1.0 : 0.0", typeof(bool4))]
|
|
||||||
public partial struct double4
|
public partial struct double4
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
namespace Misaki.HighPerformance.Mathematics;
|
namespace Misaki.HighPerformance.Mathematics;
|
||||||
|
|
||||||
[NumericType(typeof(float), sizeof(float), 2, 1, "global::Misaki.HighPerformance.Mathematics.float")]
|
[NumericType(typeof(float), sizeof(float), 2, 1, "global::Misaki.HighPerformance.Mathematics.float")]
|
||||||
[NumericConvertable("(float){v}.{c}", typeof(int2), typeof(uint2), typeof(double2))]
|
[NumericConvertable("(float){v}.{c}", typeof(int2), typeof(uint2), typeof(double2), typeof(bool2))]
|
||||||
[NumericConvertable("{v}.{c} ? 1.0f : 0.0f", typeof(bool2))]
|
|
||||||
public partial struct float2
|
public partial struct float2
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -26,8 +25,7 @@ public partial struct float2x4
|
|||||||
}
|
}
|
||||||
|
|
||||||
[NumericType(typeof(float), sizeof(float), 3, 1, "global::Misaki.HighPerformance.Mathematics.float")]
|
[NumericType(typeof(float), sizeof(float), 3, 1, "global::Misaki.HighPerformance.Mathematics.float")]
|
||||||
[NumericConvertable("(float){v}.{c}", typeof(int3), typeof(uint3), typeof(double3))]
|
[NumericConvertable("(float){v}.{c}", typeof(int3), typeof(uint3), typeof(double3), typeof(bool3))]
|
||||||
[NumericConvertable("{v}.{c} ? 1.0f : 0.0f", typeof(bool3))]
|
|
||||||
public partial struct float3
|
public partial struct float3
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -63,8 +61,7 @@ public partial struct float3x4
|
|||||||
}
|
}
|
||||||
|
|
||||||
[NumericType(typeof(float), sizeof(float), 4, 1, "global::Misaki.HighPerformance.Mathematics.float")]
|
[NumericType(typeof(float), sizeof(float), 4, 1, "global::Misaki.HighPerformance.Mathematics.float")]
|
||||||
[NumericConvertable("(float){v}.{c}", typeof(int4), typeof(uint4), typeof(double4))]
|
[NumericConvertable("(float){v}.{c}", typeof(int4), typeof(uint4), typeof(double4), typeof(bool4))]
|
||||||
[NumericConvertable("{v}.{c} ? 1.0f : 0.0f", typeof(bool4))]
|
|
||||||
public partial struct float4
|
public partial struct float4
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
namespace Misaki.HighPerformance.Mathematics;
|
namespace Misaki.HighPerformance.Mathematics;
|
||||||
|
|
||||||
[NumericType(typeof(int), sizeof(int), 2, 1, "global::Misaki.HighPerformance.Mathematics.int")]
|
[NumericType(typeof(int), sizeof(int), 2, 1, "global::Misaki.HighPerformance.Mathematics.int")]
|
||||||
[NumericConvertable("(int){v}.{c}", typeof(uint2), typeof(float2), typeof(double2))]
|
[NumericConvertable("(int){v}.{c}", typeof(uint2), typeof(float2), typeof(double2), typeof(bool2))]
|
||||||
[NumericConvertable("{v}.{c} ? 1 : 0", typeof(bool2))]
|
|
||||||
public partial struct int2
|
public partial struct int2
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -23,8 +22,7 @@ public partial struct int2x4
|
|||||||
}
|
}
|
||||||
|
|
||||||
[NumericType(typeof(int), sizeof(int), 3, 1, "global::Misaki.HighPerformance.Mathematics.int")]
|
[NumericType(typeof(int), sizeof(int), 3, 1, "global::Misaki.HighPerformance.Mathematics.int")]
|
||||||
[NumericConvertable("(int){v}.{c}", typeof(uint3), typeof(float3), typeof(double3))]
|
[NumericConvertable("(int){v}.{c}", typeof(uint3), typeof(float3), typeof(double3), typeof(bool3))]
|
||||||
[NumericConvertable("{v}.{c} ? 1 : 0", typeof(bool3))]
|
|
||||||
public partial struct int3
|
public partial struct int3
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -45,8 +43,7 @@ public partial struct int3x4
|
|||||||
}
|
}
|
||||||
|
|
||||||
[NumericType(typeof(int), sizeof(int), 4, 1, "global::Misaki.HighPerformance.Mathematics.int")]
|
[NumericType(typeof(int), sizeof(int), 4, 1, "global::Misaki.HighPerformance.Mathematics.int")]
|
||||||
[NumericConvertable("(int){v}.{c}", typeof(uint4), typeof(float4), typeof(double4))]
|
[NumericConvertable("(int){v}.{c}", typeof(uint4), typeof(float4), typeof(double4), typeof(bool4))]
|
||||||
[NumericConvertable("{v}.{c} ? 1 : 0", typeof(bool4))]
|
|
||||||
public partial struct int4
|
public partial struct int4
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,8 +1,7 @@
|
|||||||
namespace Misaki.HighPerformance.Mathematics;
|
namespace Misaki.HighPerformance.Mathematics;
|
||||||
|
|
||||||
[NumericType(typeof(uint), sizeof(uint), 2, 1, "global::Misaki.HighPerformance.Mathematics.uint")]
|
[NumericType(typeof(uint), sizeof(uint), 2, 1, "global::Misaki.HighPerformance.Mathematics.uint")]
|
||||||
[NumericConvertable("(uint){v}.{c}", typeof(int2), typeof(float2), typeof(double2))]
|
[NumericConvertable("(uint){v}.{c}", typeof(int2), typeof(float2), typeof(double2), typeof(bool2))]
|
||||||
[NumericConvertable("{v}.{c} ? 1u : 0u", typeof(bool2))]
|
|
||||||
public partial struct uint2
|
public partial struct uint2
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -23,8 +22,7 @@ public partial struct uint2x4
|
|||||||
}
|
}
|
||||||
|
|
||||||
[NumericType(typeof(uint), sizeof(uint), 3, 1, "global::Misaki.HighPerformance.Mathematics.uint")]
|
[NumericType(typeof(uint), sizeof(uint), 3, 1, "global::Misaki.HighPerformance.Mathematics.uint")]
|
||||||
[NumericConvertable("(uint){v}.{c}", typeof(int3), typeof(float3), typeof(double3))]
|
[NumericConvertable("(uint){v}.{c}", typeof(int3), typeof(float3), typeof(double3), typeof(bool3))]
|
||||||
[NumericConvertable("{v}.{c} ? 1u : 0u", typeof(bool3))]
|
|
||||||
public partial struct uint3
|
public partial struct uint3
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -45,8 +43,7 @@ public partial struct uint3x4
|
|||||||
}
|
}
|
||||||
|
|
||||||
[NumericType(typeof(uint), sizeof(uint), 4, 1, "global::Misaki.HighPerformance.Mathematics.uint")]
|
[NumericType(typeof(uint), sizeof(uint), 4, 1, "global::Misaki.HighPerformance.Mathematics.uint")]
|
||||||
[NumericConvertable("(uint){v}.{c}", typeof(int4), typeof(float4), typeof(double4))]
|
[NumericConvertable("(uint){v}.{c}", typeof(int4), typeof(float4), typeof(double4), typeof(bool4))]
|
||||||
[NumericConvertable("{v}.{c} ? 1u : 0u", typeof(bool4))]
|
|
||||||
public partial struct uint4
|
public partial struct uint4
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ public unsafe class SPMDBenchmark
|
|||||||
job.Run(_SIZE * _SIZE, 0);
|
job.Run(_SIZE * _SIZE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//[Benchmark]
|
[Benchmark]
|
||||||
public void VectorNoise()
|
public void VectorJobNoise()
|
||||||
{
|
{
|
||||||
var job = new Jobs.NoiseJobVector
|
var job = new Jobs.NoiseJobVector
|
||||||
{
|
{
|
||||||
@@ -53,34 +53,22 @@ public unsafe class SPMDBenchmark
|
|||||||
_scheduler.WaitComplete(handle);
|
_scheduler.WaitComplete(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
//[Benchmark]
|
[Benchmark]
|
||||||
public void MathNoise()
|
public void ParallelVectorNoise()
|
||||||
{
|
{
|
||||||
var job = new Jobs.NoiseJobMath
|
var job = new Jobs.NoiseJobVector
|
||||||
{
|
{
|
||||||
buffers = _buf,
|
buffers = _buf,
|
||||||
width = _SIZE,
|
width = _SIZE,
|
||||||
height = _SIZE,
|
height = _SIZE,
|
||||||
};
|
};
|
||||||
|
|
||||||
var handle = _scheduler.ScheduleParallel(ref job, _SIZE * _SIZE, 64);
|
Parallel.For(0, _SIZE * _SIZE, (i) =>
|
||||||
_scheduler.WaitComplete(handle);
|
{
|
||||||
|
job.Execute(i, 0);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//[Benchmark(Baseline = true)]
|
|
||||||
public void ManualSPMDNoise()
|
|
||||||
{
|
|
||||||
var job = new Jobs.NoiseJobMathV
|
|
||||||
{
|
|
||||||
buffers = _buf,
|
|
||||||
width = _SIZE,
|
|
||||||
height = _SIZE,
|
|
||||||
};
|
|
||||||
|
|
||||||
var iterations = (_SIZE * _SIZE + 8 - 1) / 8;
|
|
||||||
var handle = _scheduler.ScheduleParallel(ref job, iterations, 64);
|
|
||||||
_scheduler.WaitComplete(handle);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Benchmark(Baseline = true)]
|
[Benchmark(Baseline = true)]
|
||||||
public void SPMDNoise()
|
public void SPMDNoise()
|
||||||
|
|||||||
@@ -1,59 +1,2 @@
|
|||||||
using Misaki.HighPerformance;
|
|
||||||
using Misaki.HighPerformance.Jobs;
|
|
||||||
using Misaki.HighPerformance.LowLevel;
|
|
||||||
using Misaki.HighPerformance.LowLevel.Utilities;
|
|
||||||
using Misaki.HighPerformance.Mathematics.SPMD;
|
|
||||||
using Misaki.HighPerformance.Test.UnitTest.Jobs;
|
|
||||||
using System.Numerics;
|
|
||||||
using System.Runtime.Intrinsics;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
BenchmarkDotNet.Running.BenchmarkRunner.Run<Misaki.HighPerformance.Test.Benchmark.SPMDBenchmark>();
|
BenchmarkDotNet.Running.BenchmarkRunner.Run<Misaki.HighPerformance.Test.Benchmark.SPMDBenchmark>();
|
||||||
//return;
|
return;
|
||||||
//using Misaki.HighPerformance.Collections;
|
|
||||||
//using Misaki.HighPerformance.LowLevel.Buffer;
|
|
||||||
//using Misaki.HighPerformance.LowLevel.Collections;
|
|
||||||
|
|
||||||
//AllocationManager.EnableDebugLayer();
|
|
||||||
//using var csm = new UnsafeSlotMap<int>(4, Allocator.Persistent);
|
|
||||||
//AllocationManager.Dispose();
|
|
||||||
|
|
||||||
//using Misaki.HighPerformance.Mathematics;
|
|
||||||
//using System.Numerics;
|
|
||||||
|
|
||||||
//var a = new Misaki.HighPerformance.Mathematics.float4x4(
|
|
||||||
// 1, 2, 3, 4,
|
|
||||||
// 5, 6, 7, 8,
|
|
||||||
// 9, 10, 11, 12,
|
|
||||||
// 13, 14, 15, 16);
|
|
||||||
//var b = new Misaki.HighPerformance.Mathematics.float4x4(
|
|
||||||
// 16, 15, 14, 13,
|
|
||||||
// 12, 11, 10, 9,
|
|
||||||
// 8, 7, 6, 5,
|
|
||||||
// 4, 3, 2, 1);
|
|
||||||
|
|
||||||
//Console.WriteLine(math.mul(a, b));
|
|
||||||
|
|
||||||
//var ma = new Matrix4x4(
|
|
||||||
// 1, 2, 3, 4,
|
|
||||||
// 5, 6, 7, 8,
|
|
||||||
// 9, 10, 11, 12,
|
|
||||||
// 13, 14, 15, 16);
|
|
||||||
//var mb = new Matrix4x4(
|
|
||||||
// 16, 15, 14, 13,
|
|
||||||
// 12, 11, 10, 9,
|
|
||||||
// 8, 7, 6, 5,
|
|
||||||
// 4, 3, 2, 1);
|
|
||||||
//Console.WriteLine(Matrix4x4.Multiply(ma, mb));
|
|
||||||
|
|
||||||
//int[] arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
|
||||||
//int[] arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
|
||||||
|
|
||||||
//unsafe
|
|
||||||
//{
|
|
||||||
// fixed (int* p1 = arr1)
|
|
||||||
// fixed (int* p2 = arr2)
|
|
||||||
// {
|
|
||||||
// Console.WriteLine(MemoryUtility.MemCmp(p1, p2, (nuint)(arr1.Length * sizeof(int))));
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using Misaki.HighPerformance.Mathematics;
|
using Misaki.HighPerformance.Mathematics;
|
||||||
|
|
||||||
namespace Misaki.HighPerformance.Test.UnitTest.Mathematics;
|
namespace Misaki.HighPerformance.Test.UnitTest.Mathematics;
|
||||||
|
|
||||||
@@ -10,28 +10,18 @@ public class TestBool2
|
|||||||
{
|
{
|
||||||
// Default constructor
|
// Default constructor
|
||||||
var v1 = new bool2();
|
var v1 = new bool2();
|
||||||
Assert.IsFalse(v1.x);
|
Assert.AreNotEqual(math.TRUE, v1.x);
|
||||||
Assert.IsFalse(v1.y);
|
Assert.AreNotEqual(math.TRUE, v1.y);
|
||||||
|
|
||||||
// Single value constructor
|
// Single value constructor
|
||||||
var v2 = new bool2(true);
|
var v2 = new bool2(true);
|
||||||
Assert.IsTrue(v2.x);
|
Assert.AreEqual(math.TRUE, v2.x);
|
||||||
Assert.IsTrue(v2.y);
|
Assert.AreEqual(math.TRUE, v2.y);
|
||||||
|
|
||||||
// Component constructor
|
// Component constructor
|
||||||
var v3 = new bool2(true, false);
|
var v3 = new bool2(true, false);
|
||||||
Assert.IsTrue(v3.x);
|
Assert.AreEqual(math.TRUE, v3.x);
|
||||||
Assert.IsFalse(v3.y);
|
Assert.AreNotEqual(math.TRUE, v3.y);
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void TestLogicalOperators()
|
|
||||||
{
|
|
||||||
var a = new bool2(true, false);
|
|
||||||
var b = new bool2(false, true);
|
|
||||||
|
|
||||||
// Note: bool types don't typically have bitwise operators in this implementation
|
|
||||||
// They are primarily used for conditional operations with math functions
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@@ -54,12 +44,12 @@ public class TestBool2
|
|||||||
{
|
{
|
||||||
var v = new bool2(true, false);
|
var v = new bool2(true, false);
|
||||||
|
|
||||||
Assert.IsTrue(v.x);
|
Assert.AreEqual(math.TRUE, v.x);
|
||||||
Assert.IsFalse(v.y);
|
Assert.AreNotEqual(math.TRUE, v.y);
|
||||||
|
|
||||||
var xy = v.xy;
|
var xy = v.xy;
|
||||||
Assert.IsTrue(xy.x);
|
Assert.AreEqual(math.TRUE, xy.x);
|
||||||
Assert.IsFalse(xy.y);
|
Assert.AreNotEqual(math.TRUE, xy.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@@ -89,7 +79,7 @@ public class TestBool2
|
|||||||
{
|
{
|
||||||
var v = new bool2(true, false);
|
var v = new bool2(true, false);
|
||||||
|
|
||||||
Assert.IsTrue(v[0]);
|
Assert.AreEqual(math.TRUE, v[0]);
|
||||||
Assert.IsFalse(v[1]);
|
Assert.AreNotEqual(math.TRUE, v[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -282,7 +282,7 @@ public class TestMathFunctions
|
|||||||
var a = new float3(1f, 2f, 3f);
|
var a = new float3(1f, 2f, 3f);
|
||||||
var b = new float3(4f, 5f, 6f);
|
var b = new float3(4f, 5f, 6f);
|
||||||
|
|
||||||
var result = math.select(b, a, condition);
|
var result = math.select(a, b, condition);
|
||||||
|
|
||||||
Assert.AreEqual(1f, result.x, 1e-6f); // condition is true, so select a.x
|
Assert.AreEqual(1f, result.x, 1e-6f); // condition is true, so select a.x
|
||||||
Assert.AreEqual(5f, result.y, 1e-6f); // condition is false, so select b.y
|
Assert.AreEqual(5f, result.y, 1e-6f); // condition is false, so select b.y
|
||||||
|
|||||||
Reference in New Issue
Block a user