Skip to content

mixer_keyer: compose only the rectangles of keys that say so - #42

Merged
jpietek merged 1 commit into
developfrom
mixer/keyer-bounded-keys
Oct 9, 2026
Merged

jpietek merged 1 commit into
developfrom
mixer/keyer-bounded-keys

Conversation

@jpietek

@jpietek jpietek commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

What

With keys visible the keyer composes the whole canvas in one launch: the program as a full-size layer under the keys. A key on a small part of the picture pays for all of it.

Keys named in bounded_keys (a dsk key's bounded option in a show) may be composed alone. While every visible key is one of them, the output is a copy of the program frame on which the composite kernel runs only over viewports around the keys. Keys that overlap share a viewport.

  • The composite kernel is unchanged. A viewport is handed to it as its canvas: plane pointers at the viewport's origin, the viewport's size, and a rect table relative to that origin (cuda_rect_viewport.h).
  • At most four rectangles and 60 % of the canvas; beyond that, and for any other layer set, the whole canvas is composed as before.
  • Whole-canvas composition stays the default. bounded_keys is an array of key inputs, or true for all.
  • The mixer demo marks its four keys: each window is its graphic and nothing else.

Measured

Tesla T4, 1920x1080 NV12, one blended RGBA key, kernel time per frame from tests/cuda/test_rect_composite.cu:

Key Whole canvas Copy + viewport
1016x172 0.161 ms 0.091 ms
1920x360 0.252 ms 0.207 ms
1920x1080 0.502 ms whole-canvas path

The program frame is shared with the clean output, so it is copied first; that copy costs most of what the bounded launch saves.

Tests

  • tests/cuda/test_rect_composite.cu: fifteen over: cases (NV12, P010, P210; premultiplied, texture-backed, faded, scaled, overlapping, off-canvas keys) whose pixels must equal the whole-canvas launch. A deliberately wrong chroma origin fails it.
  • tests/mixer/test_graph.py: the show option reaches the node; a non-boolean is refused.
  • Ran in a 192-source show with all four keys bounded.

🤖 Generated with Claude Code

With keys visible the keyer composes the whole canvas in one launch, the
program as a full-size layer under the keys. A key on a third of the picture
then pays for all of it.

Keys named in bounded_keys (a dsk key's bounded option in a show) may be
composed alone: while every visible key is one of them, the output is a copy
of the program frame on which the composite kernel runs only over viewports
around the keys. The kernel is unchanged: a viewport is handed to it as its
canvas, with a table relative to the viewport's origin. At most four
rectangles and 60 % of the canvas; otherwise, and for any other key, the
whole canvas is composed as before, which stays the default.

On a Tesla T4 a 1016x172 key takes 0.091 ms instead of 0.161 ms, a 1920x360
one 0.207 ms instead of 0.252 ms.

tests/cuda/test_rect_composite.cu: fifteen cases whose pixels must equal the
whole-canvas launch, and timings of both paths.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jpietek
jpietek merged commit 4319b47 into develop Oct 9, 2026
2 of 5 checks passed
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