Skip to content

Commit

Permalink
bridge: fix possible command skip
Browse files Browse the repository at this point in the history
  • Loading branch information
DHrpcs3 committed Sep 5, 2024
1 parent 068d95c commit d3b9ff4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion hw/amdgpu/bridge/include/amdgpu/bridge/bridge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ struct BridgePusher {
if (position < header->size) {
header->commands[position] =
static_cast<std::uint64_t>(CommandId::Nop) |
((header->size - position - 1) << 32);
((header->size - position + cmdSize) << 32);
}

position = 0;
Expand Down
10 changes: 5 additions & 5 deletions rpcsx-os/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ static std::filesystem::path getSelfDir() {
return std::filesystem::path(path).parent_path();
}

static bool isRpsxGpuPid(int pid) {
static bool isRpcsxGpuPid(int pid) {
if (pid <= 0 || ::kill(pid, 0) != 0) {
return false;
}
Expand All @@ -702,15 +702,15 @@ static bool isRpsxGpuPid(int pid) {
std::printf("filename is '%s'\n",
std::filesystem::path(path).filename().c_str());

return std::filesystem::path(path).filename() == "rpcsx-gpu";
return std::filesystem::path(path).filename().string().starts_with("rpcsx-gpu");
}
static void runRpsxGpu() {
static void runRpcsxGpu() {
const char *cmdBufferName = "/rpcsx-gpu-cmds";
amdgpu::bridge::BridgeHeader *bridgeHeader =
amdgpu::bridge::openShmCommandBuffer(cmdBufferName);

if (bridgeHeader != nullptr && bridgeHeader->pullerPid > 0 &&
isRpsxGpuPid(bridgeHeader->pullerPid)) {
isRpcsxGpuPid(bridgeHeader->pullerPid)) {
bridgeHeader->pusherPid = ::getpid();
g_gpuPid = bridgeHeader->pullerPid;
rx::bridge.header = bridgeHeader;
Expand Down Expand Up @@ -1749,7 +1749,7 @@ int main(int argc, const char *argv[]) {
// pthread_setname_np(pthread_self(), "10.MAINTHREAD");

rx::vm::initialize(initProcess->pid);
runRpsxGpu();
runRpcsxGpu();

if (enableAudio) {
orbis::g_context.audioOut = orbis::knew<orbis::AudioOut>();
Expand Down
10 changes: 7 additions & 3 deletions rx/include/rx/MemoryTable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,18 @@ class MemoryTableWithPayload {
iterator lowerBound(std::uint64_t address) {
auto it = mAreas.lower_bound(address);

if (it == mAreas.end() || it->second.first != Kind::X) {
if (it == mAreas.end()) {
return it;
}

if (it->first == address) {
++it;
if (it->second.first == Kind::X) {
++it;
}
} else {
--it;
if (it->second.first != Kind::O) {
--it;
}
}

return it;
Expand Down

0 comments on commit d3b9ff4

Please sign in to comment.