[PR #2476] [MERGED] Handle compute packets that are split between the ends of two command buffers #2763

Closed
opened 2026-02-27 22:01:10 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/shadps4-emu/shadPS4/pull/2476
Author: @kalaposfos13
Created: 2/18/2025
Status: Merged
Merged: 3/25/2025
Merged by: @georgemoralis

Base: mainHead: bridge-split-cmd-buffers


📝 Commits (6)

  • b58199e Squashed initial implementation
  • ebcd42a Logging for checking if buffers are memory contiguous
  • e7814f4 Add check to see if first instruction is valid in the next buffer to avoid false positives
  • 6820bd9 Oof
  • a0f096f Replace old code with IndecisiveTurtle's new, better implementation
  • a564f10 Add unlikely keyword to the split packet handling branches

📊 Changes

2 files changed (+40 additions, -18 deletions)

View changed files

📝 src/video_core/amdgpu/liverpool.cpp (+36 -17)
📝 src/video_core/amdgpu/liverpool.h (+4 -1)

📄 Description

For some reason P.T. submits compute command buffers that are not aligned at instruction ends, so some instructions end up having data in two buffers. This PR fixes the issue, by doing the following:

  • If an instruction is longer than the remaining buffer size, we copy the incomplete part out to a buffer
  • When the next instrucion buffer arrives, we check if there were any "leftovers" from the previous one, and if so, do the following:
  • Check that if we took the appropriate amount of commands from the start of the buffer, the next data is a valid instruction
  • If so, we finish setting up the command by copying the remaining data to the end of the previous one, then execute this command
  • We then finish handling this new buffer, starting from the appropriate offset.

If any of these fail, we proceed to handle the new buffer as normal.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/shadps4-emu/shadPS4/pull/2476 **Author:** [@kalaposfos13](https://github.com/kalaposfos13) **Created:** 2/18/2025 **Status:** ✅ Merged **Merged:** 3/25/2025 **Merged by:** [@georgemoralis](https://github.com/georgemoralis) **Base:** `main` ← **Head:** `bridge-split-cmd-buffers` --- ### 📝 Commits (6) - [`b58199e`](https://github.com/shadps4-emu/shadPS4/commit/b58199ef8f67768de8427b4b91fb8092b558545d) Squashed initial implementation - [`ebcd42a`](https://github.com/shadps4-emu/shadPS4/commit/ebcd42aac3e4765f947d9fd993405c1f3f003f59) Logging for checking if buffers are memory contiguous - [`e7814f4`](https://github.com/shadps4-emu/shadPS4/commit/e7814f429d402cef884031505c1a06eb88e07209) Add check to see if first instruction is valid in the next buffer to avoid false positives - [`6820bd9`](https://github.com/shadps4-emu/shadPS4/commit/6820bd916a12567a6d7e9d28fea90bf99c8181dc) Oof - [`a0f096f`](https://github.com/shadps4-emu/shadPS4/commit/a0f096f716167e394da3a9f2c84b08b8aca649a0) Replace old code with IndecisiveTurtle's new, better implementation - [`a564f10`](https://github.com/shadps4-emu/shadPS4/commit/a564f1011437ea8a8dfe99b9c01399755abf60d2) Add `unlikely` keyword to the split packet handling branches ### 📊 Changes **2 files changed** (+40 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `src/video_core/amdgpu/liverpool.cpp` (+36 -17) 📝 `src/video_core/amdgpu/liverpool.h` (+4 -1) </details> ### 📄 Description For some reason P.T. submits compute command buffers that are not aligned at instruction ends, so some instructions end up having data in two buffers. This PR fixes the issue, by doing the following: - If an instruction is longer than the remaining buffer size, we copy the incomplete part out to a buffer - When the next instrucion buffer arrives, we check if there were any "leftovers" from the previous one, and if so, do the following: - Check that if we took the appropriate amount of commands from the start of the buffer, the next data is a valid instruction - If so, we finish setting up the command by copying the remaining data to the end of the previous one, then execute this command - We then finish handling this new buffer, starting from the appropriate offset. If any of these fail, we proceed to handle the new buffer as normal. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 22:01:10 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/shadPS4#2763
No description provided.