mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-17 15:03:25 +09:00
[Fix] (Pipe): the device-loss debug knob re-arms when set to a new value.
This commit is contained in:
@@ -186,9 +186,22 @@ namespace MobileGL::MG_Pipe {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (at <= 0) return false;
|
||||
static std::atomic<long> armedAt{0};
|
||||
static std::atomic<long> seen{0};
|
||||
static std::atomic<bool> fired{false};
|
||||
if (at <= 0) {
|
||||
// Unset (or 0) disarms: the same value set again counts afresh.
|
||||
if (armedAt.load(std::memory_order_relaxed) != 0) armedAt.store(0, std::memory_order_relaxed);
|
||||
return false;
|
||||
}
|
||||
// A NEW VALUE RE-ARMS. One server process outlives many sessions, so a second loss is
|
||||
// injected by setting the knob again (another value, or 0 and then a value): the count
|
||||
// restarts from the checks made after it was seen.
|
||||
if (long previous = armedAt.load(std::memory_order_acquire);
|
||||
previous != at && armedAt.compare_exchange_strong(previous, at, std::memory_order_acq_rel)) {
|
||||
seen.store(0, std::memory_order_release);
|
||||
fired.store(false, std::memory_order_release);
|
||||
}
|
||||
if (fired.load(std::memory_order_acquire)) return false;
|
||||
if (seen.fetch_add(1, std::memory_order_acq_rel) + 1 < at) return false;
|
||||
if (fired.exchange(true, std::memory_order_acq_rel)) return false;
|
||||
|
||||
@@ -119,8 +119,10 @@ namespace MobileGL::MG_Pipe {
|
||||
// A DEBUG KNOB THAT MAKES ONE DEVICE CHECK REPORT A LOSS, so the containment above can be
|
||||
// driven without a GPU that faults on demand. MOBILEGL_DEBUG_INJECT_DEVICE_LOST_AT=N (or, on
|
||||
// Android, the property debug.mobilegl.inject_device_lost_at) makes the N-th device check the
|
||||
// backends make after the knob was first seen nonzero answer "lost", once per process. The
|
||||
// backends ask at their frame boundaries and readbacks; unset (the default) it is one getenv.
|
||||
// backends make after the knob was first seen nonzero answer "lost", once per value: setting
|
||||
// another value (or 0 and then a value again) re-arms it, so one server process can lose
|
||||
// several sessions in turn. The backends ask at their frame boundaries and readbacks; unset
|
||||
// (the default) it is one getenv.
|
||||
bool MGPipeDebugDeviceLossDue();
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user