CP: close a command buffer whose last dword cannot be a packet #1405
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!1405
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1405"
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?
@Franseven on GitHub · 2026-10-11 07:46 UTC · original
Franseven:pr/cp-tail→main· +13 −1 · 1 files · 1 commits · openGame
Gran Turismo 7 (PPSA01341).
Problem
CommandProcessor::ProcessPm4ends the whole emulator when a command buffer runs out with a singledword left:
One dword cannot be a packet at all. It is not a packet whose declared length runs past the end of
the buffer — that case is still rejected by the existing checks — it is a lone word: a type-3
header with no body, or the type-2 filler word. Games do leave one behind the last real packet.
GT7 stops that way after the session has already drawn. The fatal line lands at the end of a log
that had already emitted 912 shader-counter lines, not at startup:
Other runs show the same buffer closing with a lone
0x00000000word at offset0xc4(and0xcc).Related to #1330, but the opposite case: this is the last dword of a buffer, which cannot be a
packet at all (it would be a type-0/type-3 header with no body), not a packet whose declared length
runs past the end. The two can coexist — #1330 refuses a truncated packet that declares a length,
this one ignores a trailing word that cannot declare anything.
Change
The
continuematters: the loop advancescursor.offset_dwand setsm_made_progress, so thebuffer closes normally instead of ending the run. The offset is logged at most 16 times, because
GT7 reaches this point repeatedly.
Testing
Built with clang-cl 23.1.3 (Release) on Windows; the emulator links and runs. The change is
confined to the PM4 loop, so nothing outside the command processor is affected.
eatedly.
@coderabbitai[bot] on GitHub · 2026-10-11 07:50 UTC · original
📝 Walkthrough
Walkthrough
When fewer than two dwords remain,
ProcessPm4consumes the trailing dword, logs at most 16 such cases, and marks execution progress. This replaces the previousEXIT_NOT_IMPLEMENTEDresult for that condition.Suggested reviewers:
nmzikPriority: ➖ Normal
Change: Bug fix
Merge Risk: 🔵 Low · up to
222d8A truncated final command can be silently dropped. Distinguish filler from incomplete packets before merging, or accept this bounded risk explicitly.
Pre-merge checks |
4 |
1
❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
CommandProcessor::ProcessPm4, the intended fix, logging behavior, affected game, and reported build validation.Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment
@coderabbitai helpto get the list of available commands.@ -696,3 +696,3 @@}EXIT_NOT_IMPLEMENTED(remaining_dw < 2);if (remaining_dw < 2) {@coderabbitai[bot] on GitHub · 2026-10-11 07:50 UTC · original
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 17045
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 15550
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 15550
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 1884
🌐 Web query:
KytyPS5 CommandProcessor ProcessPm4 graphicsRun.cpp Pm4Execution💡 Result:
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 8081
Reject incomplete multi-dword packets before consuming the tail.
GuestGpu::SubmitandSubmitComputeaccept one-dword command spans.CommandProcessor::Processforwards them without packet-size validation. If the dword is an ordinary PM4 header, the new tail branch consumes it beforeEXIT_IF(packet_dw > remaining_dw)runs. The command is dropped, and processing reports completion.Suggested fix
@coderabbitai[bot] on GitHub · 2026-10-11 07:50 UTC · original · reviewed
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
3d89930f-2c0c-4dc6-b8ca-8bfd8f5d0166📥 Commits
Reviewing files that changed from the base of the PR and between
c0ebf22476and222d83016c.📒 Files selected for processing (1)
src/graphics/guest_gpu/graphicsRun.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
@theantipopau on GitHub · 2026-10-12 11:13 UTC · original
The trade matches the code: graphicsRun.cpp:694 already consumes single-dword packets through
PacketSizeDw(header) == 1uand the type-2 NOP/packet-0xC0000000 forms, so a lone trailing word — one that can't even reach the header checks since it has no body — previously hit the bareEXIT_NOT_IMPLEMENTED(remaining_dw < 2)regardless of its value. Your change keeps every real packet's declared-length check (packet_dw > remaining_dwstill EXITs) and only converts the header-without-body case into a consume and close, with the capped LOGF.m_made_progress = trueis right so the buffer stack unwinds instead of spinning.One nit, non-blocking: the type-2 filler comment says "a type-2 NOP carrying a count" — on RDNA a type-2 packet is pure filler (
0xC0001000-style words carry no count); the word GT7 leaves is 0x00000000, which is neither type-0 nor type-3. Worth rewording when you next touch it, but either way the consume is correct.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.