From 376f4e6190e7832633955bad149ab4c87a4ec23c Mon Sep 17 00:00:00 2001 From: Erik Date: Tue, 23 Jun 2026 18:21:58 +0200 Subject: [PATCH] chore(diag): add particle + punch/seal glFinish timers (ACDREAM_FPS_PROF) [throwaway] Per-pass GPU attribution for the dense-town deep-dive: ParticleRenderer.Draw and PortalDepthMaskRenderer.DrawDepthFan report into FrameProfiler [PASS-GPU]. Joins the cells/terrain timers. glFinish serializes -> inflates absolutes; use for relative attribution. STRIP with the rest of the apparatus when FPS work lands. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/AcDream.App/Rendering/ParticleRenderer.cs | 14 ++++++++++++++ .../Rendering/PortalDepthMaskRenderer.cs | 15 +++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/AcDream.App/Rendering/ParticleRenderer.cs b/src/AcDream.App/Rendering/ParticleRenderer.cs index e47fc338..c5f5f453 100644 --- a/src/AcDream.App/Rendering/ParticleRenderer.cs +++ b/src/AcDream.App/Rendering/ParticleRenderer.cs @@ -123,6 +123,11 @@ public sealed unsafe class ParticleRenderer : IDisposable ParticleRenderPass renderPass = ParticleRenderPass.Scene, Func? emitterFilter = null) { + // THROWAWAY FPS apparatus: glFinish-bracket particle GPU (ACDREAM_FPS_PROF). + System.Diagnostics.Stopwatch? _pSw = null; + if (AcDream.App.Rendering.FrameProfiler.PassGpuEnabled) { _gl.Finish(); _pSw = System.Diagnostics.Stopwatch.StartNew(); } + try + { if (particles is null || camera is null) return; @@ -168,6 +173,15 @@ public sealed unsafe class ParticleRenderer : IDisposable _gl.BindVertexArray(0); _gl.DepthMask(true); _gl.Disable(EnableCap.Blend); + } + finally + { + if (_pSw is not null) + { + _gl.Finish(); + AcDream.App.Rendering.FrameProfiler.AddRendererGpu("particles", _pSw.Elapsed.TotalMilliseconds); + } + } } private List BuildDrawList( diff --git a/src/AcDream.App/Rendering/PortalDepthMaskRenderer.cs b/src/AcDream.App/Rendering/PortalDepthMaskRenderer.cs index 4f0a6436..79a48d2c 100644 --- a/src/AcDream.App/Rendering/PortalDepthMaskRenderer.cs +++ b/src/AcDream.App/Rendering/PortalDepthMaskRenderer.cs @@ -208,6 +208,12 @@ void main() { } // depth-only: color writes are masked off by the caller state ReadOnlySpan planes, bool forceFarZ) { + // THROWAWAY FPS apparatus: glFinish-bracket each punch/seal fan (accumulated + // into "punchseal") under ACDREAM_FPS_PROF. + System.Diagnostics.Stopwatch? _fSw = null; + if (AcDream.App.Rendering.FrameProfiler.PassGpuEnabled) { _gl.Finish(); _fSw = System.Diagnostics.Stopwatch.StartNew(); } + try + { if (worldVerts.Length < 3) return; int n = Math.Min(worldVerts.Length, MaxFanVerts); @@ -305,6 +311,15 @@ void main() { } // depth-only: color writes are masked off by the caller state _gl.CullFace(TriangleFace.Back); _gl.FrontFace(FrontFaceDirection.CW); _gl.UseProgram(0); + } + finally + { + if (_fSw is not null) + { + _gl.Finish(); + AcDream.App.Rendering.FrameProfiler.AddRendererGpu("punchseal", _fSw.Elapsed.TotalMilliseconds); + } + } } public void Dispose()