fix(agc): sample multisampled targets in read-only layout #19686

Closed
oneandonlydean wants to merge 3 commits from upstream-pr/19686 into main
oneandonlydean commented 2026-11-13 19:56:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-11-13T19:56:40Z.


What

On the Intel UHD 770 (#6957), a sampled OpImageFetch of a multisampled image in VK_IMAGE_LAYOUT_GENERAL after a compute imageStore returns sample 0's value for every sample index. The stores land (a typed imageLoad sees them); only a GENERAL to SHADER_READ_ONLY_OPTIMAL transition before sampling makes the fetch correct. MultisampleTarget::Sampled() on main only settles the storage writes with a memory barrier and binds the target through the borrowed-image Texture constructor, which hardcodes GENERAL, so agc_driver_sample_multisample_target fails there.

This change:

  • tracks the multisampled target's image layout in MultisampleTarget;
  • moves it to SHADER_READ_ONLY_OPTIMAL in Sampled(), and the sampled Texture view advertises that layout (the borrowed-image Texture constructor takes the layout, default GENERAL, so other callers are unchanged);
  • moves it back to GENERAL before every other use: fast clears, storage writes (Storage(), before makeStorable copies the image), recreation, and color attachment or resolve use through acquire() (PrepareForColorAttachment);
  • updates the Recorder test assertion to expect the read-only layout on the sampled view.

FirstSample() already reads its source through Sampled() with the view's own layout, so its copy follows the new layout.

This re-lands only the read-only-layout slice of #6971, which was folded into #6973. #6973 was backed out by #15935; its initial-contents half is already back on main through #15985, #15986 and #16086. The rest of #6973 (the constructor-time initial guest read and its test changes) is deliberately not part of this PR.

Two commits:

  • The change is MarcZX10's commit from #6971, adapted to the layerCount parameter the borrowed-image Texture constructor has gained since (the layout parameter follows it).
  • Amoenus's fix-up from the #6973 stack, which restores GENERAL when a target is recreated; main has that recreation path in acquire().

Tested

Linux, NVIDIA RTX 4090, Release build with GCC:

On head 5696deb265 (based on main 1d1ff1118d; main has not touched these files since), all 60 tests matching multisample|native_depth|recorder pass, none skipped:

ctest -R 'multisample|native_depth|recorder'
100% tests passed out of 60

This includes agc_driver_sample_multisample_target, agc_driver_native_multisample_depth, every agc_driver_native_depth_* test and agc_driver_recorder (with the updated layout assertion).

The UHD 770 is not available here, so this does not show the Intel fix itself; on the RTX 4090 the tests only show that the layout tracking breaks nothing. I will ask for a UHD 770 rerun of agc_driver_sample_multisample_target on this head in the thread.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none yet; Refs #6957 (closes it once the UHD 770 rerun passes)
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 4090, driver 610.57.04, Linux. Not tested on the Intel UHD 770 the issue is about.
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5301952269 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19686). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-11-13T19:56:40Z. --- ### What On the Intel UHD 770 (#6957), a sampled `OpImageFetch` of a multisampled image in `VK_IMAGE_LAYOUT_GENERAL` after a compute `imageStore` returns sample 0's value for every sample index. The stores land (a typed `imageLoad` sees them); only a `GENERAL` to `SHADER_READ_ONLY_OPTIMAL` transition before sampling makes the fetch correct. `MultisampleTarget::Sampled()` on `main` only settles the storage writes with a memory barrier and binds the target through the borrowed-image `Texture` constructor, which hardcodes `GENERAL`, so `agc_driver_sample_multisample_target` fails there. This change: - tracks the multisampled target's image layout in `MultisampleTarget`; - moves it to `SHADER_READ_ONLY_OPTIMAL` in `Sampled()`, and the sampled `Texture` view advertises that layout (the borrowed-image `Texture` constructor takes the layout, default `GENERAL`, so other callers are unchanged); - moves it back to `GENERAL` before every other use: fast clears, storage writes (`Storage()`, before `makeStorable` copies the image), recreation, and color attachment or resolve use through `acquire()` (`PrepareForColorAttachment`); - updates the Recorder test assertion to expect the read-only layout on the sampled view. `FirstSample()` already reads its source through `Sampled()` with the view's own layout, so its copy follows the new layout. This re-lands only the read-only-layout slice of #6971, which was folded into #6973. #6973 was backed out by #15935; its initial-contents half is already back on `main` through #15985, #15986 and #16086. The rest of #6973 (the constructor-time initial guest read and its test changes) is deliberately not part of this PR. Two commits: - The change is `MarcZX10`'s commit from #6971, adapted to the `layerCount` parameter the borrowed-image `Texture` constructor has gained since (the layout parameter follows it). - `Amoenus`'s fix-up from the #6973 stack, which restores `GENERAL` when a target is recreated; `main` has that recreation path in `acquire()`. ### Tested Linux, NVIDIA RTX 4090, Release build with GCC: On head `5696deb265` (based on `main` `1d1ff1118d`; `main` has not touched these files since), all 60 tests matching `multisample|native_depth|recorder` pass, none skipped: ``` ctest -R 'multisample|native_depth|recorder' 100% tests passed out of 60 ``` This includes `agc_driver_sample_multisample_target`, `agc_driver_native_multisample_depth`, every `agc_driver_native_depth_*` test and `agc_driver_recorder` (with the updated layout assertion). The UHD 770 is not available here, so this does not show the Intel fix itself; on the RTX 4090 the tests only show that the layout tracking breaks nothing. I will ask for a UHD 770 rerun of `agc_driver_sample_multisample_target` on this head in the thread. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [ ] Fixes: none yet; Refs #6957 (closes it once the UHD 770 rerun passes) - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce RTX 4090, driver 610.57.04, Linux. Not tested on the Intel UHD 770 the issue is about. - [x] AI-assisted: yes
MarcZX10 commented 2026-11-21 06:01:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T06:01:24Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the UHD 770 behavior remains unverified because the author-reported tests ran on an RTX 4090.

