Skip to content

fix(agc): take an indexed draw's base vertex as signed - #26036

Open
birdmarty wants to merge 3 commits into
boykopovar:mainfrom
birdmarty:fix/agc-negative-base-vertex
Open

birdmarty wants to merge 3 commits into
boykopovar:mainfrom
birdmarty:fix/agc-negative-base-vertex

Conversation

@birdmarty

@birdmarty birdmarty commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

What

An indexed draw whose base vertex is negative threw indexed draw vertex range overflow. The base vertex is added to every index, and a negative one is valid as long as the lowest index plus it is not below 0: the hardware's base vertex and Vulkan's vertexOffset are signed. Draw required firstVertex <= UINT32_MAX - maxIndex, which reads -532 as 0xfffffdec. The adds after that check (minIndex += firstVertex, maxIndex += firstVertex) already wrap to the right vertices, and vkCmdDrawIndexed already gets the offset as int32_t.

The indexed range check now takes the offset as signed: the lowest index plus the offset must be at least 0, and the highest index plus the offset at most UINT32_MAX. The expanded-index path (quad lists and emulated strips) now tracks its lowest index and checks both bounds the same way. Two places used the offset as unsigned as well, and now take it as signed:

  • the zero-fetch index limit (zeroFrom - firstVertex), where a negative offset gave 0;
  • the render-target alias check, which now measures from the lowest vertex the indexed draw reads (minIndex) instead of the offset.

The vertex offset of an indexed draw can also come from two words: GE_INDX_OFFSET and a vertex shader's base-vertex user SGPR, which Driver::FoldDrawOffsets adds into the draw. That add used an unsigned overflow test, so +3 and -3, a final offset of 0, threw draw vertex offset overflow. For an indexed draw the two words are now added as signed 32-bit values, and only a total outside the signed 32-bit range is refused. The in-place index path behind a pending GPU writer (InPlaceIndexBehindWriter, opt-in through APS5_INDEX_IN_PLACE_BEHIND_WRITER) compared the offset as unsigned too: a large negative offset with 16-bit indices, such as -2147483648, was bound in place with its lowest index taken as 0, and the range check then refused the draw. A negative offset now stays on the copy path, which measures the real index range.

Non-indexed draws are unchanged: their first vertex is an unsigned start.

Changes

  • core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp: the range checks above and the in-place index path.
  • core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/IndirectDraw.cpp: the signed fold in FoldDrawOffsets.
  • core/libs/prx/libSceAgcDriver/tests/execution/DrawOffsetIndices.cpp (run by agc_driver_draw_offset_indices, _poisoned and _poisoned_in_place): a direct indexed draw with base vertex -3 over the indices 5, 3, 4 fetches vertices 2, 0 and 1 for both instances; GE_INDX_OFFSET +3 with s16 -3, and -3 with +3, over the indices 2, 0, 1 fetch vertices 2, 0 and 1; GE_INDX_OFFSET 0x7fffffff with s16 1, and 0x80000000 with s16 -1, are refused with draw vertex offset overflow; an indexed quad-list draw with base vertex -3 over the indices 0, 1, 2, 2 is refused with indexed draw vertex range overflow.
  • core/libs/prx/libSceAgcDriver/tests/Recorder.cpp (agc_index_in_place_behind_writer): 16-bit index ranges with the offsets -3 and -2147483648 stay on the copy path; the case that may bind in place now uses 0x7fffffff instead of 0xffff0000, which is -65536 as a signed offset.

No debt entry changes: the change closes no recorded gap and adds none.

Tested

Windows 11 Pro (build 26300), Intel Core i9-9900K, AMD Radeon RX 6800 (AMD driver 26.10.1, Windows driver 32.0.21045.16010, Vulkan 1.4.315), MinGW-w64 GCC 15.3.0, Release, main 441fa65.

Focused set (agc_driver_graphics, agc_shader_memory, agc_driver_recorder, agc_driver_draw*, agc_driver_*vertex*, agc_driver_*index*, agc_driver_list_restart*, agc_driver_zero_stride*, agc_driver_relative*, agc_driver_mesh*, agc_driver_stencil_replay*, agc_embedded_vertex*, agc_driver_indirect*, agc_index_*, agc_driver_pm4*) with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (1.4.363) and VK_LOADER_DEBUG=layer:

main 441fa65 this change (8a0fcdd)
Passed / failed 171 / 0 171 / 0
Validation layer inserted 223 223
VUID- lines 0 0

