diff --git a/CMakeLists.txt b/CMakeLists.txt index 549d6e34..c8ae646c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -174,9 +174,9 @@ if (RTC) message(FATAL_ERROR "CRTLIB (C runtime library) Must be enabled when compiling with RTC (runtime checks)") endif() # NOTE: Adress sanitizer is disable for now because for some reason it's hiding local variables in debug mode. - set(COMPILER_FLAGS "${COMPILER_FLAGS} -DRTC=1") + # set(COMPILER_FLAGS "${COMPILER_FLAGS} -DRTC=1") # set(COMPILER_FLAGS "${COMPILER_FLAGS} -fsanitize=undefined -fno-sanitize=alignment -DRTC=1") - # set(COMPILER_FLAGS "${COMPILER_FLAGS} -fsanitize=undefined -fsanitize-trap=undefined -fno-sanitize=alignment -DRTC=1") + set(COMPILER_FLAGS "${COMPILER_FLAGS} -fsanitize=undefined -fsanitize-trap=undefined -fno-sanitize=alignment -DRTC=1") # set(COMPILER_FLAGS "${COMPILER_FLAGS} -fsanitize=address -fsanitize=undefined -fno-sanitize=alignment -DRTC=1") endif() @@ -193,7 +193,7 @@ if (UNOPTIMIZED) set(COMPILER_FLAGS "${COMPILER_FLAGS} -O0 -DUNOPTIMIZED=1") set(LINKER_FLAGS "${LINKER_FLAGS} -O0") else() - set(COMPILER_FLAGS "${COMPILER_FLAGS} -O3 -flto -fwhole-program") + set(COMPILER_FLAGS "${COMPILER_FLAGS} -O3 -flto") set(LINKER_FLAGS "${LINKER_FLAGS} -O3 -flto -fwhole-program") endif() diff --git a/src/common.h b/src/common.h index 173269c2..fa9460e4 100644 --- a/src/common.h +++ b/src/common.h @@ -110,12 +110,16 @@ extern "C" { #define CT_ASSERT2(cond, line) CT_ASSERT3(cond, line) #define CT_ASSERT(cond) CT_ASSERT2(cond, __LINE__) -#if RTC - +#if DEBINFO /* For use after a static 'L' state variable is declared. This will create a * variable that points to the 'L' variable and is kept alive (so that the * debugger can reference the state with a variable other than 'L') */ -#define DEBUG_LVAR(var) ,__attribute((used)) *var = &L; +# define DEBUG_LVAR(var) ,__attribute((used)) *var = &L; +#else +# define DEBUG_LVAR(var) +#endif + +#if RTC #define ASSERT(cond) ((cond) ? 1 : (__builtin_trap(), 0)) #define DEBUGBREAK __builtin_debugtrap() @@ -134,9 +138,6 @@ extern "C" { #else -#define DEBUG_VAR_GLOBAL(type, var, value) -#define DEBUG_LVAR(var) - #define ASSERT(cond) (void)(0) #define DEBUGBREAK #define ASAN_POISON(addr, size) diff --git a/src/user.c b/src/user.c index 1f6e6a1e..429a78ec 100644 --- a/src/user.c +++ b/src/user.c @@ -778,19 +778,19 @@ INTERNAL void user_update(void) /* Present */ i32 vsync = VSYNC_ENABLED; - struct renderer_canvas **canvases = NULL; + struct renderer_canvas **canvases = arena_dry_push(scratch.arena, struct renderer_canvas *); u64 canvases_count = 0; + { + /* Only render world if not on first frame */ + if (t0->id > 0 && t1->id > 0) { + *arena_push(scratch.arena, struct renderer_canvas *) = L.world_canvas; + ++canvases_count; + } - if (t0->id <= 0 || t1->id <= 0) { - /* Don't render world on first frame */ - struct renderer_canvas *present_canvases[] = { L.ui_canvas }; - canvases = present_canvases; - canvases_count = ARRAY_COUNT(present_canvases); - } else { - struct renderer_canvas *present_canvases[] = { L.world_canvas, L.ui_canvas }; - canvases = present_canvases; - canvases_count = ARRAY_COUNT(present_canvases); + *arena_push(scratch.arena, struct renderer_canvas *) = L.ui_canvas; + ++canvases_count; } + renderer_canvas_present(canvases, canvases_count, L.screen_size.x, L.screen_size.y, vsync); scratch_end(scratch); @@ -806,6 +806,7 @@ INTERNAL void user_thread_entry_point(void *arg) sys_timestamp_t last_frame_ts = 0; f64 target_dt = USER_FPS > 0 ? (1.0 / USER_FPS) : 0; + while (!L.shutdown) { __profscope(user_update_w_sleep); sleep_frame(last_frame_ts, target_dt);