fix(video): decode movie pictures on a worker #2913
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2913
Loading…
Reference in a new issue
No description provided.
Delete branch "omgitsgela/Longshot:fix/movie-decode-worker-main"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
A movie's pictures were decoded on the thread that has to hand one to the game every 16.7 ms. A 3.2 to 4.0 ms decode, with a worst picture of 94 to 128 ms, therefore sat directly in the Acquire path. On the Deck LCD, two first-minute runs of current
main(4908cc6d) without the pack skipped 779 and 495 pictures; with this PR they skipped 59 and 1. The earlier87045899base measured 694 and 470 to 13 and 0; the olderec889d9dbase measured 532 to 16 in the first minute and 593 to 34 over all 5,947 pictures.This changes the movie path in three parts:
host/nn_video.c: each decoder owns a native worker.dec_submitcopies the compressed packet into an owned packet and wakes the worker; the worker decodes into the existing bounded host-picture ring;dec_acquireonly leases a free guest pool, detaches a ready picture, copies, and returns the completed fence.dec_flush,dec_stopanddec_finalizejoin the worker. Acquire no longer decodes or performs the catch-up decode.gpu/vk/vk_draw.cpp: the movie upscale pipeline and one dummy dispatch are made at startup, so the first movie frame no longer pays the driver's first-dispatch compile.gpu/vk/vk_shader.cpp: a program rejected as a network left out on this card is remembered by key in a cache file scoped to the translator, device, matrix limits and relevant profile capabilities. Later runs skip its translation before doing it again. No program keys are hardcoded, and forced trials bypass the cache.Fixes #73.
Testing
Tested: Steam Deck LCD (AMD Custom GPU 0405, RADV VANGOGH, Vulkan 1.4), current base
4908cc6d, the pack built fromfix/movie-decode-worker-mainatb41a5cb7,HOS_VIDEO_LOG=1, 1280x800, 60 fps cap, test user copy. The current-base A/B is two interleaved first-minute runs per arm; the stock arm is the same base without the pack. The earlier87045899andec889d9dbases also measured the first minute, andec889d9dmeasured the whole 5,947-picture movie.Both current-base runtimes were given their shader preparation before measurement, so neither arm paid a first-launch preparation in the measured runs. The fix log contains
vk: movie upscale pipeline prewarmed: yesandvk: movie upscale dispatch prewarmed: yes.The five video checks pass on Linux with
g++:tests/test_video_worker.py(the real worker with a fake decoder),tests/test_video_catchup.py,tests/test_vcore_video_acquire.py,tests/test_video_input_limit.py(all modes), andtests/test_video_hold_early.py(both modes). The worker test takes the decoder lock for test-thread reads, covers submission, bounded output, EOS, Flush/stop/restart, an overlapping Submit/Flush, the start barrier, timer cleanup and the synchronous fallback whenCreateThreadfails; it passes ThreadSanitizer.tests/test_short_sleep_timer.pyalso passes, including the timer close. The legacy fixtures take theHOS_VIDEO_WORKER_OFFpath.pre-commitpasses on the changed files.Still to test:
decode_nextbut its callback thread affinity needs its own review (by hand, on a Windows PC with an AV1 movie).Measurements
Verdict: The worker removes nearly all of the current-base movie skips: 779 and 495 to 59 and 1 in two first-minute runs on the Deck LCD. The earlier
87045899base measured 694 and 470 to 13 and 0; the olderec889d9dbase measured 532 to 16 in the first minute and 593 to 34 over the full 5,947-picture movie.Setup: Steam Deck LCD, RADV VANGOGH, Vulkan 1.4, 1280x800, 60 fps cap, current base
4908cc6d, test user copy. Both runtimes used the same options file and were prepared warm before the measured runs. Two stock and two fixed first-minute runs were interleaved.Baseline: current
mainat4908cc6d, built without the pack. The stock and fixed arms share that base, so the difference is the pack; the pack was built fromb41a5cb7, the final fix head.4908cc6db41a5cb7[9,1,1,1,1,1,9,7](14)[7,6,1,1,6,1,7,7](22)[2,8,3,1,2,1,1,1](17)[1](1)The earlier
87045899first-minute runs were 694 and 470 to 13 and 0. The olderec889d9dfull-movie run was 593 to 34 skips over all 5,947 pictures. The current-base runs are first-minute measurements; the full-movie number is from that earlier base.Risks
MAX_QUEUEof 8 pictures; the worker blocks at the queue limit instead of discarding a picture.dec_flush,dec_stopanddec_finalizenow join the worker; a start barrier blocks a replacement until Flush has finished the backend and queue cleanup. The worker releases its thread-local sleep timer.tests/test_video_worker.pycovers Flush/stop, restart, an overlapping Submit/Flush and the failed-thread fallback; the full game remains the integration check.queue_frame, and the worker life-cycle is shared; it needs a Windows run.cache/.HOS_VIDEO_WORKER_OFF=1keeps the old Acquire-decoding path for the legacy decoder tests and a side-by-side fallback. The game never sets it; the default is the worker.longshot_options.ini.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (the five video checks pass locally; the full run is waiting on CI).main, or Measurements says why there is nothing to measure. Current-base stock/fix first-minute runs on4908cc6dare in Measurements.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.tests/test_video_worker.pycuts the real worker out of the source and exercises it with a fake decoder; the runtime A/B remains the game evidence.tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers.Assisted-by: Hermes Agent
Tested in game: Steam Deck LCD (RADV VANGOGH, Vulkan 1.4), base
ec889d9d: first-minute skips 532 -> 16; full 5,947-picture movie 593 -> 34; decode 4.0 -> 3.2 ms, worst 128.4 -> 94.3 ms; startup prewarm lines present.WIP: fix(video): decode movie pictures on a workerto fix(video): decode movie pictures on a workerRecommendation: Request changes. The worker still holds the decoder lock through decoding, so Acquire and Submit can stall for the full decode time. The persistent rejection cache can also suppress shaders on a GPU or configuration that supports them, and the production worker has no game-free coverage.
The change moves movie decoding to a worker, prewarms the movie upscale pipeline, and caches rejected network programs. The Deck run reports substantially fewer skipped pictures, but the worker still blocks callers during decoding and the new cache can retain an obsolete rejection.
Blocking (4): must change before merging.
host/nn_video.c:584: The worker holds the same exclusive lock used by Acquire and Submit throughout decode_next, including the decoder call and frame copies. (more on the line) Do: Remove the pending packet under the lock, decode into worker-owned state without holding the queue lock, and lock only to publish pictures and update shared state.gpu/vk/vk_shader.cpp:1657: The persistent rejection is keyed only by program, although the decision to reject depends on the device, its capabilities, translator behavior and switches. (more on the line) Do: Key or invalidate the cache using all inputs to the rejection decision, including device capabilities, relevant switches and translator version, or avoid persisting the decision.host/nn_video.c:578: Checking for one free queue slot before decoding does not ensure that all pictures produced by a packet or drain fit. (more on the line) Do: Provide backpressure for every produced picture, including drain output, or retain excess output until the consumer frees space.tests/test_video_input_limit.py:110: The changed fixtures stub out the worker and exercise only the legacy path, leaving the new behavior and lifecycle untested. (more on the line) Do: Add game-free behavioral tests for worker submission, bounded output, EOS, flush, stop and restart, including the worker-creation failure path; retain fallback coverage separately.Should fix (3): not blocking, but worth doing before merging.
host/nn_video.c:603: A failed worker creation leaves the decoder on the worker path with no worker to consume its pending packets. (more on the line) Do: Handle thread-creation failure explicitly, either returning an error or switching that decoder to a functioning synchronous fallback.gpu/vk/vk_shader.cpp:102: The new cache uses narrow fopen on a UTF-8 path on Windows. (more on the line) Do: Use the repository's UTF-8-safe file-opening approach for both reads and writes.host/nn_video.c:597: The new HOS_VIDEO_WORKER_OFF switch has no row in the required switch table. (more on the line) Do: Add the switch and its default to gpu/vk/switches.def, or remove the fallback switch once it is no longer needed.Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
@fixcan do L1, L2, L3, L4, L5, L6 and L7.Questions (1) (not confirmed from the code; they don't hold the recommendation)
host/nn_video.c:600: Can the supported game's decoder receive concurrent Submit calls, or can Submit race with Stop or Finalize for the same decoder?Checks: Failing on this head, which is behind its base, where they pass:
CI / Third-party parts and guide screenshots (pull_request),CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request),CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request),CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request),CI / Game-free checks (run_all.py, part 1/2) (pull_request),CI / Game-free checks (run_all.py, part 2/2) (pull_request),CI / Website build and checks (pull_request),PR description / Title and description (pull_request_target).@rebase(or@fix) brings it up to date and runs them again; not held against it.More: does it help, other systems, switches, what was read
Does it help: Unproven on the current base and head. One Deck run per arm on an older base reports first-minute skips falling from 532 to 16 and full-movie skips from 593 to 34; the PR reports no repeated interleaved runs or current-main comparison.
Other systems: The decoder also runs on Windows through Media Foundation and on Linux through FFmpeg or dav1d. The shader cache is shared across launches and may survive GPU, driver, switch, and renderer changes. The prewarm adds startup GPU work on all supported devices; its cold and warm cost and behavior on other Tier 1 hardware have not been measured.
Switches: HOS_VIDEO_WORKER_OFF is added, default off, so the worker is enabled. Its fallback has no switch-table row or production-path test; the default has only one older-base Deck comparison and no Windows validation.
Reviewed:
77a1289804againstd193d12d55: Read AGENTS.md, CONTRIBUTING.md, docs/dev/standards.md and the pull request template; docs/review-checklist.md and ../Tooling/AGENTS.md were absent. Read the diff, commit messages, decoder lifecycle and changed test fixtures; inspected the changed renderer sections and their cache and pipeline callers. The full renderer files were not read in full.; nothing run (a code review).Checked and fine:
Testing: No code, tests, builds, or project scripts were run, as requested. The supplied CI data reports no failure unique to this head.
Overlaps and merge order: Unknown; network access was unavailable.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, as omgitsgela took it out of WIP. Nothing was run; a maintainer decides.
@ -90,0 +99,4 @@if (left_out_loaded) return;left_out_loaded = true;const std::string path = cache_path("longshot_left_out.bin");if (FILE* f = fopen(path.c_str(), "rb")) {L5 (should fix): The new cache uses narrow fopen on a UTF-8 path on Windows.
When: When the game or shared shader-cache directory contains characters outside the Windows ANSI code page, opening the cache fails, so the rejection is translated again on every launch.
Do: Use the repository's UTF-8-safe file-opening approach for both reads and writes.
@ -1621,6 +1654,7 @@ void translate_into(Program& p, const NvnState& s, const Code* vsc, const Code*// (an allocation refused in the translation fails this program (NewNothrow), rather than wait 5 s in the renderer's// new_handler and stop the game: a bad shader can ask for a size no PC has)const NewNothrow nothrow;if (left_out_known(p.key)) throw std::runtime_error(network_left_out);L2 (blocking): The persistent rejection is keyed only by program, although the decision to reject depends on the device, its capabilities, translator behavior and switches.
When: A network rejected on an AMD GPU is recorded; after switching to a capable NVIDIA GPU, or setting RX_VK_NETWORK_KEEP=all, the early lookup throws before the current device and switch are checked, so the network remains disabled.
Do: Key or invalidate the cache using all inputs to the rejection decision, including device capabilities, relevant switches and translator version, or avoid persisting the decision.
@ -565,0 +575,4 @@for (;;) {AcquireSRWLockExclusive(&d->lock);while (!d->worker_quit && (!d->phead || d->qn >= MAX_QUEUE)) {ReleaseSRWLockExclusive(&d->lock);L3 (blocking): Checking for one free queue slot before decoding does not ensure that all pictures produced by a packet or drain fit.
When: With seven pictures queued, an end-of-stream drain can return several delayed FFmpeg or AV1 pictures. queue_frame drops the oldest whenever the ring fills, so pictures are discarded even though the worker is described as waiting instead.
Do: Provide backpressure for every produced picture, including drain output, or retain excess output until the consumer frees space.
@ -565,0 +581,4 @@}if (d->worker_quit) {ReleaseSRWLockExclusive(&d->lock);break;L1 (blocking): The worker holds the same exclusive lock used by Acquire and Submit throughout decode_next, including the decoder call and frame copies.
When: If Acquire arrives during the reported 94–128 ms decode, it blocks on d->lock before it can take an already queued picture; Submit also blocks at submit_refused. Moving the call to another thread therefore does not remove the decode stall from those paths.
Do: Remove the pending packet under the lock, decode into worker-owned state without holding the queue lock, and lock only to publish pictures and update shared state.
@ -565,0 +600,4 @@if (!d || d->worker_on || !worker_enabled()) return;d->worker_quit = 0;d->worker = CreateThread(NULL, 0, dec_worker_main, d, 0, NULL);d->worker_on = d->worker != NULL;L4 (should fix): A failed worker creation leaves the decoder on the worker path with no worker to consume its pending packets.
When: If CreateThread fails, Submit still returns success and Acquire skips decode_pending because worker_enabled remains true. The queue fills and the movie never receives decoded pictures.
Do: Handle thread-creation failure explicitly, either returning an error or switching that decoder to a functioning synchronous fallback.
@ -565,0 +594,4 @@static int worker_enabled(void) {static int off = -1;if (off < 0) off = env_on("HOS_VIDEO_WORKER_OFF");return !off;L7 (blocking): The new HOS_VIDEO_WORKER_OFF switch has no row in the required switch table.
When: Developers looking up host switches cannot find the fallback or its default, and the repository requires every switch to have a row.
Do: Add the switch and its default to gpu/vk/switches.def, or remove the fallback switch once it is no longer needed.
@ -104,7 +107,11 @@ static void hos_system_event_clear(uint64_t key) { event_state[key] = 0, clears+static uint64_t ids;static uint64_t submitted(void) { submissions++; return ++ids; }typedef void *HANDLE;L6 (blocking): The changed fixtures stub out the worker and exercise only the legacy path, leaving the new behavior and lifecycle untested.
When: Removing the worker's decode call or breaking its stop and restart behavior would not make these checks fail, although production movies would stop producing pictures or hang.
Do: Add game-free behavioral tests for worker submission, bounded output, EOS, flush, stop and restart, including the worker-creation failure path; retain fallback coverage separately.
@fix
77a1289804dd55a26adbRecommendation: Request changes. The worker’s submission and lifecycle behavior still has no behavioral test, including its shutdown and restart paths. The reported reduction in skipped pictures is promising, but it predates the final code and comes from single runs on an older base.
What
@fixchangedI changed this pull request: the new head is
dd55a26adb. I rebased it ontomain(ba3f14dff1). I edited its description to match the change.Changed
Not done
Nothing was built or run: the checks run again on the new head.
The change moves movie decoding to a worker, prewarms movie upscaling, and caches shader translation rejections. It could reduce skipped movie pictures, at the cost of another thread, queued pictures, startup work, and more lifecycle complexity.
Blocking (1): must change before merging.
tests/test_video_input_limit.py:110: The changed fixtures stub out the worker and exercise only the legacy path, leaving the new behavior and lifecycle untested. When: Removing the worker's decode call or breaking its stop and restart behavior would not make these checks fail, although production movies would stop producing pictures or hang. Do: Add game-free behavioral tests for worker submission, bounded output, EOS, flush, stop and restart, including the worker-creation failure path; retain fallback coverage separately. (for the author:@fixcouldn't: The input-limit fixture still stubs the worker. Behavioral coverage for submission, bounded output, EOS, flush, stop, restart, and worker-creation failure remains missing.)Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
Checks: they run again on this head (
CI / Third-party parts and guide screenshots (pull_request),CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request),CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request),CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request),CI / Game-free checks (run_all.py, part 1/2) (pull_request)failed on the last one); a failure shows on the pull request.Also noticed (4; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Unproven for the final code. The reported Deck comparison reduced skips from 532 to 16 in the first minute and 593 to 34 over the full movie, but used single runs on an older base and an earlier version of the change.
Other systems: The worker affects Linux and Windows movie decoding, including the Windows Media Foundation path. The renderer changes affect startup and shader translation across GPU vendors and drivers; the description reports no final-code runs on those other systems.
Switches: HOS_VIDEO_WORKER_OFF is added, default off, enabling the worker; its switch-table row describes the synchronous fallback. The default is not yet supported by measurements on all affected Tier 1 systems.
Reviewed:
dd55a26adbagainstba3f14dff1: Read AGENTS.md, CONTRIBUTING.md, the pull request template, standards, the fix diff, the relevant decoder and input-limit fixture code, and the reported runs. The full base diff and all changed files were not read in full; the sibling Tooling rules and docs/review-checklist.md were unavailable.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run code were executed. The reported Deck run exercised an earlier version; CI has not run on this head.
Overlaps and merge order: Not checked; network access is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.
@ -550,2 +606,4 @@avcodec_send_packet(d->ctx, NULL);drain(d);avcodec_flush_buffers(d->ctx);}L17 (should fix): The last picture can be acquired before the worker marks it as the stream's last picture.
When: If Acquire removes the final queued picture while the worker is finishing the EOS drain, the queue is empty when the worker sets eos, so that picture is returned without its last flag. A later acquire instead marks a reused buffer as last.
Do: Coordinate publication of the final picture and EOS so the actual final picture receives the last flag before Acquire can detach it.
@ -778,11 +899,12 @@ static void dec_acquire(Ctx *c) {static int by_tries = -1;L18 (blocking): Acquire waits for a second picture even when one decoded picture is ready and no further submission is pending.
When: When the worker catches up to the game's submissions with one picture queued, the game thread enters Acquire before submitting again. Acquire waits up to 100 ms for a successor that this same thread cannot submit during the wait, then returns the pool's previous picture instead of the ready picture.
Do: Preserve the final-picture marking guarantee without waiting for a successor that has not been submitted, and return the available picture promptly.
Added the worker lifecycle test in
0ac3276d: tests/test_video_worker.py runs the real worker with a fake AV1 decoder and covers submission, bounded output, EOS, stop/restart, and the synchronous fallback when CreateThread fails. The five video checks pass locally with g++; pre-commit passes on the new test. The current-main Deck rerun is still to do. Please re-review.@review
@review
@review
Recommendation: Request changes. The worker test adds useful coverage, but it still does not exercise flush or verify that a restarted worker decodes a new submission. The reported performance gain also needs repeated current-base comparisons and runs on the other affected Tier 1 systems.
The change moves movie decoding off the acquire path, prewarms the movie upscale pipeline, and caches unsupported network programs. It adds a worker thread and queue, startup GPU work, and a persistent cache.
Blocking (1): must change before merging.
tests/test_video_input_limit.py:110: The lifecycle fixture does not test flush, and its restart assertion can pass on the picture produced before the stop. When: After the first worker produces one picture, qn remains 1. The restart wait immediately succeeds at target 1 even if the restarted worker never decodes the second packet; dec_flush is not included or called by the fixture. Do: Exercise the production flush path with queued or in-flight work, and verify that a post-stop submission produces a distinct new picture after restart. (for the author:@fixcouldn't: The new fixture exercises the worker, bounded ring, EOS, direct stop and creation failure, but it never calls dec_flush. Its restart check waits for qn >= 1 while the first picture is still queued, so)Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
Since the last review (on
dd55a26adb)Resolved: L10 (The check
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request)fails on this he…); L12 (The checkCI / Renderer build check (Linux, compile --only renderer, without and with FSR…) Still open: L6 (The lifecycle fixture does not test flush, and its restart assertion can pass on the pictu…); L8 (The reported improvement is from single runs on an older base, and startup prewarming and…); L9 (The checkCI / Third-party parts and guide screenshots (pull_request)fails on this head…); L11 (The checkCI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request)fails on th…); L13 (The checkCI / Game-free checks (run_all.py, part 1/2) (pull_request)fails on this head…); L14 (The checkCI / Game-free checks (run_all.py, part 2/2) (pull_request)fails on this head…); L15 (The checkCI / Website build and checks (pull_request)fails on this head and passes on…); L16 (The checkPR description / Title and description (pull_request_target)` fails on this hea…)Checks: Failing on this head, which is behind its base, where they pass:
CI / Third-party parts and guide screenshots (pull_request),PR description / Title and description (pull_request_target),CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request),CI / Website build and checks (pull_request),CI / Game-free checks (run_all.py, part 1/2) (pull_request).@rebase(or@fix) brings it up to date and runs them again; not held against it. Still running:CI / Game-free checks (run_all.py, part 2/2) (pull_request).More: does it help, other systems, switches, what was read
Does it help: Unproven on the current base. The author's single-run Deck comparison on an older base reports skips falling from 532 to 16 in the first minute and from 593 to 34 over the full movie.
Other systems: The decoder worker affects Windows and Linux movie playback; Media Foundation on Windows has not been exercised. Pipeline prewarming and shader rejection caching affect other Vulkan devices and drivers; the reported game run covers the Deck LCD only.
Switches: HOS_VIDEO_WORKER_OFF is added, default off, enabling the worker. The default supports the intended gain, but its behavior still needs the platform runs in L8.
Reviewed:
0ac3276db1against8704589992: Read the new worker test in full, the changes since the ledger, the production diff and relevant worker and flush references. Read AGENTS.md, CONTRIBUTING.md and the pull request template; docs/review-checklist.md and ../Tooling/AGENTS.md were absent. The large production files and other changed fixtures were not read in full.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run project code were executed. The author reports five Linux video checks passing; one game-free CI check is still running.
Overlaps and merge order: none found
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@fix
Recommendation: Request changes. The worker lifecycle test still does not exercise flush, and its restart assertion can pass without decoding the new submission. The reported performance improvement also needs repeated current-base comparisons and runs on the other affected systems.
What
@fixchangedI changed this pull request: the new head is
ac42165ab9. I mergedmain(e6a71a1d18) into it, as it has merge commits.Nothing was built or run: the checks run again on the new head.
Movie decoding moves off the acquire path, while startup prewarming and a shader rejection cache aim to reduce movie stalls. This adds a worker and packet queue per decoder, startup GPU work, and a persistent cache.
Blocking (1): must change before merging.
tests/test_video_input_limit.py:110: The lifecycle fixture does not test flush, and its restart assertion can pass on the picture produced before the stop. When: After the first worker produces one picture, qn remains 1. The restart wait immediately succeeds at target 1 even if the restarted worker never decodes the second packet; dec_flush is not included or called by the fixture. Do: Exercise the production flush path with queued or in-flight work, and verify that a post-stop submission produces a distinct new picture after restart. (for the author:@fixcouldn't: The fixture never calls dec_flush. Its restart check still waits for qn >= 1 without removing the first picture, so it can pass before the second submission is decoded.)Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
Checks: they run again on this head (
CI / Third-party parts and guide screenshots (pull_request),CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request),CI / Game-free checks (run_all.py, part 1/2) (pull_request),CI / Game-free checks (run_all.py, part 2/2) (pull_request),CI / Website build and checks (pull_request)failed on the last one); a failure shows on the pull request.Also noticed (1; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Unproven for the final code: one older-base Deck comparison reports skipped pictures falling from 532 to 16 in the first minute and from 593 to 34 over the full movie. Repeated interleaved current-base runs are missing.
Other systems: The worker affects Linux and Windows decoder lifecycles, including Media Foundation AV1; prewarming and shader caching affect Vulkan devices. Windows, AMD discrete and Intel runs remain unreported.
Switches: HOS_VIDEO_WORKER_OFF is added, default off, enabling the worker by default; setting it restores synchronous acquire decoding. The default still needs the reported platform runs.
Reviewed:
ac42165ab9againste6a71a1d18: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the worker lifecycle fixture and the relevant decoder lifecycle code. Skimmed the Vulkan diff and switch table. The remaining changed files and full Vulkan code were not read in this re-check.; nothing run (a code review).Checked and fine:
Testing: No commands that run project code or tests were executed. The author reports five video checks passing on Linux and one older-base Deck comparison; CI has not yet run on this head.
Overlaps and merge order: The base diff includes the merged code-warm btrfs change, #2916.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.
@fix
Recommendation: Request changes. The worker lifecycle test still does not exercise flush, and its restart assertion can pass using the picture queued before stop. The reported performance gain also needs repeated comparisons on the current base and runs on the other affected Tier 1 systems.
What
@fixchangedI changed this pull request: the new head is
2432708821.Changed
Left for the author
mise run testand, if it passes, tick the corresponding PR-description checkbox. The HOS_VIDEO_WORKER_OFF switch already has a row in gpu/vk/switches.def:270.Nothing was built or run: the checks run again on the new head.
Movie decoding moves to a worker, with startup prewarming and a shader rejection cache intended to reduce skipped pictures. The fix updates guide image source fingerprints without changing the movie path; the worker adds a thread and packet queue per decoder.
Blocking (1): must change before merging.
tests/test_video_input_limit.py:110: The lifecycle fixture does not test flush, and its restart assertion can pass on the picture produced before the stop. When: After the first worker produces one picture, qn remains 1. The restart wait immediately succeeds at target 1 even if the restarted worker never decodes the second packet; dec_flush is not included or called by the fixture. Do: Exercise the production flush path with queued or in-flight work, and verify that a post-stop submission produces a distinct new picture after restart. (for the author:@fixcouldn't: The worker fixture still never calls dec_flush, and its restart check waits for qn >= 1 without first removing the picture produced before worker_stop.)Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
Checks: they run again on this head (
CI / Third-party parts and guide screenshots (pull_request),CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request),CI / Game-free checks (run_all.py, part 1/2) (pull_request),CI / Game-free checks (run_all.py, part 2/2) (pull_request),CI / Website build and checks (pull_request)failed on the last one); a failure shows on the pull request.Also noticed (1; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Unproven on the current base: the reported older-base Deck runs reduced first-minute skips from 532 to 16 and full-movie skips from 593 to 34, but used single runs per arm.
Other systems: The worker affects Linux and Windows decoder paths; renderer prewarming and the cache affect Vulkan devices. Windows Media Foundation and other Linux GPUs remain untested according to the PR.
Switches: HOS_VIDEO_WORKER_OFF is added, default off, enabling worker decoding; setting it restores synchronous Acquire decoding. The default's cross-platform behavior remains to be tested.
Reviewed:
2432708821againste6a71a1d18: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the full worker lifecycle fixture, the fix diff, the guide source review, and relevant switch and lifecycle references. Skimmed the manifest changes and input-limit test diff; the rest of the changed code was not read in full. The review checklist and adjacent Tooling AGENTS.md were absent.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run tests were executed. The author reports five Linux video checks passing; CI has not run on this head.
Overlaps and merge order: Not checked; network access is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.
Worker-test evidence on the Deck as well: tests/test_video_worker.py passes there with clang 23.1.5, and all five video checks pass. The current-head game-free run reports 14 pre-existing fixture failures unrelated to the video files; test_video_worker.py is not among them. I also started a clean current-main base build on the Deck with the new builder/toolchain, but it stops at the game dump because no .nup or romfs/exefs dump is present there. The current-base movie run still needs that dump.
@review
Recommendation: Request changes. The worker lifecycle test still does not exercise flush, and its restart assertion can pass without the restarted worker decoding anything. The reported movie improvement also needs repeated current-base and affected-platform runs.
Movie decoding moves off the Acquire path, and the renderer prewarms movie upscaling and caches rejected shader translations. The change adds a worker and packet queue per decoder, plus startup and cache work.
Blocking (1): must change before merging.
tests/test_video_input_limit.py:110: The lifecycle fixture does not test flush, and its restart assertion can pass on the picture produced before the stop. When: After the first worker produces one picture, qn remains 1. The restart wait immediately succeeds at target 1 even if the restarted worker never decodes the second packet; dec_flush is not included or called by the fixture. Do: Exercise the production flush path with queued or in-flight work, and verify that a post-stop submission produces a distinct new picture after restart. (for the author:@fixcouldn't: tests/test_video_worker.py never calls dec_flush. Its restart check waits for qn >= 1 while the picture from before worker_stop remains queued, so it can pass before the restarted worker produces a pi)Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
Since the last review (on
2432708821)Still open: L6 (The lifecycle fixture does not test flush, and its restart assertion can pass on the pictu…); L8 (The reported improvement is from single runs on an older base, and startup prewarming and…); L9 (The check
CI / Third-party parts and guide screenshots (pull_request)fails on this head…); L11 (The checkCI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request)fails on th…); L13 (The checkCI / Game-free checks (run_all.py, part 1/2) (pull_request)fails on this head…); L14 (The checkCI / Game-free checks (run_all.py, part 2/2) (pull_request)fails on this head…); L15 (The checkCI / Website build and checks (pull_request)fails on this head and passes on…); L16 (The checkPR description / Title and description (pull_request_target)fails on this hea…)Checks: Failing on this head, which is behind its base, where it passes:
PR description / Title and description (pull_request_target).@rebase(or@fix) brings it up to date and runs it again; not held against it. Still running: 10 checks.More: does it help, other systems, switches, what was read
Does it help: Unproven on the current base: the reported Deck comparison on an older base reduced skipped pictures from 532 to 16 in the first minute and from 593 to 34 over the full movie, but used one run per arm. Repeated current-base comparisons are still needed.
Other systems: The worker and renderer changes affect Windows and Linux, GPU drivers and movie decoding paths. The reported Deck run covers AMD RADV; Windows Media Foundation and other Linux GPU runs remain outstanding.
Switches: HOS_VIDEO_WORKER_OFF defaults to the worker enabled and retains the legacy path when set. The shader rejection cache switch was not fully assessed in this re-check.
Reviewed:
631460ef16againste6a71a1d18: Read AGENTS.md, CONTRIBUTING.md, the changed test fixture and worker lifecycle fixture; inspected the change since the ledger and the commit and diff summaries. The full pull-request diff, changed production files, remaining tests, generated files and referenced repository standards were not read in full.; nothing run (a code review).Checked and fine:
Testing: No tests or project code were run. The author reports five video checks passing and an older-base Deck game comparison; CI is still running.
Overlaps and merge order: Not checked; network access is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
Current-main A/B is done on the Deck LCD. Clean base @
87045899built on the Deck, 926/926 units, 0 failed; the pack is from0ac3276d. Two interleaved first-minute runs per arm, both runtimes warm:The fix log has both movie-upscale prewarm lines. The worker test also passes on the Deck with clang 23.1.5. This removes the current-base rerun from Still to test; Windows Media Foundation and non-Deck Linux GPUs remain.
@fix
Recommendation: Request changes. The worker lifecycle test still does not exercise flush or prove that the restarted worker produced a new picture. Windows Media Foundation and other affected hardware runs also remain outstanding.
What
@fixchangedI changed this pull request: the new head is
c5799d70f7. I mergedmain(4908cc6dad) into it, as it has merge commits.Nothing was built or run: the checks run again on the new head.
The change moves movie decoding off the acquire thread and prewarms the movie upscale path. The Deck measurements show substantially fewer skipped pictures, at the cost of a worker thread and packet queue per decoder.
Blocking (1): must change before merging.
tests/test_video_input_limit.py:110: The lifecycle fixture does not test flush, and its restart assertion can pass on the picture produced before the stop. When: After the first worker produces one picture, qn remains 1. The restart wait immediately succeeds at target 1 even if the restarted worker never decodes the second packet; dec_flush is not included or called by the fixture. Do: Exercise the production flush path with queued or in-flight work, and verify that a post-stop submission produces a distinct new picture after restart. (for the author:@fixcouldn't: The fixture does not call dec_flush, and its restart check can still accept the picture left queued before worker_stop.)Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
Checks: they run again on this head (
CI / Third-party parts and guide screenshots (pull_request),CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request),CI / Game-free checks (run_all.py, part 1/2) (pull_request),CI / Game-free checks (run_all.py, part 2/2) (pull_request),CI / Website build and checks (pull_request)failed on the last one); a failure shows on the pull request.More: does it help, other systems, switches, what was read
Does it help: Yes on the tested Deck LCD: two current-base first-minute runs fell from 694 and 470 skipped pictures to 13 and 0, according to the pull request and author’s test report. Other affected systems remain untested.
Other systems: The Windows Media Foundation AV1 path and movie playback on other Linux GPUs remain untested. The worker and prewarm paths can affect decoding, synchronization and startup on those systems.
Switches: HOS_VIDEO_WORKER_OFF defaults to off, enabling the worker; setting it to 1 selects synchronous decoding. The reported Deck measurements support the default there, but the outstanding platform runs are needed to assess it elsewhere.
Reviewed:
c5799d70f7against4908cc6dad: Read the repository rules, pull request template, worker fixture and movie decoder diff; inspected lifecycle references and the switch diff. Other changed code, generated files and recorded artifacts were not read in full. The checkout resolves HEAD toc5799d70f, not the stated631460ef16, so the requested exact-head recheck could not be completed.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run project code were executed. CI is reported as not yet run on the stated head.
Overlaps and merge order: none found
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.
@fix fix the test
Human review on the Deck, fixed runtime rt-current-fix, intro/title movie: no visual issues observed and no noticeable audio/video delay. This is a visual and sync observation to sit alongside the measured skip runs; the real save was not used.
Recommendation: Request changes. The worker lifecycle test still does not exercise flush or establish that the restarted worker produced a new picture. Those gaps leave the blocking test item unresolved.
What
@fixchangedI changed this pull request: the new head is
8b8d92e6ad. I edited its description to match the change.Changed
Nothing was built or run: the checks run again on the new head.
The change moves movie decoding off the acquire path and prewarms the upscale pipeline, reducing skipped pictures in the reported Deck runs at the cost of a worker thread and packet queue. The latest fix repairs the pipeline-cache fixture without removing that behavior.
Blocking (1): must change before merging.
tests/test_video_input_limit.py:110: The lifecycle fixture does not test flush, and its restart assertion can pass on the picture produced before the stop. When: After the first worker produces one picture, qn remains 1. The restart wait immediately succeeds at target 1 even if the restarted worker never decodes the second packet; dec_flush is not included or called by the fixture. Do: Exercise the production flush path with queued or in-flight work, and verify that a post-stop submission produces a distinct new picture after restart. (for the author:@fixcouldn't: tests/test_video_worker.py still does not call dec_flush. After worker_stop, the restart check waits for qn >= 1 without removing the existing picture, so it can pass before the restarted worker decod)Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
Checks: they run again on this head (
CI / Third-party parts and guide screenshots (pull_request),CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request),CI / Game-free checks (run_all.py, part 1/2) (pull_request),CI / Game-free checks (run_all.py, part 2/2) (pull_request),CI / Website build and checks (pull_request)failed on the last one); a failure shows on the pull request.More: does it help, other systems, switches, what was read
Does it help: Yes. The reported two interleaved first-minute Deck runs dropped from 694 and 470 skipped pictures on the base to 13 and 0 with the change. Windows and other affected systems remain untested.
Other systems: The worker also changes the Windows Media Foundation path, and prewarming affects other Vulkan devices. The reported game runs cover the Deck; the other affected Tier 1 systems still need runs.
Switches: HOS_VIDEO_WORKER_OFF defaults off, enabling the worker; setting it restores synchronous decoding. The reported Deck measurements support the default there, but other affected systems have not yet been tested.
Reviewed:
8b8d92e6adagainst4908cc6dad: Read AGENTS.md, CONTRIBUTING.md, the pull request template, tests/test_pipeline_play_cache.py and tests/test_video_worker.py; inspected the pipeline-cache fixture and the changed source around the extracted functions. The full pull request code and all changed files were not read in full; the review checklist and sibling Tooling rules were not present.; nothing run (a code review).Checked and fine:
Testing: No commands from the project were run. The author reports five video checks passing and Deck game measurements; CI has not yet run on this head.
Overlaps and merge order: Not checked; network access is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.
This PR's movie upscale prewarm should also fix two open Intel reports: #2477 (Iris Xe, Mesa 26.2.7, v3.2.0) and #2935 (Iris Xe, Mesa 26.3.1, nightly-971). Both are Linux with Mesa's Intel driver, and both show a black window from the opening movie on, with no input and no fullscreen.
Why they hang. Numbers are from #2935's log; line numbers are on main
4908cc6d.load at create: 717 of 4684 steps done, nothing finished for 30 s). The game goes on while those builds keep running in the driver.not translated: a network left out on this card), so the linearmovie_upscalestands in for them.movie_upscale(gpu/vk/vk_draw.cpp:10803) builds its pipeline the first time it's used, on the Presentation Thread. The path istexture_compute_pipeline → shared_compute_pipeline → cached_compute → ComputeTurn(vk_draw.cpp:2083).ComputeTurnwaits at the compute gate (gpu/vk/compute_gate.h), which is on by default on Mesa Intel. The fallback compiles ahead of it take minutes each on that compiler. #2477's stack shows the Presentation Thread waiting there, and 17precompile_at_createthreads waiting there too.Why this PR helps.
movie_upscale_prewarm()runs inpcache_init(), whichprecompile_runcalls beforetexture_pipelines_warm()and the load-at-create fallback builds. The pipeline is then ready before the gate fills, so the first movie frame doesn't wait in it.Three suggestions, none of them blocking:
vk: movie upscale pipeline prewarmed: yesbefore thenothing finished for 30 sline, then check that the opening plays.typed_upscale, the mask helper and FSR 3's pipelines. They could wait the same way if they're first needed while fallback builds still run. That's beyond this PR's topic, but worth knowing if an Intel run still stalls after the movie.I won't open a separate fix for #2935, so it can land with this PR.
L6 is addressed at
c320f754. tests/test_video_worker.py now cuts the production dec_flush path, flushes a queued picture plus a pending submission, asserts qn and phead are cleared, asserts the worker is joined and stopped, and requires the restarted worker's picture to be the new submission with pts 99 rather than the pre-flush picture. A second case flushes submissions that were never decoded. Focused test and the five video checks pass; a disposable mutation that leaves qn alone fails both new assertions. Please re-review at this head.b41a5cb7answers the independent review and refreshes the measurement on current main.4908cc6d: 779/495 skipped pictures in the stock first minute versus 59/1 with the fix; the PR body now carries the table and the exactb41a5cb7pack head.Focused video checks, the pipeline cache check, the short-sleep check and pre-commit pass. CI is running on
b41a5cb7; the PR-description check still waits on mise run test, and the third-party/guide job is the same source-drift failure.@review
Recommendation: Request changes. The Deck measurements show a substantial reduction in movie skips, and the flush fixture now checks the requested lifecycle behavior. Windows Media Foundation and the other affected Tier 1 systems still need runs. (It stands on L9: The check
CI / Third-party parts and guide screenshots (pull_request)fails on this head and passes on the base branch: Failing after 24s.)Movie decoding moves to a worker, while startup prewarming and a scoped rejection cache reduce movie shader preparation costs. This adds a thread and queue lifecycle per decoder and startup cache work.
Blocking (2): must change before merging.
CI / Third-party parts and guide screenshots (pull_request)fails on this head and passes on the base branch: Failing after 24s.PR description / Title and description (pull_request_target)fails on this head and passes on the base branch: Failing after 8s. (for the author:@fixcouldn't: its check runs again on this head)Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
@fixcan do L9.Since the last review (on
8b8d92e6ad)Resolved: L6 (The lifecycle fixture does not test flush, and its restart assertion can pass on the pictu…)
Still open: L8 (The worker and startup prewarming have not been exercised on the other affected Tier 1 sys…); L9 (The check
CI / Third-party parts and guide screenshots (pull_request)fails on this head…); L11 (The checkCI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request)fails on th…); L13 (The checkCI / Game-free checks (run_all.py, part 1/2) (pull_request)fails on this head…); L14 (The checkCI / Game-free checks (run_all.py, part 2/2) (pull_request)fails on this head…); L15 (The checkCI / Website build and checks (pull_request)fails on this head and passes on…); L16 (The checkPR description / Title and description (pull_request_target)fails on this hea…)Checks: Still running: 7 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes on the tested Deck LCD: two current-base first-minute runs fell from 779 and 495 skipped pictures to 59 and 1, with both arms prepared warm. Behavior on the other affected systems remains unverified.
Other systems: Windows Media Foundation AV1 callback behavior and movie playback on other Linux GPUs remain untested. The renderer prewarm and cache can affect drivers beyond the tested RADV Deck.
Switches: HOS_VIDEO_WORKER_OFF is added, default off, enabling the worker; setting it to 1 restores Acquire decoding. The default is supported by the Deck results but still needs the platform runs.
Reviewed:
b41a5cb7efagainst4908cc6dad: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the changes since the ledger, and the relevant worker, submit, flush, and finalize paths. Skimmed the overall change statistics and commits; the full base diff and all changed files were not read in full.; nothing run (a code review).Checked and fine:
Testing: The author reports focused video and timer checks passing, including ThreadSanitizer, and an in-game Deck visual and audio-sync check. CI has two head-only failures and several checks still running; no commands or tests were run for this review.
Overlaps and merge order: Intel reports #2477 and #2935 may also benefit from prewarming, but an Intel run has not confirmed this.
Automated code review by BeanBot (gpt-6.1-terra), asked for by omgitsgela. Nothing was run; a maintainer decides.
@rebase
This pull request has merge commits, so I brought it up to date by merging
main(55773e3613) into it rather than rebasing (its history stays as it is): the new head isc710f82d40.Conflicts resolved
Nothing was built or run: read the resolution before merging.
Automated rebase by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
Recommendation: Approve. The Deck measurements show substantially fewer skipped movie pictures, but the worker and startup prewarm still need runs on the other affected Tier 1 systems. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge.
Moves movie decoding off the Acquire path, prewarms the movie upscale pipeline and caches rejected network programs. It adds a worker and packet queue per decoder, plus startup GPU work and a cache file.
Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
Since the last review (on
b41a5cb7ef)Still open: L8 (The worker and startup prewarming have not been exercised on the other affected Tier 1 sys…); L9 (The check
CI / Third-party parts and guide screenshots (pull_request)fails on this head…); L11 (The checkCI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request)fails on th…); L13 (The checkCI / Game-free checks (run_all.py, part 1/2) (pull_request)fails on this head…); L14 (The checkCI / Game-free checks (run_all.py, part 2/2) (pull_request)fails on this head…); L15 (The checkCI / Website build and checks (pull_request)fails on this head and passes on…); L16 (The checkPR description / Title and description (pull_request_target)fails on this hea…)Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes on the Steam Deck LCD: the reported interleaved current-base first-minute runs fell from 779 and 495 skipped pictures to 59 and 1. Both arms were warmed and used the same settings; other systems remain untested.
Other systems: The worker also affects Windows Media Foundation and other Linux decoder paths; prewarming and the rejection cache affect Vulkan devices beyond the Deck. The reported runs do not yet establish their behavior on those systems.
Switches: HOS_VIDEO_WORKER_OFF is added, default off; setting it to 1 restores Acquire-path decoding. The worker default is supported by the Deck results, but its behavior on the remaining platforms is still to be checked.
Reviewed:
c710f82d40against55773e3613: Read AGENTS.md and CONTRIBUTING.md and inspected the host and renderer diffs, commit list and reported runs. The guide manifest changes and remaining test and documentation changes were skimmed; the full changed code files were not read.; nothing run (a code review).Checked and fine:
Testing: No code or tests were run for this review. The author reports focused Linux checks and a ThreadSanitizer pass; CI is still running.
Overlaps and merge order: No overlapping pull requests identified from the supplied information.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its rebase. Nothing was run; a maintainer decides.