From 5bbe6ec38cb7734ce29f2c2d452d93318c2ae7ce Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Fri, 1 May 2020 15:34:32 -0400 Subject: [PATCH] Integrate with RenderDoc on winit-less captures (#627) --- .github/workflows/ci.yml | 2 +- Cargo.lock | 54 +++++++++++++++++++++++++++++++++++++--- player/Cargo.toml | 1 + player/src/main.rs | 16 ++++++++++-- 4 files changed, 66 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d43835135..a4405eba3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -83,7 +83,7 @@ jobs: channel: stable build_command: rustup default stable-msvc; cargo clippy additional_core_features: trace - additional_player_features: + additional_player_features: renderdoc - os: windows-2019 name: Windows Nightly channel: nightly diff --git a/Cargo.lock b/Cargo.lock index 68c68f58b..d04cccf36 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -50,7 +50,7 @@ version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69daec0742947f33a85931fa3cb0ce5f07929159dcbd1f0cbb5b2912e2978509" dependencies = [ - "libloading", + "libloading 0.5.2", ] [[package]] @@ -270,7 +270,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc7ed48e89905e5e146bcc1951cc3facb9e44aea9adf5dc01078cda1bd24b662" dependencies = [ "bitflags", - "libloading", + "libloading 0.5.2", "winapi 0.3.8", ] @@ -286,7 +286,7 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77e51249a9d823a4cb79e3eca6dcd756153e8ed0157b6c04775d04bf1b13b76a" dependencies = [ - "libloading", + "libloading 0.5.2", ] [[package]] @@ -308,6 +308,15 @@ dependencies = [ "termcolor", ] +[[package]] +name = "float-cmp" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "499a1bfa03d254b047e7e5c1fc8dd23a8cf6b344a8eb7e622ae4bc76bfac8e68" +dependencies = [ + "num-traits", +] + [[package]] name = "foreign-types" version = "0.3.2" @@ -368,7 +377,7 @@ dependencies = [ "bitflags", "gfx-auxil", "gfx-hal", - "libloading", + "libloading 0.5.2", "log", "parking_lot", "range-alloc", @@ -577,6 +586,15 @@ dependencies = [ "winapi 0.3.8", ] +[[package]] +name = "libloading" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c4f51b790f5bdb65acb4cc94bb81d7b2ee60348a5431ac1467d390b017600b0" +dependencies = [ + "winapi 0.3.8", +] + [[package]] name = "line_drawing" version = "0.7.0" @@ -767,6 +785,12 @@ dependencies = [ "cc", ] +[[package]] +name = "once_cell" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c601810575c99596d4afc46f78a678c80105117c379eb3650cf99b8a21ce5b" + [[package]] name = "ordered-float" version = "1.0.2" @@ -841,6 +865,7 @@ dependencies = [ "env_logger", "log", "raw-window-handle", + "renderdoc", "ron", "wgpu-core", "wgpu-types", @@ -928,6 +953,27 @@ version = "0.6.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fe5bd57d1d7414c6b5ed48563a2c855d995ff777729dcd91c369ec7fea395ae" +[[package]] +name = "renderdoc" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c9e8488c98756911664c8cc7b86284c320b6a6357d95908458136d7ebe9280c" +dependencies = [ + "bitflags", + "float-cmp", + "libloading 0.6.1", + "once_cell", + "renderdoc-sys", + "winapi 0.3.8", + "wio", +] + +[[package]] +name = "renderdoc-sys" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60d4a9058849c3e765fe2fa68b72c1416b1766f27eac3c52d7bac8712ea0d390" + [[package]] name = "ron" version = "0.5.1" diff --git a/player/Cargo.toml b/player/Cargo.toml index a7d377fd0..cb165438b 100644 --- a/player/Cargo.toml +++ b/player/Cargo.toml @@ -18,6 +18,7 @@ publish = false env_logger = "0.7" log = "0.4" raw-window-handle = "0.3" +renderdoc = { version = "0.8", optional = true, default_features = false } ron = "0.5" winit = { version = "0.22", optional = true } diff --git a/player/src/main.rs b/player/src/main.rs index 96289d09e..a6d946904 100644 --- a/player/src/main.rs +++ b/player/src/main.rs @@ -427,6 +427,10 @@ fn main() { env_logger::init(); + #[cfg(feature = "renderdoc")] + let mut rd = renderdoc::RenderDoc::::new() + .expect("Failed to connect to RenderDoc: are you running without it?"); + //TODO: setting for the backend bits //TODO: setting for the target frame, or controls @@ -492,8 +496,16 @@ fn main() { log::info!("Executing actions"); #[cfg(not(feature = "winit"))] - while let Some(action) = actions.pop() { - gfx_select!(device => global.process(device, action, &dir, &mut command_buffer_id_manager)); + { + #[cfg(feature = "renderdoc")] + rd.start_frame_capture(ptr::null(), ptr::null()); + + while let Some(action) = actions.pop() { + gfx_select!(device => global.process(device, action, &dir, &mut command_buffer_id_manager)); + } + + #[cfg(feature = "renderdoc")] + rd.end_frame_capture(ptr::null(), ptr::null()); } #[cfg(feature = "winit")] {