Enhance mathematical capabilities and job system

Added new numeric types for unsigned integers, including uint2, uint3, and uint4, along with their matrix types.
Added a new `quaternion` struct with constructors and methods for creating and manipulating quaternions.
Added methods for projecting and reflecting vectors, enhancing geometric operations.
Added utility functions for generating orthonormal bases and changing vector signs.
Added comprehensive unit tests for new mathematical functions and quaternion operations.
Added a high-performance job scheduling system with job management features and worker thread management.
Added new structs for job execution, allowing efficient job scheduling and execution.
Added utility functions for job execution, including methods for obtaining unique job IDs.

Changed access modifiers and property definitions in several files for improved clarity and maintainability.
Changed property definitions and method implementations in `ImageInfo.cs`, `ImageResult.cs`, and `ImageResultFloat.cs` for better readability.
Changed memory management functions in `CRuntime.cs` and improved memory allocation tracking in `MemoryStats.cs`.
Changed the project file to include references to necessary projects and enable unsafe code blocks.

Removed the `WorkerThreadPool.cs` file, integrating worker thread management directly into the `JobScheduler`.
Removed the `float4` struct and its associated methods and properties, transitioning to a new code generation strategy.
Removed the `float4.tt` template and other related files, indicating a shift in code generation approach.
Removed the `Vectorize.cs` file, indicating a change in how vector operations are handled.

Updated the `.gitignore` file to include IDE-specific settings.
Updated various XML files to define project components and structure.
Updated the `AllocationManager.cs` to improve memory allocation management and introduce new strategies.
Updated the `UnsafeArray.cs`, `UnsafeHashMap.cs`, and `UnsafeList.cs` to enhance performance and safety in unsafe contexts.
Updated error handling and function pointer management in `MemoryLeakException.cs` and `FunctionPointer.cs`.
Updated the `AssemblyInfo.cs` file to include global using directives for better code organization.
This commit is contained in:
2025-09-06 12:07:02 +09:00
parent eeff3313b5
commit a2a760594e
114 changed files with 20826 additions and 7217 deletions

View File

@@ -4,146 +4,141 @@ using System.Collections;
using System.Collections.Generic;
using System.IO;
namespace Misaki.HighPerformance.Image
namespace Misaki.HighPerformance.Image;
internal class AnimatedGifEnumerator : IEnumerator<AnimatedFrameResult>
{
internal class AnimatedGifEnumerator : IEnumerator<AnimatedFrameResult>
private readonly StbImage.stbi__context _context;
private StbImage.stbi__gif _gif;
private readonly ColorComponents _colorComponents;
public AnimatedGifEnumerator(Stream input, ColorComponents colorComponents)
{
private readonly StbImage.stbi__context _context;
private StbImage.stbi__gif _gif;
private readonly ColorComponents _colorComponents;
if (input == null)
throw new ArgumentNullException("input");
public AnimatedGifEnumerator(Stream input, ColorComponents colorComponents)
_context = new StbImage.stbi__context(input);
if (StbImage.stbi__gif_test(_context) == 0)
throw new Exception("Input stream is not GIF file.");
_gif = new StbImage.stbi__gif();
_colorComponents = colorComponents;
}
public ColorComponents ColorComponents
{
get
{
if (input == null)
throw new ArgumentNullException("input");
_context = new StbImage.stbi__context(input);
if (StbImage.stbi__gif_test(_context) == 0)
throw new Exception("Input stream is not GIF file.");
_gif = new StbImage.stbi__gif();
_colorComponents = colorComponents;
}
public ColorComponents ColorComponents
{
get
{
return _colorComponents;
}
}
public AnimatedFrameResult Current
{
get; private set;
}
object IEnumerator.Current
{
get
{
return Current;
}
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
public unsafe bool MoveNext()
{
// Read next frame
int ccomp;
byte two_back;
var result = StbImage.stbi__gif_load_next(_context, _gif, &ccomp, (int)ColorComponents, &two_back);
if (result == null)
return false;
if (Current == null)
{
Current = new AnimatedFrameResult
{
Width = (uint)_gif.w,
Height = (uint)_gif.h,
SourceComponent = (ColorComponents)ccomp,
Component = ColorComponents == ColorComponents.Default ? (ColorComponents)ccomp : ColorComponents
};
Current.SetData(result);
}
Current.DelayInMs = _gif.delay;
return true;
}
public void Reset()
{
throw new NotImplementedException();
}
~AnimatedGifEnumerator()
{
Dispose(false);
}
protected unsafe virtual void Dispose(bool disposing)
{
if (_gif != null)
{
if (_gif._out_ != null)
{
CRuntime.free(_gif._out_);
_gif._out_ = null;
}
if (_gif.history != null)
{
CRuntime.free(_gif.history);
_gif.history = null;
}
if (_gif.background != null)
{
CRuntime.free(_gif.background);
_gif.background = null;
}
_gif = null;
}
return _colorComponents;
}
}
internal class AnimatedGifEnumerable : IEnumerable<AnimatedFrameResult>
public AnimatedFrameResult Current
{
private readonly Stream _input;
private readonly ColorComponents _colorComponents;
get; private set;
}
public AnimatedGifEnumerable(Stream input, ColorComponents colorComponents)
object IEnumerator.Current
{
get
{
_input = input;
_colorComponents = colorComponents;
}
public ColorComponents ColorComponents
{
get
{
return _colorComponents;
}
}
public IEnumerator<AnimatedFrameResult> GetEnumerator()
{
return new AnimatedGifEnumerator(_input, ColorComponents);
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
return Current;
}
}
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
public unsafe bool MoveNext()
{
// Read next frame
int ccomp;
byte two_back;
var result = StbImage.stbi__gif_load_next(_context, _gif, &ccomp, (int)ColorComponents, &two_back);
if (result == null)
return false;
Current ??= new AnimatedFrameResult
{
Data = result,
Width = (uint)_gif.w,
Height = (uint)_gif.h,
SourceComp = (ColorComponents)ccomp,
Comp = ColorComponents == ColorComponents.Default ? (ColorComponents)ccomp : ColorComponents
};
Current.DelayInMs = _gif.delay;
return true;
}
public void Reset()
{
throw new NotImplementedException();
}
~AnimatedGifEnumerator()
{
Dispose(false);
}
protected unsafe virtual void Dispose(bool disposing)
{
if (_gif != null)
{
if (_gif._out_ != null)
{
CRuntime.free(_gif._out_);
_gif._out_ = null;
}
if (_gif.history != null)
{
CRuntime.free(_gif.history);
_gif.history = null;
}
if (_gif.background != null)
{
CRuntime.free(_gif.background);
_gif.background = null;
}
_gif = null;
}
}
}
internal class AnimatedGifEnumerable : IEnumerable<AnimatedFrameResult>
{
private readonly Stream _input;
private readonly ColorComponents _colorComponents;
public AnimatedGifEnumerable(Stream input, ColorComponents colorComponents)
{
_input = input;
_colorComponents = colorComponents;
}
public ColorComponents ColorComponents
{
get
{
return _colorComponents;
}
}
public IEnumerator<AnimatedFrameResult> GetEnumerator()
{
return new AnimatedGifEnumerator(_input, ColorComponents);
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}