perf(bake): stream catalog and bound validation residency
This commit is contained in:
parent
b7b9aaa9dd
commit
90bf6bbf45
7 changed files with 217 additions and 84 deletions
|
|
@ -2,6 +2,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using AcDream.Bake;
|
||||
using AcDream.Content.Pak;
|
||||
|
||||
namespace AcDream.Bake.Tests;
|
||||
|
||||
|
|
@ -76,4 +77,59 @@ public sealed class BakeDeterminismTests : IDisposable {
|
|||
Assert.True(bytesA.AsSpan().SequenceEqual(bytesB),
|
||||
"two bakes of the same id set produced different bytes — the sorted-batching determinism guarantee is broken");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Bake_RealDuplicateCells_ShareOneBlobAcrossLandblocksAndThreads() {
|
||||
var datDir = ResolveDatDir();
|
||||
if (datDir is null) return;
|
||||
|
||||
// Full-bake discovery fixture: these eight cells span multiple
|
||||
// landblocks but have the same complete environment/structure/surface
|
||||
// tuple. They must remain eight addressable keys backed by one blob.
|
||||
var ids = new HashSet<uint> {
|
||||
0x00A90230u, 0x00B901A8u, 0x00E50602u, 0x00E50610u,
|
||||
0x00E5061Fu, 0x00F90784u, 0x00F9078Eu, 0x00FA073Eu,
|
||||
};
|
||||
var pathA = NewTempPakPath();
|
||||
var pathB = NewTempPakPath();
|
||||
|
||||
var reportA = BakeRunner.RunDetailed(
|
||||
new BakeOptions {
|
||||
DatDir = datDir,
|
||||
OutPath = pathA,
|
||||
IdFilter = ids,
|
||||
Threads = 1,
|
||||
});
|
||||
var reportB = BakeRunner.RunDetailed(
|
||||
new BakeOptions {
|
||||
DatDir = datDir,
|
||||
OutPath = pathB,
|
||||
IdFilter = ids,
|
||||
Threads = 8,
|
||||
});
|
||||
|
||||
Assert.Equal(8, reportA.EnvCellKeys);
|
||||
Assert.Equal(1, reportA.UniqueEnvCellGeometries);
|
||||
Assert.Equal(7, reportA.EnvCellAliases);
|
||||
Assert.Equal(1, reportA.PhysicalBlobs);
|
||||
Assert.Equal(reportA.TotalKeys, reportB.TotalKeys);
|
||||
Assert.True(File.ReadAllBytes(pathA).AsSpan().SequenceEqual(File.ReadAllBytes(pathB)));
|
||||
|
||||
using var reader = new PakReader(pathA);
|
||||
var receipts = ids
|
||||
.Select(id => reader.GetTocEntryForTest(
|
||||
PakKey.Compose(PakAssetType.EnvCellMesh, id)))
|
||||
.ToArray();
|
||||
Assert.All(receipts, receipt => Assert.Equal(receipts[0].Offset, receipt.Offset));
|
||||
Assert.All(receipts, receipt => Assert.Equal(receipts[0].Length, receipt.Length));
|
||||
Assert.All(receipts, receipt => Assert.Equal(receipts[0].Crc32, receipt.Crc32));
|
||||
|
||||
Assert.True(
|
||||
reader.TryReadObjectMeshData(
|
||||
PakKey.Compose(PakAssetType.EnvCellMesh, ids.Min()),
|
||||
out var geometry));
|
||||
Assert.NotNull(geometry);
|
||||
Assert.Equal(0xE000_0000_0000_0000UL,
|
||||
geometry.ObjectId & 0xF000_0000_0000_0000UL);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue