Match native surface persistence policy
This commit is contained in:
@@ -896,12 +896,24 @@ public sealed class VirtualMachine
|
||||
}
|
||||
|
||||
GfxPersistenceSnapshot gfxSnapshot = NativeGfxPersistenceCodec.Decode(state);
|
||||
for (int slot = 0; slot < 1000; slot++) _host.ReleaseSurface(slot);
|
||||
Gfx.RestorePersistenceSnapshot(gfxSnapshot);
|
||||
foreach (var (slot, resourceId, colorKey, created) in gfxSnapshot.Surfaces)
|
||||
bool releaseAllSurfaces = _o.CreateObject && _o.AutoFreeTextures;
|
||||
if (releaseAllSurfaces)
|
||||
{
|
||||
if (!created) _host.SetTexture(resourceId, slot, colorKey);
|
||||
Gfx.ReleaseSurfaceRange(0, 1000);
|
||||
_host.ReleaseSurfaceRange(0, 1000);
|
||||
}
|
||||
var restoredSurfaces = Gfx.CapturePersistenceSnapshot().Surfaces
|
||||
.ToDictionary(item => item.Slot);
|
||||
foreach (GfxSurfacePersistenceState surface in gfxSnapshot.Surfaces
|
||||
.Where(item => item.ReloadOnRestore && item.ResourceId >= 0))
|
||||
restoredSurfaces[surface.Slot] = surface;
|
||||
Gfx.RestorePersistenceSnapshot(gfxSnapshot with
|
||||
{
|
||||
Surfaces = restoredSurfaces.Values.OrderBy(item => item.Slot).ToArray(),
|
||||
});
|
||||
foreach (GfxSurfacePersistenceState surface in gfxSnapshot.Surfaces
|
||||
.Where(item => item.ReloadOnRestore && item.ResourceId >= 0))
|
||||
_host.SetTexture(surface.ResourceId, surface.Slot, surface.ColorKey);
|
||||
}
|
||||
|
||||
private static void ReplaceDensePrefix<T>(
|
||||
@@ -1025,6 +1037,8 @@ public sealed class VirtualMachine
|
||||
var a = ins.Args;
|
||||
switch (_t.Label(op))
|
||||
{
|
||||
case "script-entry":
|
||||
Gfx.ClearSurfaceReloadPolicies(); return pc + 1;
|
||||
case "add": Write(a[0], Read(a[1]) + Read(a[2])); return pc + 1;
|
||||
case "sub": Write(a[0], Read(a[1]) - Read(a[2])); return pc + 1;
|
||||
case "mul": Write(a[0], Read(a[1]) * Read(a[2])); return pc + 1;
|
||||
|
||||
@@ -10,6 +10,11 @@ namespace Age.Engine.Vm;
|
||||
/// post-exit bytecode can be explored. Leave false for native-faithful execution.</param>
|
||||
/// <param name="NativeStringCodePage">Encoding used when an opcode measures the engine's byte-string
|
||||
/// representation. SYS4 defaults to CP932; another container frontend can select its own code page.</param>
|
||||
/// <param name="CreateObject">Native set:CreateObject profile setting. Together with
|
||||
/// <paramref name="AutoFreeTextures"/>, controls the optional all-surface release before numbered load.</param>
|
||||
/// <param name="AutoFreeTextures">Native set:AutoFreeTex profile setting. Himegari defaults this off,
|
||||
/// so initialized system textures survive a numbered load unless an explicit reload record replaces them.</param>
|
||||
public sealed record VmOptions(int EmitCap = 2, long MaxSteps = 2_000_000, int CallDepthCap = 64,
|
||||
bool HaltAtWaitForInput = false, bool IgnoreExitRequests = false,
|
||||
int NativeStringCodePage = 932);
|
||||
int NativeStringCodePage = 932, bool CreateObject = true,
|
||||
bool AutoFreeTextures = false);
|
||||
|
||||
Reference in New Issue
Block a user