refactor(render): extract frame resource preparation
Move ordered resource begin, clear/state setup, live upload/reveal, weather timing, and display pacing behind focused owners while preserving the accepted frame order and retryable shutdown ownership. Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
parent
733126a272
commit
bc6f09f987
8 changed files with 1068 additions and 205 deletions
|
|
@ -85,8 +85,6 @@ public sealed class GameWindow : IDisposable
|
|||
System.Environment.GetEnvironmentVariable("ACDREAM_WB_DIAG"),
|
||||
"1",
|
||||
System.StringComparison.Ordinal);
|
||||
private readonly AcDream.App.Rendering.RollingTimingSampleWindow
|
||||
_entityUploadTiming = new(256);
|
||||
private long _frameDiagLastPublicationMilliseconds;
|
||||
|
||||
// MP0 (2026-07-05): permanent frame profiler — one FrameBoundary call
|
||||
|
|
@ -104,11 +102,14 @@ public sealed class GameWindow : IDisposable
|
|||
private AcDream.App.Diagnostics.FrameScreenshotController? _frameScreenshots;
|
||||
private AcDream.App.Diagnostics.WorldLifecycleAutomationController? _worldLifecycleAutomation;
|
||||
private AcDream.App.Rendering.GpuFrameFlightController? _gpuFrameFlights;
|
||||
private AcDream.App.Rendering.RenderFrameResourceController?
|
||||
_renderFrameResources;
|
||||
private AcDream.App.Rendering.RuntimeRenderFrameLivePreparation?
|
||||
_renderFrameLivePreparation;
|
||||
private AcDream.App.Rendering.RenderWeatherFrameController?
|
||||
_renderWeatherFrame;
|
||||
private ResourceShutdownTransaction? _shutdown;
|
||||
private readonly FramePacingController _framePacing = new();
|
||||
private bool _requestedVSync =
|
||||
AcDream.UI.Abstractions.Panels.Settings.DisplaySettings.Default.VSync;
|
||||
private int? _activeMonitorRefreshHz;
|
||||
private readonly DisplayFramePacingController _displayFramePacing;
|
||||
|
||||
// Phase A.1: streaming fields replacing the one-shot _entities list.
|
||||
private AcDream.App.Streaming.LandblockStreamer? _streamer;
|
||||
|
|
@ -513,8 +514,6 @@ public sealed class GameWindow : IDisposable
|
|||
private long _loadedSkyDayIndex = long.MinValue;
|
||||
private AcDream.Core.World.DayGroupData? _activeDayGroup;
|
||||
|
||||
private double _weatherAccum;
|
||||
|
||||
// F7 / F10 debug-cycle steps for time + weather. Initialized out of
|
||||
// range of the real values so the first press hits index 0 of the
|
||||
// cycle table cleanly.
|
||||
|
|
@ -720,6 +719,9 @@ public sealed class GameWindow : IDisposable
|
|||
_datDir = options.DatDir;
|
||||
_worldGameState = worldGameState;
|
||||
_worldEvents = worldEvents;
|
||||
_displayFramePacing = new DisplayFramePacingController(
|
||||
options.UncappedRendering,
|
||||
_frameProfiler);
|
||||
_selection = selection ?? throw new System.ArgumentNullException(nameof(selection));
|
||||
_animationDiagnostics = AnimationPresentationDiagnostics.FromEnvironment();
|
||||
_uiRegistry = uiRegistry;
|
||||
|
|
@ -760,12 +762,8 @@ public sealed class GameWindow : IDisposable
|
|||
var startupDisplay = startupStore.LoadDisplay();
|
||||
var startupBase = AcDream.UI.Abstractions.Settings.QualitySettings.From(startupDisplay.Quality);
|
||||
var startupQuality = AcDream.UI.Abstractions.Settings.QualitySettings.WithEnvOverrides(startupBase);
|
||||
_requestedVSync = startupDisplay.VSync;
|
||||
FramePacingPolicy startupPacing = FramePacingPolicy.Resolve(
|
||||
startupDisplay.VSync,
|
||||
_options.UncappedRendering,
|
||||
monitorRefreshHz: null);
|
||||
_framePacing.Apply(startupPacing);
|
||||
FramePacingPolicy startupPacing =
|
||||
_displayFramePacing.InitializeStartup(startupDisplay.VSync);
|
||||
var options = WindowOptions.Default with
|
||||
{
|
||||
Size = new Vector2D<int>(1280, 720),
|
||||
|
|
@ -789,16 +787,18 @@ public sealed class GameWindow : IDisposable
|
|||
};
|
||||
|
||||
_window = Window.Create(options);
|
||||
_displayFramePacing.BindSurface(
|
||||
new SilkDisplayFramePacingSurface(_window));
|
||||
_window.Load += OnLoad;
|
||||
_window.Update += OnUpdate;
|
||||
_window.Render += OnRender;
|
||||
// Registered after OnRender so software pacing waits after all frame
|
||||
// work and before Silk.NET performs its automatic buffer swap.
|
||||
_window.Render += OnFrameRendered;
|
||||
_window.Render += _displayFramePacing.OnFrameRendered;
|
||||
_window.Closing += OnClosing;
|
||||
_window.FocusChanged += OnFocusChanged;
|
||||
_window.Move += OnWindowMoved;
|
||||
_window.StateChanged += OnWindowStateChanged;
|
||||
_window.Move += _displayFramePacing.OnWindowMoved;
|
||||
_window.StateChanged += _displayFramePacing.OnWindowStateChanged;
|
||||
// L.0 Display tab: keep the GL viewport + camera aspect in sync
|
||||
// with the window framebuffer. Without this handler, resizing
|
||||
// the window (or applying a Display-tab Resolution change at
|
||||
|
|
@ -2840,11 +2840,56 @@ public sealed class GameWindow : IDisposable
|
|||
new AcDream.App.Streaming.LocalPlayerTeleportSession(
|
||||
_liveSessionController),
|
||||
localTeleportPresentation);
|
||||
_localPlayerTeleportSink.Bind(_localPlayerTeleport);
|
||||
// Ownership transferred to LocalPlayerTeleportController. This field
|
||||
// remains only as the staged-startup fallback used by shutdown when
|
||||
// composition fails before the transfer.
|
||||
_portalTunnel = null;
|
||||
_localPlayerTeleportSink.Bind(_localPlayerTeleport);
|
||||
var teleportRenderState =
|
||||
new AcDream.App.Rendering.LocalPlayerTeleportRenderStateSource(
|
||||
_localPlayerTeleport);
|
||||
_renderFrameLivePreparation =
|
||||
new AcDream.App.Rendering.RuntimeRenderFrameLivePreparation(
|
||||
_textureCache,
|
||||
_wbMeshAdapter,
|
||||
_worldReveal,
|
||||
teleportRenderState,
|
||||
new AcDream.App.Rendering.RenderLoginStateSource(
|
||||
_options.LiveMode,
|
||||
_localPlayerMode),
|
||||
new AcDream.App.Rendering.LiveLoginRevealCellSource(
|
||||
_liveEntities!,
|
||||
_localPlayerIdentity),
|
||||
_particleRenderer,
|
||||
_frameProfiler,
|
||||
_frameDiag);
|
||||
_renderFrameResources =
|
||||
new AcDream.App.Rendering.RenderFrameResourceController(
|
||||
_gpuFrameFlights!,
|
||||
new AcDream.App.Rendering.RuntimeRenderFrameBeginResources(
|
||||
_textureCache,
|
||||
_wbDrawDispatcher,
|
||||
_envCellRenderer,
|
||||
_portalDepthMask,
|
||||
_textRenderer,
|
||||
_uiHost?.TextRenderer,
|
||||
_clipFrame,
|
||||
_terrain,
|
||||
_sceneLightingUbo,
|
||||
_frameProfiler,
|
||||
_gl!),
|
||||
new AcDream.App.Rendering.RuntimeRenderFrameClearPhase(
|
||||
_gl!,
|
||||
WorldTime,
|
||||
Weather,
|
||||
teleportRenderState,
|
||||
_particleVisibility,
|
||||
_worldRenderDiagnostics!),
|
||||
_renderFrameLivePreparation);
|
||||
_renderWeatherFrame =
|
||||
new AcDream.App.Rendering.RenderWeatherFrameController(
|
||||
WorldTime,
|
||||
Weather);
|
||||
var liveFrameCoordinator = new AcDream.App.World.RetailLiveFrameCoordinator(
|
||||
liveObjectFrame,
|
||||
_worldState,
|
||||
|
|
@ -3223,18 +3268,6 @@ public sealed class GameWindow : IDisposable
|
|||
session.SendTurbineChatTo(
|
||||
roomId, chatType, dispatchType, senderGuid, text, cookie),
|
||||
Log: Console.WriteLine);
|
||||
private bool TryGetLoginWorldCell(out uint cell)
|
||||
{
|
||||
cell = 0;
|
||||
if (_liveEntities is null
|
||||
|| !_liveEntities.TryGetSnapshot(_playerServerGuid, out var playerSpawn)
|
||||
|| playerSpawn.Position is not { } position)
|
||||
return false;
|
||||
|
||||
cell = position.LandblockId;
|
||||
return cell != 0;
|
||||
}
|
||||
|
||||
private void UpdateSkyPes(
|
||||
float dayFraction,
|
||||
AcDream.Core.World.DayGroupData? dayGroup,
|
||||
|
|
@ -3440,112 +3473,23 @@ public sealed class GameWindow : IDisposable
|
|||
Exception? renderFailure = null;
|
||||
try
|
||||
{
|
||||
_textureCache?.BeginCompositeTextureFrame();
|
||||
_textureCache?.TickCompositeTextureCache();
|
||||
_wbDrawDispatcher?.BeginFrame(_gpuFrameFlights.CurrentSlot);
|
||||
_envCellRenderer?.BeginFrame(_gpuFrameFlights.CurrentSlot);
|
||||
_portalDepthMask?.BeginFrame(_gpuFrameFlights.CurrentSlot);
|
||||
_textRenderer?.BeginFrame(_gpuFrameFlights.CurrentSlot);
|
||||
_uiHost?.TextRenderer.BeginFrame(_gpuFrameFlights.CurrentSlot);
|
||||
_clipFrame?.BeginFrame(_gpuFrameFlights.CurrentSlot);
|
||||
_terrain?.BeginFrame(_gpuFrameFlights.CurrentSlot);
|
||||
_sceneLightingUbo?.BeginFrame(_gpuFrameFlights.CurrentSlot);
|
||||
_frameProfiler.FrameBoundary(_gl!);
|
||||
GL gl = _gl!;
|
||||
var frameInput = new AcDream.App.Rendering.RenderFrameInput(
|
||||
deltaSeconds,
|
||||
_window!.Size.X,
|
||||
_window.Size.Y);
|
||||
_renderFrameResources!.Prepare(frameInput);
|
||||
AcDream.App.Rendering.RenderFrameFoundation foundation =
|
||||
_renderFrameResources.Foundation;
|
||||
|
||||
// gmSmartBoxUI::UseTime @ 0x004D6E30 swaps visibility between the
|
||||
// normal SmartBox viewport and UIElement_Viewport's portal
|
||||
// CreatureMode; it does not redraw the world behind portal space.
|
||||
bool portalViewportVisible =
|
||||
_localPlayerTeleport?.IsPortalViewportVisible == true;
|
||||
if (portalViewportVisible)
|
||||
_particleVisibility.Reset();
|
||||
bool portalViewportVisible = foundation.PortalViewportVisible;
|
||||
|
||||
// Phase G.1: set the clear color from the current sky's fog
|
||||
// tint so the horizon band continues naturally past the
|
||||
// rendered geometry. Fog blends to this color at max distance
|
||||
// so there's no visible seam. Updated each frame from the
|
||||
// interpolated keyframe.
|
||||
var kf = WorldTime.CurrentSky;
|
||||
var atmo = Weather.Snapshot(in kf);
|
||||
bool environOverrideActive = atmo.Override != AcDream.Core.World.EnvironOverride.None;
|
||||
var fogColor = atmo.FogColor;
|
||||
// Clear to fog color (horizon haze) so if sky meshes have alpha
|
||||
// gaps or don't cover the full view, the "missing" area reads as
|
||||
// distant haze, not as pitch-black. Fog color is clamped to 0..1
|
||||
// since keyframes may pre-multiply DirBright and produce over-1
|
||||
// values that some drivers interpret as "bright clamp" (pink/green
|
||||
// frames).
|
||||
if (portalViewportVisible)
|
||||
{
|
||||
// SceneTool::BeginScene @ 0x0043DAD0 begins every retail frame
|
||||
// with RenderDevice.Clear(7, black, 1). The portal viewport later
|
||||
// clears depth only, preserving this frame's black target—not a
|
||||
// previous swap-chain image or the hidden destination world.
|
||||
_gl!.ClearColor(0f, 0f, 0f, 1f);
|
||||
}
|
||||
else
|
||||
{
|
||||
_gl!.ClearColor(
|
||||
System.Math.Clamp(fogColor.X, 0f, 1f),
|
||||
System.Math.Clamp(fogColor.Y, 0f, 1f),
|
||||
System.Math.Clamp(fogColor.Z, 0f, 1f),
|
||||
1f);
|
||||
}
|
||||
|
||||
// §4 outdoor full-world flap (2026-06-10): the depth clear DEPENDS on the depth
|
||||
// write mask — glClear(GL_DEPTH_BUFFER_BIT) is silently gated by glDepthMask.
|
||||
// A pass that leaked DepthMask(false) at frame end (EnvCellRenderer's empty
|
||||
// Transparent pass, fixed same-day) turned this clear into a no-op and the whole
|
||||
// world failed GL_LESS against its own previous-frame depth ghost. Per
|
||||
// feedback_render_self_contained_gl_state: the clear site asserts the state it
|
||||
// depends on rather than inheriting it. The [gl-state] tripwire still detects
|
||||
// any future leak.
|
||||
_gl!.DepthMask(true);
|
||||
_gl!.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit);
|
||||
|
||||
// WB GameScene.cs:830-843 establishes CW as the frame-global
|
||||
// front-face convention; per-batch CullMode changes only the culled
|
||||
// side. A8 indoor/env-cell geometry and setup meshes share that
|
||||
// convention, so keep the GL state aligned before any scene pass.
|
||||
_gl.CullFace(TriangleFace.Back);
|
||||
_gl.FrontFace(FrontFaceDirection.CW);
|
||||
|
||||
// §4 flap apparatus: GL-state tripwire — one [gl-state] line whenever the
|
||||
// state entering the world passes differs from the previous frame.
|
||||
_worldRenderDiagnostics?.EmitGlStateTripwireIfChanged(
|
||||
AcDream.Core.Rendering.RenderingDiagnostics.ProbeGlStateEnabled);
|
||||
|
||||
// Phase N.6 slice 1: one-shot surface-format histogram dump under
|
||||
// ACDREAM_DUMP_SURFACES=1. Zero cost when off.
|
||||
_textureCache?.TickSurfaceHistogramDumpIfEnabled();
|
||||
|
||||
// Phase N.4: drain WB pipeline queues (staged mesh data +
|
||||
// GL thread queue). Must happen before any draw work so that
|
||||
// resources uploaded this frame are available immediately.
|
||||
// No-op when ACDREAM_USE_WB_FOUNDATION is off (_wbMeshAdapter is null).
|
||||
// [FRAME-DIAG]: this OnRender drain is where staged GfxObj/entity meshes hit
|
||||
// the GPU (uncapped) — the H2 entity-upload suspect, separate from the apply.
|
||||
long fdE0 = _frameDiag ? System.Diagnostics.Stopwatch.GetTimestamp() : 0L;
|
||||
using (var _uplStage = _frameProfiler.BeginStage(AcDream.App.Diagnostics.FrameStage.Upload))
|
||||
{
|
||||
_wbMeshAdapter?.Tick();
|
||||
uint revealCell = _localPlayerTeleport?.ActiveDestinationCell is uint teleportCell
|
||||
&& teleportCell != 0u
|
||||
? teleportCell
|
||||
: IsLiveModeWaitingForLogin && TryGetLoginWorldCell(out uint loginCell)
|
||||
? loginCell
|
||||
: 0u;
|
||||
if (revealCell != 0)
|
||||
{
|
||||
_worldReveal?.PrepareAndEvaluate(revealCell);
|
||||
}
|
||||
_particleRenderer?.BeginFrame(_gpuFrameFlights.CurrentSlot);
|
||||
}
|
||||
if (_frameDiag)
|
||||
{
|
||||
_entityUploadTiming.PushStopwatchTicks(
|
||||
System.Diagnostics.Stopwatch.GetTimestamp() - fdE0);
|
||||
}
|
||||
AcDream.Core.World.SkyKeyframe kf = foundation.Sky;
|
||||
AcDream.Core.World.AtmosphereSnapshot atmo = foundation.Atmosphere;
|
||||
bool environOverrideActive = foundation.EnvironOverrideActive;
|
||||
|
||||
// Phase D.2a — begin ImGui frame. Paired with the Render() call
|
||||
// after the scene draws (below). ImGuiController.Update()
|
||||
|
|
@ -3554,13 +3498,7 @@ public sealed class GameWindow : IDisposable
|
|||
|
||||
// Phase G.1: weather state machine — deterministic per-day roll
|
||||
// + transitions + lightning flash.
|
||||
var cal = WorldTime.CurrentCalendar;
|
||||
int dayIndex = cal.Year * (AcDream.Core.World.DerethDateTime.DaysInAMonth *
|
||||
AcDream.Core.World.DerethDateTime.MonthsInAYear)
|
||||
+ (int)cal.Month * AcDream.Core.World.DerethDateTime.DaysInAMonth
|
||||
+ (cal.Day - 1);
|
||||
Weather.Tick(nowSeconds: _weatherAccum, dayIndex: dayIndex, dtSeconds: (float)deltaSeconds);
|
||||
_weatherAccum += deltaSeconds;
|
||||
_renderWeatherFrame!.Tick(deltaSeconds);
|
||||
|
||||
// (Pre-Bug-A code spawned camera-attached rain/snow particle
|
||||
// emitters here as a workaround for missing weather-mesh
|
||||
|
|
@ -3636,7 +3574,7 @@ public sealed class GameWindow : IDisposable
|
|||
_cameraController.Fly.FovY = fovYRad;
|
||||
if (_cameraController.Chase is not null)
|
||||
_cameraController.Chase.FovY = fovYRad;
|
||||
ApplyFramePacingPreference(d.VSync);
|
||||
_displayFramePacing.ApplyPreference(d.VSync);
|
||||
}
|
||||
|
||||
// Phase E.2 audio: update listener pose so 3D sounds pan/attenuate
|
||||
|
|
@ -4015,9 +3953,9 @@ public sealed class GameWindow : IDisposable
|
|||
// Outdoor frames have one no-clip terrain state. Indoor frames
|
||||
// defer both allocations to RetailPViewRenderer, which knows the
|
||||
// exact slice count and packs every terrain state into one arena.
|
||||
_clipFrame.ReserveTerrainUploads(_gl, 1);
|
||||
_clipFrame.UploadRegions(_gl);
|
||||
TerrainClipBufferBinding terrainBinding = _clipFrame.UploadTerrainClip(_gl);
|
||||
_clipFrame.ReserveTerrainUploads(gl, 1);
|
||||
_clipFrame.UploadRegions(gl);
|
||||
TerrainClipBufferBinding terrainBinding = _clipFrame.UploadTerrainClip(gl);
|
||||
_wbDrawDispatcher?.SetClipRegionSsbo(_clipFrame.RegionSsbo);
|
||||
_envCellRenderer?.SetClipRegionSsbo(_clipFrame.RegionSsbo);
|
||||
_terrain?.SetClipUbo(terrainBinding);
|
||||
|
|
@ -4035,13 +3973,13 @@ public sealed class GameWindow : IDisposable
|
|||
sigSkyDrawn = drawSkyThisFrame;
|
||||
if (drawSkyThisFrame)
|
||||
{
|
||||
_clipFrame.BindTerrainClip(_gl);
|
||||
_clipFrame.BindTerrainClip(gl);
|
||||
for (int _cp = 0; _cp < ClipFrame.MaxPlanes; _cp++)
|
||||
_gl.Enable(EnableCap.ClipDistance0 + _cp);
|
||||
gl.Enable(EnableCap.ClipDistance0 + _cp);
|
||||
_skyRenderer?.RenderSky(camera, camPos, (float)WorldTime.DayFraction,
|
||||
_activeDayGroup, kf, environOverrideActive);
|
||||
for (int _cp = 0; _cp < ClipFrame.MaxPlanes; _cp++)
|
||||
_gl.Disable(EnableCap.ClipDistance0 + _cp);
|
||||
gl.Disable(EnableCap.ClipDistance0 + _cp);
|
||||
|
||||
if (_particleSystem is not null && _particleRenderer is not null)
|
||||
_particleRenderer.Draw(camera, camPos,
|
||||
|
|
@ -4147,9 +4085,9 @@ public sealed class GameWindow : IDisposable
|
|||
? null
|
||||
: () =>
|
||||
{
|
||||
_gl.Disable(EnableCap.ScissorTest);
|
||||
_gl.DepthMask(true); // depth clears honor glDepthMask (c4df241 lesson)
|
||||
_gl.Clear(ClearBufferMask.DepthBufferBit);
|
||||
gl.Disable(EnableCap.ScissorTest);
|
||||
gl.DepthMask(true); // depth clears honor glDepthMask (c4df241 lesson)
|
||||
gl.Clear(ClearBufferMask.DepthBufferBit);
|
||||
},
|
||||
DrawExitPortalMasks = sliceCtx =>
|
||||
DrawRetailPViewPortalDepthWrite(sliceCtx, envCellViewProj,
|
||||
|
|
@ -4283,7 +4221,7 @@ public sealed class GameWindow : IDisposable
|
|||
// below DOES use sky.vert — it re-enables the planes in its OWN local bracket; the sky
|
||||
// pre-scene pass above already did the same. Both are scissored to the doorway too.)
|
||||
for (int _cp = 0; _cp < ClipFrame.MaxPlanes; _cp++)
|
||||
_gl.Disable(EnableCap.ClipDistance0 + _cp);
|
||||
gl.Disable(EnableCap.ClipDistance0 + _cp);
|
||||
|
||||
// Phase G.1 / E.3: draw all live particles after opaque
|
||||
// scene geometry so alpha blending composites correctly.
|
||||
|
|
@ -4342,13 +4280,13 @@ public sealed class GameWindow : IDisposable
|
|||
if (clipRoot is null && drawSkyThisFrame)
|
||||
{
|
||||
sigSkyDrawn = true;
|
||||
_clipFrame.BindTerrainClip(_gl);
|
||||
_clipFrame.BindTerrainClip(gl);
|
||||
for (int _cp = 0; _cp < ClipFrame.MaxPlanes; _cp++)
|
||||
_gl.Enable(EnableCap.ClipDistance0 + _cp);
|
||||
gl.Enable(EnableCap.ClipDistance0 + _cp);
|
||||
_skyRenderer?.RenderWeather(camera, camPos, (float)WorldTime.DayFraction,
|
||||
_activeDayGroup, kf, environOverrideActive);
|
||||
for (int _cp = 0; _cp < ClipFrame.MaxPlanes; _cp++)
|
||||
_gl.Disable(EnableCap.ClipDistance0 + _cp);
|
||||
gl.Disable(EnableCap.ClipDistance0 + _cp);
|
||||
|
||||
if (_particleSystem is not null && _particleRenderer is not null)
|
||||
_particleRenderer.Draw(camera, camPos,
|
||||
|
|
@ -5390,8 +5328,8 @@ public sealed class GameWindow : IDisposable
|
|||
// resolution + fullscreen use the on-Save path below.
|
||||
if (_window is not null)
|
||||
{
|
||||
RefreshActiveMonitorFramePacing();
|
||||
ApplyFramePacingPreference(_persistedDisplay.VSync);
|
||||
_displayFramePacing.RefreshActiveMonitor();
|
||||
_displayFramePacing.ApplyPreference(_persistedDisplay.VSync);
|
||||
ApplyDisplayWindowState(_persistedDisplay);
|
||||
}
|
||||
|
||||
|
|
@ -5532,39 +5470,6 @@ public sealed class GameWindow : IDisposable
|
|||
_window.WindowState = desiredState;
|
||||
}
|
||||
|
||||
private void ApplyFramePacingPreference(bool requestedVSync)
|
||||
{
|
||||
_requestedVSync = requestedVSync;
|
||||
FramePacingPolicy policy = FramePacingPolicy.Resolve(
|
||||
requestedVSync,
|
||||
_options.UncappedRendering,
|
||||
_activeMonitorRefreshHz);
|
||||
_framePacing.Apply(policy);
|
||||
|
||||
if (_window is not null && _window.VSync != policy.UseVSync)
|
||||
_window.VSync = policy.UseVSync;
|
||||
}
|
||||
|
||||
private void RefreshActiveMonitorFramePacing()
|
||||
{
|
||||
int? refreshHz = _window?.Monitor?.VideoMode.RefreshRate;
|
||||
_activeMonitorRefreshHz = refreshHz is > 0 ? refreshHz : null;
|
||||
ApplyFramePacingPreference(_requestedVSync);
|
||||
}
|
||||
|
||||
private void OnFrameRendered(double _)
|
||||
{
|
||||
using var pacingStage = _frameProfiler.BeginStage(
|
||||
AcDream.App.Diagnostics.FrameStage.Pacing);
|
||||
_framePacing.CompleteFrame();
|
||||
}
|
||||
|
||||
private void OnWindowMoved(Silk.NET.Maths.Vector2D<int> _)
|
||||
=> RefreshActiveMonitorFramePacing();
|
||||
|
||||
private void OnWindowStateChanged(Silk.NET.Windowing.WindowState _)
|
||||
=> RefreshActiveMonitorFramePacing();
|
||||
|
||||
private static bool TryParseResolution(string spec, out int width, out int height)
|
||||
{
|
||||
width = height = 0;
|
||||
|
|
@ -6007,7 +5912,7 @@ public sealed class GameWindow : IDisposable
|
|||
double ticksToMicros =
|
||||
1_000_000.0 / System.Diagnostics.Stopwatch.Frequency;
|
||||
AcDream.App.Rendering.RollingTimingPercentiles upload =
|
||||
_entityUploadTiming.Snapshot();
|
||||
_renderFrameLivePreparation?.UploadTiming ?? default;
|
||||
double uploadMedian = upload.MedianHundredthsMicroseconds / 100.0;
|
||||
double uploadP95 = upload.Percentile95HundredthsMicroseconds / 100.0;
|
||||
int walked = _wbDrawDispatcher?.LastDrawStats.EntitiesWalked ?? 0;
|
||||
|
|
@ -6154,6 +6059,12 @@ public sealed class GameWindow : IDisposable
|
|||
]),
|
||||
new ResourceShutdownStage("render frontends",
|
||||
[
|
||||
new("frame composition", () =>
|
||||
{
|
||||
_renderFrameResources = null;
|
||||
_renderFrameLivePreparation = null;
|
||||
_renderWeatherFrame = null;
|
||||
}),
|
||||
new("portal tunnel", () =>
|
||||
{
|
||||
_localPlayerTeleport?.Dispose();
|
||||
|
|
@ -6200,8 +6111,8 @@ public sealed class GameWindow : IDisposable
|
|||
new("debug lines", () => _debugLines?.Dispose()),
|
||||
new("text renderer", () => _textRenderer?.Dispose()),
|
||||
new("debug font", () => _debugFont?.Dispose()),
|
||||
new("frame pacing", _displayFramePacing.Dispose),
|
||||
new("frame profiler", _frameProfiler.Dispose),
|
||||
new("frame pacing", _framePacing.Dispose),
|
||||
]),
|
||||
new ResourceShutdownStage("frame flight owner",
|
||||
[
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue