generated from rpuzonas/raylib-cpp-template
add debug mode flag
This commit is contained in:
parent
be2c56fb28
commit
7c8a972228
11
Makefile
11
Makefile
@ -14,10 +14,11 @@ WEB_HEAP_SIZE := 335544320
|
||||
WEB_STACK_SIZE := 196608
|
||||
WEB_SHELL := src/shell.html
|
||||
|
||||
COMPILER_FLAGS := -std=c++17 -Wno-enum-compare -O3 -g -flto -msse4.2 -mavx
|
||||
DEBUG_MODE := no
|
||||
|
||||
COMPILER_FLAGS := -std=c++17 -Wno-enum-compare -O3 -flto -msse4.2 -mavx
|
||||
COMPILER_FLAGS += -DRPROF_IMPLEMENTATION
|
||||
COMPILER_FLAGS += -DRAYGUI_IMPLEMENTATION
|
||||
# COMPILER_FLAGS += -DRLGL_IMPLEMENTATION
|
||||
LINKER_FLAGS := -lraylib
|
||||
|
||||
# SOURCES := $(wildcard src/*.cpp)
|
||||
@ -25,6 +26,12 @@ SOURCES := src/main.cpp
|
||||
|
||||
COMPILER_FLAGS += -I$(SUBMODULES_PATH)/raygui/src/
|
||||
|
||||
ifeq ($(DEBUG_MODE), yes)
|
||||
COMPILER_FLAGS += -DDEBUG -g
|
||||
else
|
||||
COMPILER_FLAGS += -DRPROF_STUB_OUT
|
||||
endif
|
||||
|
||||
# ----------------- Prepare variables for targets ------------------
|
||||
|
||||
EXT :=
|
||||
|
@ -4,3 +4,4 @@
|
||||
-DRLGL_IMPLEMENTATION
|
||||
-DRPROF_IMPLEMENTATION
|
||||
-DRAYGUI_IMPLEMENTATION
|
||||
-DDEBUG
|
||||
|
@ -9,7 +9,12 @@
|
||||
|
||||
#define ARRAY_LEN(arr) (sizeof(arr)/sizeof(arr[0]))
|
||||
#define LogTrace(...) TraceLog(LOG_TRACE, __VA_ARGS__)
|
||||
|
||||
#ifdef DEBUG
|
||||
#define DEBUG_ASSERT(...) assert(__VA_ARGS__)
|
||||
#else
|
||||
#define DEBUG_ASSERT(...)
|
||||
#endif
|
||||
|
||||
typedef uint16_t uboid_t;
|
||||
#define MAX_BOIDS (1 << (sizeof(uboid_t)*8))
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include <emscripten/emscripten.h>
|
||||
#endif
|
||||
|
||||
// #define RPROF_STUB_OUT
|
||||
// #define RPROF_ONLY_TOTAL_TIME
|
||||
#include "rprof.h"
|
||||
|
||||
@ -33,8 +32,8 @@ void UpdateDrawFrame();
|
||||
static void profiling_test();
|
||||
|
||||
int main() {
|
||||
profiling_test();
|
||||
return 0;
|
||||
// profiling_test();
|
||||
// return 0;
|
||||
|
||||
SetTraceLogLevel(LOG_TRACE);
|
||||
|
||||
|
@ -170,6 +170,11 @@ static void chunkgrid_init(MemoryArena *arena, ChunkGrid *grid, int width, int h
|
||||
}
|
||||
|
||||
static int g_prof_interactions = 0;
|
||||
#ifdef DEBUG
|
||||
#define INCREMENT_INTERACTIONS() g_prof_interactions++;
|
||||
#else
|
||||
#define INCREMENT_INTERACTIONS()
|
||||
#endif
|
||||
|
||||
static int nearest_multiple(int num, int divisor) {
|
||||
return (num / divisor + (num % divisor > 0 ? 1 : 0)) * divisor;
|
||||
@ -181,7 +186,7 @@ struct boid_pair {
|
||||
};
|
||||
|
||||
#ifdef SIMD256
|
||||
#define GET_F32_CHUNK_FROM_BOIDS(i, SIDE, FIELD) \
|
||||
#define GET_F32_CHUNK_FROM_BOIDS(i, SIDE, FIELD) \
|
||||
_mm256_set_ps( \
|
||||
boids[b2b_cmps[8*i+7].SIDE].FIELD, \
|
||||
boids[b2b_cmps[8*i+6].SIDE].FIELD, \
|
||||
@ -193,7 +198,7 @@ struct boid_pair {
|
||||
boids[b2b_cmps[8*i+0].SIDE].FIELD \
|
||||
)
|
||||
#else
|
||||
#define GET_F32_CHUNK_FROM_BOIDS(i, SIDE, FIELD) \
|
||||
#define GET_F32_CHUNK_FROM_BOIDS(i, SIDE, FIELD) \
|
||||
_mm_set_ps( \
|
||||
boids[b2b_cmps[4*i+3].SIDE].FIELD, \
|
||||
boids[b2b_cmps[4*i+2].SIDE].FIELD, \
|
||||
@ -267,11 +272,11 @@ static void world_calc_distances_and_angles(World *world, BoidList *local_boids,
|
||||
uboid_t to_boid = b2b_cmps[cmp_idx].to;
|
||||
if (do_append_mask1_f32[j]) {
|
||||
boid_list_append(&world->frame_arena, &local_boids[from_boid], to_boid);
|
||||
g_prof_interactions++;
|
||||
INCREMENT_INTERACTIONS();
|
||||
}
|
||||
if (do_append_mask2_f32[j]) {
|
||||
boid_list_append(&world->frame_arena, &local_boids[to_boid], from_boid);
|
||||
g_prof_interactions++;
|
||||
INCREMENT_INTERACTIONS();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -320,7 +325,7 @@ static void world_compute_local_boids(BoidList *local_boids, World *world, Chunk
|
||||
|
||||
for (int j = 0; j < to_boids_count; j++) {
|
||||
// TODO:
|
||||
// DEBUG_ASSERT(b2b_cmps_count < b2b_capacity-1);
|
||||
DEBUG_ASSERT(b2b_cmps_count < b2b_capacity-1);
|
||||
b2b_cmps[b2b_cmps_count++] = {
|
||||
.from = from_boid,
|
||||
.to = to_boids[j]
|
||||
@ -343,7 +348,7 @@ static void world_compute_local_boids(BoidList *local_boids, World *world, Chunk
|
||||
for (int i = 0; i < chunk->count; i++) {
|
||||
for (int j = 0; j < neighbour_chunk->count; j++) {
|
||||
// TODO:
|
||||
// DEBUG_ASSERT(b2b_cmps_count < b2b_capacity-1);
|
||||
DEBUG_ASSERT(b2b_cmps_count < b2b_capacity-1);
|
||||
b2b_cmps[b2b_cmps_count++] = {
|
||||
.from = chunk_boids[i],
|
||||
.to = neighbour_boids[j]
|
||||
|
Loading…
Reference in New Issue
Block a user