WIP pre-reboot checkpoint: Cut 14b HbGpuCanvas HUD + 4 Cut 14a scars
This commit is contained in:
parent
8310246f89
commit
93df511b60
10 changed files with 2630 additions and 2079 deletions
|
|
@ -175,4 +175,73 @@ public sealed class HbGpuNativeTests
|
|||
atlas.ClearPending();
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PersistentAtlasOverflowDoesNotResetMidFrame()
|
||||
{
|
||||
var atlas = new HbGpuAtlasAllocator();
|
||||
var blobs = new HbGpuBlobCache(atlas);
|
||||
|
||||
// Fill persistent zone right up near PersistentCapacity without crossing it
|
||||
short[] chunk = new short[4096 * 4]; // 4096 texels
|
||||
chunk[0] = 1;
|
||||
while (atlas.PersistentCursor + 4096 <= HbGpuAtlasAllocator.PersistentCapacity)
|
||||
{
|
||||
atlas.AllocatePersistent(chunk);
|
||||
atlas.ClearPending();
|
||||
}
|
||||
|
||||
uint epochBefore = atlas.Epoch;
|
||||
uint cursorBefore = atlas.PersistentCursor;
|
||||
Assert.True(cursorBefore > HbGpuAtlasAllocator.PersistentResetWatermark);
|
||||
|
||||
// Encode a static vector that exceeds remaining PersistentCapacity: must NOT reset mid-frame!
|
||||
Span<byte> bigVerbs = stackalloc byte[64];
|
||||
Span<float> bigArgs = stackalloc float[128];
|
||||
int v = 0, a = 0;
|
||||
bigVerbs[v++] = (byte)HbGpuPathVerb.Move;
|
||||
bigArgs[a++] = 0f;
|
||||
bigArgs[a++] = 0f;
|
||||
for (int i = 1; i <= 30; i++)
|
||||
{
|
||||
float ang = i * 0.2f;
|
||||
bigVerbs[v++] = (byte)HbGpuPathVerb.LineTo;
|
||||
bigArgs[a++] = MathF.Cos(ang) * 400f;
|
||||
bigArgs[a++] = MathF.Sin(ang) * 400f;
|
||||
}
|
||||
bigVerbs[v++] = (byte)HbGpuPathVerb.Close;
|
||||
|
||||
// First force a large remaining fill so the encoded vector overflows remaining space
|
||||
uint rem = HbGpuAtlasAllocator.PersistentCapacity - atlas.PersistentCursor;
|
||||
if (rem > 2)
|
||||
{
|
||||
atlas.AllocatePersistent(new short[(rem - 1) * 4]);
|
||||
atlas.ClearPending();
|
||||
}
|
||||
cursorBefore = atlas.PersistentCursor;
|
||||
|
||||
CachedBlob overflowed = blobs.GetOrEncodeStaticPath(
|
||||
new VectorBlobKey(VectorShapeKind.Custom, 999, 1),
|
||||
1000u,
|
||||
bigVerbs[..v],
|
||||
bigArgs[..a]);
|
||||
|
||||
Assert.False(overflowed.IsValid);
|
||||
Assert.Equal(epochBefore, atlas.Epoch);
|
||||
Assert.Equal(cursorBefore, atlas.PersistentCursor);
|
||||
Assert.True(blobs.IsPersistentOverflowPending);
|
||||
|
||||
// Next BeginFrame resets cleanly and allows encoding
|
||||
Assert.True(blobs.EnsureBudgetOrReset());
|
||||
Assert.Equal(epochBefore + 1, atlas.Epoch);
|
||||
Assert.Equal(0u, atlas.PersistentCursor);
|
||||
Assert.False(blobs.IsPersistentOverflowPending);
|
||||
|
||||
CachedBlob recovered = blobs.GetOrEncodeStaticPath(
|
||||
new VectorBlobKey(VectorShapeKind.Custom, 999, 1),
|
||||
1000u,
|
||||
bigVerbs[..v],
|
||||
bigArgs[..a]);
|
||||
Assert.True(recovered.IsValid);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue