Skip to content

Use tile57 GPU scene - #10

Merged
beetlebugorg merged 7 commits into
mainfrom
feat/gpu-scene
Aug 24, 2026
Merged

Use tile57 GPU scene#10
beetlebugorg merged 7 commits into
mainfrom
feat/gpu-scene

Conversation

@beetlebugorg

Copy link
Copy Markdown
Owner

No description provided.

Scaffolding from the dash / linestyle-brick / contour-label / depth-unit / HiDPI
hunts, all of which are closed: the SPRITE, LABEL, TXT, BRICK, DASH, SCALE, ROT and
zoom/SCAMIN probes, plus the members that existed only to feed them
(portray_px_per_world_, dbg_sprite_*, dbg_zoom_).

Kept the structural diagnostics, which report on state rather than on a specific
past bug: ENTRY (which gate ate a black canvas), the portrayed-tiles and cache-
CLEARED churn lines, the GL error dump, and the ungated Init/CALIB/shader lines.

All of this was gated on TILE57_DEBUG, so this is not a steady-state speedup — but
with the env var set these ran in the per-frame path (a profile with TILE57_DEBUG on
put the zoom/SCAMIN line alone at ~0.4% of frame time), which made the plugin's own
instrumentation a term in any measurement taken with it.
Two breaking changes landed in tile57's surface callbacks:

  * tile57_rgba became tile57_color, a uint32 packed 0xRRGGBBAA. A 4-byte
    extern struct passed BY VALUE across callconv(.c) is miscompiled by zig
    0.16 on aarch64 in every optimized build mode, which delivered fully
    transparent fills, lines and text to hosts.
  * draw_text and draw_text_str gained a trailing int32_t text_group, the
    S-52 §14.5 group the label belongs to.

Unpack once at the C boundary (tile57_unpack -> Rgba8) so the renderer keeps
using colour channels internally and only the thunks speak the ABI.
Five conflicts, all where main's newer work sat on the same lines as the ABI
change:

  * on_fill_area / tessellate_rings — took main's persistent-earcut refactor
    wholesale and re-applied the colour type on top.
  * tr_text_str — took this branch's side: the new signature, with the
    TILE57_DEBUG label probe that b6b1bc5 already removed left out.
  * portray tile setup — took main's job.m.size_scale, dropping the two probe
    lines (portray_px_per_world_, dbg_sprite_name_) b6b1bc5 removed.
  * portray_view_labels — kept main's portray_mu_ lock guard, which is a real
    concurrency fix and NOT a probe, while dropping the TILE57_DEBUG block it
    was mixed in with.
  * tile57_chart.cpp zoom logging — pure probe block, left out.

The cache/portray diagnostics main added after b6b1bc5 are untouched: those
are separate from the probes that commit retired, and auto-merge kept them.

Builds clean against tile57 with the packed-colour + text-group ABI.
Replace the surface-callback renderer (earcut tessellation + a per-tile
geometry cache + an async portray worker + five bespoke vertex formats)
with the draw-ready GPU scene ABI (tile57_chart_gpu_scene): portray the
whole view ONCE into vertex/index/quad buffers already in S-52 paint
order, upload them, and walk the ranges. Adopts lookout-core's model —
one overscanned scene per view, rebuilt only when the view leaves its
coverage margin/zoom band or the mariner settings change; pan/zoom/rotate
and the SCAMIN + display-category gates are pure GPU transforms, no
re-portray.

Shaders ported to GLSL 1.20 (no integer/bitwise ops): disp_cat/map_align
ride as float attributes, category visibility as a vec3 uniform. Verts are
rebased camera-relative to the build centre on upload so f32 holds at
harbour zoom. Kept: the MSAA supersample composite, HiDPI, view rotation,
quilt scissor, and the public API tile57_chart.cpp drives.

net -1931 lines. Builds/links against tile57-main (feat/label-cache);
not yet runtime-verified in OpenCPN.
Update to tile57's current draw-ready scene contract: per-vertex color and
paint-order depth, quad flip and tangent fields, the pixel_ratio and
per-scheme sprite atlas, SDF halos in the palette background color, and
tile57_gpu_batch for draw call merging.

Split the renderer into one file per responsibility: GL object owners,
programs and stream bindings, atlases, the CPU scene build with its worker
thread, the resident GPU scene, and the host-facing renderer.

Rendering changes:
- scenes build on a worker thread; the current scene keeps drawing until
  the new one is adopted, and the first scene builds inline
- rebuilds through a zoom gesture wait up to one level; a zoom-out builds
  0.15 levels further out so its coverage holds through the ease
- the coverage record keeps the requested zoom apart from the zoom clamped
  to the chart's band, so a view past the band no longer rebuilds every
  frame
- opaque fills draw front to back with the depth test when a depth buffer
  is available; everything else draws in paint order
- ranges are batched into merged draw calls, and vertex streams bind once
  per stream rather than once per range

Drop the unused earcut dependency and update the docs to the new model.
@beetlebugorg
beetlebugorg merged commit 51fb341 into main Aug 24, 2026
3 checks passed
@beetlebugorg
beetlebugorg deleted the feat/gpu-scene branch August 24, 2026 03:23
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.

1 participant