fix(agc): read zero from a stride-0 OOB_SELECT 1 V# when every index is past NUM_RECORDS #26041
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/26041"
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 brumskysb on 2026-11-23T05:19:44Z.
What
A stride-0
OOB_SELECT1 vertex fetch reads zero, instead of throwing, when the draw's every index is at or past a nonzeroNUM_RECORDS; a draw that spansNUM_RECORDSstill throws. The pipeline binding has stride 0, so the vertices cannot differ, and the hardware reads zero for all of them; a draw with some indices belowNUM_RECORDScannot be expressed by one binding, which would have to read the element for the low indices and zero for the high ones.VertexFetchOutOfRangenow takes the draw's lowest index and returns true for that case, so the existing zero path (a zero-filled buffer and the four-component zero format) covers it and the fetch never reachesVertexBufferReadSize's record check, which still throws for a spanning draw with its existing message.NUM_RECORDS0,OOB_SELECT0/2/3, instance-rate fetches and indirect draws are unchanged.The decision is per draw and the layout cache is keyed per shader variant, so a draw whose decision differs from the descriptor-only one builds its layout with its own lowest index and never stores it in the cache. The indexed quad-list and emulated-strip expansion in
prepareDrawInputsnow tracks the lowest retained emitted index next tomaxIdxand setsinputs.minIndexfrom it (per @mihiii1337 and @oneandonlydean): an expanded draw whose every index is at or pastNUM_RECORDSreads zero, and one that spansNUM_RECORDSstill throws. A cached in-range layout therefore cannot be served to an all-past draw, and an all-past layout is never cached to be served to an in-range one; the unit test pins the cached layout and the cache entry across both decisions. A draw recipe is refused (DrawRecipeMiss::Proof) only for a draw that takes the per-draw layout, checked after its inputs are prepared, since a recipe's pipeline carries the layout it was recorded with; in-range stride-0OOB_SELECT1 draws keep using recipes. No test drives the recipe path with an all-past draw.Debt fragment:
docs/dev/debt/changes/fix-agc-zero-stride-select1-past-records.md(libSceAgcDriver, change[Zero-stride vertex fetch range]). Only the false clause is rewritten; the rest of the bullet is main's text byte for byte, and the folded bullet is 945 characters.Open PRs #9915 and #19620 also edit
VertexBufferReadSize's record check, for stridedOOB_SELECT2/3 and indirect vertex ranges; neither implements this case, and both keep the stride-0OOB_SELECT1 throw this change replaces.Tested
Ubuntu 26.04.1 LTS, Linux 7.0.0-34-generic, GCC 15.2.0, CMake 4.2.3, Release with
BUILD_TESTING=ON, built with-j6. GPU: lavapipe,llvmpipe (LLVM 21.1.8, 256 bits), Mesa 26.0.8-1ubuntu0.3, withVK_ICD_FILENAMES=/usr/share/vulkan/icd.d/lvp_icd.json,ANYPS5_GPU=llvmpipe,ANYPS5_REQUIRE_VULKAN=1andANYPS5_NO_SHADER_CACHE=1. The rule was measured on gfx1031 (RX 6700 XT) and gfx1010 per the debt entry; this test was not run on that hardware.agc_driver_zero_stride_vertex_fetch: 22 draw cases plus a spanning-draw refusal, all passing in 0.08 s. The two new cases areOOB_SELECT1 withNUM_RECORDS16 and 17 at first vertex 17, where every index (17, 18, 19) is at or past the records, and both read(0, 0, 0, 0). The spanning case isNUM_RECORDS18 at first vertex 17, where index 17 is in range and 18 and 19 are past it; it must throw, and the test requires the message to containvertex fetch exceeds descriptor record count. Onmainthe all-past case fails withAGC graphics: vertex fetch exceeds descriptor record count: OOB_SELECT 1, stride 0, NUM_RECORDS 16, vertex index 19.agc_driver_zero_vertex_fetch_rangesandagc_driver_zero_vertex_fetch_ranges_verify_plan: 109 known-zero range checks each, passing.agc_vertex_input: passes, including the new all-past, boundary, mixed,NUM_RECORDS0 and cached-layout legs.agc_vertex_input_validationandagc_driver_graphics: pass.mainand on this branch: 18 passed on each, none skipped.agc_vertex_input,agc_vertex_input_validation,agc_driver_graphics,agc_embedded_vertex_fetch,agc_embedded_vertex_fetch_aliasing,agc_vertex_barrier,agc_vertex_layer_export,agc_driver_zero_stride_vertex_fetch,agc_driver_zero_vertex_fetch_ranges,agc_driver_zero_vertex_fetch_ranges_verify_plan,agc_driver_vertex_fetch,agc_driver_vertex_table_read_order(2 entries),agc_driver_vertex_clip_cull_draw(2 entries),agc_driver_zero_position_vertex,agc_driver_scalar_swappc_fetch,agc_driver_vertex_user_data_tail.VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation: every log has theInsert instance layer "VK_LAYER_KHRONOS_validation"line (24 per neighbour run), no log haswas not found but was requested by env var VK_INSTANCE_LAYERS, andVUID-lines are 0 onmainand 0 on this branch.AGC graphics: a draw spanning NUM_RECORDS was accepted; reverting the saved diff restores the 4-test green run.dd7a53cc4f(rebased ontoaf6a58c4d3), clean build dir, everyagc*test target plus the relinker, guest-memory fixtures and the draw-recapture tool (963 targets):100% tests passed, 0 tests failed out of 2105, 0 not run, 0VUID-lines, 0 missing-layer messages.agc_driver_zero_stride_vertex_fetch): indexed quad-list{17,18,19,20}withNUM_RECORDS17 reads zero (accepted); a spanning quad{16,18,19,20}still throws with the record-count message; indexed strip{17..21}withNUM_RECORDS16 reads zero, with a printed skip on devices that restart strips natively. RED verified on the pre-fix tree (9de5da8ccesources with the new test):vertex fetch exceeds descriptor record count: OOB_SELECT 1, stride 0, NUM_RECORDS 17, vertex index 20.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)llvmpipe (LLVM 21.1.8, 256 bits), Mesa 26.0.8-1ubuntu0.3, Ubuntu 26.04.1; the rule was measured on gfx1031 (RX 6700 XT) and gfx1010 per the debt entry; this test was not run on that hardwareSummary by CodeRabbit
Bug Fixes
Documentation
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T05:36:15Z.
Review: APPROVED
Reviewed — looks good
The change handles all-past zero-stride
OOB_SELECT1 fetches while preserving the spanning-draw error, and the inspected code supports approval.What I ran
Reviewed head
9de5da8cce132b85fa99da19eb24157981b94333. Read the prepared description, commits, manifest, full diff, and all five changed files; used the pinned repository reader for targeted code context. No tests were run by this reviewer; test results in the description are author-reported.Results
Negative control
The author reports a mutation check in which using the highest index for the per-draw decision failed the spanning case. I did not run this check.
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
I did not independently run tests or verify behavior on physical console hardware. The author reports lavapipe test results and separate hardware measurements for the underlying rule; the new test was not run on that hardware.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by mihiii1337 on 2026-11-23T06:59:03Z.
Review: CHANGES_REQUESTED
Reviewed exact head
9de5da8cce132b85fa99da19eb24157981b94333. The new all-past decision still misses a supported indexed path: quad-list and emulated-strip expansion initializeinputs.minIndexto zero for indexed draws and update onlymaxIdxwhile writing the expanded indices (Draw.cpp:1915-1952, theninputs.maxIndexat 1976). They never store the lowest retained index.For example, a direct indexed quad list
{17,18,19,20},firstVertex=0, stride 0,OOB_SELECT=1, andNUM_RECORDS=17has every actual fetch out of range and should use the zero binding. This head instead carriesminIndex=0, thenVertexBufferReadSize(..., maxIndex=20, minIndex=0)takes the in-range layout and throwsvertex fetch exceeds descriptor record count. The new execution cases use auto/non-indexed indices, so they do not cover this branch.Please compute the minimum alongside
maxIdx, propagate it toinputs.minIndexfor the indexed expanded path, and add a direct indexed quad-list regression (and the strip expansion if it remains a separate branch). PR #26036 currently contains a closely related min/max expansion change, so coordinating that shared hunk may avoid duplicate fixes.I checked the exact production branch and tests, and an exact-header CPU harness reproduced the throw with reported
minIndex=0and the expected 16-byte zero fetch with the actual minimum 17; all 672 classifier combinations in that harness matched their expected cases. Hosted Windows vertex-input tests are green. I did not run a full draw on the local GPU.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-24T23:47:58Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the points below are optional.
What I ran
Reviewed head
65b3e1e481bdedc9803d6d785e87a5149accedf6. I read the prepared description, commits, manifest, diff, and all five changed files. I used the pinned repository reader for targeted source ranges. No tests were run in this review.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
I did not independently verify the author-reported test runs, GPU behavior, or recipe-path behavior for an all-past draw. The reported test description says no recipe-path test covers that case.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-26T15:07:41Z.
Review: COMMENTED
Actionable comments posted: 5
ba8581d7-e958-450c-b4b9-fbe49fbc1eb6Reviewing files that changed from the base of the PR and between
a4ed870149anddd7a53cc4f.core/libs/prx/libSceAgcDriver/Graphics/include/VertexInput.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/tests/VertexInput.cppcore/libs/prx/libSceAgcDriver/tests/execution/ZeroStrideVertexFetch.cppdocs/dev/debt/changes/fix-agc-zero-stride-select1-past-records.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-26T15:15:07Z.
Review: COMMENTED
Reviewed — comments
No blocking defect was verified; the all-past zero-fill decision and the spanning-draw rejection are supported by the inspected code and tests.
What I ran
Reviewed head
dd7a53cc4f90d2a801c161dc255d292f74510c00. No commands or tests were run. The author-reported test results in the PR description were not independently verified.Results
Negative control
Not run by this reviewer. The description reports a mutation check that fails when the decision uses the highest index.
Findings
Blocking
None verified.
Non-blocking
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp:5283.Sources
Not verified
No tests or builds were run. The PR description's results, hardware measurements, and console behavior were not independently checked. All five changed files in the manifest were included in the review folder; I read the diff and targeted ranges in the four code and documentation files, not every line of each full file. No changed files were excluded by the manifest.
To get this to a good state
Nothing is required.
Optional: add a recipe-path regression test for an all-past draw and its fallback to the ordinary draw path.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T21:29:08Z.
Review: COMMENTED
The current head conflicts with
mainf3c2cd73abinVertexInput.hpp,Draw.cppandVertexInput.cpp. Please preserve the lowest effective vertex index after the indexed base offset on every path through the resolution. The new quad and strip cases protect the expansion paths, and the spanning-draw rejection is a useful check that the decision uses the lowest index. An additional indexed case where a nonzero base offset moves the entire draw acrossNUM_RECORDSwould cover the new helper's input from the draw path. The paired Vulkan run is pending the merge resolution.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.