Integration Guide - bombomby/optick GitHub Wiki
Download the latest release version:
https://github.com/bombomby/optick/releases
Copy or Reference optick/src folder to your game.
Add optick/src folder to the 'Additional Include' folder.
â ī¸ If your Game uses dynamic linking and you are planning to use Optick from multiple dlls within the same executable - please make sure that Optick's code is added to the common Dynamic Library and this library is compiled with OPTICK_EXPORT define (Static Library won't work).
You could also use precompiled OptickCore.dll which is packaged with every release:
- Add
includefolder to the extra include dirs of your project- Add
lib/x64/debugandlib/x64/releaseto the extra library dirs of your project- Copy
lib/x64/debug/OptickCore.dllandlib/x64/release/OptickCore.dllto the debug and release output folders of your project respectively
Add OPTICK_FRAME("Main Thread"); macro to the Main Loop of your game (you'll also need to add #include "optick.h"):
#include "optick.h"
...
while( true )
{
OPTICK_FRAME("MainThread");
engine.Update();
}Use scoped OPTICK_EVENT(); macro to instrument a function.
This macro automatically extract current function name, so you don't need to worry about stale names if function name changes.
You'll use this macro 95% of the time.
Optick also allows you to override the name of the counter - useful for instrumenting multiple scopes withing the same function:
void Game::Update()
{
OPTICK_EVENT(); // Automatically captures current function name - 'Game::Update'
if (m_bUpdateAudio)
{
OPTICK_EVENT("UpdateAudio");
...
}
if (m_bUpdateAnimation)
{
OPTICK_EVENT("UpdateAnimation");
...
}
}âšī¸ Protip: You could also
OPTICK_CATEGORY("Name", Optick::Category::TYPE);macro for marking root high-level events of special types. Each category has a dedicated color which makes thread visualization easier-to-read. In the future versions there will be more functionality for filtering, categorization and budgeting for OPTICK_CATEGORY.
void Game::Update()
{
OPTICK_EVENT(); // Automatically captures current function name - 'Game::Update'
if (m_bUpdateAudio)
{
OPTICK_CATEGORY("UpdateAudio", Optick::Category::Audio);
...
}
if (m_bUpdateAnimation)
{
OPTICK_CATEGORY("UpdateAnimation", Optick::Category::Animation);
...
}
}Add scoped OPTICK_THREAD("Thread Name"); macro to each thread that you'd like to profile.
This macro registers current thread within Optick in constructor and releases all the allocated resources in destructor.
Add scoped OPTICK_CATEGORY("JobName", Optick::Category::JOB_TYPE); for each root job on the selected threads.
void AudioThread()
{
OPTICK_THREAD("Audio Thread");
while (g_audioThreadIsAlive)
{
Sleep(10); // Protip: Exclude 'idle gaps' between jobs from Optick - it will make thread visualization easier-to-use
OPTICK_CATEGORY("ProcessAudio", Optick::Category::Audio);
ProcessAudio();
}
}
...
std::thread audioThread(AudioThread);Use OPTICK_TAG("VariableName", m_Value); macro for attaching any custom data to the current scope.
Useful for object names, count, positions.
Supported types: float, int32_t, uint32_t, uint64_t, float[3], const char*.
OPTICK_TAG("PlayerName", m_Players[index]);
OPTICK_TAG("Health", 100);
OPTICK_TAG("Score", 0x80000000u);
OPTICK_TAG("Height(cm)", 176.3f);
OPTICK_TAG("Address", (uint64)*this);
OPTICK_TAG("Position", 123.0f, 456.0f, 789.0f);Edit optick.config.h to enable/disable some of the features in specific configs or platforms:
| Option | Descrition |
|---|---|
| USE_OPTICK | Master Switch. Use it to compile-out Optick in master builds. |
| OPTICK_ENABLE_TRACING | Kernel-level tracing. |
| OPTICK_ENABLE_GPU_D3D12 | GPU D3D12 counters. |
| OPTICK_ENABLE_GPU_VULKAN | GPU Vulkan counters. |
