GUI: fix overflow in timers

these timer variables are used with SDL_GetPerformanceCounter, which
returns a uint64_t. subtracting these can overflow, which is UB.
This commit is contained in:
psykose 2024-01-27 08:48:25 +00:00 committed by tildearrow
parent 68ee5167ee
commit 3f329e464d
2 changed files with 6 additions and 5 deletions

View file

@ -3411,7 +3411,7 @@ bool FurnaceGUI::detectOutOfBoundsWindow(SDL_Rect& failing) {
}
#define DECLARE_METRIC(_n) \
int __perfM##_n;
uint64_t __perfM##_n;
#define MEASURE_BEGIN(_n) \
__perfM##_n=SDL_GetPerformanceCounter();

View file

@ -27,6 +27,7 @@
#include "imgui_impl_sdl2.h"
#include <SDL.h>
#include <fftw3.h>
#include <stdint.h>
#include <initializer_list>
#include <future>
#include <memory>
@ -2164,10 +2165,10 @@ class FurnaceGUI {
ImVec2 orderScrollRealOrigin;
ImVec2 dragMobileMenuOrigin;
int layoutTimeBegin, layoutTimeEnd, layoutTimeDelta;
int renderTimeBegin, renderTimeEnd, renderTimeDelta;
int drawTimeBegin, drawTimeEnd, drawTimeDelta;
int eventTimeBegin, eventTimeEnd, eventTimeDelta;
uint64_t layoutTimeBegin, layoutTimeEnd, layoutTimeDelta;
uint64_t renderTimeBegin, renderTimeEnd, renderTimeDelta;
uint64_t drawTimeBegin, drawTimeEnd, drawTimeDelta;
uint64_t eventTimeBegin, eventTimeEnd, eventTimeDelta;
FurnaceGUIPerfMetric perfMetrics[64];
int perfMetricsLen;