Skip to content

Refactor 6/6: XR input, Vulkan helpers and the video player - #101

Merged
seaweeduk merged 1 commit into
masterfrom
refactor/wave-5
Nov 22, 2026
Merged

seaweeduk merged 1 commit into
masterfrom
refactor/wave-5

Conversation

@seaweeduk

Copy link
Copy Markdown
Owner

Last layer of the structural refactor: XR input and device creation leave XrContext, the Vulkan code loses its copies, the frame's two GPU participants share one protocol, the platform is decided once, VideoPlayer's event loop is split, and the background decoders share their helpers. Nothing changes for users.

Steps in this layer: V1, V2, V3, V4, V5, V6, plus their review fixes.

V1: XrContext housekeeping. Controller, haptics and gaze input become XrInput, which XrContext owns and destroys at the same point as before (before the session and instance). Callers use xr.input(). The 334-line Vulkan device creation becomes a builder in six steps, in xr_device.cpp; every extension, feature struct and pNext link is unchanged.

V2: one copy of each Vulkan helper. The five single-attachment offscreen passes, their framebuffers and the full-screen pipeline come from offscreen_pass. The three DMA-BUF importers share one image helper and one import helper. Each caller's formats, layouts, stages, access masks, usage bits and modifiers are passed in unchanged.

V3: frame participants. GlInterop and DirectVideo implement FrameParticipant, and SceneRenderer makes their per-frame calls, GlInterop first, as before.

flowchart LR
  R["SceneRenderer"] -- "recordAcquires / recordReleases / frameSubmitted / frameAbandoned" --> G["GlInterop"]
  R -- "same calls, after GlInterop" --> D["DirectVideo (Frame)"]
Loading

V4: the platform decided once. Five hwdec == "v4l2m2m" string compares in main.cpp become named facts in one PlatformPolicy, computed at start-up: directVideo, egl, pipelineByDefault, followVisibility and earlyRender.

V5: VideoPlayer. pollEvents hands each mpv event to its own handler (400 lines down to 59). The seek queue becomes SeekQueue and the video's sleep and resume PlayerSleep. The mpv session handshake and the Frame's early-render order don't move.

V6: shared helpers for background media work. One Interrupt, one FFmpeg open-and-decode sequence (media_decode), one background thread priority helper (thread_priority), and one vrcmd path. The depth estimator's GL drawing becomes a second patch drawer beside DirectDepth. Each caller keeps its own decoder settings, read limits, interrupt timeout and thread priority.

Review fixes. XrInput can't be copied, and only XrContext creates, syncs and destroys it. The key picker and mask probe release a drawer's values. A rendered frame is checked for a resume only while one is under way. The key colour is packed only for the Frame's drawer.

Before After
xr_context.cpp lines 1,850 1,177
VideoPlayer::pollEvents lines 400 59
VideoPlayer data members 88 63
DepthEstimator::request lines 166 106
Functions of 200+ lines 24 22

Across the whole stack:

Before After
main.cpp lines 5,202 2,754
Menu data members 213 131
Functions of 200+ lines 30 22
Lines in functions of 100+ lines 29,602 27,634

Known and left as is

  • PlayerSleep owns the sleep and resume state. VideoPlayer::setPresentationActive() still decides when to close or reopen the track because it checks player readiness and decoder release.

Important

AI disclosure

Model Variant Role
anthropic/claude-opus-5-5 high Implementation, orchestration
openai/gpt-6.2-astra high Independent review

Agent harness OpenCode 2.3.2

@seaweeduk seaweeduk added the skip-changelog Left out of release notes label Nov 22, 2026
@opencode-agent

Copy link
Copy Markdown

LGTM 👍

The refactor preserves the order-sensitive behavior: XR input still uses the predicted display time, SceneRenderer records and completes GlInterop before DirectVideo, and decoder resume still waits for the saved-position seek to restart and show a fresh picture. The shared Vulkan and FFmpeg helpers retain their callers’ synchronization parameters, decoder settings, and read limits.

github run

@seaweeduk
seaweeduk changed the base branch from refactor/wave-4 to master November 22, 2026 20:59
@seaweeduk
seaweeduk merged commit 37edddc into master Nov 22, 2026
@seaweeduk
seaweeduk deleted the refactor/wave-5 branch November 22, 2026 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changelog Left out of release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant