diff --git a/neo/libs/optick/optick.h b/neo/libs/optick/optick.h index 5042dd20..ca5ea52a 100644 --- a/neo/libs/optick/optick.h +++ b/neo/libs/optick/optick.h @@ -739,11 +739,22 @@ struct OPTICK_API Tag static void Attach(const EventDescription& description, const char* val); static void Attach(const EventDescription& description, const char* val, uint16_t length); + static void Attach(EventStorage* storage, int64_t timestamp, const EventDescription& description, float val); + static void Attach(EventStorage* storage, int64_t timestamp, const EventDescription& description, int32_t val); + static void Attach(EventStorage* storage, int64_t timestamp, const EventDescription& description, uint32_t val); + static void Attach(EventStorage* storage, int64_t timestamp, const EventDescription& description, uint64_t val); + static void Attach(EventStorage* storage, int64_t timestamp, const EventDescription& description, float val[3]); + static void Attach(EventStorage* storage, int64_t timestamp, const EventDescription& description, const char* val); + // Derived static void Attach(const EventDescription& description, float x, float y, float z) { float p[3] = { x, y, z }; Attach(description, p); } + static void Attach(EventStorage* storage, int64_t timestamp, const EventDescription& description, float x, float y, float z) + { + float p[3] = { x, y, z }; Attach(storage, timestamp, description, p); + } }; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -951,7 +962,7 @@ struct OptickApp #define OPTICK_STOP_THREAD() ::Optick::UnRegisterThread(false); // Attaches a custom data-tag. -// Supported types: int32, uint32, uint64, vec3, string (cut to 32 characters) +// Supported types: float, int32, uint32, uint64, vec3, string (cut to 32 characters) // Example: // OPTICK_TAG("PlayerName", name[index]); // OPTICK_TAG("Health", 100); @@ -1028,6 +1039,18 @@ struct OptickApp #define OPTICK_STORAGE_PUSH(STORAGE, DESCRIPTION, CPU_TIMESTAMP_START) if (::Optick::IsActive()) { ::Optick::Event::Push(STORAGE, DESCRIPTION, CPU_TIMESTAMP_START); } #define OPTICK_STORAGE_POP(STORAGE, CPU_TIMESTAMP_FINISH) if (::Optick::IsActive()) { ::Optick::Event::Pop(STORAGE, CPU_TIMESTAMP_FINISH); } +// Attaches a custom data-tag to the custom storage. +// Supported types: float, int32, uint32, uint64, vec3, string (cut to 32 characters) +// Example: +// OPTICK_STORAGE_TAG(IOStorage, cpuTimestamp, "PlayerName", name[index]); +// OPTICK_STORAGE_TAG(IOStorage, cpuTimestamp, "Health", 100); +// OPTICK_STORAGE_TAG(IOStorage, cpuTimestamp, "Score", 0x80000000u); +// OPTICK_STORAGE_TAG(IOStorage, cpuTimestamp, "Height(cm)", 176.3f); +// OPTICK_STORAGE_TAG(IOStorage, cpuTimestamp, "Address", (uint64)*this); +// OPTICK_STORAGE_TAG(IOStorage, cpuTimestamp, "Position", 123.0f, 456.0f, 789.0f); +#define OPTICK_STORAGE_TAG(STORAGE, CPU_TIMESTAMP, NAME, ...) static ::Optick::EventDescription* OPTICK_CONCAT(autogen_tag_, __LINE__) = nullptr; \ + if (OPTICK_CONCAT(autogen_tag_, __LINE__) == nullptr) OPTICK_CONCAT(autogen_tag_, __LINE__) = ::Optick::EventDescription::Create( NAME, __FILE__, __LINE__ ); \ + ::Optick::Tag::Attach(STORAGE, CPU_TIMESTAMP, *OPTICK_CONCAT(autogen_tag_, __LINE__), __VA_ARGS__); \ // Registers state change callback // If callback returns false - the call is repeated the next frame @@ -1123,6 +1146,7 @@ struct OptickApp #define OPTICK_STORAGE_EVENT(STORAGE, DESCRIPTION, CPU_TIMESTAMP_START, CPU_TIMESTAMP_FINISH) #define OPTICK_STORAGE_PUSH(STORAGE, DESCRIPTION, CPU_TIMESTAMP_START) #define OPTICK_STORAGE_POP(STORAGE, CPU_TIMESTAMP_FINISH) +#define OPTICK_STORAGE_TAG(STORAGE, CPU_TIMESTAMP, NAME, ...) #define OPTICK_SET_STATE_CHANGED_CALLBACK(CALLBACK) #define OPTICK_SET_MEMORY_ALLOCATOR(ALLOCATE_FUNCTION, DEALLOCATE_FUNCTION, INIT_THREAD_CALLBACK) #define OPTICK_SHUTDOWN() diff --git a/neo/libs/optick/optick_core.cpp b/neo/libs/optick/optick_core.cpp index 3103f11a..95acce08 100644 --- a/neo/libs/optick/optick_core.cpp +++ b/neo/libs/optick/optick_core.cpp @@ -411,6 +411,48 @@ void Tag::Attach(const EventDescription& description, const char* val, uint16_t storage->tagStringBuffer.Add(TagString(description, val, length)); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +void Tag::Attach(EventStorage* storage, int64_t timestamp, const EventDescription& description, float val) +{ + if (EventStorage* coreStorage = Core::storage) + if (storage && (coreStorage->currentMode & Mode::TAGS)) + storage->tagFloatBuffer.Add(TagFloat(description, val, timestamp)); +} +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +void Tag::Attach(EventStorage* storage, int64_t timestamp, const EventDescription& description, int32_t val) +{ + if (EventStorage* coreStorage = Core::storage) + if (storage && (coreStorage->currentMode & Mode::TAGS)) + storage->tagS32Buffer.Add(TagS32(description, val, timestamp)); +} +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +void Tag::Attach(EventStorage* storage, int64_t timestamp, const EventDescription& description, uint32_t val) +{ + if (EventStorage* coreStorage = Core::storage) + if (storage && (coreStorage->currentMode & Mode::TAGS)) + storage->tagU32Buffer.Add(TagU32(description, val, timestamp)); +} +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +void Tag::Attach(EventStorage* storage, int64_t timestamp, const EventDescription& description, uint64_t val) +{ + if (EventStorage* coreStorage = Core::storage) + if (storage && (coreStorage->currentMode & Mode::TAGS)) + storage->tagU64Buffer.Add(TagU64(description, val, timestamp)); +} +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +void Tag::Attach(EventStorage* storage, int64_t timestamp, const EventDescription& description, float val[3]) +{ + if (EventStorage* coreStorage = Core::storage) + if (storage && (coreStorage->currentMode & Mode::TAGS)) + storage->tagPointBuffer.Add(TagPoint(description, val, timestamp)); +} +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +void Tag::Attach(EventStorage* storage, int64_t timestamp, const EventDescription& description, const char* val) +{ + if (EventStorage* coreStorage = Core::storage) + if (storage && (coreStorage->currentMode & Mode::TAGS)) + storage->tagStringBuffer.Add(TagString(description, val, timestamp)); +} +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// OutputDataStream & operator<<(OutputDataStream &stream, const EventDescription &ob) { return stream << ob.name << ob.file << ob.line << ob.filter << ob.color << (float)0.0f << ob.flags;