hlsf wrong slicing solving

This commit is contained in:
Youmu Liu
2025-11-25 20:39:18 +08:00
parent 7ef57d8f33
commit 5b09160049
16 changed files with 256 additions and 149 deletions
@@ -27,6 +27,7 @@
// -----------------------------------------------------------------------
using System;
using System.Buffers;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
@@ -35,10 +36,8 @@ namespace StgSharp.HighPerformance.Memory
public unsafe partial class HybridLayerSegregatedFitAllocator : IDisposable
{
private const nuint EmptyHandle = 0;
// Bucket system field - directly in main allocator class
private ulong[] _bucketHeads;
private BucketNode*[] _bucketHeads;
private Entry* _spareMemory;
private readonly byte* m_Buffer;
@@ -57,12 +56,12 @@ namespace StgSharp.HighPerformance.Memory
m_Buffer = (byte*)NativeMemory.AlignedAlloc(byteSize, 16);
_align = 16;
_bucketHeads = new ulong[levelSizeArray.Length * 3];
_bucketHeads = new BucketNode*[levelSizeArray.Length * 3 + 1];
_spareMemory = (Entry*)_entries.Allocate();
_spareMemory->State = EntryState.Empty;
_spareMemory->PreviousNear = EmptyHandle;
_spareMemory->NextNear = EmptyHandle;
_spareMemory->PreviousNear = null;
_spareMemory->NextNear = null;
_spareMemory->Position = (nuint)m_Buffer;
_spareMemory->Size = (uint)byteSize;
}
@@ -78,12 +77,12 @@ namespace StgSharp.HighPerformance.Memory
_align = align;
_size = byteSize;
_bucketHeads = new ulong[levelSizeArray.Length * 3];
_bucketHeads = new BucketNode*[levelSizeArray.Length * 3];
_spareMemory = (Entry*)_entries.Allocate();
_spareMemory->State = EntryState.Empty;
_spareMemory->PreviousNear = EmptyHandle;
_spareMemory->NextNear = EmptyHandle;
_spareMemory->PreviousNear = null;
_spareMemory->NextNear = null;
_spareMemory->Position = (nuint)m_Buffer;
_spareMemory->Size = (uint)byteSize;
}