@@ -466,26 +466,99 @@ impl RenderBackend {
466466 snapshot. last_world_mesh_draw_state_rows = self . last_world_mesh_draw_state_rows ( ) ;
467467 }
468468
469- if ! interest. wants_stats ( ) {
470- return snapshot;
469+ if interest. wants_stats ( ) {
470+ self . populate_stats_diagnostics_snapshot ( & mut snapshot) ;
471471 }
472472
473+ if interest. wants_graph ( ) {
474+ snapshot. command_encoding = self . graph_state . latest_command_encoding ( ) ;
475+ }
476+
477+ if interest. wants_assets ( ) {
478+ self . populate_asset_diagnostics_snapshot ( & mut snapshot) ;
479+ }
480+
481+ if interest. wants_visibility ( ) {
482+ self . populate_visibility_diagnostics_snapshot ( & mut snapshot) ;
483+ }
484+
485+ snapshot
486+ }
487+
488+ fn populate_asset_diagnostics_snapshot (
489+ & self ,
490+ snapshot : & mut crate :: diagnostics:: BackendDiagSnapshot ,
491+ ) {
492+ let asset_diagnostics = self . asset_transfers . diagnostic_snapshot ( ) ;
493+ let worker_diagnostics = crate :: assets:: worker:: diagnostic_snapshot ( ) ;
494+ let material_diagnostics = self . materials . diagnostic_snapshot ( ) ;
495+
496+ snapshot. texture_format_registration_count = self . texture_format_registration_count ( ) ;
497+ snapshot. texture_mip0_ready_count = self . texture_mip0_ready_count ( ) ;
498+ snapshot. texture_pool_resident_count = self . texture_pool ( ) . len ( ) ;
499+ snapshot. render_texture_pool_len = self . render_texture_pool ( ) . len ( ) ;
500+ snapshot. mesh_pool_entry_count = self . mesh_pool ( ) . len ( ) ;
501+ snapshot. assets = crate :: diagnostics:: AssetDiagnosticsSnapshot {
502+ main_queued : asset_diagnostics. integrator . main_queued ,
503+ high_priority_queued : asset_diagnostics. integrator . high_priority_queued ,
504+ render_queued : asset_diagnostics. integrator . render_queued ,
505+ normal_priority_queued : asset_diagnostics. integrator . normal_priority_queued ,
506+ particle_queued : asset_diagnostics. integrator . particle_queued ,
507+ total_queued : asset_diagnostics. integrator . total_queued ,
508+ peak_queued : asset_diagnostics. integrator . peak_queued ,
509+ pending_mesh_uploads : asset_diagnostics. pending_mesh_uploads ,
510+ pending_texture_uploads : asset_diagnostics. pending_texture_uploads ,
511+ pending_texture3d_uploads : asset_diagnostics. pending_texture3d_uploads ,
512+ pending_cubemap_uploads : asset_diagnostics. pending_cubemap_uploads ,
513+ pending_video_texture_loads : asset_diagnostics. pending_video_texture_loads ,
514+ worker_queued : worker_diagnostics. queued ,
515+ worker_running : worker_diagnostics. running ,
516+ worker_max_queued : worker_diagnostics. max_queued ,
517+ worker_spawned : worker_diagnostics. spawned ,
518+ worker_completed : worker_diagnostics. completed ,
519+ worker_inline_executed : worker_diagnostics. inline_executed ,
520+ worker_saturated : worker_diagnostics. saturated ,
521+ pending_material_batches : material_diagnostics. pending_material_batches ,
522+ pending_shader_routes : material_diagnostics. pending_shader_routes ,
523+ material_registry_attached : material_diagnostics. material_registry_attached ,
524+ embedded_bind_attached : material_diagnostics. embedded_bind_attached ,
525+ } ;
526+ }
527+
528+ fn populate_visibility_diagnostics_snapshot (
529+ & self ,
530+ snapshot : & mut crate :: diagnostics:: BackendDiagSnapshot ,
531+ ) {
532+ snapshot. last_world_mesh_draw_stats = self . last_world_mesh_draw_stats ( ) ;
533+ snapshot. last_world_mesh_view_stats = self . last_world_mesh_view_stats ( ) ;
534+ snapshot. gpu_light_count = self . frame_services . frame_resources . frame_lights ( ) . len ( ) ;
535+ snapshot. signed_scene_color_active = self . signed_scene_color_active ( ) ;
536+ snapshot. lights = self . light_diagnostics_snapshot ( ) ;
537+ }
538+
539+ fn populate_stats_diagnostics_snapshot (
540+ & self ,
541+ snapshot : & mut crate :: diagnostics:: BackendDiagSnapshot ,
542+ ) {
473543 let store = self . material_property_store ( ) ;
474544 let material_diagnostics = self . materials . diagnostic_snapshot ( ) ;
475545 let graph_stats = self
476546 . graph_state
477547 . frame_graph_cache
478548 . compile_stats ( )
479549 . unwrap_or_default ( ) ;
480- snapshot = crate :: diagnostics:: BackendDiagSnapshot {
550+ let shader_routes = std:: mem:: take ( & mut snapshot. shader_routes ) ;
551+ let draw_state_rows = std:: mem:: take ( & mut snapshot. last_world_mesh_draw_state_rows ) ;
552+ * snapshot = crate :: diagnostics:: BackendDiagSnapshot {
481553 texture_format_registration_count : self . texture_format_registration_count ( ) ,
482554 texture_mip0_ready_count : self . texture_mip0_ready_count ( ) ,
483555 texture_pool_resident_count : self . texture_pool ( ) . len ( ) ,
484556 render_texture_pool_len : self . render_texture_pool ( ) . len ( ) ,
485557 mesh_pool_entry_count : self . mesh_pool ( ) . len ( ) ,
486- shader_routes : snapshot . shader_routes ,
558+ shader_routes,
487559 last_world_mesh_draw_stats : self . last_world_mesh_draw_stats ( ) ,
488- last_world_mesh_draw_state_rows : snapshot. last_world_mesh_draw_state_rows ,
560+ last_world_mesh_view_stats : Vec :: new ( ) ,
561+ last_world_mesh_draw_state_rows : draw_state_rows,
489562 render_world_maintenance : self . draw_preparation . render_world_maintenance_stats ( ) ,
490563 world_mesh_command_cache : self . draw_preparation . command_cache_stats ( ) ,
491564 world_mesh_instance_plan_cache : self
@@ -509,8 +582,31 @@ impl RenderBackend {
509582 gpu_light_count : self . frame_services . frame_resources . frame_lights ( ) . len ( ) ,
510583 signed_scene_color_active : self . signed_scene_color_active ( ) ,
511584 upload_arena : self . graph_state . latest_upload_stats ( ) . into ( ) ,
585+ command_encoding : Default :: default ( ) ,
586+ assets : Default :: default ( ) ,
587+ lights : Default :: default ( ) ,
512588 } ;
513- snapshot
589+ }
590+
591+ fn light_diagnostics_snapshot ( & self ) -> crate :: diagnostics:: LightDiagnosticsSnapshot {
592+ let light_visibility = self . frame_services . frame_resources . light_visibility_stats ( ) ;
593+ crate :: diagnostics:: LightDiagnosticsSnapshot {
594+ packed_default_lights : self . frame_services . frame_resources . frame_lights ( ) . len ( ) ,
595+ per_view_light_packs : self
596+ . frame_services
597+ . frame_resources
598+ . per_view_light_pack_count ( ) ,
599+ max_per_view_lights : self
600+ . frame_services
601+ . frame_resources
602+ . max_per_view_light_count ( ) ,
603+ signed_scene_color_active : self . signed_scene_color_active ( ) ,
604+ visibility_indexed_lights : light_visibility. indexed_lights ,
605+ visibility_fallback_lights : light_visibility. fallback_lights ,
606+ visibility_rejected_lights : light_visibility. rejected_lights ,
607+ visibility_bvh_queries : light_visibility. bvh_queries ,
608+ visibility_linear_queries : light_visibility. linear_queries ,
609+ }
514610 }
515611
516612 /// Mutable render-graph transient resource pool.
@@ -569,6 +665,7 @@ impl RenderBackend {
569665 history_registry,
570666 upload_arena,
571667 latest_upload_stats,
668+ latest_command_encoding,
572669 pending_transient_releases,
573670 ) = self . graph_state . execution_resources_mut ( ) ;
574671 let ( frame_resources, mesh_preprocess, mesh_deform_scratch, skin_cache) =
@@ -586,6 +683,7 @@ impl RenderBackend {
586683 history_registry,
587684 upload_arena,
588685 latest_upload_stats,
686+ latest_command_encoding,
589687 pending_transient_releases,
590688 debug_hud : self . diagnostics . bundle_mut ( ) ,
591689 scene_color_format,
0 commit comments