Skip to content

Commit 4523307

Browse files
committed
Optimize graph command recording fan-out
1 parent a0cd31d commit 4523307

21 files changed

Lines changed: 383 additions & 78 deletions

File tree

crates/renderide/src/backend/asset_transfers/video_runtime.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,19 @@ impl VideoAssetRuntime {
2828
}
2929

3030
/// Starts shutdown for an unloaded player and keeps it alive until the worker joins.
31+
#[cfg(feature = "video-textures")]
3132
pub(crate) fn retire_player(&mut self, mut player: VideoPlayer) {
3233
player.begin_shutdown();
3334
self.retiring_video_players.push(player);
3435
}
3536

37+
/// Starts shutdown for an unloaded player and keeps it alive until the worker joins.
38+
#[cfg(not(feature = "video-textures"))]
39+
pub(crate) fn retire_player(&mut self, player: VideoPlayer) {
40+
player.begin_shutdown();
41+
self.retiring_video_players.push(player);
42+
}
43+
3644
/// Polls unloaded players and drops only those whose worker has fully shut down.
3745
pub(crate) fn poll_retiring_players(&mut self) {
3846
self.retiring_video_players

crates/renderide/src/backend/facade.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,15 @@ impl RenderBackend {
224224
.unwrap_or_default()
225225
}
226226

227+
/// Snapshot of the live command-recording mode for the current frame.
228+
fn command_recording_mode(&self) -> crate::config::CommandRecordingMode {
229+
self.renderer_settings
230+
.as_ref()
231+
.and_then(|h| h.read().ok())
232+
.map(|s| s.debug.command_recording)
233+
.unwrap_or_default()
234+
}
235+
227236
/// Snapshot of the live experimental renderer settings.
228237
pub(crate) fn experimental_settings(&self) -> crate::config::ExperimentalSettings {
229238
self.renderer_settings
@@ -535,6 +544,7 @@ impl RenderBackend {
535544
let gpu_limits = self.gpu_limits().cloned();
536545
let msaa_depth_resolve = self.frame_services.msaa_depth_resolve();
537546
let live_post_processing = self.live_post_processing_settings();
547+
let command_recording_mode = self.command_recording_mode();
538548
let wall_frame_time_ms = self.debug_frame_time_ms();
539549
let skin_weight_mode = self.skin_weight_mode();
540550
let (transient_pool, history_registry, upload_arena, latest_upload_stats) =
@@ -560,6 +570,7 @@ impl RenderBackend {
560570
msaa_depth_resolve,
561571
skin_weight_mode,
562572
live_post_processing,
573+
command_recording_mode,
563574
wall_frame_time_ms,
564575
}
565576
}

crates/renderide/src/backend/facade/graph_access.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ pub(crate) struct BackendGraphAccess<'a> {
8686
pub(super) skin_weight_mode: crate::shared::SkinWeightMode,
8787
/// Live post-processing settings seeded into per-view blackboards.
8888
pub(super) live_post_processing: LivePostProcessingSettings,
89+
/// Live command-recording mode selected before graph execution borrows backend fields.
90+
pub(super) command_recording_mode: crate::config::CommandRecordingMode,
8991
/// Wall-frame delta snapshot in milliseconds.
9092
pub(super) wall_frame_time_ms: f64,
9193
}
@@ -218,6 +220,11 @@ impl<'a> BackendGraphAccess<'a> {
218220
self.debug_hud.has_visible_content()
219221
}
220222

223+
/// Render-graph command-recording mode selected for this frame.
224+
pub(crate) fn command_recording_mode(&self) -> crate::config::CommandRecordingMode {
225+
self.command_recording_mode
226+
}
227+
221228
/// Encodes the debug HUD overlay.
222229
pub(crate) fn encode_debug_hud_overlay(
223230
&mut self,
@@ -376,6 +383,10 @@ impl GraphExecutionBackend for BackendGraphAccess<'_> {
376383
BackendGraphAccess::per_view_hud_config(self)
377384
}
378385

386+
fn command_recording_mode(&self) -> crate::config::CommandRecordingMode {
387+
BackendGraphAccess::command_recording_mode(self)
388+
}
389+
379390
fn debug_hud_has_visible_content(&self) -> bool {
380391
BackendGraphAccess::debug_hud_has_visible_content(self)
381392
}

crates/renderide/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub use persist::{
6262
#[cfg(test)]
6363
pub(crate) use persist::{ConfigResolveOutcome, ConfigSource};
6464
pub use types::{
65-
AutoExposureSettings, BloomCompositeMode, BloomSettings, DebugHudMainTab,
65+
AutoExposureSettings, BloomCompositeMode, BloomSettings, CommandRecordingMode, DebugHudMainTab,
6666
DebugHudMainTabVisibility, DebugHudRendererConfigTab, DebugHudRendererConfigTabVisibility,
6767
DebugHudSettings, ExperimentalSettings, GTAO_MAX_DENOISE_PASSES, GTAO_MAX_QUALITY_LEVEL,
6868
GTAO_MAX_RESOLUTION_DIVISOR, GTAO_MAX_SLICE_COUNT, GTAO_MAX_STEPS_PER_SLICE,

crates/renderide/src/config/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ mod watchdog;
1414

1515
pub use crate::render_graph::RenderGraphValidationMode;
1616
pub use debug::{
17-
DebugHudMainTab, DebugHudMainTabVisibility, DebugHudRendererConfigTab,
17+
CommandRecordingMode, DebugHudMainTab, DebugHudMainTabVisibility, DebugHudRendererConfigTab,
1818
DebugHudRendererConfigTabVisibility, DebugHudSettings, DebugSettings, PowerPreferenceSetting,
1919
};
2020
pub use display::DisplaySettings;

crates/renderide/src/config/types/debug.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
//! - [`settings`]: the `[debug]` table struct that aggregates the master toggles plus the HUD
77
//! state.
88
9+
mod command_recording;
910
mod hud;
1011
mod power_preference;
1112
mod settings;
1213

14+
pub use command_recording::CommandRecordingMode;
1315
pub use hud::{
1416
DebugHudMainTab, DebugHudMainTabVisibility, DebugHudRendererConfigTab,
1517
DebugHudRendererConfigTabVisibility, DebugHudSettings,

crates/renderide/src/config/types/debug/settings.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use serde::{Deserialize, Serialize};
44

5-
use super::{DebugHudSettings, PowerPreferenceSetting};
5+
use super::{CommandRecordingMode, DebugHudSettings, PowerPreferenceSetting};
66
use crate::render_graph::RenderGraphValidationMode;
77

88
/// Debug and diagnostics flags. Persisted as `[debug]`.
@@ -51,6 +51,9 @@ pub struct DebugSettings {
5151
/// Render-graph declaration and runtime validation policy.
5252
#[serde(default)]
5353
pub render_graph_validation: RenderGraphValidationMode,
54+
/// Render-graph command-recording strategy override for profiling and diagnostics.
55+
#[serde(default)]
56+
pub command_recording: CommandRecordingMode,
5457
}
5558

5659
impl Default for DebugSettings {
@@ -66,6 +69,7 @@ impl Default for DebugSettings {
6669
debug_hud_links: true,
6770
hud: DebugHudSettings::default(),
6871
render_graph_validation: RenderGraphValidationMode::default(),
72+
command_recording: CommandRecordingMode::default(),
6973
}
7074
}
7175
}

crates/renderide/src/diagnostics/hud/windows/renderer_config/debug.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//! Debug, diagnostics, and watchdog renderer-config HUD controls.
22
33
use crate::config::{
4-
DebugHudSettings, PowerPreferenceSetting, RenderGraphValidationMode, RendererSettings,
5-
WatchdogAction,
4+
CommandRecordingMode, DebugHudSettings, PowerPreferenceSetting, RenderGraphValidationMode,
5+
RendererSettings, WatchdogAction,
66
};
77

88
use super::controls::{drag_f32_slider_setting, drag_u32_slider_setting};
@@ -109,6 +109,21 @@ fn debug_diagnostics_section(ui: &imgui::Ui, g: &mut RendererSettings, dirty: &m
109109
}
110110
}
111111
ui.text_disabled("Warn logs declaration/runtime issues; Strict turns them into graph errors.");
112+
ui.text_disabled("Command recording");
113+
for (i, &mode) in CommandRecordingMode::ALL.iter().enumerate() {
114+
let _id = ui.push_id_int(700 + i as i32);
115+
if ui
116+
.selectable_config(mode.label())
117+
.selected(g.debug.command_recording == mode)
118+
.build()
119+
{
120+
g.debug.command_recording = mode;
121+
*dirty = true;
122+
}
123+
}
124+
ui.text_disabled(
125+
"Auto is conservative; other modes are profiling overrides applied next frame.",
126+
);
112127
ui.text_disabled("Power preference (applies at next renderer launch)");
113128
for (i, &pref) in PowerPreferenceSetting::ALL.iter().enumerate() {
114129
let _id = ui.push_id_int(i as i32);

crates/renderide/src/profiling/plots/command_encoding.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ pub struct CommandEncodingProfileSample {
1414
pub command_buffers: usize,
1515
/// Command recording path selected by the graph executor.
1616
pub recording_path: u64,
17+
/// Command recording strategy selected by the graph executor.
18+
pub recording_strategy: u64,
19+
/// Requested command recording mode from renderer config.
20+
pub requested_recording_mode: u64,
21+
/// Estimated draw count visible to per-view command recording.
22+
pub estimated_per_view_draw_count: usize,
23+
/// Estimated draw-equivalent work visible to per-view command recording diagnostics.
24+
pub estimated_per_view_record_work: usize,
25+
/// Whether automatic per-view recording would have used Rayon.
26+
pub auto_per_view_record_admitted: u64,
27+
/// Whether the effective per-view recording plan uses Rayon.
28+
pub per_view_record_admitted: u64,
1729
/// Frame-global pass count in the compiled schedule.
1830
pub frame_global_passes: usize,
1931
/// Per-view pass count in the compiled schedule.
@@ -127,6 +139,30 @@ fn plot_pass_counts(sample: &CommandEncodingProfileSample) {
127139
"command_encoding::recording_path",
128140
sample.recording_path as f64
129141
);
142+
tracy_plot!(
143+
"command_encoding::recording_strategy",
144+
sample.recording_strategy as f64
145+
);
146+
tracy_plot!(
147+
"command_encoding::requested_recording_mode",
148+
sample.requested_recording_mode as f64
149+
);
150+
tracy_plot!(
151+
"command_encoding::estimated_per_view_draw_count",
152+
sample.estimated_per_view_draw_count as f64
153+
);
154+
tracy_plot!(
155+
"command_encoding::estimated_per_view_record_work",
156+
sample.estimated_per_view_record_work as f64
157+
);
158+
tracy_plot!(
159+
"command_encoding::auto_per_view_record_admitted",
160+
sample.auto_per_view_record_admitted as f64
161+
);
162+
tracy_plot!(
163+
"command_encoding::per_view_record_admitted",
164+
sample.per_view_record_admitted as f64
165+
);
130166
tracy_plot!(
131167
"command_encoding::frame_global_passes",
132168
sample.frame_global_passes as f64

crates/renderide/src/render_graph/builder.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,7 @@ impl GraphBuilder {
467467
for (idx, entry) in self.passes.iter_mut().enumerate() {
468468
let id = PassId(idx);
469469
let name = entry.pass.name().to_string();
470+
let profiling_label = entry.pass.profiling_label().into_owned();
470471
let mut builder = PassBuilder::new(&name);
471472
entry
472473
.pass
@@ -497,6 +498,7 @@ impl GraphBuilder {
497498
setups.push(SetupEntry {
498499
group: entry.group,
499500
name,
501+
profiling_label,
500502
setup,
501503
});
502504
}

0 commit comments

Comments
 (0)