Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Timestamp queries #3636

Merged
merged 56 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
53ff5df
feat: timestamp query on metal
FL33TW00D Mar 28, 2023
15c21f4
chore: clippy
FL33TW00D Apr 2, 2023
31b5870
chore: CHANGELOG
FL33TW00D Apr 2, 2023
f86bff8
chore: initial render mock
FL33TW00D Apr 2, 2023
cd5d147
chore: more work
FL33TW00D Apr 2, 2023
326de79
chore: working render example
FL33TW00D Apr 2, 2023
92329a6
chore: update tests, one failing
FL33TW00D Apr 2, 2023
1ce3e4e
chore: testing
FL33TW00D Apr 3, 2023
c7669c1
remove unnecessary naga patch again
Wumpf Apr 30, 2023
dfd8a3b
incorporate webgpu spec changes
Wumpf May 1, 2023
6eba839
"fix" timestamp conversion on metal, comments to clarify the situatio…
Wumpf May 1, 2023
77bbe86
fix metal timequery feature detection
Wumpf May 1, 2023
8d445f1
warning fixes
Wumpf May 1, 2023
cc84ae1
better error handling for failing to create metal timestamp counter
Wumpf May 1, 2023
c8433d8
use public version of metal in patch
Wumpf May 6, 2023
0c26cd9
disable metal deprecation warnings (and comment why and what)
Wumpf May 6, 2023
d2f7e8b
better documentation for timestamp features
Wumpf May 6, 2023
9680a18
dedicated sample for timestamp queries
Wumpf May 7, 2023
76b55bd
add command encoder timestamps on example, notes on (missing) impleme…
Wumpf May 7, 2023
7f48055
finish rolling back changes to hello-triangle & hello-compute
Wumpf May 7, 2023
e3f71b7
reset timerqueries for being/end pass queries, implement begin/end pa…
Wumpf May 7, 2023
55627de
implement begin/end pass timer queries for DX12
Wumpf May 7, 2023
f9df588
minor cleanup in new timerstamp-query sample
Wumpf May 7, 2023
70414a3
compile & warning fixes
Wumpf May 7, 2023
ca9fbc2
Merge branch 'gfx-rs:trunk' into feature/metal-timestamp
FL33TW00D May 10, 2023
641b0db
fix remaining warnings & errors
Wumpf May 14, 2023
83d2402
remove timestamp feature requirement again from hello-compute/triangle
Wumpf May 14, 2023
788b219
chore: remove patch
FL33TW00D May 21, 2023
0c0c787
remove direct dependency to foreign-types
Wumpf May 29, 2023
9b462e7
Merge remote-tracking branch 'upstream/trunk' into feature/metal-time…
Wumpf May 29, 2023
4819fa5
Merge branch 'trunk' into feature/metal-timestamp
cwfitzgerald Jun 5, 2023
a111844
Format
cwfitzgerald Jun 5, 2023
73c58ed
Merge remote-tracking branch 'upstream/trunk' into feature/metal-time…
Wumpf Jul 23, 2023
bb5ad0e
dx12: reuse write_timestamp method more often
Wumpf Jul 23, 2023
43dcabd
longer expose for timestamp query example
Wumpf Jul 23, 2023
079754c
comment fixes/improvements
Wumpf Jul 23, 2023
1b1db9b
added timestamp query tests, fix test compilation
Wumpf Jul 23, 2023
d15dabf
warning fixes
Wumpf Jul 23, 2023
9b5423e
fix dx12 compilation
Wumpf Jul 23, 2023
98f20bf
Merge remote-tracking branch 'upstream/trunk' into feature/metal-time…
Wumpf Jul 23, 2023
280e50c
d3d12::QuerySet no longer implements Clone
Wumpf Jul 23, 2023
6a8dc8b
improve timestamp test assertions
Wumpf Jul 23, 2023
4aaf264
fix send/sync assertions on wasm builds
Wumpf Jul 23, 2023
27bcd25
disable timestamp test for molkenvk
Wumpf Jul 23, 2023
9a4cc4c
Merge branch 'trunk' into feature/metal-timestamp
FL33TW00D Jul 25, 2023
8585e16
Merge branch 'trunk' into feature/metal-timestamp
FL33TW00D Jul 25, 2023
1c5e6c8
Merge branch 'trunk' into feature/metal-timestamp
FL33TW00D Jul 27, 2023
de0807e
Merge branch 'trunk' into feature/metal-timestamp
FL33TW00D Jul 29, 2023
1c7c175
Workaround https://github.com/gfx-rs/wgpu/issues/3993
Wumpf Jul 30, 2023
f942813
enable test_timestamps_passes test for molten
Wumpf Jul 30, 2023
dec97f8
fix querying invalid queries in example
Wumpf Jul 30, 2023
00f0095
enable test_timestamps_encoder on molten
Wumpf Jul 30, 2023
422a1e6
Merge branch 'trunk' into feature/metal-timestamp
FL33TW00D Aug 2, 2023
f23322e
Apply suggestions from code review
cwfitzgerald Aug 2, 2023
2fc4cf2
Simplify feature logic
cwfitzgerald Aug 2, 2023
6144694
Merge branch 'trunk' into feature/metal-timestamp
cwfitzgerald Aug 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,15 @@ Some texture format names have changed to get back in line with the spec.

By @cwfitzgerald in [#3671](https://github.com/gfx-rs/wgpu/pull/3671).

#### Pass timestamp queries

Addition of `TimestampWrites` to compute and render passes to allow profiling.
This brings us in line with the spec.

Added new example to demonstrate the various kinds of timestamps.

By @FL33TW00D & @wumpf in [#3636](https://github.com/gfx-rs/wgpu/pull/3636).

#### Misc Breaking Changes

- Change type of `mip_level_count` and `array_layer_count` (members of `TextureViewDescriptor` and `ImageSubresourceRange`) from `Option<NonZeroU32>` to `Option<u32>`. By @teoxoy in [#3445](https://github.com/gfx-rs/wgpu/pull/3445)
Expand Down
18 changes: 18 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions deno_webgpu/command_encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ pub fn op_webgpu_command_encoder_begin_render_pass(
label: label.map(Cow::from),
color_attachments: Cow::from(color_attachments),
depth_stencil_attachment: processed_depth_stencil_attachment.as_ref(),
timestamp_writes: None,
occlusion_query_set: occlusion_query_set_resource,
};

Expand All @@ -207,6 +208,7 @@ pub fn op_webgpu_command_encoder_begin_compute_pass(

let descriptor = wgpu_core::command::ComputePassDescriptor {
label: label.map(Cow::from),
timestamp_writes: None,
};

let compute_pass =
Expand Down
4 changes: 3 additions & 1 deletion deno_webgpu/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ impl From<DeviceError> for WebGpuError {
match err {
DeviceError::Lost => WebGpuError::Lost,
DeviceError::OutOfMemory => WebGpuError::OutOfMemory,
DeviceError::Invalid => WebGpuError::Validation(fmt_err(&err)),
DeviceError::ResourceCreationFailed | DeviceError::Invalid => {
WebGpuError::Validation(fmt_err(&err))
}
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions examples/boids/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ impl wgpu_example::framework::Example for Example {
label: None,
color_attachments: &color_attachments,
depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
};

Expand All @@ -293,8 +294,10 @@ impl wgpu_example::framework::Example for Example {
command_encoder.push_debug_group("compute boid movement");
{
// compute pass
let mut cpass =
command_encoder.begin_compute_pass(&wgpu::ComputePassDescriptor { label: None });
let mut cpass = command_encoder.begin_compute_pass(&wgpu::ComputePassDescriptor {
label: None,
timestamp_writes: None,
});
cpass.set_pipeline(&self.compute_pipeline);
cpass.set_bind_group(0, &self.particle_bind_groups[self.frame_num % 2], &[]);
cpass.dispatch_workgroups(self.work_group_count, 1, 1);
Expand Down
1 change: 1 addition & 0 deletions examples/bunnymark/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ impl wgpu_example::framework::Example for Example {
},
})],
depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
});
rpass.set_pipeline(&self.pipeline);
Expand Down
1 change: 1 addition & 0 deletions examples/capture/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ async fn create_red_image_with_dimensions(
},
})],
depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
});

Expand Down
2 changes: 2 additions & 0 deletions examples/conservative-raster/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ impl wgpu_example::framework::Example for Example {
},
})],
depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
});

Expand All @@ -293,6 +294,7 @@ impl wgpu_example::framework::Example for Example {
},
})],
depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
});

