Search across packages, versions, files, declarations, and comments. Use multiple terms to narrow results (AND), and add @vertex, @fragment, or @compute to filter by shader stage.
1// Must have "common.wgsl" preprocessed before this file's contents.
2//
3// To compile this locally, you can run:
4// ```
5// cat common.wgsl timestamp_normalization.wgsl | cargo run -p naga-cli -- --stdin-file-path timestamp_normalization.wgsl
6// ```
8// For an explanation of the timestamp normalization process, see
9// the `mod.rs` file in this folder.
11// These is the timestamp period turned into a fraction
12// with an integer numerator and denominator. The denominator
13// is a power of two, so the division can be done with a shift.
14override TIMESTAMP_PERIOD_MULTIPLY: u32 = 1;
15override TIMESTAMP_PERIOD_SHIFT: u32 = 0;
17@group(0) @binding(0)
18var<storage, read_write> timestamps: array<Uint64>;
20struct PushConstants {
21 timestamp_offset: u32,
22 timestamp_count: u32,
25var<push_constant> pc: PushConstants;
27@compute @workgroup_size(64)
28fn main(@builtin(global_invocation_id) id: vec3u) {
29 if id.x >= pc.timestamp_count {
30 return;
31 }
33 let index = id.x + pc.timestamp_offset;
35 let input_value = timestamps[index];
37 let tmp1 = u64_mul_u32(input_value, TIMESTAMP_PERIOD_MULTIPLY);
38 let tmp2 = shift_right_96(tmp1, TIMESTAMP_PERIOD_SHIFT);
40 timestamps[index] = truncate_u96_to_u64(tmp2);
Contents