fix(pipeline): MP1a - sink delegate restores immediate side-stage enqueue (exception-path faithfulness)
Coordinator-directed follow-up. The buffer-and-drain seam diverged from the original on the exception path: pre-MP1a, CollectEmittersFromScript enqueued particle-preload meshes DIRECTLY into _stagedMeshData mid-Prepare, so preloads staged before a later throw in the same Prepare* call (reachable via PrepareEnvCellMeshData side-staging during its StaticObjects loop, then PrepareCellStructMeshData throwing on a malformed-dat texture decode) were already safely enqueued. The drain version only flushed after a successful return — on throw, entries stranded on the shared extractor until an unrelated successful call flushed them, and were silently dropped on dispose. Fix: MeshExtractor takes an Action<ObjectMeshData>? sideStagedSink constructor parameter; the two CollectEmittersFromScript sites become _sideStagedSink?.Invoke(meshData) — the original code shape (immediate hand-off) at those exact lines. ObjectMeshManager wires the sink to _stagedMeshData.Enqueue, restoring the original immediate-enqueue semantics including on mid-Prepare throw. _sideStaged buffer, DrainSideStaged(), and the ProcessQueueAsync drain loop are deleted. The MP1b bake tool passes its own collector. Inventory doc updated: MP1a note now records the sink seam and the Content-owned upload enums, so its no-behavior-change claim is accurate. dotnet build green; full test suite 4059 passed / 0 failed / 4 skipped. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
5722681bf5
commit
932f904e00
3 changed files with 39 additions and 37 deletions
|
|
@ -39,38 +39,23 @@ public sealed class MeshExtractor {
|
|||
private readonly ThreadLocal<BcDecoder> _bcDecoder = new(() => new BcDecoder());
|
||||
|
||||
/// <summary>
|
||||
/// MP1a mechanical seam: retail's particle-preload side effect (see
|
||||
/// <see cref="CollectEmittersFromScript"/>) used to enqueue directly onto
|
||||
/// ObjectMeshManager's runtime staged-upload queue (<c>_stagedMeshData</c>).
|
||||
/// That queue is a GL-upload-lifecycle concern and stays in App per the
|
||||
/// plan's binding rules, so the extractor collects the same side-effect
|
||||
/// output here instead; ObjectMeshManager drains it via
|
||||
/// <see cref="DrainSideStaged"/> immediately after each Prepare* call and
|
||||
/// enqueues the results itself. No behavior change — same objects reach
|
||||
/// the same queue, just via an explicit hand-off instead of a shared field.
|
||||
/// ConcurrentQueue because one MeshExtractor is shared by up to
|
||||
/// MaxParallelLoads (4) decode workers — the original enqueued to the
|
||||
/// thread-safe _stagedMeshData, so the hand-off buffer must be
|
||||
/// thread-safe too.
|
||||
/// MP1a mechanical seam: receives particle-preload meshes staged
|
||||
/// mid-extraction (see <see cref="CollectEmittersFromScript"/>). The App
|
||||
/// wires this to its staged-upload queue, restoring the original
|
||||
/// immediate-enqueue semantics — entries must survive a subsequent throw
|
||||
/// in the same Prepare* call (retail's code enqueued directly onto
|
||||
/// ObjectMeshManager's <c>_stagedMeshData</c> mid-Prepare, so preloads
|
||||
/// staged before a malformed-dat texture-decode throw were already safe).
|
||||
/// The MP1b bake tool passes its own collector. The sink must be
|
||||
/// thread-safe: one MeshExtractor is shared by up to MaxParallelLoads (4)
|
||||
/// decode workers.
|
||||
/// </summary>
|
||||
private readonly ConcurrentQueue<ObjectMeshData> _sideStaged = new();
|
||||
private readonly Action<ObjectMeshData>? _sideStagedSink;
|
||||
|
||||
public MeshExtractor(IDatReaderWriter dats, ILogger logger) {
|
||||
public MeshExtractor(IDatReaderWriter dats, ILogger logger, Action<ObjectMeshData>? sideStagedSink = null) {
|
||||
_dats = dats;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Drains and returns any mesh data staged as a side effect of the most
|
||||
/// recent Prepare* call (particle emitter GfxObj preloads). See
|
||||
/// <see cref="_sideStaged"/>.
|
||||
/// </summary>
|
||||
public List<ObjectMeshData> DrainSideStaged() {
|
||||
var result = new List<ObjectMeshData>();
|
||||
while (_sideStaged.TryDequeue(out var item)) {
|
||||
result.Add(item);
|
||||
}
|
||||
return result;
|
||||
_sideStagedSink = sideStagedSink;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -176,13 +161,13 @@ public sealed class MeshExtractor {
|
|||
if (emitter.HwGfxObjId.DataId != 0) {
|
||||
var meshData = PrepareMeshData(emitter.HwGfxObjId.DataId, false, ct);
|
||||
if (meshData != null) {
|
||||
_sideStaged.Enqueue(meshData);
|
||||
_sideStagedSink?.Invoke(meshData);
|
||||
}
|
||||
}
|
||||
if (emitter.GfxObjId.DataId != 0 && emitter.GfxObjId.DataId != emitter.HwGfxObjId.DataId) {
|
||||
var meshData = PrepareMeshData(emitter.GfxObjId.DataId, false, ct);
|
||||
if (meshData != null) {
|
||||
_sideStaged.Enqueue(meshData);
|
||||
_sideStagedSink?.Invoke(meshData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue