From a220e40d131e15fb3b74fb1373355ff6d1aa9429 Mon Sep 17 00:00:00 2001 From: Jorijn van der Graaf Date: Tue, 30 Dec 2025 00:44:45 +0100 Subject: [PATCH] frametime fix --- .../Crafter.Graphics-Window_wayland.cpp | 1 + interfaces/Crafter.Graphics-Types.cppm | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/implementations/Crafter.Graphics-Window_wayland.cpp b/implementations/Crafter.Graphics-Window_wayland.cpp index fa043c4..c65c23b 100644 --- a/implementations/Crafter.Graphics-Window_wayland.cpp +++ b/implementations/Crafter.Graphics-Window_wayland.cpp @@ -378,6 +378,7 @@ void WindowWayland::QueueRender() { } void WindowWayland::StartUpdate() { + lastFrameBegin = std::chrono::high_resolution_clock::now(); cb = wl_surface_frame(surface); wl_callback_add_listener(cb, &wl_callback_listener, this); updating = true; diff --git a/interfaces/Crafter.Graphics-Types.cppm b/interfaces/Crafter.Graphics-Types.cppm index 4fe607d..e8776b2 100644 --- a/interfaces/Crafter.Graphics-Types.cppm +++ b/interfaces/Crafter.Graphics-Types.cppm @@ -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( + (static_cast<__int128>(absolute) * SCALE) / relative + ); + } + export constexpr std::int_fast32_t BoundToBoundless(std::int_fast32_t bound) { return bound * BOUND; } + export constexpr std::int_fast32_t BoundToBoundlessU(std::int_fast32_t bound) { + return static_cast((bound*2)) * BOUND; + } + export constexpr std::int_fast32_t BoundlessToBound(std::int_fast32_t bound) { return bound / BOUND; } + export constexpr std::int_fast32_t BoundlessUToBound(std::uint_fast32_t bound) { + return static_cast(bound / 2) / BOUND; + } + export constexpr std::int_fast32_t FractionalToMappedBoundless(double f) { return std::int_fast32_t(f * SCALEDOUBLEBOUNDLESS); }