You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Vector Rendering First-Frame Performance Plan - #95
Phase 1 of the vector rendering first-frame performance plan: measurement and the primary fix land together, and the new benchmark proves the fix.
Motivation
Opening the 10.3 MB, 2,459-feature shapefile took 7+ seconds before the polygons appeared (Debug; ~2 s Release). Triangulation was ~94% of time-to-first-pixel because the first OnDraw synchronously triangulated every polygon on the UI thread.
Changes
GDI-first first paint — with the default Automatic preference, a Fill-mode frame whose layers have no fill meshes yet is painted entirely with the GDI direct-ring path (~31 ms on the test dataset); OpenGL is retried on later frames once the meshes exist. One frame still uses a single backend. An explicit OpenGL preference keeps the previous lazy on-draw triangulation, documented until Phase 2 adds background preparation.
Backend reporting — RenderingBackend reports GDI and RenderingStatus states that GDI rendered the frame while the OpenGL fill meshes are pending.
End-to-end benchmark — new opt-in RenderingBaseline tests host CMapWinGISControl through its class factory (no registry registration), load MWG_RENDERING_BASELINE_DATASET through LoadVectorDatasetEx and Begin/EndLoadVectorDataset, and force the first OnDraw into a 1280x720 memory DC. Threshold-free assertions: the first frame reports GDI and performs zero triangulations.
Instrumentation — the FrameRender scope no longer double-counts triangulation, and the GPU buffer build/upload has its own OpenGlGpuBufferUpload scope.
Test host — the status bar shows the load time and first-frame time for debugger-free comparison with MapWinGIS 5.
Results (test dataset, one workstation, recorded in docs/TESTING.md)
Path
Release
Debug
LoadVectorDatasetEx → first presented frame
213 ms
1,164 ms
Begin/EndLoadVectorDataset → first presented frame
198 ms
1,162 ms
Both targets are met (≤ 250 ms Release / ≤ 1.5 s Debug). Debug and Release CTest suites pass (484 tests each, no new warnings); the C# test host builds.
With Automatic, fill rendering stays on GDI until meshes exist; Phase 2 adds background mesh preparation and the view invalidation that switches to OpenGL.
The OGR scene read (~165 ms Release) now dominates load; Phase 3 evaluates batch reading.
…e pending
- Add an end-to-end RenderingBaseline benchmark that hosts the control through its class factory, loads the dataset through LoadVectorDatasetEx and Begin/EndLoadVectorDataset, and forces the first OnDraw into a memory DC
- Assert the GDI-first contract without timing thresholds: the first Automatic frame reports GDI and performs zero triangulations
- In Automatic Fill mode, draw the frame with GDI when layers have no fill meshes yet and retry OpenGL once the meshes exist; an explicit OpenGL preference keeps lazy on-draw triangulation
- Report the active backend and a diagnostic that states GDI is in use while the meshes are pending
- Show the load time and first-paint time in the ActiveXTestHost status bar
- Fix the FrameRender scope so it no longer double-counts triangulation and add an OpenGlGpuBufferUpload scope for the GPU buffer build/upload breakdown
- Record the Release and Debug end-to-end baselines in docs/TESTING.md
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Automatic rendering can still trigger paint-thread triangulation after failed preparation, while unconditional OpenGL assertions break tests on unsupported drivers and benchmark checks miss failed triangulation attempts.
Implements Phase 1 of MapWinGIS6’s first-frame performance plan, using GDI for Automatic fill frames with pending meshes to avoid synchronous triangulation. Background mesh preparation remains deferred to Phase 2.
Changes:
Adds mesh-readiness checks and GDI-first backend reporting.
Adds hosted synchronous/asynchronous load benchmarks and separate GPU-buffer upload timing.
Adds test-host timings and documents measured results and remaining work.
The reason will be displayed to describe this comment to others. Learn more.
Automated review. The final decision is with the human reviewer.
CI: VectorLayerRenderer.AutomaticFillWithSceneMeshesUsesOpenGl fails on every build job. Existing review comments already cover this failure (the missing FBO-availability skip), the Failed-readiness retriangulation, and the zero-TriangulationFailures assertion, so they are not repeated here.
…xt exists
- Probe OpenGL availability through the coordinator in AutomaticFillWithSceneMeshesUsesOpenGl and skip on S_FALSE, matching the other OpenGL-conditional tests
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Automatic mode can still synchronously triangulate replacement or uncached scenes and stall the UI, while an incorrect fallback check causes a regression test to fail on GDI-only systems.
Automatic still enters OpenGL for Failed readiness, which can synchronously triangulate a replacement scene or an uncached layer following a cached failure. This restores the UI stall because Draw prunes stale entries and prepares missing meshes before rejecting cached failures. Only attempt OpenGL when Automatic Fill readiness is Ready; otherwise prune and use GDI with pending/failure diagnostics, and cover replacement plus both failed/pending layer orders in regression tests.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Distant geometry can make GDI hide visible polygons, stale OpenGL cache entries can falsely report triangulation failures, and probe-contaminated diagnostics cause test failures on framebuffer-capable OpenGL systems.
Automatic Fill now keeps complete, mesh-free scenes on GDI across zooms, but GDI skips an entire layer when any transformed vertex exceeds ±134,217,727 (GdiVectorLayerRenderer.cpp:128–143, 284–291). Distant off-screen geometry can therefore make visible polygons disappear, and subsequent Automatic draws cannot recover because they do not prepare meshes. Cull off-screen polygons and safely clip crossing polygons before GDI coordinate validation, with a regression covering visible and distant geometry in the same layer, without reintroducing paint-path triangulation.
- Report replacement scenes as pending before cache pruning.
- Exclude availability-probe triangulation from test counters.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed because Automatic’s GDI fallback can discard entire visible layers at extreme zoom, while framebuffer allocation costs remain misattributed to rendering.
pmeems
changed the title
MapWinGIS6 – Vector Rendering First-Frame Performance Plan
Vector Rendering First-Frame Performance Plan
Nov 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 1 of the vector rendering first-frame performance plan: measurement and the primary fix land together, and the new benchmark proves the fix.
Motivation
Opening the 10.3 MB, 2,459-feature shapefile took 7+ seconds before the polygons appeared (Debug; ~2 s Release). Triangulation was ~94% of time-to-first-pixel because the first
OnDrawsynchronously triangulated every polygon on the UI thread.Changes
Automaticpreference, a Fill-mode frame whose layers have no fill meshes yet is painted entirely with the GDI direct-ring path (~31 ms on the test dataset); OpenGL is retried on later frames once the meshes exist. One frame still uses a single backend. An explicitOpenGLpreference keeps the previous lazy on-draw triangulation, documented until Phase 2 adds background preparation.RenderingBackendreports GDI andRenderingStatusstates that GDI rendered the frame while the OpenGL fill meshes are pending.RenderingBaselinetests hostCMapWinGISControlthrough its class factory (no registry registration), loadMWG_RENDERING_BASELINE_DATASETthroughLoadVectorDatasetExandBegin/EndLoadVectorDataset, and force the firstOnDrawinto a 1280x720 memory DC. Threshold-free assertions: the first frame reports GDI and performs zero triangulations.FrameRenderscope no longer double-counts triangulation, and the GPU buffer build/upload has its ownOpenGlGpuBufferUploadscope.Results (test dataset, one workstation, recorded in
docs/TESTING.md)LoadVectorDatasetEx→ first presented frameBegin/EndLoadVectorDataset→ first presented frameBoth targets are met (≤ 250 ms Release / ≤ 1.5 s Debug). Debug and Release CTest suites pass (484 tests each, no new warnings); the C# test host builds.
Memory: updated
architecture/activex.md(Automatic GDI-first contract) andbuild/cmake.md(plain-shell cmake/vs2026 preset locations).Remaining limitations
Automatic, fill rendering stays on GDI until meshes exist; Phase 2 adds background mesh preparation and the view invalidation that switches to OpenGL.