Skip to content

Vector Rendering Performance – Optimize OpenGL rendering and data transfer - #93

Merged
pmeems merged 3 commits into
developmentfrom
phase6-optimize-opengl-rendering-v2
Nov 21, 2026
Merged

pmeems merged 3 commits into
developmentfrom
phase6-optimize-opengl-rendering-v2

Conversation

@pmeems

@pmeems pmeems commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Motivation

Reduce repeated OpenGL geometry submission and the CPU cost of copying framebuffer rows to the ActiveX/GDI presentation surface.

Key design decisions

  • Cache immutable fill and outline geometry in context-local vertex and index buffers per layer scene, with client-array fallback.
  • Apply pan and zoom through the OpenGL matrix instead of rebuilding transformed vertices, and retain the required framebuffer readback while removing the extra CPU row reversal.
  • Keep temporary renderer GPU buffers context-local; their lazy CPU triangulation meshes remain shared.

Validation

  • Debug and Release x64 CMake builds succeed with no new warnings; the Debug warning count matches development at 30 existing D9025 overrides.
  • All 474 non-interactive CTest cases pass.
  • On the generated 2,459-feature Release benchmark, steady frame/pan/zoom measured 2.5/2.3/2.3 ms versus 2.7/2.6/2.6 ms before, and eight readbacks measured 13.5 ms versus 18.3 ms.

No dependency changes. Updated the ActiveX architecture memory with the verified buffer lifetime and fallback rules.

- Cache immutable fill and outline geometry in context-local OpenGL buffers.
- Reuse matrix transforms across viewport changes and remove the CPU row reversal.
- Add cache lifecycle tests, benchmark results, and updated rendering documentation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@Julian-MW Julian-MW left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review. Final decision is with the human reviewer.

One Major finding: the stale-entry erase in DrawLayerWithGpuBuffers keeps the iterator returned by std::map::erase, so invalidating any layer that is not the last in LayerId order skips the re-upload and draws another cached layer's buffers for one frame. The rest of the design — origin-localized VBO/IBO caching, matrix-based pan/zoom, bottom-up DIB presentation without the CPU row reversal, context-local buffers for temporary renderers — checks out against the client-array fallback math and the documented cache-lifetime rules. CI is green across all builds.

- Rebuild invalidated GPU buffers instead of drawing the next cached layer
- Propagate geometry-buffer invalidation queue failures
- Avoid double-counting failed GPU upload diagnostics
- Cover multi-layer invalidation and outline-to-fill upgrades

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Layer-wide coordinate rebasing can collapse distant polygon edges, leaving a significant rendering correctness defect unresolved.

4 open issues
What changed in this PR

This PR implements Phase 6 of the vector-rendering performance plan, reducing repeated geometry submission and presentation overhead in the ActiveX OpenGL backend.

Changes:

  • Caches context-local vertex and index buffers per layer scene, using matrix transforms for navigation and retaining client-array fallback.
  • Removes CPU scanline reversal by presenting OpenGL’s bottom-up framebuffer data directly through GDI.
  • Adds GPU-cache regression tests and updates architecture, performance measurements, and planning documentation.

The PR reports successful Debug/Release builds and 474 passing non-interactive tests. Builds and tests were not rerun during this review.

File Description
tests/​MapWinGIS.ActiveX.Tests/​VectorLayerRendererTests.cpp Tests buffer reuse, invalidation, and fill-mode upgrades.
tests/​MapWinGIS.ActiveX.Tests/​OpenGlVectorLayerRendererTestAccess.h Exposes GPU-cache counters and invalidation helpers.
src/​MapWinGIS.ActiveX/​OpenGlVectorLayerRenderer.h Declares GPU-cache storage and lifecycle operations.
src/​MapWinGIS.ActiveX/​OpenGlVectorLayerRenderer.cpp Implements cached geometry, matrix transforms, fallback, and bottom-up presentation.
README.md Summarizes GPU-buffer reuse and compatibility fallback.
docs/​TESTING.md Documents regression coverage and Phase 6 measurements.
docs/​ARCHITECTURE.md Describes buffer ownership, invalidation, and presentation.
.github/​plans/​Vector-Rendering-Performance-Improvement.md Updates phase status, results, and limitations.
.ai/​memory/​architecture/​activex.md Records context-local buffer ownership and readback behavior.

Review effort: Balanced

- Localize cached polygon coordinates to preserve far-from-origin precision
- Index layer IDs during GPU cache pruning and drain deletions independently of OpenGL frames
- Add zoom-only and far-origin rendering regressions

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pmeems pmeems changed the title MapWinGIS6 – Vector Rendering Performance Improvement Plan – Phase 6 – Optimize OpenGL rendering and data transfer Vector Rendering Performance – Optimize OpenGL rendering and data transfer Nov 21, 2026
@pmeems
pmeems enabled auto-merge (squash) November 21, 2026 16:59
@pmeems
pmeems merged commit d23de58 into development Nov 21, 2026
17 checks passed
@pmeems
pmeems deleted the phase6-optimize-opengl-rendering-v2 branch November 21, 2026 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants