Skip to content

perf(streaming): reclaim 1080i depth memory and configure GPU buffers - #367

Merged
ReenigneArcher merged 3 commits into
masterfrom
codex/reclaim-1080i-depth-buffer
Nov 21, 2026
Merged

ReenigneArcher merged 3 commits into
masterfrom
codex/reclaim-1080i-depth-buffer

Conversation

@ReenigneArcher

@ReenigneArcher ReenigneArcher commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Description

pbkit allocates a 10.55 MiB depth and stencil surface during 1080i GPU setup. Streaming uses the GPU color surface as a background, so it can release the depth surface once setup is complete.

After clearing the background and allocating the requested YUY2 buffers, detach depth and stencil, wait for GPU completion, and free the depth allocation before the first video submission. Keep the allocation order because allocating the spare after freeing depth slowed xemu playback. If detaching depth times out, the presenter returns a fallback reason and leaves cleanup to pbkit.

Settings → Display → GPU Video Buffers applies to new GPU streams at any resolution. Auto tries three buffers for 720p output when the packed frame fits and uses two elsewhere. 2 uses the required pair, and 3 tries a spare. Playback uses two buffers if the spare allocation fails. The preference is saved as streaming.gpu_buffer_count, and the stream log reports the active buffer count.

Screenshot

Issues Fixed or Closed

Roadmap Issues

Testing

Compared base commit 7655ca2 with the depth release and the default buffer policy in Vulkan xemu. Both used 64 MiB of guest RAM, fixed H.264 video, stereo Opus audio, and live stats. The results show new video frames submitted per second and minimum free guest RAM during playback.

Stream mode Before FPS After FPS Before free RAM After free RAM
480p30 29.85 29.98 35.37 MiB 35.39 MiB
480p60 56.59 55.13 35.39 MiB 35.45 MiB
720p30 29.97 30.03 15.59 MiB 15.59 MiB
720p60 56.38 58.22 15.39 MiB 15.58 MiB
1080i30 29.85 29.85 4.96 MiB 15.32 MiB
1080i60 39.70 40.50 4.77 MiB 15.20 MiB

The buffer setting was tested separately at 30 and 60 FPS using the same xemu workload. Each pair compares the Auto policy baseline with the explicit setting.

Stream mode Buffers, Auto → explicit Presented FPS, Auto → explicit Free RAM, Auto → explicit
480p30 2 → 3 29.98 → 30.06 35.39 MiB → 34.79 MiB
480p60 2 → 3 55.13 → 59.53 35.45 MiB → 34.78 MiB
720p30 3 → 2 30.03 → 30.02 15.59 MiB → 17.16 MiB
720p60 3 → 2 58.22 → 58.12 15.58 MiB → 17.34 MiB
1080i30 2 → 3 29.85 → 29.82 15.29 MiB → 11.37 MiB
1080i60 2 → 3 40.32 → 40.45 15.20 MiB → 11.45 MiB
  • cmake --build cmake-build-release --parallel 8 built the Xbox release ISO.
  • ctest --test-dir cmake-build-release --output-on-failure passed all 510 native tests, including buffer count selection across output modes, settings persistence and validation, depth release ordering, and allocation and timeout fallbacks.
  • cmake --build cmake-build-release --target docs passed the strict API docs build.
  • uv run --locked lb-update-clang-format and git diff --check passed.
  • The 1080i xemu runs freed 2,700 pages during setup and returned to the shell. An injected GPU failure after release presented software frames and returned to the shell with either buffer count. In those xemu trials, forced fallback averaged 12.67 FPS with two buffers and 5.69 FPS with three. The settings build also verified that selecting Software bypasses GPU buffers.

Physical Xbox validation is pending.

Type of Change

  • feat: New feature (non-breaking change which adds functionality)
  • fix: Bug fix (non-breaking change which fixes an issue)
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semicolons, etc.)
  • refactor: Code change that neither fixes a bug nor adds a feature
  • perf: Code change that improves performance
  • test: Adding missing tests or correcting existing tests
  • build: Changes that affect the build system or external dependencies
  • ci: Changes to CI configuration files and scripts
  • chore: Other changes that don't modify src or test files
  • revert: Reverts a previous commit
  • BREAKING CHANGE: Introduces a breaking change (can be combined with any type above)

Checklist

  • Code follows the style guidelines of this project
  • Code has been self-reviewed
  • Code has been commented, particularly in hard-to-understand areas
  • Code docstring/documentation-blocks for new or existing methods/components have been added or updated
  • Tests have been added or updated for new or modified functionality, including regression tests for bug fixes

AI Usage

See our AI usage policy.

  • AI tools were used while preparing this PR

@codecov

codecov Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.90909% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.63%. Comparing base (7655ca2) to head (0fb9ef1).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/app/client_state.cpp 79.16% 1 Missing and 4 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #367      +/-   ##
==========================================
+ Coverage   74.49%   74.63%   +0.14%     
==========================================
  Files          72       72              
  Lines        8237     8288      +51     
  Branches     3532     3554      +22     
==========================================
+ Hits         6136     6186      +50     
+ Misses       1101     1099       -2     
- Partials     1000     1003       +3     
Flag Coverage Δ
Linux 73.89% <91.83%> (+0.16%) ⬆️
macOS 63.52% <79.59%> (+0.13%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/app/client_state.h 98.68% <100.00%> (+0.01%) ⬆️
src/app/settings_storage.cpp 78.64% <100.00%> (+0.74%) ⬆️
src/app/settings_storage.h 100.00% <100.00%> (ø)
src/streaming/pvideo_presenter.cpp 81.95% <100.00%> (+3.41%) ⬆️
src/streaming/pvideo_presenter.h 100.00% <100.00%> (ø)
src/streaming/video_acceleration.h 100.00% <ø> (ø)
src/app/client_state.cpp 75.24% <79.16%> (+0.05%) ⬆️

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7655ca2...0fb9ef1. Read the comment docs.

@ReenigneArcher ReenigneArcher changed the title perf(streaming): reclaim the 1080i depth buffer after setup perf(streaming): reclaim 1080i depth memory and configure GPU buffers Nov 21, 2026
@sonarqubecloud

Copy link
Copy Markdown

@ReenigneArcher
ReenigneArcher merged commit 299808d into master Nov 21, 2026
17 checks passed
@ReenigneArcher
ReenigneArcher deleted the codex/reclaim-1080i-depth-buffer branch November 21, 2026 04:36
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