Repository navigation
Conversation
DRAW_INDEX_2 and DRAW_INDEX_OFFSET_2 refused a packet whose INDEX_COUNT is larger than its MAX_SIZE. AMD PAL and Mesa RADV write MAX_SIZE as the indices left in the bound buffer and INDEX_COUNT as the draw's own count, and the hardware returns 0 for the reads past MAX_SIZE. Draw the first MAX_SIZE indices, as the CPU indirect path already does for a record past INDEX_BUFFER_SIZE. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ed_draw guest_indexed_draw still expected Pm4::Validate to refuse a DRAW_INDEX_2 or DRAW_INDEX_OFFSET_2 whose INDEX_COUNT exceeds MAX_SIZE. With this change those packets validate and resolve to MAX_SIZE indices, so the four checks now assert that. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Change: Bug fix Merge Risk:
|
What
Astro Bot (PPSA21564, 01.007.000) stops on
mainf4383b0acat 581 s, during the space flight after the opening cinematic, withAGC driver: DRAW_INDEX_OFFSET_2 at DWORD 263: index count exceeds maximum index size. The whole submission (7478 dwords, 232 of them DRAW_INDEX_OFFSET_2 packets) is rejected and the exception terminates the title (EXIT-134). This was the first time in eight 600 s runs of the title onmain; the other seven ran to the timeout.Pm4::Validaterefuses DRAW_INDEX_2 (0x27) and DRAW_INDEX_OFFSET_2 (0x35) whenever INDEX_COUNT is larger than MAX_SIZE, but that is a packet AMD's own drivers write:validIndexCount), and INDEX_COUNT to the draw's own count. Its comment calls MAX_SIZE the clamp on how much of the index buffer can be read.The change:
Validateno longer refuses INDEX_COUNT > MAX_SIZE.ResolveDrawdrawsmin(INDEX_COUNT, MAX_SIZE)indices, so it reads and range-checks only the indices inside MAX_SIZE. That is what the CPU indirect path already does for a record that runs past INDEX_BUFFER_SIZE (Driver/Draw/Draw.cpp:std::min(arguments.count, drawParameters.indexCount - arguments.firstVertexOrIndex)).The hardware reads the indices past MAX_SIZE as 0 instead of dropping them, so a triangle that straddles MAX_SIZE, or the extra points of a point list, would still be drawn on the console. The debt fragment records that difference.
Tested
Linux (Ubuntu 26.04.1, kernel 7.0), GCC 15.2, Ninja, Release,
-DBUILD_TESTING=ON, RTX 4070 Ti on NVIDIA 615.71:85bad3a7eb(mainf73d791b3dmerged in):guest_indexed_draw, whose refusal checksmainadded after this branch was opened (8b3c360), still expected the refusal; its four checks now expect the clamp (a DRAW_INDEX_2 with MAX_SIZE 3 and a count of 4 or 0xffffffff resolves to 3 indices; a DRAW_INDEX_OFFSET_2 with MAX_SIZE 2 and a count of 3 or 0xffffffff resolves to the 2 indices of the in-range offset draw).guest_indexed_drawand the 30agc_driver_pm4*tests pass in each of 3 runs.testIndexedDrawintests/Pm4.cppgains three checks: a DRAW_INDEX_OFFSET_2 with MAX_SIZE 3, offset 2 and count 6 resolves to 3 indices at the offset; a DRAW_INDEX_2 with MAX_SIZE 2 and count 5 resolves to 2 indices; a MAX_SIZE of 0 resolves to an empty draw. The check that expected the refusal is removed.ctest -R '^agc_driver_pm4'(30 tests) passes 3 runs one74ccb2d9c, which has the same code as the head (284d1c3184only shortens the debt entry).main'sPm4.cppand the new checks,agc_driver_pm4fails.git merge-treeagainstmaind7be67833eis clean.tools/check_conventions.pypasses on the branch and this body, andtools/debt_fold.py --checkreports nothing for this fragment.Windows 11 (VM, GeForce GT 1030, WinLibs GCC 16.2, Ninja, Release,
ANYPS5_REQUIRE_VULKAN=1),ctest -R '^agc_driver_pm4'on284d1c3184, 3 runs: 29 of 30 pass in each,agc_driver_pm4included.agc_driver_pm4_order_signalfails in all 3, and fails the same way on this PR's basea8b2a7d2a5(3 of 3): on this 4-vCPU VM a held submission starts 0.37-0.44 ms (median) after queue 0 begins to wait, and the test wants it at once. So that failure is not from this change.284d1c3184, applied with other PRs ontomainfd4aeed483(one combined tree, not this PR alone), Windows 11, WinLibs GCC 15.2.0 r7, Release, no validation layer: the 6agc_driver_pm4*tests pass on an NVIDIA GeForce RTX 3080 (driver 621.24) and on the AMD Radeon iGPU of a Ryzen 7 9800X3D (gfx1036).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)main). A 600 s run with this change plus a temporary log line for clamped draws reached the same point without meeting such a packet, so it shows nothing either way. If the stop shows up again, I'll post the packet's MAX_SIZE, offset and count here (discussion #357).Summary by CodeRabbit