feat(agc): execute INDEX_ATTRIBUTES_INDIRECT (PM4 0x91) #4895
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4895"
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 fdfawef324 on 2026-10-13T02:28:10Z.
What
The driver had no handler for PFP opcode 0x91 INDEX_ATTRIBUTES_INDIRECT, so a submission containing it threw
opcode is not known in the reference. Demon's Souls (PPSA01342) stops there at its first indirect draw. The packet now runs: when it executes, it reads the 16-byte record atattribute_base + attribute_index * 16from guest memory and sets INDEX_BASE, INDEX_BUFFER_SIZE and INDEX_TYPE from it, exactly as the INDEX_BASE (0x26), INDEX_BUFFER_SIZE (0x13) and INDEX_TYPE (0x2a) packets do.0xc0029100indirect_mode, bits 1-3 reserved,attribute_base_loattribute_base_hi(oraddr_offsetwhenindirect_modeis 1)attribute_indexSources:
BuildIndexAttributesIndirectandPM4_PFP_INDEX_ATTRIBUTES_INDIRECT: 4 dwords, the base must be 4-dword aligned (it asserts that the reserved bits are 0), andindirect_mode1 putsaddr_offsetin dword 2.IndexAttribIndirect, "the layout of the index buffer attributes used by a INDEX_ATTRIBUTES_INDIRECT packet":gpuVirtAddrLo,gpuVirtAddrHi,indexBufferSize(in indices, not bytes),indexType. The type uses the VGT_INDEX_TYPE encoding; theLog2IndexSizetable beside it is indexed 16, 32, 8.9a50e25cnothing undersrc/amdor radeonsi names INDEX_ATTRIBUTES_INDIRECT (sid.hincluded), and RADV's DGCdgc_emit_index_buffer(the file wasradv_device_generated_commands.c) writes VGT_INDEX_TYPE, INDEX_BASE and INDEX_BUFFER_SIZE directly.Behaviour:
indirect_mode1 throws (indirect mode (addr_offset) is not implemented);sceAgcDcbSetIndexIndirectArgs(#4392) never sets it. Reserved base bits 1-3 throw (unaligned base), and so do reserved bits 16-31 of dword 3.GuestMemory::Read(flush hook, thenCheckRangewith 16-byte alignment). A null, unmapped or overflowing record address throws, and the index state stays as it was.unsupported index type), as for the direct packets. The base and size are not checked until the draw, also as for the direct packets.AccessesMemory), so dispatch-ahead resolution stops at it andAPS5_DRAIN_ALLdrains before it.Recorded in
docs/dev/debt/libSceAgcDriver.md: the layout comes from PAL only. It was not measured on a PS5 or checked against a title.Tested
Windows Server 2025, RTX 3060, GCC 15.2 (WinLibs),
build-dev.agc_driver_pm4_tests,agc_driver_tests,agc_driver_flip_tests,agc_driver_recorder_testsandagc_driver_graphics_testspass, among themagc_driver_pm4,agc_driver_pm4_failure,agc_driver,agc_driver_flip,agc_driver_graphics,agc_pipeline_cacheandagc_draw_inputs_in_place.testIndexAttributesIndirectbuilds a 0x91 packet by hand with a record in memory. It checks that the packet loads base, size and type, and that the indexed draws DRAW_INDEX_OFFSET_2 (0x35) and DRAW_INDEX_INDIRECT (0x25) after it resolve to the same parameters as after INDEX_BASE + INDEX_BUFFER_SIZE + INDEX_TYPE. It checks that the read goes through the flush hook over exactly the record's 16 bytes. Rejections leave the index state unchanged: indirect mode, an unaligned base, reserved index bits, a wrong size, a compute queue, a null, unmapped or overflowing record address, and a record type of 4 (the message names the record address). Type 3 is rejected at the draw.testIndexAttributesReadAtExecutionsubmits WAIT_REG_MEM, then 0x91, then WRITE_DATA. While the queue waits, the record changes from an invalid one (type 4) to a valid one. The worker finishes, so the record is read when the packet runs.agc_driver_pm4fails at the catalog check (reference opcode catalog is incomplete). With the catalog count also set back to 55, it fails in the new test (INDEX_ATTRIBUTES_INDIRECT is not executed). With the change it passes.python -I tools/check_test_registration.py build-devandtools/check_conventions.pypass.agc_driver_flat_*,agc_driver_prepared_shaders_*, the execution and BDA tests). No speed change is claimed.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)sceAgcDcbSetIndexIndirectArgsbuilder; that PR is closed at present and has to be reopened)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T04:39:10Z.
Windows test (MinGW GCC 15.2, Release, Windows 10, RTX 4080 SUPER). Built on current main
3779597together with four other open GPU PRs (their own commits cherry-picked, no merge commits), so only the tests that belong to this PR say something about it:tests/Pm4.cpp(agc_driver_pm4): 3 of 3 runs passed.Not tested: no game run. The batch was built once, not per PR; nothing failed, so no bisect was needed.
AI-assisted (Claude Code).