AGC: storing a resident linear color target after every draw keeps PPSA14363's PS1 games at about 10 fps; without it they run at 60 #9217
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 thuanquang on 2026-10-21T15:28:14Z.
What
PPSA14363 (METAL GEAR SOLID Master Collection Vol. 1) runs its PS1 games through its own emulator. That emulator draws into three linear 3072x2048 R8G8B8A8 color targets of 24 MiB each, with up to about 80 draws per frame.
mainthese targets have no host import, so every draw into them is synchronous. #9188 and #9202 make that path cheaper.That per-draw store keeps the PS1 intro at about 10 fps. Without it the same content runs at the display's 60 Hz.
Measured
RX 6700 XT, AMD Windows driver 32.0.21045.5002. Local builds on
main865166414fwith local switches, which are not PRs. One run each. The table gives guest flips per second on the same content, aligned by guest flip count (the title advances one frame per flip):mainAPS5_STORE_AT_LABEL=1HostImportForinstead ofExistingHostImportForfor a linear target, which is #1191's case.keepRecordedDrawskips itsFlushPending(..., "linear target").APS5_STORE_AT_LABEL=1, the[storage]line lists no write-backs in those windows. The targets were apparently never stored back, and the title did not need them in guest memory. Its presents come from the resident images.-means the run did not reach those flips in its 150 or 180 s.Question
#6892 stores linear targets after every draw so that CPU readers which bypass the flush hook still see the results. Its test reads guest memory with
memcpyafterWaitIdle. Tiled resident targets keep their results on the GPU until something reads them.For linear targets, would keeping the results pending be acceptable? They would be stored by the existing access paths, waits, flips and idle stores, with #8246's changed-bytes merge. Or is there a cheaper rule that keeps CPU readers safe, such as storing at the labels and EOP events a guest waits on?
Related: #1191 (the import-creating case), #8246 (changed-bytes store-back, #8152), #9188, #9202.
Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-21T16:56:06Z.
Traced the open point from above, why
APS5_STORE_AT_LABEL=1stored nothing. I ran the same switches withAPS5_TRACE_FLUSH=1for 150 s into the PS1 section.No labels in the PS1 command streams. The
[packets]lines show, per 10 s:DRAW_INDEX_AUTOandDRAW_INDEX_2flipSET_*_REGandSET_*_REG_INDIRECTEVENT_WRITEandACQUIRE_MEM(1186 to 1482 each)NOPThere is no
RELEASE_MEM,WRITE_DATAor EOP packet, soWriteLabelOnGpunever runs. This guest syncs with the GPU through flips only.What was stored in those 150 s. 26
[flush]lines in total:idleflushes, each of one of two other 8.4 MiB images;The earlier run without
APS5_STORE_AT_LABEL. It had 50 to 80 idle write-backs per 10 s in its later scenes, many of them these 24 MiB targets, and ran slower there. With the same switches and no labels, the variable cannot have changed anything. So that difference came from when the GPU went idle, not from a store rule.For the rule asked above, this means:
This title never reads the targets with the CPU: its frames stay right with no store at all. A title that reads a linear target after a flip without a label would need more than a label rule.
Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-21T18:27:25Z.
Gameplay numbers with the same local switches as the last column above (import created, no per-draw store,
APS5_STORE_AT_LABEL=1, onmain865166414f, with stop 1 bypassed locally; #9115 fixes it).MGS1 gameplay at the Dock, about 110 s of it:
One run, RX 6700 XT,
APS5_TRACE_SUMMARY_EVERY=10only (no profiler).So in this title the two things these switches stand for take MGS1 gameplay to 60 fps: an import for the linear targets (#1191's case) and no store of them after every draw. #9188 and #9202 only make the synchronous path cheaper. With both, the PS1 intro reaches 35 to 58 flips/s on equal content.
For comparison,
mainb00235dda0+ #9115 + #9188 + #9202, with none of the switches, same machine, one run of 420 s. It did not reach gameplay in that time:Driver.Packetabout 41 ms per present.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T04:16:31Z.
The added trace evidence resolves why
APS5_STORE_AT_LABEL=1made no difference here: there are no label/EOP packets in this title’s command stream, and the observed speed difference tracks idle-flush timing. I would keep the normal resident-linear-target visibility guarantee for now. This title’s lack of CPU reads during the measured route does not establish that all titles avoid reading the same guest memory, and the existing issue/PR chain (#6892/#8246) specifically protects CPU writes/read visibility around resident draws. A label-only policy would still leave a title that reads the target after a flip without a label observing stale bytes. The present evidence supports optimizing the synchronous path (#9188/#9202) and recording this title-specific behavior, but not removing the general store boundary absent an access-path proof or a general synchronization contract plus regression coverage.Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-22T05:15:52Z.
Thanks. Here is a proposal for the "general synchronization contract plus regression coverage" you mention. It would let the per-draw store go without falling back to a label-only policy.
Contract. A resident linear color target written by recorded draws is stored to guest memory before each point where the guest can first observe that those draws completed:
FlipPacketHeaderflips and RELEASE_MEM-attached EOP flips. The store is recorded before the flip'sSubmitRecorded, so the flip's EOP interrupt follows it.StoreReadbackBeforeLabel, plus the interrupt-only RELEASE_MEM branch ofcommitLabel, which #6948 does not hook yet.VulkanDevice::WaitIdle.A title that reads the target after a flip without a label then sees the flip's results, which is the case you raised. The only thing it stops seeing early is a read with no signal at all, and on a console that read races the GPU too.
Bytes. Each store copies only the union of the draws' scissors since the last store: per-row spans at the guest pitch, GPU-direct into the import. A store does not wait for the same image's previous store under #6364's check.
Tests. Where the guarantee depends on the queue worker, the tests go through
AgcDriver::Submit, and all of them read with raw memcpy or volatile loads:agc_driver_linear_target_residentstays unchanged; it is covered by the WaitIdle store.APS5_SYNC_FLIP=1.LinearTargetCpuWriteswith credit, on a watched and an unwatched block: CPU stores outside the drawn rectangle survive.#8246. The two could split by ownership:
Would that work for you?
Import creation (#1191's case) stays a separate PR on top, together with its author.
What it changes for PPSA14363. Main plus #9188, #9202, #9373 and #9602 leaves the PS1 codec at about 19 fps, and the stutter is audible. In a local capture of the title's sceAudioOut stream, 50 to 81 % of its 256-frame buffers repeat the previous buffer there: the title's audio thread re-sends its last buffer while its PS1 emulator is behind. With the local switches at 60 fps it is 0.0 to 0.2 %.
If this sounds acceptable, I'll implement it on top of #6948 and post the numbers there.
Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-22T08:29:33Z.
@MarcZX10 the contract proposed above is now #9685, with its tests: completion points through
AgcDriver::Submitwith the queue held by aWAIT_REG_MEM, #8152's CPU stores afterDraw(ported from #8246 with credit), CPU stores outside the drawn rectangle, and a target pending untilWaitIdle. On PPSA14363, with the targets resident (#1191's import case, local), MGS1's PS1 opening goes from 158-168 presents per 10 s with the per-draw store to 591-600.