What I ran

Reviewed head 93c770c55abe600eefe0c0e58d1f8b980f4fee32 from the prepared review bundle using repo_read.py. No build or tests were run. Read description.md, commits.md, manifest.json, diff.patch, and all four changed files, including targeted repository context for layout transitions and target use.

Results

Check Result Note
Patch and changed code passed Layout paths inspected
Build and tests not run Author reports 60 passing tests on RTX 4090
Intel UHD 770 behavior not run Device unavailable to author

Findings

Blocking

None.

Non-blocking

  • The reported RTX 4090 run is useful regression coverage, but does not verify the Intel UHD 770 issue described in the PR. Please add the stated agc_driver_sample_multisample_target rerun when that GPU is available.

Not verified

No build, tests, or physical-console behavior were run or confirmed in this review. Author-reported test results were not independently verified. files.json has no excluded entries; all changed files were read. The review bundle excluded the full contents of Texture.cpp and Recorder.cpp, so those were inspected only around their changed lines using repo_read.py.

To get this to a good state

Nothing is required. Optional: rerun agc_driver_sample_multisample_target on an Intel UHD 770 and report the result.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6003366128 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19686#pullrequestreview-6003366128). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-21T06:01:24Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the UHD 770 behavior remains unverified because the author-reported tests ran on an RTX 4090. ## What I ran Reviewed head `93c770c55abe600eefe0c0e58d1f8b980f4fee32` from the prepared review bundle using `repo_read.py`. No build or tests were run. Read `description.md`, `commits.md`, `manifest.json`, `diff.patch`, and all four changed files, including targeted repository context for layout transitions and target use. ## Results | Check | Result | Note | |---|---|---| | Patch and changed code | passed | Layout paths inspected | | Build and tests | not run | Author reports 60 passing tests on RTX 4090 | | Intel UHD 770 behavior | not run | Device unavailable to author | ## Findings ### Blocking None. ### Non-blocking - The reported RTX 4090 run is useful regression coverage, but does not verify the Intel UHD 770 issue described in the PR. Please add the stated `agc_driver_sample_multisample_target` rerun when that GPU is available. ## Not verified No build, tests, or physical-console behavior were run or confirmed in this review. Author-reported test results were not independently verified. `files.json` has no excluded entries; all changed files were read. The review bundle excluded the full contents of `Texture.cpp` and `Recorder.cpp`, so those were inspected only around their changed lines using `repo_read.py`. ## To get this to a good state Nothing is required. Optional: rerun `agc_driver_sample_multisample_target` on an Intel UHD 770 and report the result.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!19686
No description provided.