move tracy src file compilation from build system to src file
This commit is contained in:
parent
d38046a007
commit
d7f0cb2d5e
22
build.c
22
build.c
@ -328,8 +328,8 @@ void OnBuild(StringList cli_args)
|
|||||||
|
|
||||||
String tracy_env_var_name = Lit("TRACY_SRC_PATH");
|
String tracy_env_var_name = Lit("TRACY_SRC_PATH");
|
||||||
String tracy_src_dir_path = OS_GetEnvVar(&perm, tracy_env_var_name);
|
String tracy_src_dir_path = OS_GetEnvVar(&perm, tracy_env_var_name);
|
||||||
String tracy_public_dir_path = StringF(&perm, Lit("%F%F"), FmtStr(tracy_src_dir_path), FmtStr(Lit("/public")));
|
String tracy_client_header_path = OS_GetAbsPath(&perm, StringF(&perm, Lit("%F%F"), FmtStr(tracy_src_dir_path), FmtStr(Lit("/public/tracy/TracyC.h"))));
|
||||||
String tracy_include_path = StringF(&perm, Lit("%F%F"), FmtStr(tracy_public_dir_path), FmtStr(Lit("/tracy/TracyC.h")));
|
String tracy_client_src_path = OS_GetAbsPath(&perm, StringF(&perm, Lit("%F%F"), FmtStr(tracy_src_dir_path), FmtStr(Lit("/public/TracyClient.cpp"))));
|
||||||
{
|
{
|
||||||
typedef enum ArgState {
|
typedef enum ArgState {
|
||||||
ArgState_None,
|
ArgState_None,
|
||||||
@ -589,13 +589,8 @@ void OnBuild(StringList cli_args)
|
|||||||
Error(StringF(&perm, Lit("Profiling is enabled but tracy directory \"%F\" does not exist (set by environment variable \"%F\")"), FmtStr(tracy_src_dir_path), FmtStr(tracy_env_var_name)));
|
Error(StringF(&perm, Lit("Profiling is enabled but tracy directory \"%F\" does not exist (set by environment variable \"%F\")"), FmtStr(tracy_src_dir_path), FmtStr(tracy_env_var_name)));
|
||||||
OS_Exit(1);
|
OS_Exit(1);
|
||||||
}
|
}
|
||||||
StringListAppend(&perm, &compile_args, StringF(&perm, Lit("-DTRACY_INCLUDE_PATH=\"%F\""), FmtStr(tracy_include_path)));
|
StringListAppend(&perm, &compile_args, StringF(&perm, Lit("-DTRACY_CLIENT_HEADER_PATH=\\\"%F\\\""), FmtStr(tracy_client_header_path)));
|
||||||
|
StringListAppend(&perm, &compile_args, StringF(&perm, Lit("-DTRACY_CLIENT_SRC_PATH=\\\"%F\\\""), FmtStr(tracy_client_src_path)));
|
||||||
/* Disable compiler warnings when compiling tracy client */
|
|
||||||
compile_warnings = (StringList) { 0 };
|
|
||||||
link_warnings = (StringList) { 0 };
|
|
||||||
StringListAppend(&perm, &compile_warnings, Lit("-Wno-everything"));
|
|
||||||
StringListAppend(&perm, &link_warnings, Lit("-Wno-everything"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!arg_msvc) {
|
if (!arg_msvc) {
|
||||||
@ -829,14 +824,6 @@ void OnBuild(StringList cli_args)
|
|||||||
D_Tag src_dir = D_TagFromPath(&perm, Lit("src"), D_TagKind_Dir);
|
D_Tag src_dir = D_TagFromPath(&perm, Lit("src"), D_TagKind_Dir);
|
||||||
D_TagList src_files = D_GetDirContents(&perm, src_dir, false);
|
D_TagList src_files = D_GetDirContents(&perm, src_dir, false);
|
||||||
|
|
||||||
if (arg_profiling) {
|
|
||||||
D_Tag tracy_src_dir = D_TagFromPath(&perm, tracy_public_dir_path, D_TagKind_Dir);
|
|
||||||
D_TagList tracy_src_files = D_GetDirContents(&perm, tracy_src_dir, true);
|
|
||||||
for (D_TagListNode *n = tracy_src_files.first; n; n = n->next) {
|
|
||||||
D_TagListAppend(&perm, &src_files, n->tag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (D_TagListNode *n = src_files.first; n; n = n->next) {
|
for (D_TagListNode *n = src_files.first; n; n = n->next) {
|
||||||
Bool ignore = true;
|
Bool ignore = true;
|
||||||
|
|
||||||
@ -857,7 +844,6 @@ void OnBuild(StringList cli_args)
|
|||||||
if (PlatformWindows) {
|
if (PlatformWindows) {
|
||||||
ignore = !(StringEqual(name, Lit("sys_win32.c")) ||
|
ignore = !(StringEqual(name, Lit("sys_win32.c")) ||
|
||||||
StringEqual(name, Lit("sock_win32.c")) ||
|
StringEqual(name, Lit("sock_win32.c")) ||
|
||||||
StringEqual(name, Lit("gp_dx11.c")) ||
|
|
||||||
StringEqual(name, Lit("gp_dx12.c")) ||
|
StringEqual(name, Lit("gp_dx12.c")) ||
|
||||||
StringEqual(name, Lit("playback_wasapi.c")) ||
|
StringEqual(name, Lit("playback_wasapi.c")) ||
|
||||||
StringEqual(name, Lit("mp3_mmf.c")) ||
|
StringEqual(name, Lit("mp3_mmf.c")) ||
|
||||||
|
|||||||
8
src/prof_tracy.cpp
Normal file
8
src/prof_tracy.cpp
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#if PROFILING
|
||||||
|
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Weverything"
|
||||||
|
# include TRACY_CLIENT_SRC_PATH
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -13,22 +13,29 @@
|
|||||||
#define PROFILING_D3D 1
|
#define PROFILING_D3D 1
|
||||||
#define PROFILING_CMD_WSTR L"tracy-profiler.exe -a 127.0.0.1"
|
#define PROFILING_CMD_WSTR L"tracy-profiler.exe -a 127.0.0.1"
|
||||||
|
|
||||||
/* Include tracy client */
|
/* Tracy defines */
|
||||||
#define TRACY_ENABLE
|
#define TRACY_ENABLE
|
||||||
#if !PROFILING_SYSTEM_TRACE
|
#if !PROFILING_SYSTEM_TRACE
|
||||||
# define TRACY_NO_CALLSTACK
|
# define TRACY_NO_CALLSTACK
|
||||||
# define TRACY_NO_SYSTEM_TRACING
|
# define TRACY_NO_SYSTEM_TRACING
|
||||||
#endif
|
#endif
|
||||||
#include STRINGIZE(TRACY_INCLUDE_PATH)
|
|
||||||
|
/* Include tracy client */
|
||||||
|
#pragma clang diagnostic ignored "-Wshadow"
|
||||||
|
#pragma clang diagnostic ignored "-Wextra-semi"
|
||||||
|
#pragma clang diagnostic ignored "-Wextra-semi-stmt"
|
||||||
|
#pragma clang diagnostic ignored "-Wpointer-sign"
|
||||||
|
#pragma clang diagnostic ignored "-Wincompatible-pointer-types-discards-qualifiers"
|
||||||
|
#include TRACY_CLIENT_HEADER_PATH
|
||||||
|
|
||||||
/* Clang/GCC cleanup macros */
|
/* Clang/GCC cleanup macros */
|
||||||
#define __prof static const struct ___tracy_source_location_data CAT(__tracy_source_location,__LINE__) = { NULL, __func__, __FILE__, (uint32_t)__LINE__, 0 }; __attribute((cleanup(__prof_zone_cleanup_func))) TracyCZoneCtx __tracy_zone_ctx = ___tracy_emit_zone_begin( &CAT(__tracy_source_location,__LINE__), true );
|
#define __prof static const struct ___tracy_source_location_data CAT(__tracy_source_location,__LINE__) = { NULL, __func__, __FILE__, (uint32_t)__LINE__, 0 }; __attribute((cleanup(__prof_zone_cleanup_func))) TracyCZoneCtx __tracy_zone_ctx = ___tracy_emit_zone_begin( &CAT(__tracy_source_location,__LINE__), true )
|
||||||
#define __profscope(name) static const struct ___tracy_source_location_data CAT(__tracy_source_location,__LINE__) = { #name, __func__, __FILE__, (uint32_t)__LINE__, 0 }; __attribute((cleanup(__prof_zone_cleanup_func))) TracyCZoneCtx __tracy_zone_ctx = ___tracy_emit_zone_begin( &CAT(__tracy_source_location,__LINE__), true );
|
#define __profscope(name) static const struct ___tracy_source_location_data CAT(__tracy_source_location,__LINE__) = { #name, __func__, __FILE__, (uint32_t)__LINE__, 0 }; __attribute((cleanup(__prof_zone_cleanup_func))) TracyCZoneCtx __tracy_zone_ctx = ___tracy_emit_zone_begin( &CAT(__tracy_source_location,__LINE__), true )
|
||||||
INLINE void __prof_zone_cleanup_func(TracyCZoneCtx *ctx) { TracyCZoneEnd(*ctx); }
|
INLINE void __prof_zone_cleanup_func(TracyCZoneCtx *ctx) { TracyCZoneEnd(*ctx) }
|
||||||
|
|
||||||
#define __profalloc(ptr, size) TracyCAlloc((ptr), (size))
|
#define __profalloc(ptr, size) TracyCAlloc((ptr), (size))
|
||||||
#define __proffree(ptr) TracyCFree((ptr))
|
#define __proffree(ptr) TracyCFree((ptr))
|
||||||
#define __profmsg(txt, len, col) TracyCMessageC((txt), (len), BGR32(col));
|
#define __profmsg(txt, len, col) TracyCMessageC((txt), (len), BGR32(col))
|
||||||
#define __profframe(name) TracyCFrameMarkNamed((name))
|
#define __profframe(name) TracyCFrameMarkNamed((name))
|
||||||
#define __profthread(name) TracyCSetThreadName((name))
|
#define __profthread(name) TracyCSetThreadName((name))
|
||||||
|
|
||||||
@ -95,14 +102,14 @@ enum __prof_plot_type {
|
|||||||
#if PROFILING_D3D
|
#if PROFILING_D3D
|
||||||
/* Dx11 */
|
/* Dx11 */
|
||||||
INLINE void __prof_dx11_zone_cleanup_func(TracyCD3D11ZoneCtx *ctx) { ___tracy_d3d11_emit_zone_end(*ctx); }
|
INLINE void __prof_dx11_zone_cleanup_func(TracyCD3D11ZoneCtx *ctx) { ___tracy_d3d11_emit_zone_end(*ctx); }
|
||||||
# define __profscope_dx11(dx11_ctx, name, color) static const struct ___tracy_source_location_data CAT(__tracy_gpu_d3d11_source_location,__LINE__) = { #name, __func__, __FILE__, (uint32_t)__LINE__, BGR32(color) }; __attribute((cleanup(__prof_dx11_zone_cleanup_func))) TracyCD3D11ZoneCtx __tracy_d3d11_zone_ctx; ___tracy_d3d11_emit_zone_begin( dx11_ctx, &__tracy_d3d11_zone_ctx, &CAT(__tracy_gpu_d3d11_source_location,__LINE__), true);
|
# define __profscope_dx11(dx11_ctx, name, color) static const struct ___tracy_source_location_data CAT(__tracy_gpu_d3d11_source_location,__LINE__) = { #name, __func__, __FILE__, (uint32_t)__LINE__, BGR32(color) }; __attribute((cleanup(__prof_dx11_zone_cleanup_func))) TracyCD3D11ZoneCtx __tracy_d3d11_zone_ctx; ___tracy_d3d11_emit_zone_begin( dx11_ctx, &__tracy_d3d11_zone_ctx, &CAT(__tracy_gpu_d3d11_source_location,__LINE__), true)
|
||||||
# define __prof_dx11_ctx(name) struct TracyCD3D11Ctx *name
|
# define __prof_dx11_ctx(name) struct TracyCD3D11Ctx *name
|
||||||
# define __prof_dx11_ctx_alloc(ctx, device, device_ctx, name, name_len) ctx = ___tracy_d3d11_context_announce(device, device_ctx, name, name_len)
|
# define __prof_dx11_ctx_alloc(ctx, device, device_ctx, name, name_len) ctx = ___tracy_d3d11_context_announce(device, device_ctx, name, name_len)
|
||||||
# define __prof_dx11_ctx_release(ctx) ___tracy_d3d11_context_terminate(ctx)
|
# define __prof_dx11_ctx_release(ctx) ___tracy_d3d11_context_terminate(ctx)
|
||||||
# define __prof_dx11_collect(ctx) ___tracy_d3d11_context_collect(ctx)
|
# define __prof_dx11_collect(ctx) ___tracy_d3d11_context_collect(ctx)
|
||||||
/* Dx12 */
|
/* Dx12 */
|
||||||
INLINE void __prof_dx12_zone_cleanup_func(TracyCD3D12ZoneCtx *ctx) { ___tracy_d3d12_emit_zone_end(*ctx); }
|
INLINE void __prof_dx12_zone_cleanup_func(TracyCD3D12ZoneCtx *ctx) { ___tracy_d3d12_emit_zone_end(*ctx); }
|
||||||
# define __profscope_dx12(dx12_ctx, cmd_list, name, color) static const struct ___tracy_source_location_data CAT(__tracy_gpu_d3d12_source_location,__LINE__) = { #name, __func__, __FILE__, (uint32_t)__LINE__, BGR32(color) }; __attribute((cleanup(__prof_dx12_zone_cleanup_func))) TracyCD3D12ZoneCtx __tracy_d3d12_zone_ctx; ___tracy_d3d12_emit_zone_begin( dx12_ctx, cmd_list, &__tracy_d3d12_zone_ctx, &CAT(__tracy_gpu_d3d12_source_location,__LINE__), true);
|
# define __profscope_dx12(dx12_ctx, cmd_list, name, color) static const struct ___tracy_source_location_data CAT(__tracy_gpu_d3d12_source_location,__LINE__) = { #name, __func__, __FILE__, (uint32_t)__LINE__, BGR32(color) }; __attribute((cleanup(__prof_dx12_zone_cleanup_func))) TracyCD3D12ZoneCtx __tracy_d3d12_zone_ctx; ___tracy_d3d12_emit_zone_begin( dx12_ctx, cmd_list, &__tracy_d3d12_zone_ctx, &CAT(__tracy_gpu_d3d12_source_location,__LINE__), true)
|
||||||
# define __prof_dx12_ctx(name) struct TracyCD3D12Ctx *name
|
# define __prof_dx12_ctx(name) struct TracyCD3D12Ctx *name
|
||||||
# define __prof_dx12_ctx_alloc(ctx, device, queue, name, name_len) ctx = ___tracy_d3d12_context_announce(device, queue, name, name_len)
|
# define __prof_dx12_ctx_alloc(ctx, device, queue, name, name_len) ctx = ___tracy_d3d12_context_announce(device, queue, name, name_len)
|
||||||
# define __prof_dx12_ctx_release(ctx) ___tracy_d3d12_context_terminate(ctx)
|
# define __prof_dx12_ctx_release(ctx) ___tracy_d3d12_context_terminate(ctx)
|
||||||
@ -121,7 +128,7 @@ INLINE void __prof_dx12_zone_cleanup_func(TracyCD3D12ZoneCtx *ctx) { ___tracy_d3
|
|||||||
#endif /* PROFILING_D3D */
|
#endif /* PROFILING_D3D */
|
||||||
|
|
||||||
#if PROFILING_CAPTURE_FRAME_IMAGE
|
#if PROFILING_CAPTURE_FRAME_IMAGE
|
||||||
# define __profframeimage(image, width, height, offset, flipped) TracyCFrameImage((image), (width), (height), (offset), (flipped));
|
# define __profframeimage(image, width, height, offset, flipped) TracyCFrameImage((image), (width), (height), (offset), (flipped))
|
||||||
#else
|
#else
|
||||||
# define __profframeimage(image, width, height, offset, flipped)
|
# define __profframeimage(image, width, height, offset, flipped)
|
||||||
#endif /* PROFILING_CAPTURE_FRAME_IMAGE */
|
#endif /* PROFILING_CAPTURE_FRAME_IMAGE */
|
||||||
|
|||||||
@ -2549,7 +2549,8 @@ int CALLBACK wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev_instance,
|
|||||||
/* Launch profiler */
|
/* Launch profiler */
|
||||||
if (!__prof_is_connected()) {
|
if (!__prof_is_connected()) {
|
||||||
__profscope(Launch profiler);
|
__profscope(Launch profiler);
|
||||||
STARTUPINFO si = { sizeof(si) };
|
STARTUPINFO si = ZI;
|
||||||
|
si.cb = sizeof(si);
|
||||||
PROCESS_INFORMATION pi = ZI;
|
PROCESS_INFORMATION pi = ZI;
|
||||||
wchar_t cmd[sizeof(PROFILING_CMD_WSTR)] = ZI;
|
wchar_t cmd[sizeof(PROFILING_CMD_WSTR)] = ZI;
|
||||||
MEMCPY(cmd, PROFILING_CMD_WSTR, sizeof(PROFILING_CMD_WSTR));
|
MEMCPY(cmd, PROFILING_CMD_WSTR, sizeof(PROFILING_CMD_WSTR));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user