Rebased onto origin/main 0af6efa as 6080bb0 (resolving conflicts with merged #26775 by preserving !wholeRange on firstByte in Draw.cpp and the 5-argument attempt(...) signature in tests/Recorder.cpp). Re-verified on the same RX 6800 with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (1.4.363.0), VK_LOADER_DEBUG=layer:

  • Focused 20-test set (agc_driver_draw_offset_indices*, agc_index_in_place_behind_writer, agc_driver_graphics, agc_driver_list_restart*, agc_driver_indirect*, agc_driver_zero_stride*, agc_driver_recorder): 20 / 20 passed on both origin/main 0af6efa and 6080bb0, 34 validation layer inserts on both, 0 VUID- lines.
  • Negative control (checking out origin/main 0af6efa's Draw.cpp and IndirectDraw.cpp against 6080bb0's tests): 4 / 4 failed (agc_driver_draw_offset_indices, _poisoned, _poisoned_in_place with AGC driver: draw vertex offset overflow, and agc_index_in_place_behind_writer on the -2147483648 case); all 4 pass on 6080bb0.
  • Earlier 171-test full sweep on 441fa65 / 8a0fcdd above; tools/check_conventions.py --base origin/main and tools/debt_fold.py --check pass on 6080bb0.

Forza Horizon 5 (PPSA22327 01.685.672), local stack of open PRs:

  • What the game does: an indexed triangle-list draw with 16-bit indices from 0x214 to 0x1698 and a base vertex of 0xfffffdec (-532), so it reads vertices 0 to 0x1484.
  • Without this change: the refusal stopped 3 runs, at 252.7 s, 261.1 s and 259.9 s.
  • With this change: 3 runs on d85e9ac, none with it. All three ran 610 s, past the point where it stopped, to a later, unrelated freeze. 4f888ba, 8a0fcdd and rebased 6080bb0 were not run in the game.

py -3 tools/check_conventions.py --base origin/main and py -3 tools/debt_fold.py --check pass. py -3 tools/pr_overlap.py --branch fix/agc-negative-base-vertex (2,508 open PRs): all 83 mergeable PRs that share files merge cleanly. The 45 PRs that conflict with main were searched by hand; #9897 and #14032 set draw.firstVertex in tests, #10193, #13928 and #22647 change where the zero-fetch vertex attributes come from, and #22647 calls FoldDrawOffsets; none takes the base vertex as signed or changes the fold or the in-place index check.

Not tested: a negative base vertex through an indirect draw's arguments in a title, the expanded-index path with a negative base vertex in a title, other GPUs, Linux.

Related

Part of the Forza Horizon 5 (PPSA22327) bring-up, #25152. It was found on the stack of PRs the game needed (#24960, #24994, #25151, #25867–#25874, #26034 and #26035 are now merged; #23688, #23545, #21479, #11825, #23778, #21155, #22306 and #21199) and stands alone: it applies to main by itself and needs none of them to build or pass its tests.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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
  • Unblocks: PPSA22327 Forza Horizon 5 (PPSA22327) #25152
  • GPUs tested: AMD Radeon RX 6800 (vendor=0x1002, device=0x73bf), AMD proprietary driver 26.10.1 (Windows driver 32.0.21045.16010, Vulkan 1.4.315), Windows 11 Pro (build 26300); Khronos validation layer 1.4.363.0 on main and this change, 0 VUIDs
  • AI-assisted: yes

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Corrected vertex-offset handling for indexed draws, including negative offsets and values near the supported range limits.
    • Improved validation of indexed-draw vertex ranges to prevent invalid or overflowing ranges from being accepted.

@github-actions github-actions Bot added the unblocks title Names a title ID on the Unblocks line label Nov 23, 2026

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — changes requested

Changes are required before merge: fix the expanded-index range check so it also rejects a negative resulting vertex index.

What I ran

Reviewed head d85e9ac04d8aa897d51921aaf790911658a49154. Read description.md, commits.md, manifest.json, diff.patch, and the full text of both changed files in review/manifest.json. No commands or tests were run; repo_read.py was unavailable in this session.

Results

Check Result Note
Changed code review failed Expanded-index check misses lower bound
Tests not run Author-reported results not independently verified

Findings

Blocking

  • Draw.cpp:1974: The expanded-index path checks only maxIdx + firstVertex <= UINT32_MAX. With a signed negative base vertex, this permits a lowest index smaller than the magnitude of the offset. For example, index 2 with offset -3 passes the upper-bound check, then the indexed range check at line 2096 rejects the same invalid draw later. The expanded path must validate the lower bound too, before the subsequent additions and index limit checks.

Non-blocking

None.

Not verified

The test file’s full text was included in the changed-file bundle, but the reader returned only the requested out-of-range slice for the test read; the changed test lines are visible in diff.patch. No test execution, author-reported validation, hardware behavior, or other repository context was independently verified. No files were excluded according to manifest.json; review/files.json was not available.

To get this to a good state

Add the lower-bound validation to the expanded-index path and run the focused draw tests, including a negative offset whose lowest expanded index would become negative.

@birdmarty

Copy link
Copy Markdown
Contributor Author

@MarcZX10 thanks, you're right. Fixed in 4f888ba: the expanded-index check now also requires the lowest expanded index plus the base vertex to be at least 0, the same two bounds as the later indexed check.

Before this commit such a draw was still refused, by the later indexed check with the same message, so nothing was fetched below vertex 0. The expanded path just didn't check it by itself.

  • New test case in DrawOffsetIndices.cpp: an indexed quad-list draw with base vertex -3 over the indices 0, 1, 2, 2 must be refused with indexed draw vertex range overflow.
  • Results: it passes on 4f888ba. It also passes on the PR's first commit, d85e9ac, where the later check refuses the same draw. So it pins the behaviour, but it does not fail without this commit.
  • Focused set with the Khronos validation layer: main 441fa65 and 4f888ba both pass 140 of 140, with 222 layer inserts and 0 VUID- lines on each.
  • Repository checks: check_conventions and debt_fold --check pass. pr_overlap gives the same result as before.

Not done: game runs on 4f888ba. The Forza runs in the PR body were on d85e9ac.

AI-assisted: yes (Claude Code).

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

The reviewed change handles signed indexed base vertices and adds regression coverage for valid and invalid ranges; the available evidence supports merging.

What I ran

Reviewed head 4f888baf4a6b016330ecf057da5fc1e7647d07dd using repo_read.py to inspect the prepared diff and relevant code ranges. No commands or tests were run by me.

Read: description.md, commits.md, manifest.json, diff.patch, and all relevant ranges of Draw.cpp and DrawOffsetIndices.cpp. Both files listed in the manifest as reviewed were read. files.json was unavailable through the reader; its exclusions were not verified.

Results

Check Result Note
Diff and code review passed Two changed files reviewed
Tests run by reviewer not run Author reports focused tests passed
Excluded files not verified files.json unavailable

Findings

Blocking

None.

Non-blocking

None.

Not verified

I did not run tests or independently verify the author's test, hardware, or game-run reports. Excluded-file details were not available. The review was based on the prepared diff and the two changed files listed in the manifest.

To get this to a good state

Nothing is required.

@github-actions github-actions Bot added the agc libSceAgc* label Nov 23, 2026
@Doorriiaann

Copy link
Copy Markdown
Contributor

NVIDIA run on Linux: no regression in the draw offset indices, indirect and graphics tests. unused_filter_indirect, a relinker test the pattern also matches, fails on base and head alike on this machine.

Setup: RTX 3070 8 GB, NVIDIA 610.57.04, Ryzen 5 5600X, Debian 13 (kernel 6.12.115), GCC 13.3.0 Release, validation layer 1.4.335. Base is the merge-base 441fa65, head is 4f888ba. ANYPS5_GPU=NVIDIA ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer ctest -R '(draw_offset_indices|agc_driver_graphics$|indirect|base_vertex)' -V, 2 runs each.

base this PR
unused_filter_indirect 2 failed 2 failed
the other 34 matching tests 68/68 pass 68/68 pass

Every Vulkan test's log selects the RTX 3070 and shows the layer inserted, none reports it missing, and no log has a VUID- line.

AI-assisted: yes

@mihiii1337 mihiii1337 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed exact head 4f888baf4a6b016330ecf057da5fc1e7647d07dd. The new range checks correctly interpret the final indexed base vertex as signed, but the producer can still reject a valid signed result before those checks.

Driver::FoldDrawOffsets adds the shader/user-SGPR word to DrawParameters::firstVertex with an unsigned overflow test. For a direct indexed draw with GE_INDX_OFFSET=+3 and a folded shader base-vertex word of -3 (0xfffffffd), the correct final signed base vertex is 0. The current check treats the second word as 4294967293 and throws draw vertex offset overflow. The reverse -3 + +3 case has the same problem. The two new indexed fixtures both seed firstVertex=0, so they do not cover composition with the PM4 offset.

Please combine the two words in signed/widened arithmetic for indexed draws, check the representable final signed offset, and keep the existing unsigned behavior for non-indexed starts. Add a regression through the existing FoldedDraw wrapper with nonzero firstVertex, e.g. +3 plus shader -3 over {0,1,2}.

A local CPU probe using byte-verified copies of the exact drawUserWord, FoldDrawOffsets, and changed range logic reproduced both mixed-direction rejections and passed 12 boundary/negative controls; the exact changed Draw.cpp also passed a WinLibs compile-only check. Hosted Windows is green but its logged selection did not run draw_offset_indices; the author and peer GPU runs cover the current fixtures. I did not run a local GPU test.

The overlapping index-expansion hunk in #26041 merges cleanly with this head; this finding is in the unchanged producer-side folding code.

AI-assisted: yes.

@birdmarty

Copy link
Copy Markdown
Contributor Author

@mihiii1337 thanks, confirmed and fixed in 8a0fcdd.

  • The fold: for an indexed draw, FoldDrawOffsets now adds GE_INDX_OFFSET and the shader's base-vertex word as signed 32-bit values. It refuses only a total outside the signed 32-bit range. Non-indexed starts keep the unsigned check.
  • One more place with the same assumption: InPlaceIndexBehindWriter, the opt-in APS5_INDEX_IN_PLACE_BEHIND_WRITER path, compared the offset as unsigned.
    • A large negative offset with 16-bit indices, such as -2147483648, was bound in place with its lowest index taken as 0. The range check then refused a draw whose real indices could be fine.
    • A negative offset now stays on the copy path, which measures the real range.

I also checked every other place the base vertex is combined or compared, and none needed a change:

  • indirect draws on the CPU path, which fold the record's base vertex through the same function;
  • both GPU indirect rules, which pass it as int32_t;
  • the expanded and main range checks, the zero-fetch limit and the alias check;
  • the mesh path.

New tests:

  • DrawOffsetIndices.cpp, through FoldedDraw:
    • GE_INDX_OFFSET +3 with s16 -3, and -3 with +3, over the indices 2, 0, 1: both fetch vertices 2, 0 and 1.
    • 0x7fffffff + 1 and 0x80000000 + (-1): refused with draw vertex offset overflow.
  • agc_index_in_place_behind_writer:
    • 16-bit ranges with the offsets -3 and -2147483648 stay on the copy path.
    • The existing case that may bind in place now uses 0x7fffffff instead of 0xffff0000. Read as a signed offset, 0xffff0000 is -65536.

Results:

Not done: game runs on 8a0fcdd, Linux, other GPUs.

AI-assisted: yes (Claude Code).

@mihiii1337 mihiii1337 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed fix head 8a0fcdd82559dd2a7e238653b46cf61fcb731cef. This resolves both parts of my earlier finding: indexed offset folding now uses a signed wide intermediate with checked narrowing, and every negative final indexed offset is routed away from the in-place writer.

Exact-source CPU A/B results:

  • indexed folding mismatches: 90/196 on 4f888baf → 0/196 here, including both +3 + (-3) cancellation directions and signed upper overflow;
  • unsigned/non-indexed controls: 0/196 on both revisions;
  • extracted full InPlaceIndexBehindWriter gate with unrelated gates controlled: 4/28 → 0/28.

All four changed translation units pass WinLibs C++20 syntax checks. The recorder fixture generated its ten exact shaders with the previously built CPU glslang and current embed script, without Vulkan initialization. The new folded-draw tests cover positive/negative cancellation, signed overflow and returned vertex/instance IDs; the recorder cases discriminate the in-place gate.

Scope nuance is accurate: INT_MIN is a gate counterexample for 16-bit indices, not an otherwise renderable 16-bit draw; valid small negative offsets already selected the copy path before this follow-up. The production signed-fold fix remains independently necessary and proven. The author reports 171/171 focused tests on base and head with 223 validation-layer insertions and 0 VUIDs, plus negative controls. I ran no local GPU test. Merge preview with #26041 and current main is clean; hosted Windows is still running with no failures.

AI-assisted: yes.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

The indexed draw changes and the added regression cases were reviewed at head 8a0fcdd82559dd2a7e238653b46cf61fcb731cef; no blocking defect was found in the code read.

What I ran

No commands or tests were run. I read the prepared review bundle and used the pinned repository reader for the changed test file excluded from the bundle.

Results

Check Result Note
Change and targeted code review passed Signed offset handling inspected
Tests and build not run Author-reported results were not rerun

Findings

Blocking

None.

Non-blocking

None.

Not verified

core/libs/prx/libSceAgcDriver/tests/Recorder.cpp was not read in full; its changed lines and surrounding function were read from the pinned head. No commands or tests were run. The author-reported test results and game behavior were not independently verified. Other GPUs, Linux, and title behavior for indirect negative offsets and expanded-index draws were not verified.

Files read: review/description.md, review/commits.md, review/manifest.json, review/diff.patch; core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/IndirectDraw.cpp, core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp, core/libs/prx/libSceAgcDriver/tests/Recorder.cpp (targeted range), and core/libs/prx/libSceAgcDriver/tests/execution/DrawOffsetIndices.cpp (targeted ranges). Excluded from full-text bundle: core/libs/prx/libSceAgcDriver/tests/Recorder.cpp because it was too large.

To get this to a good state

Nothing is required.

@Helldiverr

Copy link
Copy Markdown
Contributor

Head 8a0fcdd825 merged onto upstream/main f5b7e1d1ac: no defect found. The focused tests pass 3/3 on RDNA4 (gfx1201) with the Khronos validation layer loaded, and they log no VUID-. This adds a newer AMD generation and the current main to the RX 6800 and RTX 3070 runs already posted.

Code. I found no problem.

  • FoldDrawOffsets (Execution/src/Driver/Draw/IndirectDraw.cpp) now adds the two words as signed values for indexed draws only.
  • Every indexed branch of prepareDrawInputs sets inputs.minIndex before the signed range check. That covers the expanded path, list restart, in-place, a fresh copy and a reused copy (copy.lowest).
  • The behind-writer branch keeps lowest = 0, but InPlaceIndexBehindWriter now refuses every negative offset, so that branch never meets one.
  • The new firstByte only feeds the render-target alias check.
  • Repo rules: no code comments are added.

Negative control. I copied the PR's DrawOffsetIndices.cpp and Recorder.cpp onto main:

  • draw_offset_indices, _poisoned and _poisoned_in_place fail with draw vertex offset overflow.
  • agc_index_in_place_behind_writer fails on the -2147483648 case.

This matches the author's control on RX 6800.

GPU.

ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer ctest --test-dir build -R "^(agc_driver_draw_offset_indices|agc_driver_draw_offset_indices_poisoned|agc_driver_draw_offset_indices_poisoned_in_place|agc_index_in_place_behind_writer|agc_driver_graphics)$" -V
run draw_offset_indices _poisoned _poisoned_in_place index_in_place_behind_writer agc_driver_graphics
main Passed 1.12 s Passed 0.29 s Passed 0.32 s Passed 0.20 s Passed 15.94 s
main + PR tests Failed 0.25 s Failed 0.23 s Failed 0.23 s Failed 0.15 s n/a
head 1 Passed 0.30 s Passed 0.27 s Passed 0.28 s Passed 0.17 s Passed 14.25 s
head 2 Passed 0.34 s Passed 0.29 s Passed 0.28 s Passed 0.18 s Passed 13.65 s
head 3 Passed 0.35 s Passed 0.32 s Passed 0.33 s Passed 0.17 s Passed 14.46 s

agc_driver_graphics creates no Vulkan instance: it has no layer insertion and no device line. The other four select the R9700. No test skipped.

Validation.

  • Each run has 4 Insert instance layer "VK_LAYER_KHRONOS_validation" lines, one per Vulkan test.
  • was not found but was requested by env var VK_INSTANCE_LAYERS appears in none of them.
  • VUID- lines: 0 on main and 0 on each head run.

Host:

  • GPU: AMD Radeon AI PRO R9700 (gfx1201, 1002:7551), driver 32.0.31044.16, Vulkan 1.4.349
  • Validation layer: Khronos 1.4.363 (LunarG SDK)
  • CPU: Ryzen 9 9950X3D
  • OS: Windows 11 Pro 26300
  • Toolchain: WinLibs GCC 15.2, Release
  • Commits measured: main f5b7e1d1ac; head f15b926719 (8a0fcdd825 merged onto f5b7e1d1ac)

AI-assisted: yes

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 1395 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 4448 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 5609 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 5925 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 6186 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 6188 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 6192 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 6209 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 7085 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 7256 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 7275 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 7642 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/IndirectDraw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/execution/DrawOffsetIndices.cpp
PR 8246 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 9289 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 9356 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 9387 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 9508 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/IndirectDraw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/execution/DrawOffsetIndices.cpp
PR 9712 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 9852 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 9897 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 9915 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 10193 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 10359 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/IndirectDraw.cpp
PR 10497 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 11452 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 11551 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 11825 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 13148 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 13251 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 13809 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 13863 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 13920 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 13928 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 13929 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 14032 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 14944 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 15136 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 15343 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 15456 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 15548 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 15570 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 16879 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 17022 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 17611 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 17943 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 18029 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 18082 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 18173 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 20041 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 20518 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 21923 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 22029 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 22424 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 22434 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 22647 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 22697 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 23553 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 23811 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/IndirectDraw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/execution/DrawOffsetIndices.cpp
PR 24083 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 24572 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 24735 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 25684 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 26041 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 26084 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 27133 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 27807 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/IndirectDraw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 28142 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 28150 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 28176 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 28193 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/execution/DrawOffsetIndices.cpp
PR 28229 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 28250 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 28372 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 28384 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 28470 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 28487 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 28488 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 28586 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 28590 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 28673 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 28808 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 28920 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp

@nexus1692

Copy link
Copy Markdown
Contributor

Independent NVIDIA Blackwell validation of agc_driver_draw_offset_indices*

The PR's Tested block is complete and covers Windows 11 on an AMD Radeon RX 6800. This run adds the other vendor: native Windows 11 on an RTX 5070 Ti (Blackwell) with the Khronos validation layer, plus the implementation-revert control.

Hardware and toolchain

OS Windows 11 (x86-64)
Compiler WinLibs GCC 16.2.0 (MinGW-w64 x86_64-ucrt-posix-seh, built by Brecht Sanders, r3)
CMake / Ninja 4.4.4 / 1.13.2, CMAKE_BUILD_TYPE=Release, BUILD_TESTING=ON
GPU NVIDIA GeForce RTX 5070 Ti 16 GB, vendor=0x10de device=0x2c05, driver 621.24
Validation layer VK_LAYER_KHRONOS_validation 1.4.363 (Vulkan SDK 1.4.363)
Environment ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, APS5_NO_PIPELINE_JOURNAL=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, VK_LOADER_DEBUG=layer
Head 8a0fcdd825
Base for the control 441fa65119 (the merge base, same base the PR used)

Build

cmake -S . -B build      # exit 0, the new tests/execution/DrawOffsetIndices.cpp is picked up by the glob
ninja -C build agc_driver_draw_offset_indices_tests

Exit 0, plus the usual MinGW .rsrc merge failure: multiple non-default manifests link warning.

Results

ctest --test-dir build -R '^agc_driver_draw_offset_indices' -V, three tests per run, 3 consecutive runs:

Run _draw_offset_indices _poisoned _poisoned_in_place device=0x2c05 Instance layer inserts VUID-
1 Passed, 1.54 s Passed, 0.46 s Passed, 0.44 s yes 3 0
2 Passed Passed Passed yes 3 0
3 Passed Passed Passed yes 3 0
implementation reverted Failed Failed Failed yes 3 0

3/3 tests green on every run, no skips, no was not found but was requested by env var VK_INSTANCE_LAYERS line, and 0 VUID- lines in all three runs. Each test prints its own verdict (draw offset index tests passed), so these are real device runs, not VulkanTestSkipped.

Negative control (implementation reverted, tests kept)

Keep the PR's tests and revert only the implementation to 441fa65119: Execution/src/Driver/Draw/IndirectDraw.cpp and Graphics/src/Draw.cpp. Rebuild is clean and all three suites fail with assertion output, not a crash:

a program that copies v5 and v8 before its fetch adds: folded value observable outside the fetch add: vertex 1 instance 1; expected 1 1
a program whose fetch adds are the only readers of v5, v8, s16 and s17: folded value observable outside the fetch add: vertex 0 instance 0; expected 0 0
a program that reads the instance add's carry: folded value observable outside the fetch add: vertex 0 instance 1; expected 0 1
a program whose vertex add is a clamped v_sad_u32: folded value observable outside the fetch add: vertex 1 instance 0; expected 1 0
0% tests passed, 3 tests failed out of 3

So on NVIDIA the new assertions fail exactly when the signed base-vertex handling is missing, and pass with it.

What this does and does not establish

Establishes, on native Windows 11 with GCC 16.2.0/UCRT in Release on an RTX 5070 Ti:

  • the new agc_driver_draw_offset_indices suites build and pass on Windows/Blackwell, 3/3 tests, 3/3 runs, with the validation layer inserted at instance and device and zero VUID- lines;
  • the tests create a real Vulkan device on this GPU and exercise the indexed-draw vertex fetch path (v5/v8 copies, v_sad_u32 clamped add, instance-add carry) through the SPIR-V the recompiler emits;
  • reverting only the two implementation files makes all three suites fail on the same assertions, so the fix is what they measure — this is the second vendor where that holds.

Does not establish:

  • console behaviour: the expected folded values are the test's reading of the ISA, not a PS5 capture;
  • the full 171-test sweep from the PR body: only the three draw_offset_indices suites were run here;
  • AMD/Intel parity: the Radeon RX 6800 result in the PR body is the author's; this machine has no AMD GPU, so cross-vendor agreement is inferred from two independent reports, not measured on one machine;
  • no title or homebrew run, and no other Windows version or driver.

Workspace cleaned up afterwards: temporary branch deleted, main left at origin/main, no local changes.

@upipibi

upipibi commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

RTX 3070 run of 8a0fcdd825, merged with --no-ff onto main 4d4a7e2980, against main alone.

Tested

  • NVIDIA GeForce RTX 3070 (driver 616.56, subgroup 32), Windows 11 Pro 26100, WinLibs GCC 15.2.0, Ninja, Release; ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation.
  • ctest -R "^agc_driver_draw_offset_indices$|^agc_index_in_place_behind_writer$", 3 runs each:
    • main: 2/2 passed in all 3 runs.
    • this PR: 2/2 passed in all 3 runs.
  • Validation layer inserted in every Vulkan test (2 per run on the PR side), 0 VUID- messages. Build: 0 failed targets.

Not tested: AMD, titles.

AI-assisted (Claude Code).

@github-actions github-actions Bot added review queue Next in the maintainer review queue: checks pass, no open change request, no conflict needs rebase Conflicts with main, rebase needed and removed review queue Next in the maintainer review queue: checks pass, no open change request, no conflict labels Nov 24, 2026
@birdmarty
birdmarty force-pushed the fix/agc-negative-base-vertex branch from 8a0fcdd to 6080bb0 Compare November 26, 2026 10:48
@birdmarty

Copy link
Copy Markdown
Contributor Author

Rebased onto origin/main 0af6efa as 6080bb0 to resolve the conflicts with merged #26775:

  • core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp: preserved !wholeRange on firstByte (!wholeRange ? VertexBufferReadOffset(attribute, draw.indexed ? inputs.minIndex : draw.firstVertex, draw.firstInstance) : 0).
  • core/libs/prx/libSceAgcDriver/tests/Recorder.cpp: updated the negative-offset InPlaceIndexBehindWriter test calls to perf(agc): bind indices behind a GPU writer for draws with vertex attributes #26775's 5-argument attempt(...) signature.

Re-verified on Windows 11 Pro (build 26300), i9-9900K, WinLibs GCC 15.3.0 Release, AMD Radeon RX 6800 (AMD driver 26.10.1, Vulkan 1.4.315), Khronos validation layer 1.4.363.0:

  • Focused 20-test set (agc_driver_draw_offset_indices*, agc_index_in_place_behind_writer, agc_driver_graphics, agc_driver_list_restart*, agc_driver_indirect*, agc_driver_zero_stride*, agc_driver_recorder): 20 / 20 passed on both origin/main 0af6efa and 6080bb0, 34 validation layer inserts on both, 0 VUID- lines.
  • Negative control (checking out origin/main 0af6efa's Draw.cpp and IndirectDraw.cpp against 6080bb0's tests): 4 / 4 failed (agc_driver_draw_offset_indices* with AGC driver: draw vertex offset overflow, agc_index_in_place_behind_writer on the -2147483648 case); all 4 pass on 6080bb0.
  • tools/check_conventions.py --base origin/main and tools/debt_fold.py --check: passed.

Not done: new Forza run, Linux, or other GPUs on 6080bb0.

AI-assisted: yes.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

Nothing in the inspected changes shows a blocking defect, and the tests reported by the author cover the signed offset cases added here.

What I ran

Reviewed head 6080bb0b9372ff9d6eae0f170212093c52b57f80. No commands or tests were run; test results in the description are author-reported.

Results

Check Result Note
Source review passed Changed runtime paths and tests inspected
Tests not run Author reports focused tests passed
Negative control not run Author reports four expected failures

Findings

Blocking

None.

Non-blocking

None.

Not verified

No test execution was performed. The game runs, other GPUs, Linux, and indirect or expanded-index negative-offset behavior in titles were not verified. Recorder.cpp was excluded from the prepared review bundle; its changed lines were read through the pinned-head reader, but its surrounding full test context was not reviewed. The other changed files were included and inspected at the relevant changed sections.

To get this to a good state

Nothing is required.

@github-actions github-actions Bot added review queue Next in the maintainer review queue: checks pass, no open change request, no conflict and removed needs rebase Conflicts with main, rebase needed labels Nov 26, 2026
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed review queue Next in the maintainer review queue: checks pass, no open change request, no conflict labels Nov 28, 2026
birdmarty and others added 3 commits November 30, 2026 00:23
An indexed draw with a negative base vertex (a vertex offset that
cancels the lowest index) threw "indexed draw vertex range overflow",
because the offset was compared as unsigned. Vulkan's vertexOffset and
the hardware's base vertex are signed; check the offset range of the
lowest and highest index with signed arithmetic, track the lowest index
of expanded indices, clamp the zero-fetch index limit with it, and
measure the render-target alias check from the lowest vertex read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ET as signed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@birdmarty
birdmarty force-pushed the fix/agc-negative-base-vertex branch from 6080bb0 to 8f5ca2b Compare November 29, 2026 22:53
@birdmarty

Copy link
Copy Markdown
Contributor Author

Rebased onto origin/main 1f27e2a as 8f5ca2b to resolve the conflict in core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp with merged #27686 (preserved this PR's firstByte expression !wholeRange ? VertexBufferReadOffset(attribute, draw.indexed ? inputs.minIndex : draw.firstVertex, draw.firstInstance) : 0 together with #27686's aliasesTarget / NeedsIndividualRecords fallback; IndirectDraw.cpp, tests/Recorder.cpp, and DrawOffsetIndices.cpp merged cleanly).

Re-verified on Windows 11 Pro (build 26300), i9-9900K, WinLibs GCC 15.3.0 Release, AMD Radeon RX 6800 (AMD driver 26.10.1, Vulkan 1.4.315), Khronos validation layer 1.4.363.0:

  • Focused 20-test set (agc_driver_draw_offset_indices*, agc_index_in_place_behind_writer, agc_driver_graphics, agc_driver_list_restart*, agc_driver_indirect*, agc_driver_zero_stride*, agc_driver_recorder): 20 / 20 passed on both origin/main 1f27e2a and 8f5ca2b, 34 validation layer inserts on both, 0 VUID- lines.
  • Negative control (origin/main 1f27e2a's Draw.cpp and IndirectDraw.cpp against 8f5ca2b's tests): 4 / 4 failed (agc_driver_draw_offset_indices* with AGC driver: draw vertex offset overflow, agc_index_in_place_behind_writer on the -2147483648 case).
  • tools/rebase_verify.py, tools/check_conventions.py --base origin/main, and tools/debt_fold.py --check: all passed.

Not done: new Forza run, Linux, or other GPUs on 8f5ca2b.

AI-assisted: yes.

@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes: Indexed Draw Offset Handling

Layer / File(s) Summary
Signed offset composition
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/IndirectDraw.cpp, core/libs/prx/libSceAgcDriver/tests/execution/DrawOffsetIndices.cpp
Indexed indirect draws combine the base vertex and offset as signed 32-bit values. Execution tests cover positive and negative offsets and overflow errors.
Indexed range validation and fetch bounds
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp, core/libs/prx/libSceAgcDriver/tests/Recorder.cpp, core/libs/prx/libSceAgcDriver/tests/execution/DrawOffsetIndices.cpp
Indexed draw paths track minimum and maximum indices, validate adjusted bounds, and use adjusted indices for fetch ranges. Tests cover offset boundaries and vertex-range errors.

Possibly related PRs

  • boykopovar/AnyPS5#27686: This PR also changes the render-target alias-check logic and overlaps with the firstByte expression.

Suggested reviewers: marczx10, mihiii1337, celegans12

Change: Bug fix

Merge Risk: Minimal · up to 8f5ca

Indexed draws with negative base vertices are now accepted, with range checks that reject out-of-bounds index ranges. The change is contained to indexed-draw offset arithmetic and covered by focused tests. No merge-blocking issue remains, though the latest rebase has not been run in a title or on other hardware.

Security architecture risk: Minimal · up to 8f5ca

The change accepts valid negative offsets while rejecting draws whose adjusted vertex range falls outside the allowed bounds. It also tightens the conditions for reading indices before a pending write has finished. The review did not establish a new security or failure-containment issue.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The changed exposure is at the guest-draw-to-host-rendering boundary: guest-provided offsets and index data influence acceptance and vertex-fetch ranges through the existing renderer submission path.

Trust Boundaries and Controls

  • observed — The ordinary import path flushes pending writes and declines the import if an overlapping writer remains. The copy path flushes before reading or reusing a snapshot, and validates the bound copy using its scanned or cached bounds.
Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

Cppcheck (2.22.0)

Cppcheck (2.22.0) exceeded its 180-second time budget. Findings from completed work are retained; remaining checks are incomplete.

core/libs/prx/libSceAgcDriver/tests/Recorder.cpp

Cppcheck interrupted; analysis of this file is incomplete

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fd931f91-5812-4389-af14-86292a6b7682
Commits

Reviewing files that changed from the base of the PR and between 1f27e2a and 8f5ca2b.

Files selected for processing: 4

  • core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/IndirectDraw.cpp
  • core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
  • core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
  • core/libs/prx/libSceAgcDriver/tests/execution/DrawOffsetIndices.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.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

Nothing blocks this change; the review supports merging.

What I ran

Reviewed head 8f5ca2b793c6210e10e065bae0fccc4d504938b2. I did not run commands or tests. I read the prepared description, commits, manifest, and diff, plus the relevant changed functions and test additions at the pinned head.

Results

Check Result Note
Code review passed Signed indexed ranges checked
Tests in this review not run Author-reported runs only
Negative control not run Author reports four failures on prior code

Findings

Blocking

None.

Non-blocking

None.

Not verified

I read the full text for IndirectDraw.cpp, Draw.cpp, and DrawOffsetIndices.cpp, and the changed Recorder.cpp lines through the pinned reader. All four changed files marked reviewed in the manifest were read; Recorder.cpp was excluded from the review folder because of its size, so I read only its changed region. I did not run the reported test suites or inspect unrelated file contents. Console behavior, other GPUs, Linux, and the title scenarios identified by the author as untested remain unverified.

To get this to a good state

Nothing is required.

@github-actions github-actions Bot added review queue Next in the maintainer review queue: checks pass, no open change request, no conflict and removed needs rebase Conflicts with main, rebase needed labels Nov 29, 2026
@B-Howell

B-Howell commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Windows test at head 8f5ca2b793c6: passes, control fails.

Setup: Windows 11 Pro, RTX 4080 SUPER (driver 621.14), WinLibs GCC 15.2.0, Release, Ninja. Head merged onto main b396d834cb05 (merges cleanly).

  • Built agc_driver_recorder_tests and agc_driver_draw_offset_indices_tests.
  • Ran with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (LunarG 1.4.363.1 layer, Insert instance layer "VK_LAYER_KHRONOS_validation" in the logs, no was not found line):
    • PR: 186 of 186 passed, 3 runs out of 3. 0 VUID-, 0 SYNC-HAZARD.
    • main, the same 186 tests: 186 of 186 passed, 3 runs out of 3. 0 VUID-, 0 SYNC-HAZARD. The PR adds no validation errors.
  • Control: Draw.cpp and IndirectDraw.cpp from main, tests kept. 4 fail: agc_driver_draw_offset_indices, _poisoned and _poisoned_in_place with draw vertex offset overflow, and agc_index_in_place_behind_writer on the -2147483648 vertex offset case.
  • tools/check_conventions.py --base origin/main passes. Read the change against AGENTS.md: no comments, no title-specific values. Only indexed draws take the offset as signed; non-indexed draws keep the unsigned overflow check. No problems found.

Did not run Forza Horizon 5.

@Plyxen Plyxen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read the diff at 8f5ca2b793. Windows 11, GCC 15.2, merged into main at cf556db18c3 together with other open PRs (so not an isolated build), with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 and VK_LAYER_KHRONOS_validation on an RTX 5080 (621.24) and a Radeon iGPU (26.11.2).

  • the 186 tests of agc_driver_draw_offset_indices_tests and agc_driver_recorder_tests (2 of them skip on the Radeon): pass on both GPUs. The loader log shows the layer inserted and no "was not found" line, and neither run has a VUID- or SYNC-HAZARD line.
  • Control (same tree and tests, the changed files of those PRs put back to main's): agc_driver_draw_offset_indices, its two poisoned variants and agc_index_in_place_behind_writer fail on both GPUs: "draw vertex offset overflow", and a 16-bit index range "whose vertex offset of -2147483648 takes every index below vertex 0". The others pass.

Not checked: a title.

AI-assisted: yes (Claude Code)

@ligmaSec ligmaSec left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The signed widening covers both the offset fold and post-index range checks. The new fixture covers opposite-sign register offsets, both signed fold limits, a lowest effective vertex of zero and a quad that crosses below zero. Please add a successful expanded quad with a negative base and all raw indices above zero. That would exercise carrying the expanded minimum through to the vertex upload and alias calculation, beyond the expanded path's rejection case. The paired draw-offset and behind-writer tests are queued on Linux lavapipe.

AI-assisted: yes.

@ycbuzi

ycbuzi commented Dec 5, 2026

Copy link
Copy Markdown
Contributor

Tested 8f5ca2b793 merged into main, with the whole ctest suite on each machine below. Nothing fails that does not also fail on main on the same machine.

  • Windows Server 2022 (GitHub-hosted runner), full build, WinLibs GCC 15.2.0: 99% tests passed, 3 tests failed out of 7668; 99% tests passed, 3 tests failed out of 7668. 3 of the failing tests fail on main too. run
  • Windows Server 2025 (GitHub-hosted runner), full build, WinLibs GCC 15.2.0: 100% tests passed, 0 tests failed out of 7668; 100% tests passed, 0 tests failed out of 7668. run

GPU (software Vulkan): 18 GPU tests (AGC) passed twice on Mesa lavapipe (Mesa 25.2.8-0ubuntu0.24.04.5 (LLVM 20.1.2)) on a GitHub-hosted Ubuntu 24.04 runner, with the Khronos validation layer on and the shader cache off, alongside main 0da1e9d48b: no Vulkan validation message appears that main does not also produce. run

Not covered: GPU hardware. lavapipe runs Vulkan on the CPU, so this says nothing about how real GPU drivers handle the changed paths.

AI-assisted: yes (Claude Code); the runs are automated, this summary was written from their reports.

@blawesom

blawesom commented Dec 6, 2026

Copy link
Copy Markdown
Contributor

Validated 8f5ca2b793c6 cleanly merged onto main 0c8722f3a4ec; no contributor branch was modified.

Linux/RADV: RX 9070 XT (RADV GFX1201), Mesa 26.3.1, Khronos validation 1.4.363. agc_driver_draw_offset_indices, agc_vertex_input, agc_vertex_input_validation and agc_driver_graphics passed 4/4 with ANYPS5_REQUIRE_VULKAN=1, cache disabled and the Khronos layer loaded. There are four layer insertions, no missing-layer diagnostic and zero VUID- lines. The fixture covers the base-vertex -3 + GE_INDX_OFFSET 3 case, signed-fold overflow boundaries, low-index fetch allocation and the indexed quad-list below-zero refusal.

Negative control: replacing only the indexed fold with the previous unsigned-overflow arithmetic leaves the rest of the PR intact and makes agc_driver_draw_offset_indices fail with AGC driver: draw vertex offset overflow. Restoring the signed sum preserves the above green result. This isolates the packet-fold change rather than treating its green run as acceptance by itself.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* review queue Next in the maintainer review queue: checks pass, no open change request, no conflict unblocks title Names a title ID on the Unblocks line

Projects

None yet

Development

Successfully merging this pull request may close these issues.