fix(agc): view cleared surfaces without flushing handed-over results #9999
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9999"
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?
Imported from boykopovar/AnyPS5. Originally posted by camezaro-intc on 2026-10-23T03:35:08Z.
What
Preserve texture A's pending GPU results when texture B is sampled through matching DCC clear keys; sampling B does not overwrite A's backing memory. The regression test now reads A's backing memory after B is sampled but before B writes, and verifies that A's results remain visible. B's subsequent write is the point where its overlapping units may be superseded. Removed the untested unconditional refresh upload for every handed-over clear-key refresh.
Tested
Windows 11 (build 26300), AMD Radeon RX 5700 XT, driver 32.0.21045.16010. Baseline
main(2960e9a6e7e1fc99c4ed180c71495b5eb83464c7) and PR head (d72cc8ca6a70205a4e1fe96eb1c107d540a73f95) were tested on the same machine and GPU.For both baseline and PR:
cmake --build C:\a5-pr11727-full --target agc_driver_recorder_tests agc_driver_staged_clear_sampled_read_tests --parallel 8— passed.ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1, andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation:ctest --test-dir C:\a5-pr11727-full --output-on-failure -V -R '^(agc_storage_clear_hand_over|agc_driver_staged_clear_sampled_read)$'— passed, 2/2.VUID-messages were present in either captured run.Additional checks:
python tools/check_conventions.py --base upstream/main— passed.git diff --check upstream/main...HEAD— passed.python tools/check_conventions.py --base origin/main— reports an unrelated non-Conventional-Commit revert already in that stale fork base (97f1d41a2c) and existing debt-length warnings; checking against the actual upstream PR base passes.No title run or AMD/Intel comparison beyond this RX 5700 XT was performed.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T04:37:26Z.
Review: APPROVED
Reviewed the exact diff and manually compared the Texture.hpp/Texture.cpp hunks against the #9431 stack and its open follow-ups (#9891/#9892/#9893/#9895). Those PRs alter independent mip/layout/copy regions; they will need textual rebases where files overlap, but this change does not depend on their behavior. The candidate-source selection now rejects clear-key aliases at another DCC address, staged-clear flushes are limited to matching pending layers, and the refreshed cached storage image supersedes handed-over writes before it becomes the sampled source. The new SampledClear case exercises the supersession path. Current-main diff check is clean; CI conventions, eligibility, intake, labels and report pass while product jobs skip by path policy. I cannot run Vulkan on this host; the PR reports both focused Windows tests passing with the Khronos layer and no VUIDs. No blocking issue found in the reviewed scope.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T22:17:55Z.
Review: CHANGES_REQUESTED
I re-reviewed the current head
cc1d50526dff8c4dffcba9b44a604e7a1e96477e, including the clear-key source selection, staged-clear restriction, handed-over unit supersession, and theSampledClearregression. The Windows validation-layer runs and the Linux/Windows broader test results described in the thread are useful evidence, but I did not run them locally. The current hosted PR checks shown here are from the earlier run; product jobs are path-skipped.This head is based on
d7948b09f95ea8e302590c09dbb3c0c0b714b84aand is 5,752 commits behind currentmain(319621ba2e578bd053b0baba2877fe70520e0737). Currentmainhas also changedTexture.hpp,ShaderResources.cpp, andTexture.cpp, the same production files this PR changes. Please rebase/merge currentmain, rerunagc_storage_clear_hand_overandagc_driver_staged_clear_sampled_readon the resulting tree (including the Vulkan validation layer where available), and refresh the hosted build checks before merge. The existing merge-order agreement with #7085 should remain in place. I cannot approve until that integration is verified.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T05:01:45Z.
Review: APPROVED
Reviewed — looks good
The exact current head includes the requested mainline integration and focused validation evidence; the change and its regression test are consistent, with no blocking issue found.
What I ran
b433c40f2f.52c09d567d. The merge preview is clean; the intervening main commit does not touch any of this PR's four changed paths.Results
Raw integration and CI output
The test command and per-test output are in the author's exact-head test report.
Negative control
Findings
Blocking
None.
Non-blocking
The focused Vulkan tests were run by the PR author, not locally in this review environment. Linux and specialized hosted jobs are skipped for this PR.
Sources
Not verified
To get this to a good state
No further action is needed for approval. If the head changes, I will rerun the same merge, diff, and focused-test checks on the new revision.
Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-29T05:17:11Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The merged tree builds and the focused tests pass under the Khronos validation layer with no
VUID-lines, but the newSupersedeHandedOver()call on the sampled path drops A's pending results before anything overwrites them, which a scratch test shows as lost data thatmainkeeps.What I ran
f555ebfc360e48f3a35b51179f053c1a79a30e7fmain:52c09d567d2fa453494dd720fcf53a98149468e4main: clean (merge commit1a03fce653e45016ece9f2cd30b822e9f23b4f18)Results
maingit diff --checktools/check_conventions.py --base origin/mainAll conventions checks passed.agc_driver_recorder_tests,agc_driver_staged_clear_sampled_read_tests,libs)VUID-linesmain, validation layerVUID-linesInsert instance layer "VK_LAYER_KHRONOS_validation"in all 3 tests on both trees; nowas not found but was requested by env var VK_INSTANCE_LAYERSagc_storage_*, merged treemain)agc_storage_clear_hand_overfails, as intendedSupersedeHandedOver()call removedagc_storage_clear_hand_overpasses|| handOverKeys.has_value()removedagc_storage_clear_hand_overpassesmainand with the call removedFocused tests, merged tree
Focused tests, main
Negative control
I restored
Texture.hpp,ShaderResources.cppandTexture.cppfrommainand kept the PR'sRecorder.cpp.agc_storage_clear_hand_overfails:The new case does test the
stagedClearrestriction. It does not test two other production changes: with either one removed alone, the test still passes (see Non-blocking 1).Findings
Blocking
Sampling B now drops A's pending results that nothing has overwritten yet.
ShaderResources.cpp:840callscandidate->SupersedeHandedOver(), which runssupersedeHandedOver(0, trackedLayers). That clearslayerPendingon every handed-over unit of A under B. Until now, only a write by B dropped those units (Texture.cpp:3885, in the mark-pending path). That rule is correct: only B's write replaces the bytes A rendered. Sampling B through its clear keys reads the keys' clear value but leaves the memory unchanged, so a later read of that memory through A's descriptor, or by the CPU, must still see A's results. The existingReadFirstcase checks the same rule for the refresh path.Scratch check: in the
SampledClearcase, right after theCachedSampledTexturecall and beforedraw(imageB, ...), I added:clear-key hand-over (watched), B sampled under clear keys, on: SCRATCH a read of A's memory after B was sampled, before B wrote, did not see A's results.SupersedeHandedOver()call removed, the read sees red. The only later failure issuperseded == 2(dropped 1), which is expected, because the read stored one unit, as inReadFirst.main's production files (the PR's two sampled-viewRequires removed, since they fail there by design), the read also sees red. The only later failure is the PR's supersede count (dropped 0).So the PR introduces this loss.
mainkeeps A's results here.Suggested fix: drop the
SupersedeHandedOver()call, and with it the public wrapper if nothing else uses it. TheAnyLayerPending()condition onstagedClearalready keeps the sample from storing A's results over B. With the call removed, all ofagc_storage_clear_hand_overstill passes: B's following draw drops the same two units atTexture.cpp:3885. Please also add aSampledClearvariant that reads A's memory after the sample, like the scratch line above. It would catch this regression.Earlier reviews here approved this path; this check is new evidence against it.
Non-blocking
SupersedeHandedOver()call removed, or with only the|| handOverKeys.has_value()inTexture.cpp:2271removed,agc_storage_clear_hand_overstill passes. For the first, theon.superseded == 2check forSampledClearatRecorder.cpp:11370cannot tell a drop at the sample from the drop at the followingdraw(imageB, ...)(Recorder.cpp:11342). The test therefore does not support the description's claim that it "drops superseded units". For therefresh()change, please add a case that fails without it: B taken from the cache with clear keys equal touploadedKeys, while newer results from A are handed over. Otherwise, remove the change.|| handOverKeys.has_value()marks every tracked layer changed on each refresh that hands over, including repeated refreshes with the same keys and the same handed-over writes. That costs a full GPU clear each time. If this is intended, the case that needs it (item 1) would show why a narrower condition is not enough, for example comparing the handed-overwriteswith the previous hand-over.PPSA01325 #3232).PPSA26344 Ghost of Yōteihas no discussion number.Not verified
agc_storage_*,agc_driver_staged_clear_sampled_readand its_draw_pipelinevariant.cachedTextureis on every sampled-texture path, and I did not run the wider AGC suite.To get this to a good state
SupersedeHandedOver()call atShaderResources.cpp:840, or show why dropping A's units at sample time is correct when A's memory is read before B writes. Then add the read-after-sample check above toSampledClear.refresh()change with a case that fails without it, or remove it.agc_storage_clear_hand_overandagc_driver_staged_clear_sampled_readonmainand on the change with the validation layer, as before.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T05:28:13Z.
Review: CHANGES_REQUESTED
Re-reviewed — changes requested
New exact-head evidence identifies a data-loss case that my earlier approval did not cover. That approval is superseded by this review.
What I ran
52c09d567d.Results
Negative control
The reviewer’s scratch readback after sampling B but before B writes sees A’s red results on main and when only the new SupersedeHandedOver call is removed, but fails with this PR. That isolates the newly added sample-time supersession as the source of the lost pending data.
Findings
Blocking
Sampling B discards A’s pending results before a write replaces them. In cachedTexture, the new candidate->SupersedeHandedOver() call clears A’s handed-over pending state as soon as B is selected for sampling. The scratch readback described above shows that a subsequent read of A’s backing memory, before B writes, no longer sees A’s results, whereas main preserves them. Please remove this call or demonstrate why this sequence is semantically allowed; add the read-after-sample assertion to SampledClear so this data-preservation case remains covered.
The Unblocks entry lacks the required game bring-up discussion number. It names PPSA26344 / Ghost of Yōtei but does not give the discussion reference required by the contribution template. Please add that discussion number or use Unblocks: none if this change does not directly unblock that title.
Non-blocking
Sources
Not verified
To get this to a good state
Remove or justify sample-time supersession, add the read-after-sample backing-memory assertion, and correct the Unblocks reference. Then rerun the focused storage/hand-over tests with validation enabled on the updated exact head.
Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-29T06:19:49Z.
Review: APPROVED
Re-checked — approved
The new commit
d72cc8ca6aremoves the sample-timeSupersedeHandedOver()call and the|| handOverKeys.has_value()refresh condition, and adds a read-after-sample check toSampledClear. That check fails when the old call is put back, and the focused tests pass under the Khronos validation layer with noVUID-lines.What changed since my last review
main2960e9a6e7.git range-diffshows the first commit (112cb54942) is unchanged from thef555ebfc36I reviewed.d72cc8ca6a"fix(agc): preserve pending results when sampling clears":StorageTexture::SupersedeHandedOver()and its call incachedTexture;refresh()back toif (keys != uploadedKeys);SampledClear, reads A's memory after B is sampled and before B writes, and expects red;SampledClearsupersede count from== 2to== 1.Unblocks: none.Testednow reports Windows 11 / RX 5700 XT runs onmainand on the head.What I ran
d72cc8ca6a70205a4e1fe96eb1c107d540a73f95main:2960e9a6e7e1fc99c4ed180c71495b5eb83464c7main: clean (merge commitd76c1e8e9c469d2b623a516cead71bca408ad993)Results
maingit diff --checktools/check_conventions.py --base origin/mainAll conventions checks passed.agc_driver_recorder_tests,agc_driver_staged_clear_sampled_read_tests,libs)VUID-linesmain, validation layerVUID-linesInsert instance layer "VK_LAYER_KHRONOS_validation"in all 3 tests on both trees; nowas not found but was requested by env var VK_INSTANCE_LAYERSagc_storage_*, merged treeagc_storage_clear_hand_overfails on the new read-after-sample checkmainagc_storage_clear_hand_overfailsstagedClearrestriction removed, or onlyAnyLayerPending()removedagc_storage_clear_hand_overfailsShaderResources.cpp:818removedagc_storage_clear_hand_overpasses (see Non-blocking 1)Focused tests, merged tree
Focused tests, main
Controls
Previous findings
Recorder.cpp:11342check passes on the merged tree. It fails when only this commit's production changes are reverted, so it catches the regression I reported.SampledClearnow expectssuperseded == 1, which separates a drop at the sample from the drop at B's write.refresh()hunk is gone from the PR diff.Unblocks: none, which the template allows.New findings
Blocking
None.
Non-blocking
ShaderResources.cpp:818has no test that fails without it. This line drops a pending source whose own DCC address differs from the sampled descriptor's when the keys read as a clear. The line is from the first commit and is not new in this push, but I had not tested it on its own before. With only this line deleted,agc_storage_clear_hand_overstill passes. The othercachedTexturechanges are covered (see Results). Please add a case in whichFindPendingreturns an image with a different DCC address for a descriptor whose keys read as a clear, for example aSampledClearvariant in which A is still pending over B's memory when B is sampled, and confirm that it fails with the line removed. Otherwise, explain in the description why the line is needed.Recorder.cpp:11374,&& watchedis always true, because the!watchedbranch above it ends incontinue. You can drop it.Not verified
agc_storage_*,agc_driver_staged_clear_sampled_readand its_draw_pipelinevariant.cachedTextureis on every sampled-texture path, and I did not run the wider AGC suite.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T06:38:06Z.
Review: APPROVED
Re-reviewed — approved
I reviewed exact head
d72cc8ca6a70205a4e1fe96eb1c107d540a73f95against currentmain2960e9a6e7e1fc99c4ed180c71495b5eb83464c7.What I ran
ShaderResources.cpp,Texture.cpp, andRecorder.cpp, including the newSampledClearorder.git merge-tree --write-tree refs/remotes/upstream/main refs/review/upstream-9999; it returned clean tree4fcf67dfc3ac67f4add0e16d361fcee9e8dfdb85.git diff --check refs/remotes/upstream/main...refs/review/upstream-9999; exit 0, no output.Results
VUID-messagesNegative control
I did not run a local control. The negative control above is reported by the independent reviewer on the exact head.
Findings
Blocking
None. The added read-after-sample assertion covers the data-loss case from my previous review, the supersession call and repeated-refresh condition are removed, and the
Unblockschecklist now saysnone.Non-blocking
The existing source-selection guard in
ShaderResources.cppthat drops a mismatched-DCC source when the keys are clear still lacks an isolated test that fails when that guard is removed. This does not block approval of the fixed data-loss regression, but a focused negative control would make that branch easier to maintain.Sources
Not verified
I did not independently run the C++ tests, Vulkan validation, Linux behavior, or a game title. The reported Windows GPU runs and negative control are attributed above to the author and independent reviewer.