Skip to content

feat(cvcGL): StreamTextureBinding — zero-copy video stream -> GeometryNode texture (Phase 2 PR2) - #518

Merged
transfix merged 2 commits into
masterfrom
feat/cvcgl-stream-texture
Oct 1, 2026
Merged

transfix merged 2 commits into
masterfrom
feat/cvcgl-stream-texture

Conversation

@transfix

@transfix transfix commented Oct 1, 2026

Copy link
Copy Markdown
Owner

The consumer sink for the Phase-2 streaming path. cvc::gl::ariadne::StreamTextureBinding drives a GeometryNode's texture from a cvc::stream latest-mode subscription: once per rendered frame the host calls tick() (render/owner thread), and on a newer frame seq it aliases the frame into the node's vtkTexture zero-copy via cvc::stream::to_image (PR1) + GeometryNode::setTexture.

  • Node held weakly; when it's gone, tick() unsubscribes so the stream's pool slab + the channel's committed slots are released promptly, not pinned for the whole scene lifetime (planning-critique MED-3 fix). Subscription re-resolved via stream_registry at release, so a stream that closed first is handled cleanly.
  • Per-seq dirty-check (a tick with no newer frame is a no-op); an un-aliasable frame (to_image throws) is skipped, not drawn as garbage.

Test cvcgl_stream_texture (headless — setTexture runs inline, no GL context): proves the end-to-end zero-copy path (texture scalar array points at the SAME bytes the frame borrows), the seq dirty-check, and prompt unsubscribe on node teardown. valgrind: 0 invalid reads/writes across the texture-aliases-slab lifetime.

Scope: binding + test only. The declarative register_scene_node_type("stream") realizer (quad geometry + GL end-to-end) and (gl-bind-stream node s) land with PR6 (DSL surface), where the quad/TCoord + render-loop wiring belongs. Depends on PR1 (merged). The per-seq setTexture rebuild cost (planning-critique MED-4) is noted for a profiling/fast-path follow-up.

…yNode texture (Phase 2 PR2)

The consumer sink for the Phase-2 streaming path (roadmap STATE_BINARY_STREAMING.md).
cvc::gl::ariadne::StreamTextureBinding drives a GeometryNode's texture from a
cvc::stream latest-mode subscription: once per rendered frame the host calls tick()
on the render/owner thread, and on a newer frame seq it aliases the frame into the
node's vtkTexture ZERO-COPY via cvc::stream::to_image (PR1) + GeometryNode::setTexture
(which itself marshals to the owner thread and holds the aliased buffer alive).

- Holds the node weakly; when the node is gone, tick() unsubscribes so the stream's
  pool slab and the channel's committed slots are released promptly rather than
  pinned for the whole scene lifetime (planning-critique MED-3 fix). The subscription
  is re-resolved through stream_registry at release so a stream that closed first is
  handled (the sub is already closed; dropping it suffices).
- Per-seq dirty-check: a tick with no newer frame is a no-op. A frame that cannot be
  aliased losslessly (to_image throws) is skipped, not drawn as garbage.

Test cvcgl_stream_texture (headless, no GL context — setTexture runs inline): proves
the END-TO-END zero-copy path (the texture's scalar array points at the SAME bytes the
stream frame borrows), the seq dirty-check, and prompt unsubscribe on node teardown
(subscriber_count returns to 0). valgrind: 0 invalid reads/writes across the
texture-aliases-slab lifetime.

Scope: the binding + its test only. The declarative register_scene_node_type("stream")
realizer (quad geometry + GL end-to-end) and (gl-bind-stream node s) land with PR6
(the DSL surface), where the quad/TCoord + render-loop wiring belongs.
…R5 TODO; cover slab release

Adversarial review of PR2 (verdict SHIP-AFTER-FIXES): the code is correct under the
single-threaded-owner model that cvcGL uses; fold in the must-fix contract docs + the
flagged TODO + the should-fix test gap.

- Header: explicit THREADING & LIFETIME CONTRACT — not thread-safe; construction,
  every tick(), and destruction must all run on the single owner/render thread (what
  makes the non-atomic last_seq_/released_ and release()'s registry raw-pointer
  re-resolve safe); the stream+channel must outlive the binding and be torn down on
  that same thread (the producer may run on its own thread but never destroys the
  stream); the cvc::app must outlive the binding.
- release(): TODO tying the token-only registry lookup to PR5's (scope,token) re-key
  (else the prompt slot/slab release silently regresses), plus a note on the benign
  same-id-reopen case where token-only lookup resolves the new channel and unsubscribe
  harmlessly no-ops.
- Test: after node teardown, drop the test's own subscription ref and assert
  pool().in_use() goes 1 -> 0, proving the SLAB (not just the committed-slot
  accounting) is recycled.

No functional change; test still passes.
@transfix
transfix merged commit 14a457f into master Oct 1, 2026
13 checks passed
@transfix
transfix deleted the feat/cvcgl-stream-texture branch October 29, 2026 20:52
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