summaryrefslogtreecommitdiff
path: root/src/include/debug.h
diff options
context:
space:
mode:
authorFox Caminiti <fox@foxcam.net>2022-12-16 20:16:43 -0500
committerFox Caminiti <fox@foxcam.net>2022-12-16 20:16:43 -0500
commitbedd6906eabdd513042d6a178d4dc56a3a41d1d3 (patch)
tree2bcbd3e46ae61e583707a2ccc5b3f5cfeacb61a8 /src/include/debug.h
parentcdb9e1f7240cb0716b7d99df5e1fd7c3fc3407a8 (diff)
v3, file/build organization
Diffstat (limited to 'src/include/debug.h')
-rw-r--r--src/include/debug.h99
1 files changed, 99 insertions, 0 deletions
diff --git a/src/include/debug.h b/src/include/debug.h
new file mode 100644
index 0000000..6321679
--- /dev/null
+++ b/src/include/debug.h
@@ -0,0 +1,99 @@
+#if DEBUG
+
+static int32 *debugnull = NULL;
+#define Assert(Expression) if(!(Expression)) {*debugnull = 21;}
+
+enum valtype {
+ d_float,
+ d_uint,
+ d_int
+};
+
+union debugval {
+ real32 f;
+ uint32 u;
+ int32 i;
+};
+
+// things that get cleared every frame with the UI
+struct debug_temp
+{
+ valtype DebugPropertyType[16];
+ debugval Val[16];
+ char *String[16];
+ uint32 WatchedProperties;
+};
+
+struct project_debug
+{
+ debug_temp Temp;
+ bool32 ToggleWindow = 1;
+ bool32 ReloadUI = true;
+ bool32 NoThreading = 0;
+ bool32 DisableAlpha = 0;
+ uint64 PixelCountTransparent;
+ uint64 PixelCountRendered;
+ uint64 PixelCountChecked;
+ // NOTE(fox): Pixel count isn't thread safe; don't use with multithreading!
+ uint64 LayerCycleCount[64];
+ uint32 UndoState = 0;
+ uint64 ScratchSize[6];
+ uint32 ScratchState = 0;
+};
+
+static project_debug Debug;
+
+static void
+DebugWatchVar(char *Name, void *Address, valtype Type) {
+ uint32 i = Debug.Temp.WatchedProperties;
+ Debug.Temp.String[i] = Name;
+ if (Type == d_float)
+ Debug.Temp.Val[i].f = *(real32 *)Address;
+ if (Type == d_uint)
+ Debug.Temp.Val[i].u = *(uint32 *)Address;
+ if (Type == d_int)
+ Debug.Temp.Val[i].i = *(int32 *)Address;
+ Debug.Temp.DebugPropertyType[i] = Type;
+ Debug.Temp.WatchedProperties++;
+}
+
+#else
+
+#define Assert(Expression)
+
+enum valtype {
+};
+
+union debugval {
+};
+
+struct debug_temp
+{
+};
+
+struct project_debug
+{
+};
+
+static void
+DebugWatchVar(char *Name, void *Address, valtype Type) {
+}
+
+static void
+DebugPrintMemoryUsage(memory Memory) {
+}
+#endif
+
+#ifdef PERF
+
+struct perf_stats
+{
+ uint64 PixelCountTransparent;
+ uint64 PixelCountRendered;
+ uint64 PixelCountChecked;
+};
+
+static uint64 Test;
+
+#endif
+