Expand Down
1 change: 1 addition & 0 deletions examples/cube/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ impl wgpu_example::framework::Example for Example {
},
})],
depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
});
rpass.push_debug_group("Prepare data for draw.");
Expand Down
5 changes: 4 additions & 1 deletion examples/hello-compute/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ async fn execute_gpu_inner(
let mut encoder =
device.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None });
{
let mut cpass = encoder.begin_compute_pass(&wgpu::ComputePassDescriptor { label: None });
let mut cpass = encoder.begin_compute_pass(&wgpu::ComputePassDescriptor {
label: None,
timestamp_writes: None,
});
cpass.set_pipeline(&compute_pipeline);
cpass.set_bind_group(0, &bind_group, &[]);
cpass.insert_debug_marker("compute collatz iterations");
Expand Down
4 changes: 4 additions & 0 deletions examples/hello-compute/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ fn test_compute_1() {
TestParameters::default()
.downlevel_flags(wgpu::DownlevelFlags::COMPUTE_SHADERS)
.limits(wgpu::Limits::downlevel_defaults())
.features(wgpu::Features::TIMESTAMP_QUERY)
.specific_failure(None, None, Some("V3D"), true),
|ctx| {
let input = &[1, 2, 3, 4];
Expand All @@ -33,6 +34,7 @@ fn test_compute_2() {
TestParameters::default()
.downlevel_flags(wgpu::DownlevelFlags::COMPUTE_SHADERS)
.limits(wgpu::Limits::downlevel_defaults())
.features(wgpu::Features::TIMESTAMP_QUERY)
.specific_failure(None, None, Some("V3D"), true),
|ctx| {
let input = &[5, 23, 10, 9];
Expand All @@ -54,6 +56,7 @@ fn test_compute_overflow() {
TestParameters::default()
.downlevel_flags(wgpu::DownlevelFlags::COMPUTE_SHADERS)
.limits(wgpu::Limits::downlevel_defaults())
.features(wgpu::Features::TIMESTAMP_QUERY)
.specific_failure(None, None, Some("V3D"), true),
|ctx| {
let input = &[77031, 837799, 8400511, 63728127];
Expand All @@ -74,6 +77,7 @@ fn test_multithreaded_compute() {
TestParameters::default()
.downlevel_flags(wgpu::DownlevelFlags::COMPUTE_SHADERS)
.limits(wgpu::Limits::downlevel_defaults())
.features(wgpu::Features::TIMESTAMP_QUERY)
.specific_failure(None, None, Some("V3D"), true)
// https://github.com/gfx-rs/wgpu/issues/3944
.specific_failure(
Expand Down
1 change: 1 addition & 0 deletions examples/hello-triangle/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ async fn run(event_loop: EventLoop<()>, window: Window) {
},
})],
depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
});
rpass.set_pipeline(&render_pipeline);
Expand Down
1 change: 1 addition & 0 deletions examples/hello-windows/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ async fn run(event_loop: EventLoop<()>, viewports: Vec<(Window, wgpu::Color)>) {
},
})],
depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
});
}
Expand Down
2 changes: 2 additions & 0 deletions examples/mipmap/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ impl Example {
},
})],
depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
});
if let Some(ref query_sets) = query_sets {
Expand Down Expand Up @@ -493,6 +494,7 @@ impl wgpu_example::framework::Example for Example {
},
})],
depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
});
rpass.set_pipeline(&self.draw_pipeline);
Expand Down
1 change: 1 addition & 0 deletions examples/msaa-line/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ impl wgpu_example::framework::Example for Example {
label: None,
color_attachments: &[Some(rpass_color_attachment)],
depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
})
.execute_bundles(iter::once(&self.bundle));
Expand Down
2 changes: 2 additions & 0 deletions examples/shadow/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,7 @@ impl wgpu_example::framework::Example for Example {
}),
stencil_ops: None,
}),
timestamp_writes: None,
occlusion_query_set: None,
});
pass.set_pipeline(&self.shadow_pass.pipeline);
Expand Down Expand Up @@ -820,6 +821,7 @@ impl wgpu_example::framework::Example for Example {
}),
stencil_ops: None,
}),
timestamp_writes: None,
occlusion_query_set: None,
});
pass.set_pipeline(&self.forward_pass.pipeline);
Expand Down
1 change: 1 addition & 0 deletions examples/skybox/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ impl wgpu_example::framework::Example for Skybox {
}),
stencil_ops: None,
}),
timestamp_writes: None,
occlusion_query_set: None,
});

Expand Down
1 change: 1 addition & 0 deletions examples/stencil-triangles/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ impl wgpu_example::framework::Example for Triangles {
store: true,
}),
}),
timestamp_writes: None,
occlusion_query_set: None,
});

Expand Down
1 change: 1 addition & 0 deletions examples/texture-arrays/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ impl wgpu_example::framework::Example for Example {
},
})],
depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
});

Expand Down
30 changes: 30 additions & 0 deletions examples/timestamp-queries/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[package]
name = "wgpu-timestamp-queries-example"
version.workspace = true
license.workspace = true
edition.workspace = true
description = "wgpu timestamp query example"
publish = false

[[bin]]
name = "timestamp-queries"
path = "src/main.rs"

[dependencies]
bytemuck.workspace = true
env_logger.workspace = true
futures-intrusive.workspace = true
pollster.workspace = true
wgpu.workspace = true
winit.workspace = true

[target.'cfg(target_arch = "wasm32")'.dependencies]
console_error_panic_hook.workspace = true
console_log.workspace = true
log.workspace = true
wasm-bindgen-futures.workspace = true

[dev-dependencies]
wasm-bindgen-test.workspace = true
wgpu-test.workspace = true

9 changes: 9 additions & 0 deletions examples/timestamp-queries/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# timestamp-queries

This example shows various ways of querying time when supported.

## To Run

```
cargo run --bin timestamp-queries
```
Loading
Loading