feat(agc): divide the PS4 vertex instance index by VGT_INSTANCE_STEP_RATE_0 #20153
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/20153"
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 puridanish284 on 2026-11-14T18:24:02Z.
What
PS4 (GCN) vertex programs with a
VGT_INSTANCE_STEP_RATE_0other than 1 were refused withGCN vertex instance step rates other than 1 are not implemented. A plain vertex program whoseSPI_SHADER_PGM_RSRC1_VS.VGPR_COMP_CNTloads v1 now receives the instance index divided by that rate in v1. v2 and v3 keep the instance index, as before. This is the layout the vertex case of shadPS4'sEmitPrologue(a26cac679b3f) uses for v1 and v3.DecodeShaderStagesreads the rate intoShaderStages::instanceStepRate(1 when the register is unset), andApplyInstanceStepRatecopies it intoShaderVertexStageInfoat the four places that already apply the point size.CacheKey.hpp), the draw cache (DrawLookup,sameVertexInfo) and the serialized request. The request serialization version goes to 64 (mainwrites 63 and refuses 58 to 61). The rate is written beforemain's version 63 emulated barycentrics flag, and version 63, 62 and 57 requests still read with a rate of 1.UDiv32(instance, rate)when the rate is not 1.VGT_INSTANCE_STEP_RATE_1other than 1 when v2 is loaded (shadPS4 divides by it, but what a plain VS receives in v2 is not confirmed). Both are recorded indocs/dev/debt/libSceAgcDriver.md.legacyVertex, because these fields reach pipelines through the shader requests. Only theShaderStagessize assert moves from 164 to 168, andsizeof(State)stays 952.Tested
WSL2 Ubuntu 24.04, gcc 13.3, Release, lavapipe (Mesa 25.2.8, Vulkan 1.4.318), Khronos validation layer 1.3.275,
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation. Same machine and build directory for both runs.agc_driver_gcn_instance_step_rate: a GFX7 vertex program stores v1, v2 and v3 into a buffer indexed by v3, over 7 instances at rates 1, 2, 3 and 8. It checks v1 = instance / rate and v2 = v3 = instance. With v1 forced back to the plain instance, it fails (rate 2, instance 1: v1 is 1, not ... (0)).agc_driver_graphics: decode of the rate for VGPR_COMP_CNT 1 to 3, an unset register, a program that loads no instance, the two refusals, the cache key and the request round trip.request_serializer: version 64 round trip, truncation and reading versions 63, 62 and 57;main's version 63 single-sample dither checks now start from version 64 and probe 65 as unsupported.agc_shader_memoryandagc_shader_memory_coherent_atomic_loads: the new-request prefix is version 64, the unsupported-version probe moves to 65,main's emulated barycentrics check starts from version 64, and the version 56 fixture also drops the 4-byte rate of a vertex request.main26194f0fcf:request_serializer,agc_shader_memory*,agc_gcn_*,agc_driver_gcn_*,agc_driver_graphics,agc_driver_draw_cache*, withVK_LOADER_DEBUG=layer(every test's log showsInsert instance layer "VK_LAYER_KHRONOS_validation").26194f0fcf5e025f010dVUID-vkCmdDraw-None-07629VUID-VkDeviceCreateInfo-pNext-pNextwas not found but was requested by env var VK_INSTANCE_LAYERSagc_driver_gcn_compare_exec_writesskips on lavapipe on both. ThepNextVUID is the known one from Ubuntu's older validation layer (#17693) and comes once per device creation, so the 3 extra lines are the new test's own devices.07629comes from tests this PR does not touch and has the same count on both.Not run on a title: no title report hits this refusal yet.
pr_overlapfailed closed: 97 of the 105 branches it flags conflict withmainthemselves. The 8 it could compare (#11551, #14561, #15343, #19373, #19821, #20010, #20030, #20111) share only the serialization version number or theShaderStagessize assert, which whichever merges second re-bumps. None of them handles instance step rates.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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-16T22:52:34Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the implementation and the included tests support merging on the inspected paths.
What I ran
Reviewed head
0c982d8a274d3cf00d9106f131df8d1c09d40dd9using the prepared diff and pinned reader. No build or tests were run; test results below are author-reported.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The full text of
core/libs/prx/libSceAgcDriver/tests/Graphics.cppandcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppwas excluded as too large; only their changed hunks were reviewed. No local test or build run was performed, and no title or physical console behavior was verified. Other included changed files were read from the prepared diff or targeted reader ranges; not every full file was read.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T17:16:29Z.
Review: COMMENTED
Reviewed — no blocking findings
The inspected code implements the described instance step rate handling; the author-reported tests were not run during this review.
What I ran
Reviewed head
a525340b4dec598e4f7a78c6c8dafb360ba585ddusing the prepared diff andrepo_read.pyto inspect changed hunks and relevant code. No tests or build commands were run.Results
Findings
Blocking
None identified in the code inspected.
Non-blocking
The change has no console validation yet, as noted in the PR description and debt entry. The behavior should be confirmed on console hardware when available.
Not verified
I did not run the reported test suite or build, and did not verify behavior on console hardware. The prepared folder omitted the full text of
Graphics.cppandShaderMemory.cpp; I read the changed regions for both throughrepo_read.py. I inspected changed hunks and relevant context rather than every line of every changed file.To get this to a good state
Nothing is required. Keep the console validation limitation documented until that behavior is confirmed.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T02:02:53Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing in the inspected changes shows a verified blocking defect; the author’s reported test results were not run in this review.
What I ran
Reviewed head
5e025f010d3d7f5bd4b3e2ca0d616e141b6ac25dusingrepo_read.pyto inspect the prepared diff and targeted source context. No tests or builds were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No build or test commands were run. Console behavior is unverified, as the description states. Reviewed changed files:
Draw.cpp,DrawLookup.cpp,DrawRegisterKey.cpp,ShaderRegistry.cpp,State.hpp,PipelineJournal.cpp,State.cpp,Graphics.cpp(changed region),ShaderMemory.cpp(changed regions),GcnInstanceStepRate.cpp,CacheKey.hpp,RequestSerializer.cpp,ShaderStageInputInfo.hpp,Recompiler.hpp,InstructionTranslator.cpp,ShaderInputInfoBuilder.cpp,RequestSerializerTests.cpp(changed regions), andlibSceAgcDriver.md. No changed files were excluded from review; full-file text forGraphics.cppandShaderMemory.cppwas not included, so only their changed regions were read.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T05:14:52Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the implementation and inspected tests support the stated instance-rate behavior, though the two oversized changed test files were inspected only at relevant ranges.
What I ran
90cf083c26fa3b65e5e9c3b2d3e4a742e08b5187throughrepo_read.py.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
core/libs/prx/libSceAgcDriver/tests/Graphics.cppandcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppwere not read; targeted changed regions were reviewed.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T22:23:59Z.
Review: COMMENTED
The trial merge onto
a1b75b0947conflicts inRequestSerializer.cpp,RequestSerializerTests.cpp, andShaderMemory.cpp. There is a concrete format collision as well. I compiled the exact PR and main serializers and round-tripped a version 64 vertex request on each. Main rejected the instance-step-rate capture as truncated. This PR rejected main’s capture at the emulated-barycentrics flag. Please give the combined layout a distinct version and preserve compatibility for main’s existing version 64 captures when rebasing the serializer and cache key.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.