| 302 | |
| 303 | |
| 304 | void RenderProfiler(HProfile profile, dmGraphics::HContext graphics_context, dmRender::HRenderContext render_context, dmRender::HFontMap system_font_map) |
| 305 | { |
| 306 | if(gRenderProfile && g_ProfilerCurrentFrame) |
| 307 | { |
| 308 | DM_PROFILE("RenderProfiler"); |
| 309 | |
| 310 | { |
| 311 | DM_MUTEX_SCOPED_LOCK(g_ProfilerMutex); |
| 312 | |
| 313 | // Make sure the main thread is at the front so it's picked by default |
| 314 | std::sort(g_ProfilerCurrentFrame->m_Threads.Begin(), g_ProfilerCurrentFrame->m_Threads.End(), ThreadSortPred(&g_ProfilerThreadSortOrder)); |
| 315 | |
| 316 | dmProfileRender::UpdateRenderProfile(gRenderProfile, g_ProfilerCurrentFrame); |
| 317 | } |
| 318 | |
| 319 | // Enable alpha blending |
| 320 | dmGraphics::PipelineState ps_before = dmGraphics::GetPipelineState(graphics_context); |
| 321 | dmGraphics::EnableState(graphics_context, dmGraphics::STATE_BLEND); |
| 322 | dmGraphics::SetBlendFunc(graphics_context, dmGraphics::BLEND_FACTOR_ONE, dmGraphics::BLEND_FACTOR_ONE_MINUS_SRC_ALPHA); |
| 323 | |
| 324 | dmRender::RenderListBegin(render_context); |
| 325 | dmProfileRender::Draw(gRenderProfile, render_context, system_font_map); |
| 326 | dmRender::RenderListEnd(render_context); |
| 327 | dmRender::SetViewMatrix(render_context, dmVMath::Matrix4::identity()); |
| 328 | dmRender::SetProjectionMatrix(render_context, dmVMath::Matrix4::orthographic(0.0f, dmGraphics::GetWindowWidth(graphics_context), 0.0f, dmGraphics::GetWindowHeight(graphics_context), 1.0f, -1.0f)); |
| 329 | dmRender::DrawRenderList(render_context, 0, 0, 0, dmRender::SORT_BACK_TO_FRONT); |
| 330 | dmRender::ClearRenderObjects(render_context); |
| 331 | dmProfileRender::ClearTransientTextLayouts(gRenderProfile); |
| 332 | |
| 333 | // Restore blend state |
| 334 | if (!ps_before.m_BlendEnabled) |
| 335 | { |
| 336 | dmGraphics::DisableState(graphics_context, dmGraphics::STATE_BLEND); |
| 337 | } |
| 338 | dmGraphics::SetBlendFunc(graphics_context, (dmGraphics::BlendFactor) ps_before.m_BlendSrcFactor, (dmGraphics::BlendFactor) ps_before.m_BlendDstFactor); |
| 339 | } |
| 340 | |
| 341 | dmProfileRender::ProfilerFrame* dump_frame = 0; |
| 342 | if (g_ProfilerCurrentFrame) |
| 343 | { |
| 344 | DM_MUTEX_SCOPED_LOCK(g_ProfilerMutex); |
| 345 | |
| 346 | if (g_ProfilerDumpNextFrame) |
| 347 | dump_frame = dmProfileRender::DuplicateProfilerFrame(g_ProfilerCurrentFrame); |
| 348 | g_ProfilerDumpNextFrame = false; |
| 349 | |
| 350 | g_ProfilerCurrentFrame->m_Properties.SetSize(0); |
| 351 | } |
| 352 | |
| 353 | if (dump_frame) |
| 354 | { |
| 355 | dmProfileRender::DumpFrame(dump_frame); |
| 356 | dmProfileRender::DeleteProfilerFrame(dump_frame); |
| 357 | } |
| 358 | } |
| 359 | |
| 360 | /*# get current detailed memory usage for app reported by the platform |
| 361 | * Get the detailed amount of memory used by the application in bytes, as reported by the platform. |