-
-
Notifications
You must be signed in to change notification settings - Fork 296
Home
Basic scoped performance counter. Use this counter 99% of the time.
It automatically extracts the name of the current function.
void Function()
{
OPTICK_EVENT();
...
}
You could also pass an optional name for this macro to override the name - OPTICK_EVENT("ScopeName");
.
Useful for marking multiple scopes within one function.
Scoped performance counter with dedicated category.
Categories always go with predefined set of colors.
Use categories for high-level overview of the code.
A macro for declaring a new thread.
Required for collecting events from the current thread.
void WorkerThread(Engine* engine)
{
OPTICK_THREAD("WorkerThread")
...
}
A macro for attaching any custom data to the current scope.
Supported types: float, int32_t, uint32_t, uint64_t, float[3], const char*.
OPTICK_TAG("PlayerName", name[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);
A macro for subscribing on state change event.
Useful for attaching screenshots or any custom files and data to the capture.
#if USE_OPTICK
bool OnOptickStateChanged(Optick::State::Type state)
{
if (state == Optick::State::STOP_CAPTURE)
{
// Starting to save screenshot
g_TakingScreenshot = true;
}
if (state == Optick::State::DUMP_CAPTURE)
{
// Wait for screenshot to be ready
// Returning false from this function will force Optick to retry again the next frame
if (g_TakingScreenshot)
return false;
// Attach screenshot
Optick::AttachFile(Optick::File::OPTICK_IMAGE, "Screenshot.bmp", g_ScreenshotRequest.c_str());
// Attach text file
const char* textFile = "You could attach custom text files!";
Optick::AttachFile(Optick::File::OPTICK_TEXT, "Test.txt", (uint8_t*)textFile, (uint32_t)strlen(textFile));
// Attaching some custom data
Optick::AttachSummary("Build", __DATE__ " " __TIME__);
}
return true;
}
OPTICK_SET_STATE_CHANGED_CALLBACK(OnOptickStateChanged);
#endif
Initializes DirectX12 GPU Profiler. Allocates a heap for 8192 timestamp queries.
Check WindowsD3D12 Sample for more details.
ID3D12Device* pDevice = m_device.Get();
ID3D12CommandQueue* pCommandQueue = m_commandQueue.Get();
OPTICK_GPU_INIT_D3D12(pDevice, &pCommandQueue, 1);
Initializes Vulkan GPU Profiler. Allocates a heap for 8192 timestamp queries.
Check WindowsVulkan Sample for more details.
OPTICK_GPU_INIT_VULKAN(&device, &physicalDevice, &queue, &vulkanDevice->queueFamilyIndices.graphics, 1);
Scoped macro for declaring current command list/buffer.
OPTICK_GPU_CONTEXT(pShadowCommandList);
OPTICK_GPU_EVENT("DrawShadows");
for (int j = 0; j < _countof(SampleAssets::Draws); ++j)
{
OPTICK_EVENT("DrawIndexedInstanced");
...
}
Scoped GPU event.
OPTICK_GPU_EVENT("DrawShadows");
This macro should be called just before present.
{
OPTICK_GPU_FLIP(m_swapChain.Get());
OPTICK_CATEGORY("Present", Optick::Category::Wait);
ThrowIfFailed(m_swapChain->Present(1, 0));
}