Skip to content

Commit

Permalink
Add shader compile markers
Browse files Browse the repository at this point in the history
  • Loading branch information
kvark committed Apr 27, 2021
1 parent 13015c8 commit 087bd07
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 19 deletions.
18 changes: 9 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions wgpu-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,24 @@ thiserror = "1"
gpu-alloc = { git = "https://github.com/zakarumych/gpu-alloc.git", rev = "2cd1ad650cdd24d1647b6041f77ced0cbf1ff2a6" }
gpu-descriptor = { version = "0.1" }

hal = { package = "gfx-hal", git = "https://github.com/gfx-rs/gfx", rev = "46735bb079997257b4e5d8e813e6ed9c71aefd3e" }
gfx-backend-empty = { git = "https://github.com/gfx-rs/gfx", rev = "46735bb079997257b4e5d8e813e6ed9c71aefd3e" }
hal = { package = "gfx-hal", git = "https://github.com/gfx-rs/gfx", rev = "32684a7da923cfd661fe4d3003f4275270e9c40d" }
gfx-backend-empty = { git = "https://github.com/gfx-rs/gfx", rev = "32684a7da923cfd661fe4d3003f4275270e9c40d" }

[target.'cfg(all(not(target_arch = "wasm32"), all(unix, not(target_os = "ios"), not(target_os = "macos"))))'.dependencies]
gfx-backend-vulkan = { git = "https://github.com/gfx-rs/gfx", rev = "46735bb079997257b4e5d8e813e6ed9c71aefd3e", features = ["naga"] }
gfx-backend-gl = { git = "https://github.com/gfx-rs/gfx", rev = "46735bb079997257b4e5d8e813e6ed9c71aefd3e" }
gfx-backend-vulkan = { git = "https://github.com/gfx-rs/gfx", rev = "32684a7da923cfd661fe4d3003f4275270e9c40d", features = ["naga"] }
gfx-backend-gl = { git = "https://github.com/gfx-rs/gfx", rev = "32684a7da923cfd661fe4d3003f4275270e9c40d" }

[target.'cfg(all(not(target_arch = "wasm32"), any(target_os = "ios", target_os = "macos")))'.dependencies]
gfx-backend-metal = { git = "https://github.com/gfx-rs/gfx", rev = "46735bb079997257b4e5d8e813e6ed9c71aefd3e" }
gfx-backend-vulkan = { git = "https://github.com/gfx-rs/gfx", rev = "46735bb079997257b4e5d8e813e6ed9c71aefd3e", optional = true }
gfx-backend-metal = { git = "https://github.com/gfx-rs/gfx", rev = "32684a7da923cfd661fe4d3003f4275270e9c40d" }
gfx-backend-vulkan = { git = "https://github.com/gfx-rs/gfx", rev = "32684a7da923cfd661fe4d3003f4275270e9c40d", optional = true }

[target.'cfg(all(not(target_arch = "wasm32"), windows))'.dependencies]
gfx-backend-dx12 = { git = "https://github.com/gfx-rs/gfx", rev = "46735bb079997257b4e5d8e813e6ed9c71aefd3e" }
gfx-backend-dx11 = { git = "https://github.com/gfx-rs/gfx", rev = "46735bb079997257b4e5d8e813e6ed9c71aefd3e" }
gfx-backend-vulkan = { git = "https://github.com/gfx-rs/gfx", rev = "46735bb079997257b4e5d8e813e6ed9c71aefd3e", features = ["naga"] }
gfx-backend-dx12 = { git = "https://github.com/gfx-rs/gfx", rev = "32684a7da923cfd661fe4d3003f4275270e9c40d" }
gfx-backend-dx11 = { git = "https://github.com/gfx-rs/gfx", rev = "32684a7da923cfd661fe4d3003f4275270e9c40d" }
gfx-backend-vulkan = { git = "https://github.com/gfx-rs/gfx", rev = "32684a7da923cfd661fe4d3003f4275270e9c40d", features = ["naga"] }

[target.'cfg(target_arch = "wasm32")'.dependencies]
gfx-backend-gl = { git = "https://github.com/gfx-rs/gfx", rev = "46735bb079997257b4e5d8e813e6ed9c71aefd3e" }
gfx-backend-gl = { git = "https://github.com/gfx-rs/gfx", rev = "32684a7da923cfd661fe4d3003f4275270e9c40d" }

[dependencies.naga]
git = "https://github.com/gfx-rs/naga"
Expand Down
4 changes: 4 additions & 0 deletions wgpu-core/src/device/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,7 @@ impl<B: GfxBackend> Device<B> {
// First, try to produce a Naga module.
let (spv, module) = match source {
pipeline::ShaderModuleSource::SpirV(spv) => {
profiling::scope!("naga::spv::parse");
// Parse the given shader code and store its representation.
let options = naga::front::spv::Options {
adjust_coordinate_space: false, // we require NDC_Y_UP feature
Expand All @@ -1010,6 +1011,7 @@ impl<B: GfxBackend> Device<B> {
(Some(spv), module)
}
pipeline::ShaderModuleSource::Wgsl(code) => {
profiling::scope!("naga::wgsl::parse_str");
// TODO: refactor the corresponding Naga error to be owned, and then
// display it instead of unwrapping
match naga::front::wgsl::parse_str(&code) {
Expand All @@ -1026,6 +1028,7 @@ impl<B: GfxBackend> Device<B> {
let (naga_result, interface) = match module {
// If succeeded, then validate it and attempt to give it to gfx-hal directly.
Some(module) if desc.flags.contains(wgt::ShaderFlags::VALIDATION) || spv.is_none() => {
profiling::scope!("naga::validate");
let info = naga::valid::Validator::new(naga::valid::ValidationFlags::all())
.validate(&module)?;
if !self.features.contains(wgt::Features::PUSH_CONSTANTS)
Expand Down Expand Up @@ -1069,6 +1072,7 @@ impl<B: GfxBackend> Device<B> {
Some(data) => Ok(data),
None => {
// Produce a SPIR-V from the Naga module
profiling::scope!("naga::wpv::write_vec");
let shader = maybe_shader.unwrap();
naga::back::spv::write_vec(&shader.module, &shader.info, &self.spv_options)
.map(Cow::Owned)
Expand Down
2 changes: 2 additions & 0 deletions wgpu-core/src/device/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,8 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let (mut command_buffer_guard, mut token) = hub.command_buffers.write(&mut token);

if !command_buffer_ids.is_empty() {
profiling::scope!("submit preparation");

let (render_bundle_guard, mut token) = hub.render_bundles.read(&mut token);
let (_, mut token) = hub.pipeline_layouts.read(&mut token);
let (bind_group_guard, mut token) = hub.bind_groups.read(&mut token);
Expand Down

0 comments on commit 087bd07

Please sign in to comment.