presentation: copy the video-out subresource the texture cache resolved #2372

Closed
github-bot wants to merge 2 commits from gh-pr/2372/head into gh-pr/2372/base
Owner

@⁠Nawid3333 on GitHub · 2026-11-18 06:17 UTC · original
Nawid3333:fix/present-resolved-subresource → main · +149 −18 · 3 files · 2 commits · closed without merging

Problem

Beat Saber (PPSA15035, #2337) stops at its first flips. @⁠Crispy81's log on official 1e87171:

Error: condition (copy.srcSubresource.layerCount != copy.dstSubresource.layerCount) is true in ...\src\graphics\presentation\window\swapchain.cpp:219

Presenter::Impl::ResolveSurface looks the flip address up with FindImage, asking for level 0, layer 0 and one layer. When a larger cached image covers the address, FindImage returns that image: at the image's start address the view keeps level 0 and layer 0 (textureCache.cpp:811-817 at 2638b1b07), inside it the view gets the matching level and layer (textureCache.cpp:830-834, 1316-1321). ResolveSurface returned only the Image&, and Frame::CopyFrom copied all source.backing.layers layers into the one-layer frame, so an array image at the flip address ends in the layer-count EXIT_IF (swapchain.cpp:219).

In Beat Saber the flipped buffer is the left eye texture ("Hmd2: separate eye textures are not supported; showing the left one"), the start of a cached two-layer 1632x1836 image. A diagnostic build printed presentation copy layer mismatch: source layers=2 extent=1632x1836 format=64 | frame layers=1 extent=1632x1836 format=64.

Change

  • ResolveSurface returns a PresentSource: the image plus the base_level and base_layer that FindImage resolved.
  • CopyFrom copies that one level and layer into layer 0 of the frame, and the copy extent is that level's extent, clamped to the frame as before.
  • PrepareFrame sizes the frame from that level's extent.
  • A flip of a one-layer image at level 0 (every flip that worked before) copies the same region as before.

Tests

shader_recompiler_compute_tests --present-array-layer-only (CTest video_out_array_layer, next to pm4_flip and video_out_flip_rate): a cached two-layer 128x128 R8G8B8A8Srgb render target has one video-out buffer of the same format and extent on each layer (the array start and the second layer's 64 KiB slice), and the flip of each must complete. The presenter has no frame readback, so the test checks that both flips complete, not the copied pixels.

RX 9070 XT (Windows 11, clang-cl): with the change the test passes, and pm4_flip and video_out_flip_rate still pass. With main's swapchain.cpp the same test stops at the game's exact check:

Error: condition (copy.srcSubresource.layerCount != copy.dstSubresource.layerCount) is true in ...\swapchain.cpp:219

Fork build of this head (run 44248180832): Windows, Linux and macOS build.

In a game

  • @⁠Crispy81 ran Beat Saber with a fork build of this commit on 2638b1b (452d8a6). The game got past the presenter and stopped later, in a color resolve between two formats (image.cpp:421), which #2371 fixes.
  • With this commit and #2371 together (fork build 23237f3, run 44195030260), Beat Saber reaches its language selection menu at 30 fps (screenshot in #2337). Going further needs the PS VR2 Sense controllers.

Written with Claude Code (AI): Claude Code found the cause in the reporter's logs, wrote the change and the tester builds; GLM fact-checked this text.

**@⁠Nawid3333** on GitHub · 2026-11-18 06:17 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2372) `Nawid3333:fix/present-resolved-subresource` → `main` · +149 −18 · 3 files · 2 commits · closed without merging ## Problem Beat Saber (PPSA15035, #2337) stops at its first flips. @⁠Crispy81's log on official 1e87171: ``` Error: condition (copy.srcSubresource.layerCount != copy.dstSubresource.layerCount) is true in ...\src\graphics\presentation\window\swapchain.cpp:219 ``` `Presenter::Impl::ResolveSurface` looks the flip address up with `FindImage`, asking for level 0, layer 0 and one layer. When a larger cached image covers the address, `FindImage` returns that image: at the image's start address the view keeps level 0 and layer 0 (textureCache.cpp:811-817 at 2638b1b07), inside it the view gets the matching level and layer (textureCache.cpp:830-834, 1316-1321). `ResolveSurface` returned only the `Image&`, and `Frame::CopyFrom` copied all `source.backing.layers` layers into the one-layer frame, so an array image at the flip address ends in the layer-count `EXIT_IF` (swapchain.cpp:219). In Beat Saber the flipped buffer is the left eye texture ("Hmd2: separate eye textures are not supported; showing the left one"), the start of a cached two-layer 1632x1836 image. A diagnostic build printed `presentation copy layer mismatch: source layers=2 extent=1632x1836 format=64 | frame layers=1 extent=1632x1836 format=64`. ## Change - `ResolveSurface` returns a `PresentSource`: the image plus the `base_level` and `base_layer` that `FindImage` resolved. - `CopyFrom` copies that one level and layer into layer 0 of the frame, and the copy extent is that level's extent, clamped to the frame as before. - `PrepareFrame` sizes the frame from that level's extent. - A flip of a one-layer image at level 0 (every flip that worked before) copies the same region as before. ## Tests `shader_recompiler_compute_tests --present-array-layer-only` (CTest `video_out_array_layer`, next to `pm4_flip` and `video_out_flip_rate`): a cached two-layer 128x128 `R8G8B8A8Srgb` render target has one video-out buffer of the same format and extent on each layer (the array start and the second layer's 64 KiB slice), and the flip of each must complete. The presenter has no frame readback, so the test checks that both flips complete, not the copied pixels. RX 9070 XT (Windows 11, clang-cl): with the change the test passes, and `pm4_flip` and `video_out_flip_rate` still pass. With main's `swapchain.cpp` the same test stops at the game's exact check: ``` Error: condition (copy.srcSubresource.layerCount != copy.dstSubresource.layerCount) is true in ...\swapchain.cpp:219 ``` Fork build of this head ([run 44248180832](https://github.com/Nawid3333/KytyPS5/actions/runs/44248180832)): Windows, Linux and macOS build. ## In a game - @⁠Crispy81 ran Beat Saber with a fork build of this commit on 2638b1b (452d8a6). The game got past the presenter and stopped later, in a color resolve between two formats (`image.cpp:421`), which #2371 fixes. - With this commit and #2371 together (fork build 23237f3, [run 44195030260](https://github.com/Nawid3333/KytyPS5/actions/runs/44195030260)), Beat Saber reaches its language selection menu at 30 fps ([screenshot in #2337](https://git.gtahub.st/github/KytyPS5--KytyPS5/issues/2337)). Going further needs the PS VR2 Sense controllers. Written with Claude Code (AI): Claude Code found the cause in the reporter's logs, wrote the change and the tester builds; GLM fact-checked this text.
FindImage can resolve a flip address into a larger cached image and
reports the matching level and layer through the view info. The
presenter dropped that view and copied every layer of the backing into
the one-layer frame, so a flip of an array surface (Beat Saber, a
two-layer 1632x1836 image) ended in the layer-count EXIT.

Copy only the resolved level and layer, sized to that level's extent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:19:04 +00:00
github-bot closed this pull request 2026-11-26 10:19:04 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-18 06:24 UTC · original

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Presentation sources now include mip and array-layer selection. Frame preparation uses the selected mip’s extent, and frame copying targets the selected mip and layer. A new host test submits flips for both layers of a two-layer image, and CTest can run that test directly.

Suggested reviewers: nmzik, pcniado

Change: Bug fix

Merge Risk: Minimal · up to 75198

Presentation now copies the single mip level and array layer that the texture cache resolves, which fixes the reported Beat Saber layer-count failure on two-layer images. Flips of one-layer images at level 0 behave as before. The new test checks that flips on both layers complete but not the displayed pixels. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the change the presenter now makes: it copies the video-out subresource (mip level and array layer) that the texture cache resolved. The raw summary and objectives confirm that Resolve…
Description check Passed The description explains the problem (Beat Saber failing at the swapchain.cpp:219 layer-count check), the cause (FindImage resolves a level and layer that the presenter discarded), the change (Resolve…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the change the presenter now makes: it copies the video-out subresource (mip level and array layer) that the texture cache resolved. The raw summary and objectives confirm that ResolveSurface now returns the resolved base level and layer, and CopyFrom copies that subresource. The title is specific and matches the main change.

Full details: Description check

Explanation

The description explains the problem (Beat Saber failing at the swapchain.cpp:219 layer-count check), the cause (FindImage resolves a level and layer that the presenter discarded), the change (ResolveSurface returns a PresentSource, CopyFrom copies one level and layer, PrepareFrame sizes from that level), the added test, and in-game results. It is closely related to the changeset.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 2638b1b076 and 7519894e0b.

Files selected for processing: 3

  • CMakeLists.txt
  • src/graphics/presentation/window/swapchain.cpp
  • tests/ShaderRecompilerComputeTests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-11-18 06:24 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2372#issuecomment-6970919525) <!-- coderabbit-ai-generated:v1 --> <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/2372?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg" alt="Explain Change →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- recent_review_status_start --> No actionable comments were generated in the recent review. <!-- recent_review_status_end --> <!-- walkthrough_start --> <details> <summary><strong>Walkthrough</strong></summary> <dl> <dd> <br> Presentation sources now include mip and array-layer selection. Frame preparation uses the selected mip’s extent, and frame copying targets the selected mip and layer. A new host test submits flips for both layers of a two-layer image, and CTest can run that test directly. **Suggested reviewers:** `nmzik`, `pcniado` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> <!-- change_assessment_commit:"7519894e0bbe819ba5f5164735b06bd38098e799" --> <!-- change_assessment_priority:{"version":1,"urgency":"p2","manual":false} --> **Change:** Bug fix <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/risk-unassessed-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minimal</strong> · up to <code>75198</code></summary> <dl> <dd> <br> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **⚪ Minimal** · up to `75198` --> <!-- final_review_risk_coverage:{"sourceCommitId":"7519894e0bbe819ba5f5164735b06bd38098e799","coveredCommitId":"7519894e0bbe819ba5f5164735b06bd38098e799","kind":"reviewed"} --> Presentation now copies the single mip level and array layer that the texture cache resolves, which fixes the reported Beat Saber layer-count failure on two-layer images. Flips of one-layer images at level 0 behave as before. The new test checks that flips on both layers complete but not the displayed pixels. No concrete merge-blocking risk was found. <!-- final_review_risk_end --> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4</strong></summary> <dl> <dd> <br> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title names the change the presenter now makes: it copies the video-out subresource (mip level and array layer) that the texture cache resolved. The raw summary and objectives confirm that Resolve… | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description explains the problem (Beat Saber failing at the swapchain.cpp:219 layer-count check), the cause (FindImage resolves a level and layer that the presenter discarded), the change (Resolve… | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | <details> <summary><strong>Full details: Title check</strong></summary> <dl> <dd> <br> **Explanation** The title names the change the presenter now makes: it copies the video-out subresource (mip level and array layer) that the texture cache resolved. The raw summary and objectives confirm that ResolveSurface now returns the resolved base level and layer, and CopyFrom copies that subresource. The title is specific and matches the main change. </dd> </dl> </details> <details> <summary><strong>Full details: Description check</strong></summary> <dl> <dd> <br> **Explanation** The description explains the problem (Beat Saber failing at the swapchain.cpp:219 layer-count check), the cause (FindImage resolves a level and layer that the presenter discarded), the change (ResolveSurface returns a PresentSource, CopyFrom copies one level and layer, PrepareFrame sizes from that level), the added test, and in-game results. It is closely related to the changeset. </dd> </dl> </details> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- tips_start --> Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=2372)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>Share</strong></summary> <dl> <dd> <br> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </dd> </dl> </details> <!-- tips_end --> <!-- recent_review_start --> <h6> <details> <summary><strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="12" height="12" align="absmiddle" alt=""></picture> Recent review info</strong></summary> <dl> <dd> <br> <!-- review_info_content --> <details> <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</strong></summary> <dl> <dd> <br> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/2638b1b07613dc32a4708d2cd61a75711b84b6cf/.coderabbit.yaml>) - **Commit**: [2638b1b](<https://github.com/KytyPS5/KytyPS5/commit/2638b1b07613dc32a4708d2cd61a75711b84b6cf>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `741c2e05-71b3-461f-9093-ec3452b2f738` </dd> </dl> </details> <details> <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</strong></summary> <dl> <dd> <br> Reviewing files that changed from the base of the PR and between 2638b1b07613dc32a4708d2cd61a75711b84b6cf and 7519894e0bbe819ba5f5164735b06bd38098e799. </dd> </dl> </details> <details> <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 3</strong></summary> <dl> <dd> <br> * `CMakeLists.txt` * `src/graphics/presentation/window/swapchain.cpp` * `tests/ShaderRecompilerComputeTests.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review. </dd> </dl> </details> </h6> <!-- recent_review_end -->
Author
Owner

@⁠Nmzik on GitHub · 2026-11-18 14:20 UTC · original

Credited

**@⁠Nmzik** on GitHub · 2026-11-18 14:20 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2372#issuecomment-6981276064) Credited

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.