Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/plans/Vector-Rendering-Performance-Improvement.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ Copilot: Update this checklist as each phase is implemented. Only mark a phase c
- Normal scene construction now preserves source rings and bounds without triangulating polygons; fill meshes remain available through explicit preparation.
- GDI fills directly from source rings, and OpenGL can draw mesh-free polygon outlines while fill requests retain the existing mesh requirement and GDI fallback.
- Limitation: OpenGL fill meshes are prepared explicitly rather than generated lazily; lazy triangulation and cache reuse remain Phase 3 and Phase 4 work.
- [ ] **Phase 3 – Implement lazy polygon triangulation** (PR 3)
- [x] **Phase 3 – Implement lazy polygon triangulation** (PR 3)
- OpenGL fill draws now generate missing polygon meshes on demand and reuse them for later draws of the same immutable scene, including temporary scaled draws.
- Explicitly prepared meshes remain preferred; outline and GDI paths continue to use source rings without requiring fill meshes.
- Triangulation failures, including exceptions from GDAL logging callbacks, return to the coordinator for GDI fallback without preventing outline rendering.
- Limitation: triangulation remains synchronous, and broader cache ownership, memory limits, and invalidation rules remain Phase 4 work.
- [ ] **Phase 4 – Add intelligent caching and invalidation** (PR 4)
- [ ] **Phase 5 – Introduce viewport-aware geometry processing** (PR 5)
- [ ] **Phase 6 – Optimize OpenGL rendering and data transfer** (PR 6)
Expand Down Expand Up @@ -524,6 +528,7 @@ Each PR must:
5. Avoid unrelated refactoring.
6. Be independently reviewable.
7. Include a clear description of limitations and remaining work.
8. The PR title should reflect the title of the plan combined with the title of the phase.

Do not wait for all phases to be completed before creating PRs. Each phase should result in a separate PR against the `development` branch, following the repository's existing contribution workflow.

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ release the loaded datasets before switching or refreshing them.

Core stores polygon coordinates in flat buffers and caches prepared geometry
per map layer. Visibility changes reuse that geometry without rereading
datasets or triangulating polygons again.
datasets or triangulating polygons again. OpenGL generates missing fill
meshes on the first fill draw and reuses them for that render scene.

## Build and test

Expand Down
32 changes: 18 additions & 14 deletions docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,12 @@ rings and has no mesh. `ViewTransform` captures the `Viewport` once
per frame so both backends transform every vertex of every layer with the
same arithmetic as `Viewport::MapToScreen`; GDI draws a screen position in
the pixel that contains it (`ToPixel`). One backend draws the whole frame.
The coordinator tries the OpenGL backend when every polygon of every layer
has a triangulated fill mesh for a fill draw. OpenGL outline mode draws the
source rings without requiring fill meshes. GDI checks each layer before
drawing it; a layer with non-finite or out-of-range device coordinates is
For an OpenGL fill draw, the backend accepts a mesh-free source scene and
triangulates each polygon that has no prepared fill mesh.
The generated meshes remain associated with that immutable scene and are
reused by later draws; they do not mutate the Core scene. OpenGL outline
mode draws the source rings without requiring fill meshes. GDI checks each
layer before drawing it; a layer with non-finite or out-of-range device coordinates is
skipped and reported (`GetFailedLayers`, `RenderingStatus`) while the other
layers are still drawn.
OpenGL uses a context created on a hidden, never-presented window, draws with
Expand All @@ -344,16 +346,18 @@ buffer before copying them to the host device context.
BGRA stores blue, green, red, and alpha bytes in that order.
The screen renderer retains its staging allocation and GPU framebuffer.
Alternate-size draws use a temporary OpenGL renderer that releases both after
the draw and leaves the screen resources unchanged.
the draw and shares the screen renderer's lazy fill meshes, leaving the screen
resources unchanged.
A separate vertex buffer is reused across polygons within each layer.
This avoids a fresh allocation for every polygon's transformed triangle vertices.
Rendering into a framebuffer object avoids undefined pixels from window
pixel-ownership rules. Presentation still copies pixels through GDI.
Interior rings and concave boundaries draw identically in both backends
because both consume the same scene. A fill request without a usable mesh,
missing framebuffer-object support, initialization failures, and drawing
failures use the GDI backend. GDI fills and outlines the original rings, so
a self-intersecting ring that GEOS cannot triangulate can still be displayed.
because both consume the same scene. A failed lazy triangulation, an unusable
explicitly prepared mesh, missing framebuffer-object support, initialization
failures, and drawing failures use the GDI backend. GDI fills and outlines
the original rings, so a self-intersecting ring that GEOS cannot triangulate
can still be displayed.
The GDI backend draws the original rings of the whole supported polygon scene,
including its interior rings and concave boundaries. Both backends draw source coordinates without reprojection,
and scene preparation currently supports Polygon, MultiPolygon, CurvePolygon,
Expand Down Expand Up @@ -487,14 +491,14 @@ and `Ring` types remain available for caller-created triangulation input.
There is no tiling, paging, or clipping to the visible extent. GDI skips a
layer whose device coordinates exceed its range. It clips drawing to the
requested target rectangle and the host's existing clip region, then restores
the device context. Fill triangulation runs only when scene preparation
explicitly requests it; view changes (resize, zoom, pan) and redraws reuse
the retained meshes. The opt-in
the device context. Fill triangulation runs when scene preparation explicitly
requests it or when OpenGL first needs a missing mesh. View changes (resize,
zoom, pan) and redraws reuse the retained meshes. The opt-in
rendering baseline (see [TESTING.md](TESTING.md#rendering-performance-baseline))
tracks scene preparation, mesh storage, and backend frame costs on both a
convex grid and a complex mix of concave, holed multipart, and many-vertex
polygons. OpenGL fills every polygon from its retained triangle mesh and
copies each frame through CPU memory. Its reusable CPU
polygons. OpenGL fills every polygon from a supplied or lazily generated
triangle mesh and copies each frame through CPU memory. Its reusable CPU
staging buffer is limited to 64 MiB per frame; target dimensions are also
limited by the detected framebuffer and viewport capabilities. GDI is the supported
Windows CPU fallback; Core has no independent platform-neutral renderer.
Expand Down
4 changes: 3 additions & 1 deletion docs/TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,9 @@ and configuration C for OpenGL outline-only rendering).
`MeasuresCoreSceneAndBackendCosts` explicitly requests fill-mesh preparation
(configurations B and D). Successful backends report first and steady frame
times, plus pan and zoom frames, for a 1280x720 off-screen target. Normal scene
creation does not perform triangulation.
creation does not perform triangulation. OpenGL fill rendering lazily
triangulates source-only scenes on their first fill draw and reuses those
backend-owned meshes on later draws.

Performance diagnostics are disabled by default and aggregate process-wide
timings with `std::chrono::steady_clock`. The collector records dataset
Expand Down
1 change: 1 addition & 0 deletions src/MapWinGIS.ActiveX/MapWinGISControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,7 @@ STDMETHODIMP CMapWinGISControl::ClearLayers()
InvalidateLayerCache();
FireViewChange();
}
_renderer.InvalidateSceneCache();
return S_OK;
}

Expand Down
Loading