Repository navigation
feat(cvcGL): StreamTextureBinding — zero-copy video stream -> GeometryNode texture (Phase 2 PR2) - #518
Merged
Conversation
…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.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The consumer sink for the Phase-2 streaming path.
cvc::gl::ariadne::StreamTextureBindingdrives aGeometryNode's texture from acvc::streamlatest-mode subscription: once per rendered frame the host callstick()(render/owner thread), and on a newer frame seq it aliases the frame into the node'svtkTexturezero-copy viacvc::stream::to_image(PR1) +GeometryNode::setTexture.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 viastream_registryat release, so a stream that closed first is handled cleanly.to_imagethrows) is skipped, not drawn as garbage.Test
cvcgl_stream_texture(headless —setTextureruns 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-seqsetTexturerebuild cost (planning-critique MED-4) is noted for a profiling/fast-path follow-up.