bridge: fix possible command skip

This commit is contained in:
DH 2024-09-05 20:31:36 +03:00
parent 068d95c078
commit d3b9ff4292
3 changed files with 13 additions and 9 deletions

View file

@ -266,7 +266,7 @@ private:
if (position < header->size) { if (position < header->size) {
header->commands[position] = header->commands[position] =
static_cast<std::uint64_t>(CommandId::Nop) | static_cast<std::uint64_t>(CommandId::Nop) |
((header->size - position - 1) << 32); ((header->size - position + cmdSize) << 32);
} }
position = 0; position = 0;

View file

@ -684,7 +684,7 @@ static std::filesystem::path getSelfDir() {
return std::filesystem::path(path).parent_path(); return std::filesystem::path(path).parent_path();
} }
static bool isRpsxGpuPid(int pid) { static bool isRpcsxGpuPid(int pid) {
if (pid <= 0 || ::kill(pid, 0) != 0) { if (pid <= 0 || ::kill(pid, 0) != 0) {
return false; return false;
} }
@ -702,15 +702,15 @@ static bool isRpsxGpuPid(int pid) {
std::printf("filename is '%s'\n", std::printf("filename is '%s'\n",
std::filesystem::path(path).filename().c_str()); 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"; const char *cmdBufferName = "/rpcsx-gpu-cmds";
amdgpu::bridge::BridgeHeader *bridgeHeader = amdgpu::bridge::BridgeHeader *bridgeHeader =
amdgpu::bridge::openShmCommandBuffer(cmdBufferName); amdgpu::bridge::openShmCommandBuffer(cmdBufferName);
if (bridgeHeader != nullptr && bridgeHeader->pullerPid > 0 && if (bridgeHeader != nullptr && bridgeHeader->pullerPid > 0 &&
isRpsxGpuPid(bridgeHeader->pullerPid)) { isRpcsxGpuPid(bridgeHeader->pullerPid)) {
bridgeHeader->pusherPid = ::getpid(); bridgeHeader->pusherPid = ::getpid();
g_gpuPid = bridgeHeader->pullerPid; g_gpuPid = bridgeHeader->pullerPid;
rx::bridge.header = bridgeHeader; rx::bridge.header = bridgeHeader;
@ -1749,7 +1749,7 @@ int main(int argc, const char *argv[]) {
// pthread_setname_np(pthread_self(), "10.MAINTHREAD"); // pthread_setname_np(pthread_self(), "10.MAINTHREAD");
rx::vm::initialize(initProcess->pid); rx::vm::initialize(initProcess->pid);
runRpsxGpu(); runRpcsxGpu();
if (enableAudio) { if (enableAudio) {
orbis::g_context.audioOut = orbis::knew<orbis::AudioOut>(); orbis::g_context.audioOut = orbis::knew<orbis::AudioOut>();

View file

@ -262,14 +262,18 @@ public:
iterator lowerBound(std::uint64_t address) { iterator lowerBound(std::uint64_t address) {
auto it = mAreas.lower_bound(address); auto it = mAreas.lower_bound(address);
if (it == mAreas.end() || it->second.first != Kind::X) { if (it == mAreas.end()) {
return it; return it;
} }
if (it->first == address) { if (it->first == address) {
++it; if (it->second.first == Kind::X) {
++it;
}
} else { } else {
--it; if (it->second.first != Kind::O) {
--it;
}
} }
return it; return it;