| 230 | } |
| 231 | |
| 232 | void Profiler::EndFrame(uint32 displayWidth, uint32 displayHeight) |
| 233 | { |
| 234 | uint64 gpuFrequency = 0; |
| 235 | const uint64* frameQueryData = nullptr; |
| 236 | if(enableGPUProfiling) |
| 237 | { |
| 238 | DX12::GfxQueue->GetTimestampFrequency(&gpuFrequency); |
| 239 | |
| 240 | const uint64* queryData = readbackBuffer.Map<uint64>(); |
| 241 | frameQueryData = queryData + (DX12::CurrFrameIdx * MaxProfiles * 2); |
| 242 | } |
| 243 | |
| 244 | bool drawText = false; |
| 245 | if(showUI == false) |
| 246 | { |
| 247 | ImGui::SetNextWindowSize(ImVec2(75.0f, 25.0f)); |
| 248 | ImGui::SetNextWindowPos(ImVec2(25.0f, 50.0f)); |
| 249 | ImGuiWindowFlags flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | |
| 250 | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings; |
| 251 | if(ImGui::Begin("profiler_button", nullptr, ImVec2(75.0f, 25.0f), 0.0f, flags)) |
| 252 | { |
| 253 | if(ImGui::Button("Timing")) |
| 254 | showUI = true; |
| 255 | } |
| 256 | } |
| 257 | else |
| 258 | { |
| 259 | ImVec2 initialSize = ImVec2(displayWidth * 0.5f, float(displayHeight) * 0.25f); |
| 260 | ImGui::SetNextWindowSize(initialSize, ImGuiSetCond_FirstUseEver); |
| 261 | ImGui::SetNextWindowPos(ImVec2(10.0f, 10.0f), ImGuiSetCond_FirstUseEver); |
| 262 | |
| 263 | drawText = ImGui::Begin("Timing", &showUI); |
| 264 | |
| 265 | if(logToClipboard) |
| 266 | ImGui::LogToClipboard(); |
| 267 | } |
| 268 | |
| 269 | if(drawText) |
| 270 | { |
| 271 | ImGui::Text("GPU Timing"); |
| 272 | ImGui::Separator(); |
| 273 | } |
| 274 | |
| 275 | // Iterate over all of the profiles |
| 276 | for(uint64 profileIdx = 0; profileIdx < numProfiles; ++profileIdx) |
| 277 | UpdateProfile(profiles[profileIdx], profileIdx, drawText, gpuFrequency, frameQueryData); |
| 278 | |
| 279 | if(drawText) |
| 280 | { |
| 281 | ImGui::Text(" "); |
| 282 | ImGui::Text("CPU Timing"); |
| 283 | ImGui::Separator(); |
| 284 | } |
| 285 | |
| 286 | for(uint64 profileIdx = 0; profileIdx < numCPUProfiles; ++profileIdx) |
| 287 | UpdateProfile(cpuProfiles[profileIdx], profileIdx, drawText, gpuFrequency, frameQueryData); |
| 288 | |
| 289 | if(showUI) |
no test coverage detected