mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-19 22:11:01 +01:00
Properly implement timestamp periods (#1907)
This commit is contained in:
1 parent
9c51fcbe85
commit
d785da86ce
8 files changed
+27
-3
No files matched your search
@@ -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),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
|
||||
@@ -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)]
|
||||
|
||||
@@ -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()),
|
||||
});
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in new issue
Block a user