frametime fix

This commit is contained in:
Jorijn van der Graaf 2025-12-30 00:44:45 +01:00
commit a220e40d13
2 changed files with 15 additions and 0 deletions

View file

@ -378,6 +378,7 @@ void WindowWayland::QueueRender() {
} }
void WindowWayland::StartUpdate() { void WindowWayland::StartUpdate() {
lastFrameBegin = std::chrono::high_resolution_clock::now();
cb = wl_surface_frame(surface); cb = wl_surface_frame(surface);
wl_callback_add_listener(cb, &wl_callback_listener, this); wl_callback_add_listener(cb, &wl_callback_listener, this);
updating = true; updating = true;

View file

@ -150,14 +150,28 @@ namespace Crafter {
); );
} }
export constexpr std::int_fast32_t AbsoluteToRelative(std::int_fast32_t absolute, std::int_fast32_t relative) {
return static_cast<std::int_fast32_t>(
(static_cast<__int128>(absolute) * SCALE) / relative
);
}
export constexpr std::int_fast32_t BoundToBoundless(std::int_fast32_t bound) { export constexpr std::int_fast32_t BoundToBoundless(std::int_fast32_t bound) {
return bound * BOUND; return bound * BOUND;
} }
export constexpr std::int_fast32_t BoundToBoundlessU(std::int_fast32_t bound) {
return static_cast<std::uint_fast32_t>((bound*2)) * BOUND;
}
export constexpr std::int_fast32_t BoundlessToBound(std::int_fast32_t bound) { export constexpr std::int_fast32_t BoundlessToBound(std::int_fast32_t bound) {
return bound / BOUND; return bound / BOUND;
} }
export constexpr std::int_fast32_t BoundlessUToBound(std::uint_fast32_t bound) {
return static_cast<std::int_fast32_t>(bound / 2) / BOUND;
}
export constexpr std::int_fast32_t FractionalToMappedBoundless(double f) { export constexpr std::int_fast32_t FractionalToMappedBoundless(double f) {
return std::int_fast32_t(f * SCALEDOUBLEBOUNDLESS); return std::int_fast32_t(f * SCALEDOUBLEBOUNDLESS);
} }