fix(portal): synchronize destination presentation state

This commit is contained in:
Erik 2026-07-16 21:17:13 +02:00
parent 4b1bceefbb
commit e95f55f25b
42 changed files with 2815 additions and 288 deletions

View file

@ -12,8 +12,13 @@ namespace AcDream.App.Streaming;
/// </summary>
public abstract record LandblockStreamJob(uint LandblockId)
{
public sealed record Load(uint LandblockId, LandblockStreamJobKind Kind) : LandblockStreamJob(LandblockId);
public sealed record Unload(uint LandblockId) : LandblockStreamJob(LandblockId);
public sealed record Load(
uint LandblockId,
LandblockStreamJobKind Kind,
ulong Generation = 0) : LandblockStreamJob(LandblockId);
public sealed record Unload(
uint LandblockId,
ulong Generation = 0) : LandblockStreamJob(LandblockId);
/// <summary>
/// Control job: drop every queued (not-yet-started) Load from the worker's
@ -32,7 +37,7 @@ public abstract record LandblockStreamJob(uint LandblockId)
/// an unload notification (tells the render thread to release GPU state
/// for this landblock id).
/// </summary>
public abstract record LandblockStreamResult(uint LandblockId)
public abstract record LandblockStreamResult(uint LandblockId, ulong Generation)
{
/// <summary>
/// A landblock load completed. <see cref="Tier"/> distinguishes Far
@ -43,15 +48,17 @@ public abstract record LandblockStreamResult(uint LandblockId)
uint LandblockId,
LandblockStreamTier Tier,
LandblockBuild Build,
LandblockMeshData MeshData
) : LandblockStreamResult(LandblockId)
LandblockMeshData MeshData,
ulong Generation = 0
) : LandblockStreamResult(LandblockId, Generation)
{
public Loaded(
uint landblockId,
LandblockStreamTier tier,
LoadedLandblock landblock,
LandblockMeshData meshData)
: this(landblockId, tier, new LandblockBuild(landblock), meshData)
LandblockMeshData meshData,
ulong generation = 0)
: this(landblockId, tier, new LandblockBuild(landblock), meshData, generation)
{
}
@ -69,14 +76,16 @@ public abstract record LandblockStreamResult(uint LandblockId)
public sealed record Promoted(
uint LandblockId,
LandblockBuild Build,
LandblockMeshData MeshData
) : LandblockStreamResult(LandblockId)
LandblockMeshData MeshData,
ulong Generation = 0
) : LandblockStreamResult(LandblockId, Generation)
{
public Promoted(
uint landblockId,
LoadedLandblock landblock,
LandblockMeshData meshData)
: this(landblockId, new LandblockBuild(landblock), meshData)
LandblockMeshData meshData,
ulong generation = 0)
: this(landblockId, new LandblockBuild(landblock), meshData, generation)
{
}
@ -84,8 +93,13 @@ public abstract record LandblockStreamResult(uint LandblockId)
public IReadOnlyList<WorldEntity> Entities => Landblock.Entities;
}
public sealed record Failed(uint LandblockId, string Error) : LandblockStreamResult(LandblockId);
public sealed record Unloaded(uint LandblockId) : LandblockStreamResult(LandblockId);
public sealed record Failed(
uint LandblockId,
string Error,
ulong Generation = 0) : LandblockStreamResult(LandblockId, Generation);
public sealed record Unloaded(
uint LandblockId,
ulong Generation = 0) : LandblockStreamResult(LandblockId, Generation);
/// <summary>
/// The worker loop itself crashed with an unhandled exception. Not tied
@ -94,5 +108,5 @@ public abstract record LandblockStreamResult(uint LandblockId)
/// than retrying a single landblock later. LandblockId is 0 by
/// convention; readers should pattern-match on the type, not the id.
/// </summary>
public sealed record WorkerCrashed(string Error) : LandblockStreamResult(0);
public sealed record WorkerCrashed(string Error) : LandblockStreamResult(0, 0);
}