fix(windows): use precise sleeps for sub-millisecond polling

Co-authored-by: Shaan <shaansahai2007@gmail.com>
This commit is contained in:
MarcZX100 2026-10-09 12:01:30 +00:00
parent 9d89f7b787
commit 54a9018514
3 changed files with 6 additions and 3 deletions

View File

@ -1,6 +1,7 @@
#include "prx/libSceAgcDriver/Execution/include/Pm4.hpp"
#include "prx/libSceAgcDriver/Execution/include/GuestMemory.hpp"
#include "prx/libc/include/General.hpp"
#include "prx/libc/include/PreciseWait.hpp"
#include <algorithm>
#include <thread>
#include <chrono>
@ -839,7 +840,7 @@ void Execute(std::span<const std::uint32_t> packet, QueueState& queue) {
const auto start = std::chrono::steady_clock::now();
bool warned = false;
while (!WaitSatisfied(packet)) {
std::this_thread::sleep_for(std::chrono::microseconds(50));
PreciseSleepUs(50);
if (!warned && std::chrono::steady_clock::now() - start > std::chrono::seconds(5)) {
warned = true;
std::fprintf(stderr, "[gpu] WAIT_REG_MEM at 0x%llx still waiting after 5s (function %u ref 0x%x mask 0x%x)\n",

View File

@ -12,6 +12,7 @@
#include <unordered_map>
#include <unordered_set>
#include "prx/libc/include/PreciseWait.hpp"
#include "prx/libSceFont/include/FontInternal.hpp"
namespace {
@ -56,7 +57,7 @@ Font::FontState::~FontState() {
}
void Font::Backoff() {
std::this_thread::sleep_for(std::chrono::microseconds(30));
PreciseSleepUs(30);
}
std::uint32_t Font::AcquireWordLock(std::uint32_t& word) {

View File

@ -2,6 +2,7 @@
#include <cstddef>
#include "SceTypes.hpp"
#include "prx/libc/include/General.hpp"
#include "prx/libc/include/PreciseWait.hpp"
#include "prx/libc/include/GuestArena.hpp"
#include "prx/libkernel/Apr/include/AprCommandBuffer.hpp"
#include "prx/libkernel/DirectMemory/DirectMemory.hpp"
@ -585,7 +586,7 @@ void _execute(const Apr::CommandBufferObject& buffer) {
return std::atomic_ref<std::uint64_t>(*reinterpret_cast<std::uint64_t*>(command.address)).load(std::memory_order_acquire);
};
const std::uint64_t reference = (command.reference & command.mask) << unused;
while (!_waitSatisfied(command.compare, (current() & command.mask) << unused, reference)) std::this_thread::sleep_for(std::chrono::microseconds(50));
while (!_waitSatisfied(command.compare, (current() & command.mask) << unused, reference)) PreciseSleepUs(50);
break;
}
case Apr::Opcode::WriteKernelEventQueue: {