Fix package dependency problem
All checks were successful
Publish NuGet Packages / publish (push) Successful in 1m47s
All checks were successful
Publish NuGet Packages / publish (push) Successful in 1m47s
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
using Misaki.HighPerformance.Image.Runtime;
|
using Misaki.HighPerformance.Image.Runtime;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -86,7 +86,7 @@ internal class AnimatedGifEnumerator : IEnumerator<AnimatedFrameResult>
|
|||||||
Dispose(false);
|
Dispose(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected unsafe virtual void Dispose(bool disposing)
|
protected virtual unsafe void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (_gif != null)
|
if (_gif != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
namespace Misaki.HighPerformance.Image.Runtime
|
namespace Misaki.HighPerformance.Image.Runtime
|
||||||
{
|
{
|
||||||
internal unsafe static class MemoryStats
|
internal static unsafe class MemoryStats
|
||||||
{
|
{
|
||||||
private static int _allocations;
|
private static int _allocations;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
namespace Misaki.HighPerformance.Jobs;
|
namespace Misaki.HighPerformance.Jobs;
|
||||||
|
|
||||||
internal unsafe static class JobExecutor
|
internal static unsafe class JobExecutor
|
||||||
{
|
{
|
||||||
public static bool Execute<T>(void* pJobData, ref JobRanges jobRanges, ref int remainingBatches, int threadIndex)
|
public static bool Execute<T>(void* pJobData, ref JobRanges jobRanges, ref int remainingBatches, int threadIndex)
|
||||||
where T : unmanaged, IJob
|
where T : unmanaged, IJob
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using Misaki.HighPerformance.Collections;
|
using Misaki.HighPerformance.Collections;
|
||||||
using Misaki.HighPerformance.LowLevel.Buffer;
|
using Misaki.HighPerformance.LowLevel.Buffer;
|
||||||
using Misaki.HighPerformance.LowLevel.Utilities;
|
using Misaki.HighPerformance.LowLevel.Utilities;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
@@ -15,7 +15,7 @@ namespace Misaki.HighPerformance.Jobs;
|
|||||||
/// of worker threads through job batching and work-stealing mechanisms. This class is thread-safe and can be used in
|
/// of worker threads through job batching and work-stealing mechanisms. This class is thread-safe and can be used in
|
||||||
/// multi-threaded environments. However, it must be disposed when no longer needed to release resources and terminate
|
/// multi-threaded environments. However, it must be disposed when no longer needed to release resources and terminate
|
||||||
/// worker threads.</remarks>
|
/// worker threads.</remarks>
|
||||||
public unsafe sealed class JobScheduler : IDisposable
|
public sealed unsafe class JobScheduler : IDisposable
|
||||||
{
|
{
|
||||||
private const int _SLEEP_THRESHOLD = 100;
|
private const int _SLEEP_THRESHOLD = 100;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
global using static Misaki.HighPerformance.LowLevel.Utilities.MemoryUtility;
|
global using static Misaki.HighPerformance.LowLevel.Utilities.MemoryUtility;
|
||||||
|
|
||||||
|
|
||||||
global using unsafe AllocFunc = delegate*<void*, nuint, nuint, Misaki.HighPerformance.LowLevel.Buffer.AllocationOption, void*>;
|
global using unsafe AllocFunc = delegate*<void*, nuint, nuint, Misaki.HighPerformance.LowLevel.Buffer.AllocationOption, void*>;
|
||||||
|
global using unsafe FreeFunc = delegate*<void*, void*, void>;
|
||||||
global using unsafe ReallocFunc = delegate*<void*, void*, nuint, nuint, nuint, Misaki.HighPerformance.LowLevel.Buffer.AllocationOption, void*>;
|
global using unsafe ReallocFunc = delegate*<void*, void*, nuint, nuint, nuint, Misaki.HighPerformance.LowLevel.Buffer.AllocationOption, void*>;
|
||||||
global using unsafe FreeFunc = delegate*<void*, void*, void>;
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Misaki.HighPerformance.LowLevel.Buffer;
|
namespace Misaki.HighPerformance.LowLevel.Buffer;
|
||||||
|
|
||||||
@@ -6,7 +6,7 @@ namespace Misaki.HighPerformance.LowLevel.Buffer;
|
|||||||
/// Represents an allocated memory block with metadata.
|
/// Represents an allocated memory block with metadata.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public unsafe readonly struct MemoryBlock
|
public readonly unsafe struct MemoryBlock
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Pointer to the actual allocated memory.
|
/// Pointer to the actual allocated memory.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using Misaki.HighPerformance.LowLevel.Buffer;
|
using Misaki.HighPerformance.LowLevel.Buffer;
|
||||||
|
|
||||||
namespace Misaki.HighPerformance.LowLevel.Collections.Contracts;
|
namespace Misaki.HighPerformance.LowLevel.Collections.Contracts;
|
||||||
|
|
||||||
@@ -7,7 +7,7 @@ public unsafe interface IUnsafeCollection : IDisposable
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicates whether the object has been created. Returns true if the object is created, otherwise false.
|
/// Indicates whether the object has been created. Returns true if the object is created, otherwise false.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsCreated
|
bool IsCreated
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
}
|
}
|
||||||
@@ -15,13 +15,13 @@ public unsafe interface IUnsafeCollection : IDisposable
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Removes all elements from the collection. The collection will be empty after this operation.
|
/// Removes all elements from the collection. The collection will be empty after this operation.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Clear();
|
void Clear();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a pointer to an unmanaged memory location. This pointer can be used for low-level memory operations.
|
/// Returns a pointer to an unmanaged memory location. This pointer can be used for low-level memory operations.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The method returns a void pointer to the unsafe memory location.</returns>
|
/// <returns>The method returns a void pointer to the unsafe memory location.</returns>
|
||||||
public void* GetUnsafePtr();
|
void* GetUnsafePtr();
|
||||||
}
|
}
|
||||||
|
|
||||||
public unsafe interface IUnsafeCollection<T> : IUnsafeCollection, IEnumerable<T>
|
public unsafe interface IUnsafeCollection<T> : IUnsafeCollection, IEnumerable<T>
|
||||||
@@ -30,7 +30,7 @@ public unsafe interface IUnsafeCollection<T> : IUnsafeCollection, IEnumerable<T>
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the number of elements in a collection. The value is read-only.
|
/// Gets the number of elements in a collection. The value is read-only.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Count
|
int Count
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
}
|
}
|
||||||
@@ -40,7 +40,7 @@ public unsafe interface IUnsafeCollection<T> : IUnsafeCollection, IEnumerable<T>
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>This is to adjust the element count of the collection, not the size of the underlying buffer in memory.</remarks>
|
/// <remarks>This is to adjust the element count of the collection, not the size of the underlying buffer in memory.</remarks>
|
||||||
/// <param name="newSize">Specifies the new size to which the collection should be adjusted.</param>
|
/// <param name="newSize">Specifies the new size to which the collection should be adjusted.</param>
|
||||||
public void Resize(int newSize, AllocationOption option);
|
void Resize(int newSize, AllocationOption option);
|
||||||
}
|
}
|
||||||
|
|
||||||
public unsafe interface IUnTypedCollection : IUnsafeCollection
|
public unsafe interface IUnTypedCollection : IUnsafeCollection
|
||||||
@@ -48,11 +48,11 @@ public unsafe interface IUnTypedCollection : IUnsafeCollection
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The total size of the buffer in bytes.
|
/// The total size of the buffer in bytes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public uint Size
|
uint Size
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ref T GetElementAt<T>(uint index)
|
ref T GetElementAt<T>(uint index)
|
||||||
where T : unmanaged;
|
where T : unmanaged;
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
using Misaki.HighPerformance.LowLevel.Buffer;
|
using Misaki.HighPerformance.LowLevel.Buffer;
|
||||||
using Misaki.HighPerformance.LowLevel.Collections.Contracts;
|
using Misaki.HighPerformance.LowLevel.Collections.Contracts;
|
||||||
using Misaki.HighPerformance.LowLevel.Contracts;
|
using Misaki.HighPerformance.LowLevel.Contracts;
|
||||||
using Misaki.HighPerformance.LowLevel.Utilities;
|
using Misaki.HighPerformance.LowLevel.Utilities;
|
||||||
@@ -93,7 +93,7 @@ public unsafe struct UnsafeSlotMap<T> : IUnsafeCollection<T>
|
|||||||
{
|
{
|
||||||
throw new ArgumentOutOfRangeException(nameof(capacity), "Capacity must be greater than zero.");
|
throw new ArgumentOutOfRangeException(nameof(capacity), "Capacity must be greater than zero.");
|
||||||
}
|
}
|
||||||
|
|
||||||
_data = new UnsafeArray<SlotData>(capacity, ref handle, allocationOption);
|
_data = new UnsafeArray<SlotData>(capacity, ref handle, allocationOption);
|
||||||
_freeSlots = new UnsafeQueue<int>(capacity, ref handle, allocationOption);
|
_freeSlots = new UnsafeQueue<int>(capacity, ref handle, allocationOption);
|
||||||
_count = 0;
|
_count = 0;
|
||||||
@@ -266,7 +266,7 @@ public unsafe struct UnsafeSlotMap<T> : IUnsafeCollection<T>
|
|||||||
|
|
||||||
ref var slot = ref _data[slotIndex];
|
ref var slot = ref _data[slotIndex];
|
||||||
|
|
||||||
if (!slot.isValid|| slot.generation != generation)
|
if (!slot.isValid || slot.generation != generation)
|
||||||
{
|
{
|
||||||
exist = false;
|
exist = false;
|
||||||
return ref Unsafe.NullRef<T>();
|
return ref Unsafe.NullRef<T>();
|
||||||
@@ -292,7 +292,7 @@ public unsafe struct UnsafeSlotMap<T> : IUnsafeCollection<T>
|
|||||||
_count = 0;
|
_count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public unsafe readonly void* GetUnsafePtr()
|
public readonly unsafe void* GetUnsafePtr()
|
||||||
{
|
{
|
||||||
return _data.GetUnsafePtr();
|
return _data.GetUnsafePtr();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using Misaki.HighPerformance.LowLevel.Buffer;
|
using Misaki.HighPerformance.LowLevel.Buffer;
|
||||||
using Misaki.HighPerformance.LowLevel.Collections.Contracts;
|
using Misaki.HighPerformance.LowLevel.Collections.Contracts;
|
||||||
using Misaki.HighPerformance.LowLevel.Contracts;
|
using Misaki.HighPerformance.LowLevel.Contracts;
|
||||||
using Misaki.HighPerformance.LowLevel.Utilities;
|
using Misaki.HighPerformance.LowLevel.Utilities;
|
||||||
@@ -61,7 +61,7 @@ public unsafe struct UnsafeSparseSet<T> : IUnsafeCollection<T>
|
|||||||
get => Current;
|
get => Current;
|
||||||
}
|
}
|
||||||
|
|
||||||
public unsafe readonly void Dispose()
|
public readonly unsafe void Dispose()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
namespace Misaki.HighPerformance.LowLevel.Contracts;
|
namespace Misaki.HighPerformance.LowLevel.Contracts;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A structure that encapsulates function pointers for memory allocation operations.
|
/// A structure that encapsulates function pointers for memory allocation operations.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public unsafe readonly struct AllocationHandle
|
public readonly unsafe struct AllocationHandle
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a pointer to the allocator instance associated with this allocation handle.
|
/// Gets a pointer to the allocator instance associated with this allocation handle.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using Misaki.HighPerformance.LowLevel.Buffer;
|
using Misaki.HighPerformance.LowLevel.Buffer;
|
||||||
using Misaki.HighPerformance.LowLevel.Collections;
|
using Misaki.HighPerformance.LowLevel.Collections;
|
||||||
using Misaki.HighPerformance.LowLevel.Collections.Contracts;
|
using Misaki.HighPerformance.LowLevel.Collections.Contracts;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
@@ -9,7 +9,7 @@ namespace Misaki.HighPerformance.LowLevel.Utilities;
|
|||||||
/// Provides extension methods for copying elements between unsafe collections and spans, converting collections to
|
/// Provides extension methods for copying elements between unsafe collections and spans, converting collections to
|
||||||
/// arrays or lists, and searching for values.
|
/// arrays or lists, and searching for values.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public unsafe static class UnsafeCollectionExtensions
|
public static unsafe class UnsafeCollectionExtensions
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Copies elements from a source UnsafeCollection to a destination Span, ensuring both have the same size.
|
/// Copies elements from a source UnsafeCollection to a destination Span, ensuring both have the same size.
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
using Microsoft.CodeAnalysis;
|
using Microsoft.CodeAnalysis;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Misaki.HighPerformance.Mathematics.CodeGen.Generators
|
namespace Misaki.HighPerformance.Mathematics.CodeGen.Generators
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,109 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace Misaki.HighPerformance.Mathematics.CodeGen
|
|
||||||
{
|
|
||||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, Inherited = false)]
|
|
||||||
public class NumericTypeAttribute : Attribute
|
|
||||||
{
|
|
||||||
public NumericTypeAttribute(Type componentType, int componentSize, int row, int column, string typePrefix, bool arithmetic = true, bool canInverse = true, Type? elementType = default, Type? vectorType = default)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, Inherited = false, AllowMultiple = true)]
|
|
||||||
public class NumericConvertableAttribute : Attribute
|
|
||||||
{
|
|
||||||
public NumericConvertableAttribute(string template, params Type[] types)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Flags]
|
|
||||||
public enum SupportedVectorMath
|
|
||||||
{
|
|
||||||
None = 0,
|
|
||||||
Min = 1 << 0,
|
|
||||||
Max = 1 << 1,
|
|
||||||
Lerp = 1 << 2,
|
|
||||||
Unlerp = 1 << 3,
|
|
||||||
Remap = 1 << 4,
|
|
||||||
Mad = 1 << 5,
|
|
||||||
Clamp = 1 << 6,
|
|
||||||
Saturate = 1 << 7,
|
|
||||||
Abs = 1 << 8,
|
|
||||||
Dot = 1 << 9,
|
|
||||||
Tan = 1 << 10,
|
|
||||||
TanH = 1 << 11,
|
|
||||||
Atan = 1 << 12,
|
|
||||||
Atan2 = 1 << 13,
|
|
||||||
Cos = 1 << 14,
|
|
||||||
CosH = 1 << 15,
|
|
||||||
Acos = 1 << 16,
|
|
||||||
Sin = 1 << 17,
|
|
||||||
SinH = 1 << 18,
|
|
||||||
Asin = 1 << 19,
|
|
||||||
Floor = 1 << 20,
|
|
||||||
Ceil = 1 << 21,
|
|
||||||
Round = 1 << 22,
|
|
||||||
Trunc = 1 << 23,
|
|
||||||
Frac = 1 << 24,
|
|
||||||
Rcp = 1 << 25,
|
|
||||||
Sign = 1 << 26,
|
|
||||||
Pow = 1 << 27,
|
|
||||||
Exp = 1 << 28,
|
|
||||||
Exp2 = 1 << 29,
|
|
||||||
Exp10 = 1 << 30,
|
|
||||||
Log = 1 << 31,
|
|
||||||
Log2 = 1 << 32,
|
|
||||||
Log10 = 1 << 33,
|
|
||||||
Fmod = 1 << 34,
|
|
||||||
Modf = 1 << 35,
|
|
||||||
Sqrt = 1 << 36,
|
|
||||||
Rsqrt = 1 << 37,
|
|
||||||
Length = 1 << 38,
|
|
||||||
LengthSq = 1 << 39,
|
|
||||||
Distance = 1 << 40,
|
|
||||||
DistanceSq = 1 << 41,
|
|
||||||
Cross = 1 << 42,
|
|
||||||
SmoothStep = 1 << 43,
|
|
||||||
Select = 1 << 44,
|
|
||||||
Step = 1 << 45,
|
|
||||||
FaceForward = 1 << 46,
|
|
||||||
SinCos = 1 << 47,
|
|
||||||
Any = 1 << 48,
|
|
||||||
All = 1 << 49,
|
|
||||||
Normalize = 1 << 50,
|
|
||||||
Reflect = 1 << 51,
|
|
||||||
Refract = 1 << 52,
|
|
||||||
Project = 1 << 53,
|
|
||||||
CountBits = 1 << 54,
|
|
||||||
Lzcnt = 1 << 55,
|
|
||||||
Tzcnt = 1 << 56,
|
|
||||||
ReverseBits = 1 << 57,
|
|
||||||
Rol = 1 << 58,
|
|
||||||
Ror = 1 << 59,
|
|
||||||
CeilPow2 = 1 << 60,
|
|
||||||
CeilLog2 = 1 << 61,
|
|
||||||
FloorLog2 = 1 << 62,
|
|
||||||
Radians = 1 << 63,
|
|
||||||
Degrees = 1 << 64,
|
|
||||||
Cmin = 1 << 65,
|
|
||||||
Cmax = 1 << 66,
|
|
||||||
|
|
||||||
FloatingPointMask = ~0 & ~(CountBits | Lzcnt | Tzcnt | ReverseBits | Rol | Ror | CeilPow2 | CeilLog2 | FloorLog2),
|
|
||||||
IntegerMask = Min | Max | Mad | Clamp | Abs | Dot | Sign | Any | All | Select | CountBits | Lzcnt | Tzcnt | ReverseBits | Rol | Ror | CeilPow2 | CeilLog2 | FloorLog2 | Cmin | Cmax,
|
|
||||||
UnsignedIntegerMask = IntegerMask & ~(Sign),
|
|
||||||
}
|
|
||||||
|
|
||||||
[Flags]
|
|
||||||
public enum SupportedMatrixMath
|
|
||||||
{
|
|
||||||
Transpose = 1 << 0,
|
|
||||||
Determinant = 1 << 1,
|
|
||||||
Inverse = 1 << 2,
|
|
||||||
Adjugate = 1 << 3,
|
|
||||||
Cofactor = 1 << 4,
|
|
||||||
Minor = 1 << 5,
|
|
||||||
OuterProduct = 1 << 6,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
using Microsoft.CodeAnalysis;
|
using Microsoft.CodeAnalysis;
|
||||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||||
using Misaki.HighPerformance.Mathematics.CodeGen.Generators;
|
using Misaki.HighPerformance.Mathematics.CodeGen.Generators;
|
||||||
using Misaki.HighPerformance.Mathematics.CodeGen.Models;
|
using Misaki.HighPerformance.Mathematics.CodeGen.Models;
|
||||||
@@ -14,7 +14,7 @@ namespace Misaki.HighPerformance.Mathematics.CodeGen
|
|||||||
// Create a provider that finds all types with NumericTypeAttribute
|
// Create a provider that finds all types with NumericTypeAttribute
|
||||||
var typesWithAttribute = context.SyntaxProvider
|
var typesWithAttribute = context.SyntaxProvider
|
||||||
.ForAttributeWithMetadataName(
|
.ForAttributeWithMetadataName(
|
||||||
fullyQualifiedMetadataName: typeof(NumericTypeAttribute).FullName,
|
fullyQualifiedMetadataName: "Misaki.HighPerformance.Mathematics.NumericTypeAttribute",
|
||||||
predicate: static (node, _) => node is ClassDeclarationSyntax or StructDeclarationSyntax,
|
predicate: static (node, _) => node is ClassDeclarationSyntax or StructDeclarationSyntax,
|
||||||
transform: static (context, _) => GetTypeInfo(context))
|
transform: static (context, _) => GetTypeInfo(context))
|
||||||
.Where(static typeInfo => typeInfo is not null);
|
.Where(static typeInfo => typeInfo is not null);
|
||||||
@@ -52,10 +52,10 @@ namespace Misaki.HighPerformance.Mathematics.CodeGen
|
|||||||
|
|
||||||
// Get the attribute data
|
// Get the attribute data
|
||||||
var attribute = typeSymbol.GetAttributes()
|
var attribute = typeSymbol.GetAttributes()
|
||||||
.FirstOrDefault(a => a.AttributeClass?.ToDisplayString() == typeof(NumericTypeAttribute).FullName);
|
.FirstOrDefault(a => a.AttributeClass?.ToDisplayString() == "Misaki.HighPerformance.Mathematics.NumericTypeAttribute");
|
||||||
|
|
||||||
var convertableAttributes = typeSymbol.GetAttributes()
|
var convertableAttributes = typeSymbol.GetAttributes()
|
||||||
.Where(a => a.AttributeClass?.ToDisplayString() == typeof(NumericConvertableAttribute).FullName);
|
.Where(a => a.AttributeClass?.ToDisplayString() == "Misaki.HighPerformance.Mathematics.NumericConvertableAttribute");
|
||||||
|
|
||||||
if (attribute == null)
|
if (attribute == null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
namespace Misaki.HighPerformance.Mathematics.Geometry;
|
namespace Misaki.HighPerformance.Mathematics.Geometry;
|
||||||
|
|
||||||
@@ -232,13 +232,13 @@ public struct AABB : IEquatable<AABB>
|
|||||||
return !(left == right);
|
return !(left == right);
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly override int GetHashCode()
|
public override readonly int GetHashCode()
|
||||||
{
|
{
|
||||||
return HashCode.Combine(Min, Max);
|
return HashCode.Combine(Min, Max);
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public readonly override string ToString()
|
public override readonly string ToString()
|
||||||
{
|
{
|
||||||
return string.Format("AABB({0}, {1})", Min, Max);
|
return string.Format("AABB({0}, {1})", Min, Max);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace Misaki.HighPerformance.Mathematics.Geometry;
|
namespace Misaki.HighPerformance.Mathematics.Geometry;
|
||||||
|
|
||||||
public struct OBB : IEquatable<OBB>
|
public struct OBB : IEquatable<OBB>
|
||||||
{
|
{
|
||||||
@@ -38,7 +38,7 @@ public struct OBB : IEquatable<OBB>
|
|||||||
max = centerProjection + r;
|
max = centerProjection + r;
|
||||||
}
|
}
|
||||||
|
|
||||||
public unsafe readonly bool Overlaps(OBB other)
|
public readonly unsafe bool Overlaps(OBB other)
|
||||||
{
|
{
|
||||||
// Using the Separating Axis Theorem (SAT) for OBB-OBB intersection test
|
// Using the Separating Axis Theorem (SAT) for OBB-OBB intersection test
|
||||||
var axes = stackalloc float3[15];
|
var axes = stackalloc float3[15];
|
||||||
@@ -109,12 +109,12 @@ public struct OBB : IEquatable<OBB>
|
|||||||
return Rotation.Equals(other.Rotation) && Center.Equals(other.Center) && Extents.Equals(other.Extents);
|
return Rotation.Equals(other.Rotation) && Center.Equals(other.Center) && Extents.Equals(other.Extents);
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly override bool Equals(object? obj)
|
public override readonly bool Equals(object? obj)
|
||||||
{
|
{
|
||||||
return obj is OBB obb && Equals(obb);
|
return obj is OBB obb && Equals(obb);
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly override int GetHashCode()
|
public override readonly int GetHashCode()
|
||||||
{
|
{
|
||||||
return HashCode.Combine(Rotation, Center, Extents);
|
return HashCode.Combine(Rotation, Center, Extents);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
namespace Misaki.HighPerformance.Mathematics.Geometry;
|
namespace Misaki.HighPerformance.Mathematics.Geometry;
|
||||||
|
|
||||||
@@ -98,12 +98,12 @@ public struct SphereBounds : IEquatable<SphereBounds>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly override string ToString()
|
public override readonly string ToString()
|
||||||
{
|
{
|
||||||
return $"Center: {Center}, Radius: {Radius}";
|
return $"Center: {Center}, Radius: {Radius}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly override int GetHashCode()
|
public override readonly int GetHashCode()
|
||||||
{
|
{
|
||||||
return HashCode.Combine(Center, Radius);
|
return HashCode.Combine(Center, Radius);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,14 +6,14 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||||
<Authors>Misaki</Authors>
|
<Authors>Misaki</Authors>
|
||||||
<Version>1.2.5</Version>
|
<Version>1.2.6</Version>
|
||||||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
||||||
<PackageProjectUrl>https://git.personalnas.com/Misaki/Misaki.HighPerformance.git</PackageProjectUrl>
|
<PackageProjectUrl>https://git.personalnas.com/Misaki/Misaki.HighPerformance.git</PackageProjectUrl>
|
||||||
<RepositoryUrl>https://git.personalnas.com/Misaki/Misaki.HighPerformance.git</RepositoryUrl>
|
<RepositoryUrl>https://git.personalnas.com/Misaki/Misaki.HighPerformance.git</RepositoryUrl>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Misaki.HighPerformance.Mathematics.CodeGen\Misaki.HighPerformance.Mathematics.CodeGen.csproj" OutputItemType="Analyzer" />
|
<ProjectReference Include="..\Misaki.HighPerformance.Mathematics.CodeGen\Misaki.HighPerformance.Mathematics.CodeGen.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
106
Misaki.HighPerformance.Mathematics/NumericType.cs
Normal file
106
Misaki.HighPerformance.Mathematics/NumericType.cs
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
namespace Misaki.HighPerformance.Mathematics;
|
||||||
|
|
||||||
|
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, Inherited = false)]
|
||||||
|
public class NumericTypeAttribute : Attribute
|
||||||
|
{
|
||||||
|
public NumericTypeAttribute(Type componentType, int componentSize, int row, int column, string typePrefix, bool arithmetic = true, bool canInverse = true, Type? elementType = default, Type? vectorType = default)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, Inherited = false, AllowMultiple = true)]
|
||||||
|
public class NumericConvertableAttribute : Attribute
|
||||||
|
{
|
||||||
|
public NumericConvertableAttribute(string template, params Type[] types)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
public enum SupportedVectorMath
|
||||||
|
{
|
||||||
|
None = 0,
|
||||||
|
Min = 1 << 0,
|
||||||
|
Max = 1 << 1,
|
||||||
|
Lerp = 1 << 2,
|
||||||
|
Unlerp = 1 << 3,
|
||||||
|
Remap = 1 << 4,
|
||||||
|
Mad = 1 << 5,
|
||||||
|
Clamp = 1 << 6,
|
||||||
|
Saturate = 1 << 7,
|
||||||
|
Abs = 1 << 8,
|
||||||
|
Dot = 1 << 9,
|
||||||
|
Tan = 1 << 10,
|
||||||
|
TanH = 1 << 11,
|
||||||
|
Atan = 1 << 12,
|
||||||
|
Atan2 = 1 << 13,
|
||||||
|
Cos = 1 << 14,
|
||||||
|
CosH = 1 << 15,
|
||||||
|
Acos = 1 << 16,
|
||||||
|
Sin = 1 << 17,
|
||||||
|
SinH = 1 << 18,
|
||||||
|
Asin = 1 << 19,
|
||||||
|
Floor = 1 << 20,
|
||||||
|
Ceil = 1 << 21,
|
||||||
|
Round = 1 << 22,
|
||||||
|
Trunc = 1 << 23,
|
||||||
|
Frac = 1 << 24,
|
||||||
|
Rcp = 1 << 25,
|
||||||
|
Sign = 1 << 26,
|
||||||
|
Pow = 1 << 27,
|
||||||
|
Exp = 1 << 28,
|
||||||
|
Exp2 = 1 << 29,
|
||||||
|
Exp10 = 1 << 30,
|
||||||
|
Log = 1 << 31,
|
||||||
|
Log2 = 1 << 32,
|
||||||
|
Log10 = 1 << 33,
|
||||||
|
Fmod = 1 << 34,
|
||||||
|
Modf = 1 << 35,
|
||||||
|
Sqrt = 1 << 36,
|
||||||
|
Rsqrt = 1 << 37,
|
||||||
|
Length = 1 << 38,
|
||||||
|
LengthSq = 1 << 39,
|
||||||
|
Distance = 1 << 40,
|
||||||
|
DistanceSq = 1 << 41,
|
||||||
|
Cross = 1 << 42,
|
||||||
|
SmoothStep = 1 << 43,
|
||||||
|
Select = 1 << 44,
|
||||||
|
Step = 1 << 45,
|
||||||
|
FaceForward = 1 << 46,
|
||||||
|
SinCos = 1 << 47,
|
||||||
|
Any = 1 << 48,
|
||||||
|
All = 1 << 49,
|
||||||
|
Normalize = 1 << 50,
|
||||||
|
Reflect = 1 << 51,
|
||||||
|
Refract = 1 << 52,
|
||||||
|
Project = 1 << 53,
|
||||||
|
CountBits = 1 << 54,
|
||||||
|
Lzcnt = 1 << 55,
|
||||||
|
Tzcnt = 1 << 56,
|
||||||
|
ReverseBits = 1 << 57,
|
||||||
|
Rol = 1 << 58,
|
||||||
|
Ror = 1 << 59,
|
||||||
|
CeilPow2 = 1 << 60,
|
||||||
|
CeilLog2 = 1 << 61,
|
||||||
|
FloorLog2 = 1 << 62,
|
||||||
|
Radians = 1 << 63,
|
||||||
|
Degrees = 1 << 64,
|
||||||
|
Cmin = 1 << 65,
|
||||||
|
Cmax = 1 << 66,
|
||||||
|
|
||||||
|
FloatingPointMask = ~0 & ~(CountBits | Lzcnt | Tzcnt | ReverseBits | Rol | Ror | CeilPow2 | CeilLog2 | FloorLog2),
|
||||||
|
IntegerMask = Min | Max | Mad | Clamp | Abs | Dot | Sign | Any | All | Select | CountBits | Lzcnt | Tzcnt | ReverseBits | Rol | Ror | CeilPow2 | CeilLog2 | FloorLog2 | Cmin | Cmax,
|
||||||
|
UnsignedIntegerMask = IntegerMask & ~(Sign),
|
||||||
|
}
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
public enum SupportedMatrixMath
|
||||||
|
{
|
||||||
|
Transpose = 1 << 0,
|
||||||
|
Determinant = 1 << 1,
|
||||||
|
Inverse = 1 << 2,
|
||||||
|
Adjugate = 1 << 3,
|
||||||
|
Cofactor = 1 << 4,
|
||||||
|
Minor = 1 << 5,
|
||||||
|
OuterProduct = 1 << 6,
|
||||||
|
}
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
using Misaki.HighPerformance.Mathematics.CodeGen;
|
|
||||||
|
|
||||||
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(bool), sizeof(bool), 2, 1, "global::Misaki.HighPerformance.Mathematics.bool", false, vectorType: typeof(byte))]
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
using Misaki.HighPerformance.Mathematics.CodeGen;
|
|
||||||
|
|
||||||
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")]
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
using Misaki.HighPerformance.Mathematics.CodeGen;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
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")]
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
using Misaki.HighPerformance.Mathematics.CodeGen;
|
|
||||||
|
|
||||||
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")]
|
||||||
|
|||||||
@@ -4724,9 +4724,9 @@ public static partial class math
|
|||||||
/// <param name="defaultvalue">Vector to return if normalized vector is not finite.</param>
|
/// <param name="defaultvalue">Vector to return if normalized vector is not finite.</param>
|
||||||
/// <returns>The normalized vector or the default value if the normalized vector is not finite.</returns>
|
/// <returns>The normalized vector or the default value if the normalized vector is not finite.</returns>
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
static public float2 normalizesafe(float2 x, float2 defaultvalue = new float2())
|
public static float2 normalizesafe(float2 x, float2 defaultvalue = new float2())
|
||||||
{
|
{
|
||||||
float len = math.dot(x, x);
|
var len = math.dot(x, x);
|
||||||
return math.select(defaultvalue, x * math.rsqrt(len), len > FLT_MIN_NORMAL);
|
return math.select(defaultvalue, x * math.rsqrt(len), len > FLT_MIN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4738,9 +4738,9 @@ public static partial class math
|
|||||||
/// <param name="defaultvalue">Vector to return if normalized vector is not finite.</param>
|
/// <param name="defaultvalue">Vector to return if normalized vector is not finite.</param>
|
||||||
/// <returns>The normalized vector or the default value if the normalized vector is not finite.</returns>
|
/// <returns>The normalized vector or the default value if the normalized vector is not finite.</returns>
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
static public float3 normalizesafe(float3 x, float3 defaultvalue = new float3())
|
public static float3 normalizesafe(float3 x, float3 defaultvalue = new float3())
|
||||||
{
|
{
|
||||||
float len = math.dot(x, x);
|
var len = math.dot(x, x);
|
||||||
return math.select(defaultvalue, x * math.rsqrt(len), len > FLT_MIN_NORMAL);
|
return math.select(defaultvalue, x * math.rsqrt(len), len > FLT_MIN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4752,9 +4752,9 @@ public static partial class math
|
|||||||
/// <param name="defaultvalue">Vector to return if normalized vector is not finite.</param>
|
/// <param name="defaultvalue">Vector to return if normalized vector is not finite.</param>
|
||||||
/// <returns>The normalized vector or the default value if the normalized vector is not finite.</returns>
|
/// <returns>The normalized vector or the default value if the normalized vector is not finite.</returns>
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
static public float4 normalizesafe(float4 x, float4 defaultvalue = new float4())
|
public static float4 normalizesafe(float4 x, float4 defaultvalue = new float4())
|
||||||
{
|
{
|
||||||
float len = math.dot(x, x);
|
var len = math.dot(x, x);
|
||||||
return math.select(defaultvalue, x * math.rsqrt(len), len > FLT_MIN_NORMAL);
|
return math.select(defaultvalue, x * math.rsqrt(len), len > FLT_MIN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4767,9 +4767,9 @@ public static partial class math
|
|||||||
/// <param name="defaultvalue">Vector to return if normalized vector is not finite.</param>
|
/// <param name="defaultvalue">Vector to return if normalized vector is not finite.</param>
|
||||||
/// <returns>The normalized vector or the default value if the normalized vector is not finite.</returns>
|
/// <returns>The normalized vector or the default value if the normalized vector is not finite.</returns>
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
static public double2 normalizesafe(double2 x, double2 defaultvalue = new double2())
|
public static double2 normalizesafe(double2 x, double2 defaultvalue = new double2())
|
||||||
{
|
{
|
||||||
double len = math.dot(x, x);
|
var len = math.dot(x, x);
|
||||||
return math.select(defaultvalue, x * math.rsqrt(len), len > FLT_MIN_NORMAL);
|
return math.select(defaultvalue, x * math.rsqrt(len), len > FLT_MIN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4781,9 +4781,9 @@ public static partial class math
|
|||||||
/// <param name="defaultvalue">Vector to return if normalized vector is not finite.</param>
|
/// <param name="defaultvalue">Vector to return if normalized vector is not finite.</param>
|
||||||
/// <returns>The normalized vector or the default value if the normalized vector is not finite.</returns>
|
/// <returns>The normalized vector or the default value if the normalized vector is not finite.</returns>
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
static public double3 normalizesafe(double3 x, double3 defaultvalue = new double3())
|
public static double3 normalizesafe(double3 x, double3 defaultvalue = new double3())
|
||||||
{
|
{
|
||||||
double len = math.dot(x, x);
|
var len = math.dot(x, x);
|
||||||
return math.select(defaultvalue, x * math.rsqrt(len), len > FLT_MIN_NORMAL);
|
return math.select(defaultvalue, x * math.rsqrt(len), len > FLT_MIN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4795,9 +4795,9 @@ public static partial class math
|
|||||||
/// <param name="defaultvalue">Vector to return if normalized vector is not finite.</param>
|
/// <param name="defaultvalue">Vector to return if normalized vector is not finite.</param>
|
||||||
/// <returns>The normalized vector or the default value if the normalized vector is not finite.</returns>
|
/// <returns>The normalized vector or the default value if the normalized vector is not finite.</returns>
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
static public double4 normalizesafe(double4 x, double4 defaultvalue = new double4())
|
public static double4 normalizesafe(double4 x, double4 defaultvalue = new double4())
|
||||||
{
|
{
|
||||||
double len = math.dot(x, x);
|
var len = math.dot(x, x);
|
||||||
return math.select(defaultvalue, x * math.rsqrt(len), len > FLT_MIN_NORMAL);
|
return math.select(defaultvalue, x * math.rsqrt(len), len > FLT_MIN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6039,7 +6039,7 @@ public static partial class math
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static float2 refract(float2 i, float2 n, float indexOfRefraction)
|
public static float2 refract(float2 i, float2 n, float indexOfRefraction)
|
||||||
{
|
{
|
||||||
float ni = dot(n, i);
|
var ni = dot(n, i);
|
||||||
var k = 1.0f - indexOfRefraction * indexOfRefraction * (1.0f - ni * ni);
|
var k = 1.0f - indexOfRefraction * indexOfRefraction * (1.0f - ni * ni);
|
||||||
return select(0.0f, indexOfRefraction * i - (indexOfRefraction * ni + sqrt(k)) * n, k >= 0);
|
return select(0.0f, indexOfRefraction * i - (indexOfRefraction * ni + sqrt(k)) * n, k >= 0);
|
||||||
}
|
}
|
||||||
@@ -6052,7 +6052,7 @@ public static partial class math
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static float3 refract(float3 i, float3 n, float indexOfRefraction)
|
public static float3 refract(float3 i, float3 n, float indexOfRefraction)
|
||||||
{
|
{
|
||||||
float ni = dot(n, i);
|
var ni = dot(n, i);
|
||||||
var k = 1.0f - indexOfRefraction * indexOfRefraction * (1.0f - ni * ni);
|
var k = 1.0f - indexOfRefraction * indexOfRefraction * (1.0f - ni * ni);
|
||||||
return select(0.0f, indexOfRefraction * i - (indexOfRefraction * ni + sqrt(k)) * n, k >= 0);
|
return select(0.0f, indexOfRefraction * i - (indexOfRefraction * ni + sqrt(k)) * n, k >= 0);
|
||||||
}
|
}
|
||||||
@@ -6065,7 +6065,7 @@ public static partial class math
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static float4 refract(float4 i, float4 n, float indexOfRefraction)
|
public static float4 refract(float4 i, float4 n, float indexOfRefraction)
|
||||||
{
|
{
|
||||||
float ni = dot(n, i);
|
var ni = dot(n, i);
|
||||||
var k = 1.0f - indexOfRefraction * indexOfRefraction * (1.0f - ni * ni);
|
var k = 1.0f - indexOfRefraction * indexOfRefraction * (1.0f - ni * ni);
|
||||||
return select(0.0f, indexOfRefraction * i - (indexOfRefraction * ni + sqrt(k)) * n, k >= 0);
|
return select(0.0f, indexOfRefraction * i - (indexOfRefraction * ni + sqrt(k)) * n, k >= 0);
|
||||||
}
|
}
|
||||||
@@ -6079,7 +6079,7 @@ public static partial class math
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static double2 refract(double2 i, double2 n, double indexOfRefraction)
|
public static double2 refract(double2 i, double2 n, double indexOfRefraction)
|
||||||
{
|
{
|
||||||
double ni = dot(n, i);
|
var ni = dot(n, i);
|
||||||
var k = 1.0 - indexOfRefraction * indexOfRefraction * (1.0 - ni * ni);
|
var k = 1.0 - indexOfRefraction * indexOfRefraction * (1.0 - ni * ni);
|
||||||
return select(0.0f, indexOfRefraction * i - (indexOfRefraction * ni + sqrt(k)) * n, k >= 0);
|
return select(0.0f, indexOfRefraction * i - (indexOfRefraction * ni + sqrt(k)) * n, k >= 0);
|
||||||
}
|
}
|
||||||
@@ -6092,7 +6092,7 @@ public static partial class math
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static double3 refract(double3 i, double3 n, double indexOfRefraction)
|
public static double3 refract(double3 i, double3 n, double indexOfRefraction)
|
||||||
{
|
{
|
||||||
double ni = dot(n, i);
|
var ni = dot(n, i);
|
||||||
var k = 1.0 - indexOfRefraction * indexOfRefraction * (1.0 - ni * ni);
|
var k = 1.0 - indexOfRefraction * indexOfRefraction * (1.0 - ni * ni);
|
||||||
return select(0.0f, indexOfRefraction * i - (indexOfRefraction * ni + sqrt(k)) * n, k >= 0);
|
return select(0.0f, indexOfRefraction * i - (indexOfRefraction * ni + sqrt(k)) * n, k >= 0);
|
||||||
}
|
}
|
||||||
@@ -6105,7 +6105,7 @@ public static partial class math
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static double4 refract(double4 i, double4 n, double indexOfRefraction)
|
public static double4 refract(double4 i, double4 n, double indexOfRefraction)
|
||||||
{
|
{
|
||||||
double ni = dot(n, i);
|
var ni = dot(n, i);
|
||||||
var k = 1.0 - indexOfRefraction * indexOfRefraction * (1.0 - ni * ni);
|
var k = 1.0 - indexOfRefraction * indexOfRefraction * (1.0 - ni * ni);
|
||||||
return select(0.0f, indexOfRefraction * i - (indexOfRefraction * ni + sqrt(k)) * n, k >= 0);
|
return select(0.0f, indexOfRefraction * i - (indexOfRefraction * ni + sqrt(k)) * n, k >= 0);
|
||||||
}
|
}
|
||||||
@@ -8470,7 +8470,7 @@ public static partial class math
|
|||||||
const uint Prime4 = 668265263;
|
const uint Prime4 = 668265263;
|
||||||
const uint Prime5 = 374761393;
|
const uint Prime5 = 374761393;
|
||||||
|
|
||||||
uint4* p = (uint4*)pBuffer;
|
var p = (uint4*)pBuffer;
|
||||||
var hash = seed + Prime5;
|
var hash = seed + Prime5;
|
||||||
if (numBytes >= 16)
|
if (numBytes >= 16)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
using static Misaki.HighPerformance.Mathematics.math;
|
using static Misaki.HighPerformance.Mathematics.math;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
using Misaki.HighPerformance.Mathematics.CodeGen;
|
|
||||||
|
|
||||||
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")]
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
//var threadCount = 8;
|
//var threadCount = 8;
|
||||||
//var map = new ConcurrentSlotMap<int>();
|
//var map = new ConcurrentSlotMap<int>();
|
||||||
|
|
||||||
//var barrier = new Barrier(threadCount);
|
//var barrier = new Barrier(threadCount);
|
||||||
@@ -43,4 +43,4 @@
|
|||||||
using Misaki.HighPerformance.LowLevel.Buffer;
|
using Misaki.HighPerformance.LowLevel.Buffer;
|
||||||
using Misaki.HighPerformance.LowLevel.Collections;
|
using Misaki.HighPerformance.LowLevel.Collections;
|
||||||
|
|
||||||
var array = new UnsafeArray<int>(10, Allocator.Persistent);
|
var array = new UnsafeArray<int>(10, Allocator.Persistent);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using Misaki.HighPerformance.LowLevel.Buffer;
|
using Misaki.HighPerformance.LowLevel.Buffer;
|
||||||
using Misaki.HighPerformance.LowLevel.Collections;
|
using Misaki.HighPerformance.LowLevel.Collections;
|
||||||
|
|
||||||
namespace Misaki.HighPerformance.Test.UnitTest.Collections;
|
namespace Misaki.HighPerformance.Test.UnitTest.Collections;
|
||||||
@@ -127,7 +127,7 @@ public class TestUnsafeSparseSet
|
|||||||
_sparseSet.Remove(ids[1], gens[1]); // Remove the second element (20)
|
_sparseSet.Remove(ids[1], gens[1]); // Remove the second element (20)
|
||||||
|
|
||||||
var ptr = (int*)_sparseSet.GetUnsafePtr();
|
var ptr = (int*)_sparseSet.GetUnsafePtr();
|
||||||
|
|
||||||
Assert.AreEqual(2, _sparseSet.Count);
|
Assert.AreEqual(2, _sparseSet.Count);
|
||||||
|
|
||||||
var index = 0;
|
var index = 0;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public static class CollectionUtility
|
|||||||
{
|
{
|
||||||
return CollectionsMarshal.AsSpan(list);
|
return CollectionsMarshal.AsSpan(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Removes the element at the specified index from the list by replacing it with the last element, then removing
|
/// Removes the element at the specified index from the list by replacing it with the last element, then removing
|
||||||
/// the last element. This operation does not preserve the order of elements.
|
/// the last element. This operation does not preserve the order of elements.
|
||||||
@@ -34,12 +34,12 @@ public static class CollectionUtility
|
|||||||
{
|
{
|
||||||
throw new ArgumentOutOfRangeException(nameof(index));
|
throw new ArgumentOutOfRangeException(nameof(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index != lastIndex)
|
if (index != lastIndex)
|
||||||
{
|
{
|
||||||
list[index] = list[lastIndex];
|
list[index] = list[lastIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
list.RemoveAt(lastIndex);
|
list.RemoveAt(lastIndex);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user