fix(recompiler): leave out descriptor sources behind a branch the capture decides #3952
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3952"
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 xXPBSXx on 2026-10-11T19:44:28Z.
What
A compute kernel can pick a buffer or an image path from a word of its SRT and read the same address as a V# in one path and as a T# in the other. Teardown (PPSA15246) has such a copy kernel; the recompiler validated the descriptor of the path the capture does not take and threw
runtime image descriptor is invalid(details in #3701).The machinery to leave such a source out already exists (
IrResourcePlan::controlFlowand theactivepass inEvaluateRuntimeSourcesImpl: an inactive source is bound as zero words and not validated), but nothing outside a unit test filledcontrolFlow. This PR fills it:ResourceTrackerrecords, per block, the descriptor sources the block uses, and buildscontrolFlowfrom the structured block terminators (blockInfo: true/false blocks and the branch condition). A block whose terminator is neither a plain nor a conditional branch (indirect branches, loop headers) keeps all its CFG successors, so no source is dropped for a path that cannot be decided.controlFlowis only set when some source is used only behind a conditional branch; otherwise the plan is unchanged.verifyGuardedDescriptorSourcesinShaderMemory.cpp: a T# behind a branch on an SRT word is left null when the branch skips it (even if it holds garbage), still read when the branch is taken, and still rejected when invalid and taken; and twoimage_stores of different dimensions on one T# in the two branches compile for the dimension that matches and fail for the one that does not. It fails without the change (the branch around the image was not planned, and without the image trackingincompatible with the static runtime image interface).docs/dev/TechnicalDebt.mdlists the limits.Tested
main(a11c8f7f7):agc_shader_memorypasses with the new case and fails without the change. 37 related tests pass (agc_shader_*,agc_structurizer,agc_scalar_select_mask,agc_driver_{bindless_images,compute_user_data_calls,guarded_null_pointer,oversized_descriptor_sets,scalar_*},shader_buffer_address);agc_driver_oversized_dispatchwas not built here, so not run.tools/check_conventions.py --base upstream/mainpasses.runtime image descriptor is invalidstop and the followingimage descriptor is incompatible with the static runtime image interfacestop are both gone; the copy kernel now compiles and the title runs on tosceNpTrophy2GetGroupInfo: invalid argumentandAGC graphics: CMASK fast clears of a mipmapped, 3D or array color target are unsupported. Both are unrelated to this change.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-11T23:19:43Z.
EvaluateRuntimeSourcesImplnow catches the evaluator'sruntime_errorand goes on with both paths active (SrtDescriptorEvaluation.cpp:97-101). Catching an error to take another path isn't allowed here, and this one swallows every evaluator error, not only unreadable memory. Please drop the catch, or have the evaluator return "not evaluable" for that case without throwing and update the TechnicalDebt entry that says such a branch condition throws at record time.The new comments in
ShaderMemory.cpp(verifyGuardedDescriptorSources) need to go as well.Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-12T00:58:44Z.
Pushed the change you asked for: the
catchis gone. Conditions are evaluated with a null-root sink on the clean evaluator, and a condition that read through a null user-data pointer is "not evaluable", so every successor stays active as before. Theagc_shader_memoryguarded-pointer case (null pointer chain) passes without any exception handling; TechnicalDebt wording updated (a pointer from user data that is not null still throws, as before).Tested:
agc_shader_memory, theagc|shader|srtctest subset on Windows. Two unrelated failures:agc_write_tracking(fixed by #4131 on main, passes after merging main) andagc_driver_prepared_shaders_registered_workgroup_sync, which fails the same way with the control-flow planning disabled, so it is not caused by this PR.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-12T01:14:40Z.
Follow-up: the unrelated
registered_workgroup_syncfailure is now tracked in https://github.com/boykopovar/AnyPS5/issues/4204 (it fails on clean main7a84b2226as well).AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-12T17:56:39Z.
Rebased onto
main2a5eca11c(no merge commits, headd7313bb69; same four commits as before).agc_shader_memorypasses on Windows after the rebase. The review point about thecatchwas addressed ind7313bb69(a null-root read in a condition now makes the condition not evaluable instead of throwing; TechnicalDebt entry adjusted); please re-check when you have time.AI-assisted (Claude Code).