mirror of
https://github.com/yuzu-emu/yuzu-android
synced 2024-11-25 11:19:09 +00:00
Merge pull request #10244 from liamwhite/lower-upper
time: implement ContinuousAdjustmentTimePoint
This commit is contained in:
commit
9c739f1506
3 changed files with 34 additions and 2 deletions
|
@ -59,6 +59,18 @@ static_assert(sizeof(SystemClockContext) == 0x20, "SystemClockContext is incorre
|
||||||
static_assert(std::is_trivially_copyable_v<SystemClockContext>,
|
static_assert(std::is_trivially_copyable_v<SystemClockContext>,
|
||||||
"SystemClockContext must be trivially copyable");
|
"SystemClockContext must be trivially copyable");
|
||||||
|
|
||||||
|
struct ContinuousAdjustmentTimePoint {
|
||||||
|
s64 measurement_offset;
|
||||||
|
s64 diff_scale;
|
||||||
|
u32 shift_amount;
|
||||||
|
s64 lower;
|
||||||
|
s64 upper;
|
||||||
|
Common::UUID clock_source_id;
|
||||||
|
};
|
||||||
|
static_assert(sizeof(ContinuousAdjustmentTimePoint) == 0x38);
|
||||||
|
static_assert(std::is_trivially_copyable_v<ContinuousAdjustmentTimePoint>,
|
||||||
|
"ContinuousAdjustmentTimePoint must be trivially copyable");
|
||||||
|
|
||||||
/// https://switchbrew.org/wiki/Glue_services#TimeSpanType
|
/// https://switchbrew.org/wiki/Glue_services#TimeSpanType
|
||||||
struct TimeSpanType {
|
struct TimeSpanType {
|
||||||
s64 nanoseconds{};
|
s64 nanoseconds{};
|
||||||
|
|
|
@ -30,6 +30,25 @@ void SharedMemory::SetupStandardSteadyClock(const Common::UUID& clock_source_id,
|
||||||
}
|
}
|
||||||
|
|
||||||
void SharedMemory::UpdateLocalSystemClockContext(const Clock::SystemClockContext& context) {
|
void SharedMemory::UpdateLocalSystemClockContext(const Clock::SystemClockContext& context) {
|
||||||
|
// lower and upper are related to the measurement point for the steady time point,
|
||||||
|
// and compare equal on boot
|
||||||
|
const s64 time_point_ns = context.steady_time_point.time_point * 1'000'000'000LL;
|
||||||
|
|
||||||
|
// This adjusts for some sort of time skew
|
||||||
|
// Both 0 on boot
|
||||||
|
const s64 diff_scale = 0;
|
||||||
|
const u32 shift_amount = 0;
|
||||||
|
|
||||||
|
const Clock::ContinuousAdjustmentTimePoint adjustment{
|
||||||
|
.measurement_offset = system.CoreTiming().GetGlobalTimeNs().count(),
|
||||||
|
.diff_scale = diff_scale,
|
||||||
|
.shift_amount = shift_amount,
|
||||||
|
.lower = time_point_ns,
|
||||||
|
.upper = time_point_ns,
|
||||||
|
.clock_source_id = context.steady_time_point.clock_source_id,
|
||||||
|
};
|
||||||
|
|
||||||
|
StoreToLockFreeAtomicType(&GetFormat()->continuous_adjustment_timepoint, adjustment);
|
||||||
StoreToLockFreeAtomicType(&GetFormat()->standard_local_system_clock_context, context);
|
StoreToLockFreeAtomicType(&GetFormat()->standard_local_system_clock_context, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,14 +65,15 @@ public:
|
||||||
LockFreeAtomicType<Clock::SystemClockContext> standard_local_system_clock_context;
|
LockFreeAtomicType<Clock::SystemClockContext> standard_local_system_clock_context;
|
||||||
LockFreeAtomicType<Clock::SystemClockContext> standard_network_system_clock_context;
|
LockFreeAtomicType<Clock::SystemClockContext> standard_network_system_clock_context;
|
||||||
LockFreeAtomicType<bool> is_standard_user_system_clock_automatic_correction_enabled;
|
LockFreeAtomicType<bool> is_standard_user_system_clock_automatic_correction_enabled;
|
||||||
u32 format_version;
|
LockFreeAtomicType<Clock::ContinuousAdjustmentTimePoint> continuous_adjustment_timepoint;
|
||||||
};
|
};
|
||||||
static_assert(offsetof(Format, standard_steady_clock_timepoint) == 0x0);
|
static_assert(offsetof(Format, standard_steady_clock_timepoint) == 0x0);
|
||||||
static_assert(offsetof(Format, standard_local_system_clock_context) == 0x38);
|
static_assert(offsetof(Format, standard_local_system_clock_context) == 0x38);
|
||||||
static_assert(offsetof(Format, standard_network_system_clock_context) == 0x80);
|
static_assert(offsetof(Format, standard_network_system_clock_context) == 0x80);
|
||||||
static_assert(offsetof(Format, is_standard_user_system_clock_automatic_correction_enabled) ==
|
static_assert(offsetof(Format, is_standard_user_system_clock_automatic_correction_enabled) ==
|
||||||
0xc8);
|
0xc8);
|
||||||
static_assert(sizeof(Format) == 0xd8, "Format is an invalid size");
|
static_assert(offsetof(Format, continuous_adjustment_timepoint) == 0xd0);
|
||||||
|
static_assert(sizeof(Format) == 0x148, "Format is an invalid size");
|
||||||
|
|
||||||
void SetupStandardSteadyClock(const Common::UUID& clock_source_id,
|
void SetupStandardSteadyClock(const Common::UUID& clock_source_id,
|
||||||
Clock::TimeSpanType current_time_point);
|
Clock::TimeSpanType current_time_point);
|
||||||
|
|
Loading…
Reference in a new issue