mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-12 19:31:47 +00:00
Clean up imported functions in multi-dll projects.
This commit is contained in:
parent
8c912890f0
commit
9bd1037347
@ -11,78 +11,9 @@
|
|||||||
|
|
||||||
// Define TRACY_ENABLE to enable profiler.
|
// Define TRACY_ENABLE to enable profiler.
|
||||||
|
|
||||||
#include "common/TracySystem.cpp"
|
|
||||||
|
|
||||||
#ifdef TRACY_ENABLE
|
#ifdef TRACY_ENABLE
|
||||||
|
# ifndef TRACY_IMPORTS
|
||||||
#include "client/TracyProfiler.hpp"
|
# define TRACY_IMPORTS 1
|
||||||
#include "client/concurrentqueue.h"
|
# endif
|
||||||
|
# include "common/TracySystem.cpp"
|
||||||
#include "common/TracyQueue.hpp"
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
# include <TargetConditionals.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace tracy
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
# define DLL_IMPORT __declspec(dllimport)
|
|
||||||
#else
|
|
||||||
# define DLL_IMPORT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
DLL_IMPORT void*(*get_rpmalloc())(size_t size);
|
|
||||||
DLL_IMPORT void(*get_rpfree())(void* ptr);
|
|
||||||
DLL_IMPORT moodycamel::ConcurrentQueue<QueueItem>::ExplicitProducer*(*get_token())();
|
|
||||||
DLL_IMPORT Profiler&(*get_profiler())();
|
|
||||||
DLL_IMPORT std::atomic<uint32_t>&(*get_getlockcounter())();
|
|
||||||
DLL_IMPORT std::atomic<uint8_t>&(*get_getgpuctxcounter())();
|
|
||||||
DLL_IMPORT GpuCtxWrapper&(*get_getgpuctx())();
|
|
||||||
|
|
||||||
static void*(*rpmalloc_fpt)(size_t size) = get_rpmalloc();
|
|
||||||
static void(*rpfree_fpt)(void* ptr) = get_rpfree();
|
|
||||||
static moodycamel::ConcurrentQueue<QueueItem>::ExplicitProducer*(*GetToken_fpt)() = get_token();
|
|
||||||
static Profiler&(*GetProfiler_fpt)() = get_profiler();
|
|
||||||
static std::atomic<uint32_t>&(*GetLockCounter_fpt)() = get_getlockcounter();
|
|
||||||
static std::atomic<uint8_t>&(*GetGpuCtxCounter_fpt)() = get_getgpuctxcounter();
|
|
||||||
static GpuCtxWrapper&(*GetGpuCtx_fpt)() = get_getgpuctx();
|
|
||||||
|
|
||||||
RPMALLOC_RESTRICT void* rpmalloc(size_t size) { return rpmalloc_fpt(size); }
|
|
||||||
void rpfree(void* ptr) { rpfree_fpt(ptr); }
|
|
||||||
moodycamel::ConcurrentQueue<QueueItem>::ExplicitProducer* GetToken() { return GetToken_fpt(); }
|
|
||||||
Profiler& GetProfiler() { return GetProfiler_fpt(); }
|
|
||||||
std::atomic<uint32_t>& GetLockCounter() { return GetLockCounter_fpt(); }
|
|
||||||
std::atomic<uint8_t>& GetGpuCtxCounter() { return GetGpuCtxCounter_fpt(); }
|
|
||||||
GpuCtxWrapper& GetGpuCtx() { return GetGpuCtx_fpt(); }
|
|
||||||
|
|
||||||
#if defined TRACY_HW_TIMER && __ARM_ARCH >= 6 && !defined TARGET_OS_IOS
|
|
||||||
DLL_IMPORT int64_t(*get_GetTimeImpl())();
|
|
||||||
|
|
||||||
int64_t(*GetTimeImpl)() = get_GetTimeImpl();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef TRACY_COLLECT_THREAD_NAMES
|
|
||||||
DLL_IMPORT std::atomic<ThreadNameData*>&(*get_getthreadnamedata())();
|
|
||||||
DLL_IMPORT void(*get_rpmalloc_thread_initialize())();
|
|
||||||
DLL_IMPORT void(*get_InitRPMallocThread())();
|
|
||||||
|
|
||||||
static std::atomic<ThreadNameData*>&(*GetThreadNameData_fpt)() = get_getthreadnamedata();
|
|
||||||
static void(*rpmalloc_thread_initialize_fpt)() = get_rpmalloc_thread_initialize();
|
|
||||||
static void(*InitRPMallocThread_fpt)() = get_InitRPMallocThread();
|
|
||||||
|
|
||||||
std::atomic<ThreadNameData*>& GetThreadNameData() { return GetThreadNameData_fpt(); }
|
|
||||||
void rpmalloc_thread_initialize(void) { rpmalloc_thread_initialize_fpt(); }
|
|
||||||
void InitRPMallocThread() { InitRPMallocThread_fpt(); }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef TRACY_ON_DEMAND
|
|
||||||
DLL_IMPORT LuaZoneState&(*get_getluazonestate())();
|
|
||||||
|
|
||||||
static LuaZoneState&(*GetLuaZoneState_fpt)() = get_getluazonestate();
|
|
||||||
|
|
||||||
LuaZoneState& GetLuaZoneState() { return GetLuaZoneState_fpt(); }
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -136,7 +136,7 @@ namespace tracy
|
|||||||
{
|
{
|
||||||
|
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
LuaZoneState& GetLuaZoneState();
|
TRACY_API LuaZoneState& GetLuaZoneState();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
|
@ -772,12 +772,12 @@ static Thread* s_thread;
|
|||||||
|
|
||||||
#ifdef TRACY_DELAYED_INIT
|
#ifdef TRACY_DELAYED_INIT
|
||||||
struct ThreadNameData;
|
struct ThreadNameData;
|
||||||
moodycamel::ConcurrentQueue<QueueItem>& GetQueue();
|
TRACY_API moodycamel::ConcurrentQueue<QueueItem>& GetQueue();
|
||||||
|
|
||||||
struct RPMallocInit { RPMallocInit() { rpmalloc_initialize(); } };
|
struct RPMallocInit { RPMallocInit() { rpmalloc_initialize(); } };
|
||||||
struct RPMallocThreadInit { RPMallocThreadInit() { rpmalloc_thread_initialize(); } };
|
struct RPMallocThreadInit { RPMallocThreadInit() { rpmalloc_thread_initialize(); } };
|
||||||
|
|
||||||
void InitRPMallocThread()
|
TRACY_API void InitRPMallocThread()
|
||||||
{
|
{
|
||||||
rpmalloc_initialize();
|
rpmalloc_initialize();
|
||||||
rpmalloc_thread_initialize();
|
rpmalloc_thread_initialize();
|
||||||
@ -834,24 +834,24 @@ static ProfilerThreadData& GetProfilerThreadData()
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
moodycamel::ConcurrentQueue<QueueItem>::ExplicitProducer* GetToken() { return GetProfilerThreadData().token.ptr; }
|
TRACY_API moodycamel::ConcurrentQueue<QueueItem>::ExplicitProducer* GetToken() { return GetProfilerThreadData().token.ptr; }
|
||||||
Profiler& GetProfiler() { return GetProfilerData().profiler; }
|
TRACY_API Profiler& GetProfiler() { return GetProfilerData().profiler; }
|
||||||
moodycamel::ConcurrentQueue<QueueItem>& GetQueue() { return GetProfilerData().queue; }
|
TRACY_API moodycamel::ConcurrentQueue<QueueItem>& GetQueue() { return GetProfilerData().queue; }
|
||||||
int64_t GetInitTime() { return GetProfilerData().initTime; }
|
TRACY_API int64_t GetInitTime() { return GetProfilerData().initTime; }
|
||||||
std::atomic<uint32_t>& GetLockCounter() { return GetProfilerData().lockCounter; }
|
TRACY_API std::atomic<uint32_t>& GetLockCounter() { return GetProfilerData().lockCounter; }
|
||||||
std::atomic<uint8_t>& GetGpuCtxCounter() { return GetProfilerData().gpuCtxCounter; }
|
TRACY_API std::atomic<uint8_t>& GetGpuCtxCounter() { return GetProfilerData().gpuCtxCounter; }
|
||||||
GpuCtxWrapper& GetGpuCtx() { return GetProfilerThreadData().gpuCtx; }
|
TRACY_API GpuCtxWrapper& GetGpuCtx() { return GetProfilerThreadData().gpuCtx; }
|
||||||
|
|
||||||
# ifdef TRACY_COLLECT_THREAD_NAMES
|
# ifdef TRACY_COLLECT_THREAD_NAMES
|
||||||
std::atomic<ThreadNameData*>& GetThreadNameData() { return GetProfilerData().threadNameData; }
|
TRACY_API std::atomic<ThreadNameData*>& GetThreadNameData() { return GetProfilerData().threadNameData; }
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef TRACY_ON_DEMAND
|
# ifdef TRACY_ON_DEMAND
|
||||||
LuaZoneState& GetLuaZoneState() { return GetProfilerThreadData().luaZoneState; }
|
TRACY_API LuaZoneState& GetLuaZoneState() { return GetProfilerThreadData().luaZoneState; }
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
void InitRPMallocThread()
|
TRACY_API void InitRPMallocThread()
|
||||||
{
|
{
|
||||||
rpmalloc_thread_initialize();
|
rpmalloc_thread_initialize();
|
||||||
}
|
}
|
||||||
@ -893,52 +893,23 @@ thread_local LuaZoneState init_order(104) s_luaZoneState { 0, false };
|
|||||||
|
|
||||||
static Profiler init_order(105) s_profiler;
|
static Profiler init_order(105) s_profiler;
|
||||||
|
|
||||||
moodycamel::ConcurrentQueue<QueueItem>::ExplicitProducer* GetToken() { return s_token.ptr; }
|
TRACY_API moodycamel::ConcurrentQueue<QueueItem>::ExplicitProducer* GetToken() { return s_token.ptr; }
|
||||||
Profiler& GetProfiler() { return s_profiler; }
|
TRACY_API Profiler& GetProfiler() { return s_profiler; }
|
||||||
moodycamel::ConcurrentQueue<QueueItem>& GetQueue() { return s_queue; }
|
TRACY_API moodycamel::ConcurrentQueue<QueueItem>& GetQueue() { return s_queue; }
|
||||||
int64_t GetInitTime() { return s_initTime.val; }
|
TRACY_API int64_t GetInitTime() { return s_initTime.val; }
|
||||||
std::atomic<uint32_t>& GetLockCounter() { return s_lockCounter; }
|
TRACY_API std::atomic<uint32_t>& GetLockCounter() { return s_lockCounter; }
|
||||||
std::atomic<uint8_t>& GetGpuCtxCounter() { return s_gpuCtxCounter; }
|
TRACY_API std::atomic<uint8_t>& GetGpuCtxCounter() { return s_gpuCtxCounter; }
|
||||||
GpuCtxWrapper& GetGpuCtx() { return s_gpuCtx; }
|
TRACY_API GpuCtxWrapper& GetGpuCtx() { return s_gpuCtx; }
|
||||||
|
|
||||||
# ifdef TRACY_COLLECT_THREAD_NAMES
|
# ifdef TRACY_COLLECT_THREAD_NAMES
|
||||||
std::atomic<ThreadNameData*>& GetThreadNameData() { return s_threadNameData; }
|
TRACY_API std::atomic<ThreadNameData*>& GetThreadNameData() { return s_threadNameData; }
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef TRACY_ON_DEMAND
|
# ifdef TRACY_ON_DEMAND
|
||||||
LuaZoneState& GetLuaZoneState() { return s_luaZoneState; }
|
TRACY_API LuaZoneState& GetLuaZoneState() { return s_luaZoneState; }
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// DLL exports to enable TracyClientDLL.cpp to retrieve the instances of Tracy objects and functions
|
|
||||||
#ifdef _WIN32
|
|
||||||
# define DLL_EXPORT __declspec(dllexport)
|
|
||||||
#else
|
|
||||||
# define DLL_EXPORT __attribute__((visibility("default")))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
DLL_EXPORT void*(*get_rpmalloc())(size_t size) { return rpmalloc; }
|
|
||||||
DLL_EXPORT void(*get_rpfree())(void* ptr) { return rpfree; }
|
|
||||||
DLL_EXPORT moodycamel::ConcurrentQueue<QueueItem>::ExplicitProducer*(*get_token())() { return GetToken; }
|
|
||||||
DLL_EXPORT Profiler&(*get_profiler())() { return GetProfiler; }
|
|
||||||
DLL_EXPORT std::atomic<uint32_t>&(*get_getlockcounter())() { return GetLockCounter; }
|
|
||||||
DLL_EXPORT std::atomic<uint8_t>&(*get_getgpuctxcounter())() { return GetGpuCtxCounter; }
|
|
||||||
DLL_EXPORT GpuCtxWrapper&(*get_getgpuctx())() { return GetGpuCtx; }
|
|
||||||
|
|
||||||
#if defined TRACY_HW_TIMER && __ARM_ARCH >= 6 && !defined TARGET_OS_IOS
|
|
||||||
DLL_EXPORT int64_t(*get_GetTimeImpl())() { return GetTimeImpl; }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef TRACY_COLLECT_THREAD_NAMES
|
|
||||||
DLL_EXPORT std::atomic<ThreadNameData*>&(*get_getthreadnamedata())() { return GetThreadNameData; }
|
|
||||||
DLL_EXPORT void(*get_rpmalloc_thread_initialize())() { return rpmalloc_thread_initialize; }
|
|
||||||
DLL_EXPORT void(*get_InitRPMallocThread())() { return InitRPMallocThread; }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef TRACY_ON_DEMAND
|
|
||||||
DLL_EXPORT LuaZoneState&(*get_getluazonestate())() { return GetLuaZoneState; }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
enum { BulkSize = TargetFrameSize / QueueItemSize };
|
enum { BulkSize = TargetFrameSize / QueueItemSize };
|
||||||
|
|
||||||
Profiler::Profiler()
|
Profiler::Profiler()
|
||||||
|
@ -53,11 +53,11 @@ struct GpuCtxWrapper
|
|||||||
GpuCtx* ptr;
|
GpuCtx* ptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
moodycamel::ConcurrentQueue<QueueItem>::ExplicitProducer* GetToken();
|
TRACY_API moodycamel::ConcurrentQueue<QueueItem>::ExplicitProducer* GetToken();
|
||||||
Profiler& GetProfiler();
|
TRACY_API Profiler& GetProfiler();
|
||||||
std::atomic<uint32_t>& GetLockCounter();
|
TRACY_API std::atomic<uint32_t>& GetLockCounter();
|
||||||
std::atomic<uint8_t>& GetGpuCtxCounter();
|
TRACY_API std::atomic<uint8_t>& GetGpuCtxCounter();
|
||||||
GpuCtxWrapper& GetGpuCtx();
|
TRACY_API GpuCtxWrapper& GetGpuCtx();
|
||||||
|
|
||||||
void InitRPMallocThread();
|
void InitRPMallocThread();
|
||||||
|
|
||||||
|
@ -1906,7 +1906,7 @@ _memory_guard_block(void* block) {
|
|||||||
|
|
||||||
// Extern interface
|
// Extern interface
|
||||||
|
|
||||||
RPMALLOC_RESTRICT void*
|
TRACY_API RPMALLOC_RESTRICT void*
|
||||||
rpmalloc(size_t size) {
|
rpmalloc(size_t size) {
|
||||||
#if ENABLE_VALIDATE_ARGS
|
#if ENABLE_VALIDATE_ARGS
|
||||||
if (size >= MAX_ALLOC_SIZE) {
|
if (size >= MAX_ALLOC_SIZE) {
|
||||||
@ -1920,7 +1920,7 @@ rpmalloc(size_t size) {
|
|||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
TRACY_API void
|
||||||
rpfree(void* ptr) {
|
rpfree(void* ptr) {
|
||||||
_memory_guard_validate(ptr);
|
_memory_guard_validate(ptr);
|
||||||
_memory_deallocate(ptr);
|
_memory_deallocate(ptr);
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
|
#include "../common/TracyApi.h"
|
||||||
|
|
||||||
namespace tracy
|
namespace tracy
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -103,7 +105,7 @@ rpmalloc_config(void);
|
|||||||
extern void
|
extern void
|
||||||
rpmalloc_finalize(void);
|
rpmalloc_finalize(void);
|
||||||
|
|
||||||
extern void
|
void
|
||||||
rpmalloc_thread_initialize(void);
|
rpmalloc_thread_initialize(void);
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
@ -121,10 +123,10 @@ rpmalloc_thread_statistics(rpmalloc_thread_statistics_t* stats);
|
|||||||
extern void
|
extern void
|
||||||
rpmalloc_global_statistics(rpmalloc_global_statistics_t* stats);
|
rpmalloc_global_statistics(rpmalloc_global_statistics_t* stats);
|
||||||
|
|
||||||
extern RPMALLOC_RESTRICT void*
|
TRACY_API RPMALLOC_RESTRICT void*
|
||||||
rpmalloc(size_t size) RPMALLOC_ATTRIBUTE;
|
rpmalloc(size_t size) RPMALLOC_ATTRIBUTE;
|
||||||
|
|
||||||
extern void
|
TRACY_API void
|
||||||
rpfree(void* ptr);
|
rpfree(void* ptr);
|
||||||
|
|
||||||
extern RPMALLOC_RESTRICT void*
|
extern RPMALLOC_RESTRICT void*
|
||||||
|
14
common/TracyApi.h
Normal file
14
common/TracyApi.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#ifndef __TRACYAPI_H__
|
||||||
|
#define __TRACYAPI_H__
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
# if defined TRACY_IMPORTS
|
||||||
|
# define TRACY_API __declspec(dllimport)
|
||||||
|
# else
|
||||||
|
# define TRACY_API __declspec(dllexport)
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# define TRACY_API __attribute__((visibility("default")))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // __TRACYAPI_H__
|
@ -44,8 +44,8 @@ struct ThreadNameData
|
|||||||
const char* name;
|
const char* name;
|
||||||
ThreadNameData* next;
|
ThreadNameData* next;
|
||||||
};
|
};
|
||||||
std::atomic<ThreadNameData*>& GetThreadNameData();
|
TRACY_API std::atomic<ThreadNameData*>& GetThreadNameData();
|
||||||
void InitRPMallocThread();
|
TRACY_API void InitRPMallocThread();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void SetThreadName( std::thread& thread, const char* name )
|
void SetThreadName( std::thread& thread, const char* name )
|
||||||
|
@ -18,6 +18,8 @@ extern "C" __declspec(dllimport) unsigned long __stdcall GetCurrentThreadId(void
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
|
#include "TracyApi.h"
|
||||||
|
|
||||||
namespace tracy
|
namespace tracy
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user