Properly implement timestamp periods (#1907)

This commit is contained in:
Connor Fitzgerald authored and Dzmitry Malyshau committed 2021-09-08 17:47:12 -04:00
1 parent 5da13ef826
commit cd64e407c9
8 files changed
+27 -3

No files matched your search

+1 -1
View File
@@ -836,7 +836,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let mut token = Token::root();
let (device_guard, _) = hub.devices.read(&mut token);
match device_guard.get(queue_id) {
Ok(_device) => Ok(1.0), //TODO?
Ok(device) => Ok(unsafe { device.queue.get_timestamp_period() }),
Err(_) => Err(InvalidQueue),
}
}
+6
View File
@@ -746,4 +746,10 @@ impl crate::Queue<Api> for Queue {
Ok(())
}
unsafe fn get_timestamp_period(&self) -> f32 {
let mut frequency = 0u64;
self.raw.GetTimestampFrequency(&mut frequency);
(1_000_000_000.0 / frequency as f64) as f32
}
}
+4
View File
@@ -103,6 +103,10 @@ impl crate::Queue<Api> for Context {
) -> Result<(), crate::SurfaceError> {
Ok(())
}
unsafe fn get_timestamp_period(&self) -> f32 {
1.0
}
}
impl crate::Device<Api> for Context {
+4
View File
@@ -972,4 +972,8 @@ impl crate::Queue<super::Api> for super::Queue {
let gl = &self.shared.context.get_without_egl_lock();
surface.present(texture, gl)
}
unsafe fn get_timestamp_period(&self) -> f32 {
1.0
}
}
+1
View File
@@ -314,6 +314,7 @@ pub trait Queue<A: Api>: Send + Sync {
surface: &mut A::Surface,
texture: A::SurfaceTexture,
) -> Result<(), SurfaceError>;
unsafe fn get_timestamp_period(&self) -> f32;
}
/// Encoder for commands in command buffers.
+5
View File
@@ -378,6 +378,11 @@ impl crate::Queue<Api> for Queue {
});
Ok(())
}
unsafe fn get_timestamp_period(&self) -> f32 {
// TODO: This is hard, see https://github.com/gpuweb/gpuweb/issues/1325
1.0
}
}
#[derive(Debug)]
+1 -1
View File
@@ -858,7 +858,7 @@ impl super::Adapter {
vendor_id: self.phd_capabilities.properties.vendor_id,
downlevel_flags: self.downlevel_flags,
private_caps: self.private_caps.clone(),
_timestamp_period: self.phd_capabilities.properties.limits.timestamp_period,
timestamp_period: self.phd_capabilities.properties.limits.timestamp_period,
render_passes: Mutex::new(Default::default()),
framebuffers: Mutex::new(Default::default()),
});
+5 -1
View File
@@ -221,7 +221,7 @@ struct DeviceShared {
instance: Arc<InstanceShared>,
extension_fns: DeviceExtensionFunctions,
vendor_id: u32,
_timestamp_period: f32,
timestamp_period: f32,
downlevel_flags: wgt::DownlevelFlags,
private_caps: PrivateCapabilities,
render_passes: Mutex<fxhash::FxHashMap<RenderPassKey, vk::RenderPass>>,
@@ -540,6 +540,10 @@ impl crate::Queue<Api> for Queue {
}
Ok(())
}
unsafe fn get_timestamp_period(&self) -> f32 {
self.device.timestamp_period
}
}
impl From<vk::Result> for crate::DeviceError {