launch profiler capture program at start
This commit is contained in:
parent
fdf35c698d
commit
ca94dbec3e
@ -290,7 +290,6 @@ void draw_grid(struct gp_flow *flow, struct xform xf, u32 bg0_color, u32 bg1_col
|
|||||||
/* Returns the rect of the text area */
|
/* Returns the rect of the text area */
|
||||||
struct rect draw_text(struct gp_flow *flow, struct draw_text_params params)
|
struct rect draw_text(struct gp_flow *flow, struct draw_text_params params)
|
||||||
{
|
{
|
||||||
__prof;
|
|
||||||
struct arena_temp scratch = scratch_begin_no_conflict();
|
struct arena_temp scratch = scratch_begin_no_conflict();
|
||||||
|
|
||||||
f32 inv_font_image_width = 1.0 / (f32)params.font->image_width;
|
f32 inv_font_image_width = 1.0 / (f32)params.font->image_width;
|
||||||
|
|||||||
@ -1475,7 +1475,6 @@ struct gp_flow *gp_flow_alloc(void)
|
|||||||
|
|
||||||
i32 gp_push_cmd(struct gp_flow *gp_flow, struct gp_cmd_desc *cmd_desc)
|
i32 gp_push_cmd(struct gp_flow *gp_flow, struct gp_cmd_desc *cmd_desc)
|
||||||
{
|
{
|
||||||
__prof;
|
|
||||||
i32 ret = 0;
|
i32 ret = 0;
|
||||||
struct flow *flow = (struct flow *)gp_flow;
|
struct flow *flow = (struct flow *)gp_flow;
|
||||||
if (flow) {
|
if (flow) {
|
||||||
|
|||||||
@ -42,7 +42,7 @@ struct alignas(64) worker_ctx {
|
|||||||
i32 pin_depth;
|
i32 pin_depth;
|
||||||
b32 initialized;
|
b32 initialized;
|
||||||
};
|
};
|
||||||
STATIC_ASSERT(alignof(struct worker_ctx) == 64); /* To avoid false sharing */
|
STATIC_ASSERT(alignof(struct worker_ctx) == 64); /* Avoid false sharing */
|
||||||
|
|
||||||
/* ========================== *
|
/* ========================== *
|
||||||
* Global state
|
* Global state
|
||||||
|
|||||||
@ -11,7 +11,8 @@
|
|||||||
#define PROFILING_CAPTURE_FRAME_IMAGE 0
|
#define PROFILING_CAPTURE_FRAME_IMAGE 0
|
||||||
#define PROFILING_LOCKS 0
|
#define PROFILING_LOCKS 0
|
||||||
#define PROFILING_D3D 0
|
#define PROFILING_D3D 0
|
||||||
#define PROFILING_CMD_WSTR L"tracy-profiler.exe -a 127.0.0.1"
|
#define PROFILING_FILE_WSTR L".tracy"
|
||||||
|
#define PROFILING_CMD_WSTR L"cmd /C start \"\" /wait tracy-capture.exe -o .tracy -a 127.0.0.1 && start \"\" tracy-profiler.exe .tracy"
|
||||||
|
|
||||||
/* Tracy defines */
|
/* Tracy defines */
|
||||||
#define TRACY_ENABLE
|
#define TRACY_ENABLE
|
||||||
|
|||||||
@ -490,7 +490,7 @@ b32 sys_run_command(struct string cmd);
|
|||||||
i32 sys_current_fiber_id(void);
|
i32 sys_current_fiber_id(void);
|
||||||
|
|
||||||
/* ========================== *
|
/* ========================== *
|
||||||
* Scratch
|
* Scratch context
|
||||||
* ========================== */
|
* ========================== */
|
||||||
|
|
||||||
#define SYS_SCRATCH_ARENAS_PER_CTX 2
|
#define SYS_SCRATCH_ARENAS_PER_CTX 2
|
||||||
|
|||||||
@ -121,7 +121,7 @@ struct alignas(64) fiber_ctx {
|
|||||||
u8 pad[40]; /* 40 bytes */
|
u8 pad[40]; /* 40 bytes */
|
||||||
};
|
};
|
||||||
STATIC_ASSERT(sizeof(struct fiber_ctx) == 64); /* Assume ctx fits in one cache line (increase if necessary) */
|
STATIC_ASSERT(sizeof(struct fiber_ctx) == 64); /* Assume ctx fits in one cache line (increase if necessary) */
|
||||||
STATIC_ASSERT(alignof(struct fiber_ctx) == 64); /* To avoid false sharing */
|
STATIC_ASSERT(alignof(struct fiber_ctx) == 64); /* Avoid false sharing */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -208,6 +208,7 @@ INTERNAL i32 fiber_ctx_init(void)
|
|||||||
|
|
||||||
INTERNAL struct fiber_ctx *fiber_ctx_from_id(i32 id)
|
INTERNAL struct fiber_ctx *fiber_ctx_from_id(i32 id)
|
||||||
{
|
{
|
||||||
|
ASSERT(id >= 0 && id < SYS_MAX_FIBERS);
|
||||||
return &G.fiber_contexts[id];
|
return &G.fiber_contexts[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,7 +218,7 @@ i32 sys_current_fiber_id(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ========================== *
|
/* ========================== *
|
||||||
* Scratch ctx
|
* Scratch context
|
||||||
* ========================== */
|
* ========================== */
|
||||||
|
|
||||||
struct sys_scratch_ctx *sys_scratch_ctx_from_fiber_id(i32 id)
|
struct sys_scratch_ctx *sys_scratch_ctx_from_fiber_id(i32 id)
|
||||||
@ -1985,14 +1986,7 @@ INTERNAL DWORD WINAPI win32_thread_proc(LPVOID vt)
|
|||||||
__profthread(t->thread_name_cstr);
|
__profthread(t->thread_name_cstr);
|
||||||
|
|
||||||
i32 fiber_id = fiber_ctx_init();
|
i32 fiber_id = fiber_ctx_init();
|
||||||
void *fiber_addr = ConvertThreadToFiber((void *)(i64)fiber_id);
|
ConvertThreadToFiber((void *)(i64)fiber_id);
|
||||||
(UNUSED)fiber_addr;
|
|
||||||
{
|
|
||||||
i32 test = sys_current_fiber_id();
|
|
||||||
(UNUSED)test;
|
|
||||||
(UNUSED)fiber_ctx_from_id;
|
|
||||||
DEBUGBREAKABLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Initialize COM */
|
/* Initialize COM */
|
||||||
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
||||||
@ -2414,6 +2408,23 @@ int CALLBACK wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev_instance,
|
|||||||
(UNUSED)cmdline_wstr;
|
(UNUSED)cmdline_wstr;
|
||||||
(UNUSED)show_code;
|
(UNUSED)show_code;
|
||||||
|
|
||||||
|
#if PROFILING
|
||||||
|
/* Launch profiler */
|
||||||
|
{
|
||||||
|
__profscope(Launch profiler);
|
||||||
|
STARTUPINFO si = ZI;
|
||||||
|
si.cb = sizeof(si);
|
||||||
|
PROCESS_INFORMATION pi = ZI;
|
||||||
|
wchar_t cmd[sizeof(PROFILING_CMD_WSTR)] = ZI;
|
||||||
|
MEMCPY(cmd, PROFILING_CMD_WSTR, sizeof(PROFILING_CMD_WSTR));
|
||||||
|
DeleteFileW(PROFILING_FILE_WSTR);
|
||||||
|
b32 success = CreateProcessW(NULL, cmd, NULL, NULL, FALSE, DETACHED_PROCESS, NULL, NULL, &si, &pi);
|
||||||
|
if (!success) {
|
||||||
|
MessageBoxExW(NULL, L"Failed to launch capture using command '" PROFILING_CMD_WSTR L"'. Is the app in your path?", L"Error", MB_ICONSTOP | MB_SETFOREGROUND | MB_TOPMOST, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Convert main thread to fiber */
|
/* Convert main thread to fiber */
|
||||||
i32 fiber_id = fiber_ctx_init();
|
i32 fiber_id = fiber_ctx_init();
|
||||||
ConvertThreadToFiber((void *)(i64)fiber_id);
|
ConvertThreadToFiber((void *)(i64)fiber_id);
|
||||||
@ -2591,26 +2602,6 @@ int CALLBACK wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev_instance,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if PROFILING
|
|
||||||
/* Launch profiler */
|
|
||||||
if (!__prof_is_connected()) {
|
|
||||||
__profscope(Launch profiler);
|
|
||||||
STARTUPINFO si = ZI;
|
|
||||||
si.cb = sizeof(si);
|
|
||||||
PROCESS_INFORMATION pi = ZI;
|
|
||||||
wchar_t cmd[sizeof(PROFILING_CMD_WSTR)] = ZI;
|
|
||||||
MEMCPY(cmd, PROFILING_CMD_WSTR, sizeof(PROFILING_CMD_WSTR));
|
|
||||||
b32 success = CreateProcessW(NULL, cmd, NULL, NULL, FALSE, DETACHED_PROCESS, NULL, NULL, &si, &pi);
|
|
||||||
if (success) {
|
|
||||||
while (!__prof_is_connected()) {
|
|
||||||
ix_pause();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
MessageBoxExW(NULL, L"Failed to launch tracy profiler using command " PROFILING_CMD_WSTR, L"Error", MB_ICONSTOP | MB_SETFOREGROUND | MB_TOPMOST, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
25
src/user.c
25
src/user.c
@ -172,7 +172,6 @@ GLOBAL READONLY enum user_bind_kind g_binds[SYS_BTN_COUNT] = {
|
|||||||
[SYS_BTN_F1] = USER_BIND_KIND_DEBUG_PAUSE,
|
[SYS_BTN_F1] = USER_BIND_KIND_DEBUG_PAUSE,
|
||||||
[SYS_BTN_F2] = USER_BIND_KIND_DEBUG_CAMERA,
|
[SYS_BTN_F2] = USER_BIND_KIND_DEBUG_CAMERA,
|
||||||
[SYS_BTN_F3] = USER_BIND_KIND_DEBUG_DRAW,
|
[SYS_BTN_F3] = USER_BIND_KIND_DEBUG_DRAW,
|
||||||
[SYS_BTN_F4] = USER_BIND_KIND_PROFILER,
|
|
||||||
[SYS_BTN_GRAVE_ACCENT] = USER_BIND_KIND_DEBUG_CONSOLE,
|
[SYS_BTN_GRAVE_ACCENT] = USER_BIND_KIND_DEBUG_CONSOLE,
|
||||||
[SYS_BTN_F11] = USER_BIND_KIND_FULLSCREEN,
|
[SYS_BTN_F11] = USER_BIND_KIND_FULLSCREEN,
|
||||||
[SYS_BTN_MWHEELUP] = USER_BIND_KIND_ZOOM_IN,
|
[SYS_BTN_MWHEELUP] = USER_BIND_KIND_ZOOM_IN,
|
||||||
@ -850,26 +849,6 @@ INTERNAL void user_update(void)
|
|||||||
if (G.bind_states[USER_BIND_KIND_DEBUG_CAMERA].num_presses > 0) {
|
if (G.bind_states[USER_BIND_KIND_DEBUG_CAMERA].num_presses > 0) {
|
||||||
G.debug_camera = !G.debug_camera;
|
G.debug_camera = !G.debug_camera;
|
||||||
}
|
}
|
||||||
if (G.bind_states[USER_BIND_KIND_PROFILER].num_presses > 0) {
|
|
||||||
if (G.profiler_launched) {
|
|
||||||
logf_warning("Profiler already launched");
|
|
||||||
} else {
|
|
||||||
#if PROFILING
|
|
||||||
__profscope(Launch profiler);
|
|
||||||
struct string cmd = string_from_wstr_no_limit(scratch.arena, PROFILING_CMD_WSTR);
|
|
||||||
logf_info("Launching profiler with command \"%F\"", FMT_STR(cmd));
|
|
||||||
b32 success = sys_run_command(cmd);
|
|
||||||
if (success) {
|
|
||||||
G.profiler_launched = true;
|
|
||||||
logf_success("Launched profiler successfully");
|
|
||||||
} else {
|
|
||||||
logf_error("Failed to launch profiler using command \"%F\" (is the executable in your PATH?)", FMT_STR(cmd));
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
logf_warning("Cannot launch profiler: Program is not in profiling mode");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
if (G.bind_states[USER_BIND_KIND_DEBUG_FOLLOW].num_presses > 0) {
|
if (G.bind_states[USER_BIND_KIND_DEBUG_FOLLOW].num_presses > 0) {
|
||||||
@ -1718,16 +1697,20 @@ INTERNAL void user_update(void)
|
|||||||
struct xform xf = XFORM_TRS(.t = crosshair_pos, .s = size);
|
struct xform xf = XFORM_TRS(.t = crosshair_pos, .s = size);
|
||||||
draw_texture(G.ui_gp_flow, DRAW_TEXTURE_PARAMS(.xf = xf, .sprite = crosshair_tag));
|
draw_texture(G.ui_gp_flow, DRAW_TEXTURE_PARAMS(.xf = xf, .sprite = crosshair_tag));
|
||||||
|
|
||||||
|
#if 0
|
||||||
struct rect cursor_clip = RECT_FROM_V2(G.user_screen_offset, G.user_size);
|
struct rect cursor_clip = RECT_FROM_V2(G.user_screen_offset, G.user_size);
|
||||||
cursor_clip.pos = v2_add(cursor_clip.pos, v2_mul(size, 0.5f));
|
cursor_clip.pos = v2_add(cursor_clip.pos, v2_mul(size, 0.5f));
|
||||||
cursor_clip.pos = v2_add(cursor_clip.pos, V2(1, 1));
|
cursor_clip.pos = v2_add(cursor_clip.pos, V2(1, 1));
|
||||||
cursor_clip.size = v2_sub(cursor_clip.size, size);
|
cursor_clip.size = v2_sub(cursor_clip.size, size);
|
||||||
sys_window_cursor_hide(G.window);
|
sys_window_cursor_hide(G.window);
|
||||||
sys_window_cursor_enable_clip(G.window, cursor_clip);
|
sys_window_cursor_enable_clip(G.window, cursor_clip);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
__profscope(Update windows cursor);
|
__profscope(Update windows cursor);
|
||||||
|
#if 0
|
||||||
sys_window_cursor_disable_clip(G.window);
|
sys_window_cursor_disable_clip(G.window);
|
||||||
sys_window_cursor_show(G.window);
|
sys_window_cursor_show(G.window);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ========================== *
|
/* ========================== *
|
||||||
|
|||||||
@ -35,7 +35,6 @@ enum user_bind_kind {
|
|||||||
USER_BIND_KIND_DEBUG_WALLS,
|
USER_BIND_KIND_DEBUG_WALLS,
|
||||||
USER_BIND_KIND_DEBUG_FOLLOW,
|
USER_BIND_KIND_DEBUG_FOLLOW,
|
||||||
USER_BIND_KIND_DEBUG_DRAW,
|
USER_BIND_KIND_DEBUG_DRAW,
|
||||||
USER_BIND_KIND_PROFILER,
|
|
||||||
USER_BIND_KIND_DEBUG_CONSOLE,
|
USER_BIND_KIND_DEBUG_CONSOLE,
|
||||||
USER_BIND_KIND_DEBUG_CAMERA,
|
USER_BIND_KIND_DEBUG_CAMERA,
|
||||||
USER_BIND_KIND_DEBUG_PAUSE,
|
USER_BIND_KIND_DEBUG_PAUSE,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user