78 #ifndef INCLUDED_PROFILER2
79 #define INCLUDED_PROFILER2
155 Write(type, &item,
sizeof(item));
200 u32 size = 1 + itemSize;
221 memcpy(&
m_Buffer[start + 1], item, itemSize);
378 static void TLSDtor(
void* data);
446 #define PROFILE2(region) CProfile2Region profile2__(region)
448 #define PROFILE2_GPU(region) CProfile2GPURegion profile2gpu__(region)
453 #define PROFILE2_EVENT(name) g_Profiler2.RecordEvent(name)
461 #define PROFILE2_ATTR g_Profiler2.RecordAttribute
463 #endif // INCLUDED_PROFILER2
const std::string & GetName()
#define COMPILER_FENCE
prevent the compiler from reordering loads or stores across this point.
#define VPRINTF_ARGS(fmtpos)
CProfile2Region(const char *name)
void AddThreadStorage(ThreadStorage *storage)
void RecordFrameStart()
Call in main thread at the start of a frame.
void RecordAttribute(const char *fmt,...) PRINTF_ARGS(2)
ThreadStorage(CProfiler2 &profiler, const std::string &name)
CProfile2GPURegion(const char *name)
#define ASSERT(expr)
same as ENSURE in debug mode, does nothing in release mode.
#define PRINTF_ARGS(fmtpos)
A non-recursive mutual exclusion lock.
void EnableHTTP()
Call in main thread to enable the HTTP server.
Scope-based enter/leave helper.
void RecordAttributePrintf(const char *fmt,...) PRINTF_ARGS(2)
void RecordGPURegionEnter(const char *id)
#define ENSURE(expr)
ensure the expression <expr> evaluates to non-zero.
void IncrementFrameNumber()
void RecordSyncMarker(double t)
EItem
Item type identifiers.
std::string GetBuffer()
Returns a copy of a subset of the thread's buffer.
static const u8 RESYNC_MAGIC[8]
An arbitrary number to help resyncing with the item stream when parsing.
void RegisterCurrentThread(const std::string &name)
Call in any thread to enable the profiler in that thread.
void SaveToFile()
Call in any thread to save a JSONP representation of the buffers for all threads, to a file named pro...
void RecordAttribute(const char *fmt, va_list argp) VPRINTF_ARGS(2)
ThreadStorage & GetThreadStorage()
void ShutdownGPU()
Call in main thread to shut down the GPU profiling support, before shutting down OpenGL.
static const size_t BUFFER_SIZE
void Record(EItem type, double t, const char *id)
void Write(EItem type, const void *item, u32 itemSize)
Store an item into the buffer.
void RecordGPURegionLeave(const char *id)
void Initialise()
Call in main thread to set up the profiler, before calling any other profiler functions.
CProfiler2 & GetProfiler()
void * pthread_getspecific(pthread_key_t key)
void RecordRegionEnter(const char *id)
void Shutdown()
Call in main thread to shut everything down.
Used by CProfiler2 for GPU profiling support.
void RecordGPUFrameStart()
void EnableGPU()
Call in main thread to enable the GPU profiling support, after OpenGL has been initialised.
void RecordEvent(const char *id)
bool IsMainThread()
Returns whether the current thread is the 'main' thread (i.e.
void RemoveThreadStorage(ThreadStorage *storage)
void RecordRegionLeave(const char *id)
static const size_t MAX_ATTRIBUTE_LENGTH
Scope-based GPU enter/leave helper.
void ConstructJSONOverview(std::ostream &stream)
Call in any thread to produce a JSON representation of the general state of the application.
unsigned int pthread_key_t
void RecordSyncMarker()
Non-main threads should call this occasionally, especially if it's been a long time since their last ...
An item with a relative time and an ID string pointer.
std::vector< ThreadStorage * > m_Threads
static void TLSDtor(void *data)
Called by pthreads when a registered thread is destroyed.
Class instantiated in every registered thread.
const char * ConstructJSONResponse(std::ostream &stream, const std::string &thread)
Call in any thread to produce a JSON representation of the buffer for a given thread.
NONCOPYABLE(ThreadStorage)
void RecordFrameStart(double t)