1355: Add shader compile markers r=kvark a=kvark

**Connections**
Picks up https://github.com/gfx-rs/gfx/pull/3736 and prior PRs

**Description**
Allows clearly seeing the times spent in shader translation code.

**Testing**
Tested on vange-rs

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
This commit is contained in:
bors[bot] 2021-04-27 16:24:37 +00:00 committed by GitHub
commit c727b1a7f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 19 deletions

18
Cargo.lock generated
View File

@ -465,7 +465,7 @@ dependencies = [
[[package]]
name = "gfx-auxil"
version = "0.8.0"
source = "git+https://github.com/gfx-rs/gfx?rev=46735bb079997257b4e5d8e813e6ed9c71aefd3e#46735bb079997257b4e5d8e813e6ed9c71aefd3e"
source = "git+https://github.com/gfx-rs/gfx?rev=32684a7da923cfd661fe4d3003f4275270e9c40d#32684a7da923cfd661fe4d3003f4275270e9c40d"
dependencies = [
"fxhash",
"gfx-hal",
@ -475,7 +475,7 @@ dependencies = [
[[package]]
name = "gfx-backend-dx11"
version = "0.7.0"
source = "git+https://github.com/gfx-rs/gfx?rev=46735bb079997257b4e5d8e813e6ed9c71aefd3e#46735bb079997257b4e5d8e813e6ed9c71aefd3e"
source = "git+https://github.com/gfx-rs/gfx?rev=32684a7da923cfd661fe4d3003f4275270e9c40d#32684a7da923cfd661fe4d3003f4275270e9c40d"
dependencies = [
"arrayvec",
"bitflags",
@ -496,7 +496,7 @@ dependencies = [
[[package]]
name = "gfx-backend-dx12"
version = "0.7.0"
source = "git+https://github.com/gfx-rs/gfx?rev=46735bb079997257b4e5d8e813e6ed9c71aefd3e#46735bb079997257b4e5d8e813e6ed9c71aefd3e"
source = "git+https://github.com/gfx-rs/gfx?rev=32684a7da923cfd661fe4d3003f4275270e9c40d#32684a7da923cfd661fe4d3003f4275270e9c40d"
dependencies = [
"arrayvec",
"bit-set",
@ -517,7 +517,7 @@ dependencies = [
[[package]]
name = "gfx-backend-empty"
version = "0.7.0"
source = "git+https://github.com/gfx-rs/gfx?rev=46735bb079997257b4e5d8e813e6ed9c71aefd3e#46735bb079997257b4e5d8e813e6ed9c71aefd3e"
source = "git+https://github.com/gfx-rs/gfx?rev=32684a7da923cfd661fe4d3003f4275270e9c40d#32684a7da923cfd661fe4d3003f4275270e9c40d"
dependencies = [
"gfx-hal",
"log",
@ -527,7 +527,7 @@ dependencies = [
[[package]]
name = "gfx-backend-gl"
version = "0.7.0"
source = "git+https://github.com/gfx-rs/gfx?rev=46735bb079997257b4e5d8e813e6ed9c71aefd3e#46735bb079997257b4e5d8e813e6ed9c71aefd3e"
source = "git+https://github.com/gfx-rs/gfx?rev=32684a7da923cfd661fe4d3003f4275270e9c40d#32684a7da923cfd661fe4d3003f4275270e9c40d"
dependencies = [
"arrayvec",
"bitflags",
@ -550,7 +550,7 @@ dependencies = [
[[package]]
name = "gfx-backend-metal"
version = "0.7.0"
source = "git+https://github.com/gfx-rs/gfx?rev=46735bb079997257b4e5d8e813e6ed9c71aefd3e#46735bb079997257b4e5d8e813e6ed9c71aefd3e"
source = "git+https://github.com/gfx-rs/gfx?rev=32684a7da923cfd661fe4d3003f4275270e9c40d#32684a7da923cfd661fe4d3003f4275270e9c40d"
dependencies = [
"arrayvec",
"bitflags",
@ -576,7 +576,7 @@ dependencies = [
[[package]]
name = "gfx-backend-vulkan"
version = "0.7.0"
source = "git+https://github.com/gfx-rs/gfx?rev=46735bb079997257b4e5d8e813e6ed9c71aefd3e#46735bb079997257b4e5d8e813e6ed9c71aefd3e"
source = "git+https://github.com/gfx-rs/gfx?rev=32684a7da923cfd661fe4d3003f4275270e9c40d#32684a7da923cfd661fe4d3003f4275270e9c40d"
dependencies = [
"arrayvec",
"ash",
@ -596,7 +596,7 @@ dependencies = [
[[package]]
name = "gfx-hal"
version = "0.7.0"
source = "git+https://github.com/gfx-rs/gfx?rev=46735bb079997257b4e5d8e813e6ed9c71aefd3e#46735bb079997257b4e5d8e813e6ed9c71aefd3e"
source = "git+https://github.com/gfx-rs/gfx?rev=32684a7da923cfd661fe4d3003f4275270e9c40d#32684a7da923cfd661fe4d3003f4275270e9c40d"
dependencies = [
"bitflags",
"naga",
@ -1172,7 +1172,7 @@ dependencies = [
[[package]]
name = "range-alloc"
version = "0.1.2"
source = "git+https://github.com/gfx-rs/gfx?rev=46735bb079997257b4e5d8e813e6ed9c71aefd3e#46735bb079997257b4e5d8e813e6ed9c71aefd3e"
source = "git+https://github.com/gfx-rs/gfx?rev=32684a7da923cfd661fe4d3003f4275270e9c40d#32684a7da923cfd661fe4d3003f4275270e9c40d"
[[package]]
name = "raw-window-handle"

View File

@ -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"

View File

@ -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
@ -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) {
@ -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)
@ -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)

View File

@ -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);