aboutsummaryrefslogtreecommitdiff
path: root/example/perf.h
diff options
context:
space:
mode:
Diffstat (limited to 'example/perf.h')
-rw-r--r--example/perf.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/example/perf.h b/example/perf.h
new file mode 100644
index 0000000..3ca67b2
--- /dev/null
+++ b/example/perf.h
@@ -0,0 +1,46 @@
+#ifndef PERF_H
+#define PERF_H
+
+#include "nanovg.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum GraphrenderStyle {
+ GRAPH_RENDER_FPS,
+ GRAPH_RENDER_MS,
+ GRAPH_RENDER_PERCENT,
+};
+
+#define GRAPH_HISTORY_COUNT 100
+struct PerfGraph {
+ int style;
+ char name[32];
+ float values[GRAPH_HISTORY_COUNT];
+ int head;
+};
+typedef struct PerfGraph PerfGraph;
+
+void initGraph(PerfGraph* fps, int style, const char* name);
+void updateGraph(PerfGraph* fps, float frameTime);
+void renderGraph(NVGcontext* vg, float x, float y, PerfGraph* fps);
+float getGraphAverage(PerfGraph* fps);
+
+#define GPU_QUERY_COUNT 5
+struct GPUtimer {
+ int supported;
+ int cur, ret;
+ unsigned int queries[GPU_QUERY_COUNT];
+};
+typedef struct GPUtimer GPUtimer;
+
+void initGPUTimer(GPUtimer* timer);
+void startGPUTimer(GPUtimer* timer);
+int stopGPUTimer(GPUtimer* timer, float* times, int maxTimes);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // PERF_H \ No newline at end of file