remove tracy if not specified on cmd line
This commit is contained in:
@@ -38,7 +38,7 @@
|
||||
#define unlikely(x) __builtin_expect(!!(x), 0)
|
||||
#endif
|
||||
|
||||
static int tracy_profiling_enabled = 0;
|
||||
int tracy_profiling_enabled = 0;
|
||||
|
||||
#define ENGINE "scripts/core/engine.js"
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
typedef JSValue (*MODULEFN)(JSContext *js);
|
||||
|
||||
extern int tracy_profiling_enabled;
|
||||
|
||||
typedef struct tagMTRand {
|
||||
uint32_t mt[STATE_VECTOR_LENGTH];
|
||||
int32_t index;
|
||||
|
||||
@@ -1,14 +1,3 @@
|
||||
#ifdef TRACY_ENABLE
|
||||
#include <tracy/TracyC.h>
|
||||
#else
|
||||
/* Provide harmless stubs when Tracy is not in use so the rest of the code
|
||||
can still call the hooks unconditionally. */
|
||||
#define TracyCAllocN(ptr, size, name) ((void)0)
|
||||
#define TracyCFreeN(ptr, name) ((void)0)
|
||||
#define TracyCFiberEnter(name) ((void)0)
|
||||
#define TracyCFiberLeave(name) ((void)0)
|
||||
#endif
|
||||
|
||||
#define MIST_CFUNC_DEF(name, length, func1, props) { name, props, JS_DEF_CFUNC, 0, .u = { .func = { length, JS_CFUNC_generic, { .generic = func1 } } } }
|
||||
|
||||
#define MIST_FUNC_DEF(TYPE, FN, LEN) MIST_CFUNC_DEF(#FN, LEN, js_##TYPE##_##FN, JS_PROP_C_W_E)
|
||||
@@ -102,7 +91,6 @@ JSValue js_##ID##_get_##ENTRY (JSContext *js, JSValue self) { \
|
||||
JSClassID js_##TYPE##_id;\
|
||||
static void js_##TYPE##_finalizer(JSRuntime *rt, JSValue val){\
|
||||
TYPE *n = JS_GetOpaque(val, js_##TYPE##_id);\
|
||||
TracyCFreeN(n, #TYPE); \
|
||||
TYPE##_free(rt,n);}\
|
||||
static JSClassDef js_##TYPE##_class = {\
|
||||
.class_name = #TYPE,\
|
||||
@@ -116,14 +104,12 @@ JSValue TYPE##2js(JSContext *js, TYPE *n) { \
|
||||
JSValue j = JS_NewObjectClass(js,js_##TYPE##_id);\
|
||||
JS_SetOpaque(j,n);\
|
||||
__VA_ARGS__ \
|
||||
TracyCAllocN(n, 1, #TYPE); \
|
||||
return j; }\
|
||||
\
|
||||
|
||||
#define QJSCLASSMARK(TYPE, ...)\
|
||||
static void js_##TYPE##_finalizer(JSRuntime *rt, JSValue val){\
|
||||
TYPE *n = JS_GetOpaque(val, js_##TYPE##_id);\
|
||||
TracyCFreeN(n, #TYPE); \
|
||||
TYPE##_free(rt,n);}\
|
||||
static JSClassDef js_##TYPE##_class = {\
|
||||
.class_name = #TYPE,\
|
||||
@@ -138,14 +124,12 @@ JSValue TYPE##2js(JSContext *js, TYPE *n) { \
|
||||
JSValue j = JS_NewObjectClass(js,js_##TYPE##_id);\
|
||||
JS_SetOpaque(j,n);\
|
||||
__VA_ARGS__ \
|
||||
TracyCAllocN(n, 1, #TYPE); \
|
||||
return j; }\
|
||||
\
|
||||
|
||||
#define QJSCLASSMARK_EXTERN(TYPE, ...)\
|
||||
static void js_##TYPE##_finalizer(JSRuntime *rt, JSValue val){\
|
||||
TYPE *n = JS_GetOpaque(val, js_##TYPE##_id);\
|
||||
TracyCFreeN(n, #TYPE); \
|
||||
TYPE##_free(rt,n);}\
|
||||
static JSClassDef js_##TYPE##_class = {\
|
||||
.class_name = #TYPE,\
|
||||
@@ -161,7 +145,6 @@ JSValue TYPE##2js(JSContext *js, TYPE *n) { \
|
||||
JSValue j = JS_NewObjectClass(js,js_##TYPE##_id);\
|
||||
JS_SetOpaque(j,n);\
|
||||
__VA_ARGS__ \
|
||||
TracyCAllocN(n, 1, #TYPE); \
|
||||
return j; }\
|
||||
\
|
||||
|
||||
|
||||
@@ -263,10 +263,12 @@ static JSValue js_os_rusage(JSContext *js, JSValue self, int argc, JSValue *argv
|
||||
#ifdef TRACY_ENABLE
|
||||
#include <tracy/TracyC.h>
|
||||
JSC_CCALL(os_frame,
|
||||
if (!tracy_profiling_enabled) return JS_UNDEFINED;
|
||||
TracyCFrameMark
|
||||
)
|
||||
|
||||
JSC_CCALL(os_trace_img,
|
||||
if (!tracy_profiling_enabled) return JS_UNDEFINED;
|
||||
size_t len;
|
||||
double width, height;
|
||||
JS_ToFloat64(js,&width,argv[1]);
|
||||
@@ -275,6 +277,7 @@ JSC_CCALL(os_trace_img,
|
||||
)
|
||||
|
||||
JSC_CCALL(os_trace_message,
|
||||
if (!tracy_profiling_enabled) return JS_UNDEFINED;
|
||||
size_t len;
|
||||
const char *str = JS_ToCStringLen(js, &len, argv[0]);
|
||||
TracyCMessage(str,len);
|
||||
|
||||
@@ -66,7 +66,6 @@ var camera = {
|
||||
|
||||
var images = {}
|
||||
|
||||
|
||||
// Convert high-level draw commands to low-level renderer commands
|
||||
function translate_draw_commands(commands) {
|
||||
if (!graphics) return
|
||||
@@ -250,7 +249,6 @@ function loop()
|
||||
|
||||
// Calculate average FPS
|
||||
var avg_fps = fps_sum / fps_samples.length
|
||||
console.log(`FPS: ${avg_fps.toFixed(1)}`)
|
||||
}
|
||||
|
||||
loop()
|
||||
|
||||
Reference in New Issue
Block a user