mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-29 10:13:34 +00:00
Properly expose [Adapter::get_presentation_timestamp
] (#3321)
This commit is contained in:
parent
9b9cc330ca
commit
6f4ec4fbab
@ -36,14 +36,15 @@ pub use wgt::{
|
|||||||
DepthStencilState, DeviceType, DownlevelCapabilities, DownlevelFlags, DynamicOffset, Extent3d,
|
DepthStencilState, DeviceType, DownlevelCapabilities, DownlevelFlags, DynamicOffset, Extent3d,
|
||||||
Face, Features, FilterMode, FrontFace, ImageDataLayout, ImageSubresourceRange, IndexFormat,
|
Face, Features, FilterMode, FrontFace, ImageDataLayout, ImageSubresourceRange, IndexFormat,
|
||||||
Limits, MultisampleState, Origin3d, PipelineStatisticsTypes, PolygonMode, PowerPreference,
|
Limits, MultisampleState, Origin3d, PipelineStatisticsTypes, PolygonMode, PowerPreference,
|
||||||
PresentMode, PrimitiveState, PrimitiveTopology, PushConstantRange, QueryType,
|
PresentMode, PresentationTimestamp, PrimitiveState, PrimitiveTopology, PushConstantRange,
|
||||||
RenderBundleDepthStencil, SamplerBindingType, SamplerBorderColor, ShaderLocation, ShaderModel,
|
QueryType, RenderBundleDepthStencil, SamplerBindingType, SamplerBorderColor, ShaderLocation,
|
||||||
ShaderStages, StencilFaceState, StencilOperation, StencilState, StorageTextureAccess,
|
ShaderModel, ShaderStages, StencilFaceState, StencilOperation, StencilState,
|
||||||
SurfaceCapabilities, SurfaceConfiguration, SurfaceStatus, TextureAspect, TextureDimension,
|
StorageTextureAccess, SurfaceCapabilities, SurfaceConfiguration, SurfaceStatus, TextureAspect,
|
||||||
TextureFormat, TextureFormatFeatureFlags, TextureFormatFeatures, TextureSampleType,
|
TextureDimension, TextureFormat, TextureFormatFeatureFlags, TextureFormatFeatures,
|
||||||
TextureUsages, TextureViewDimension, VertexAttribute, VertexFormat, VertexStepMode,
|
TextureSampleType, TextureUsages, TextureViewDimension, VertexAttribute, VertexFormat,
|
||||||
COPY_BUFFER_ALIGNMENT, COPY_BYTES_PER_ROW_ALIGNMENT, MAP_ALIGNMENT, PUSH_CONSTANT_ALIGNMENT,
|
VertexStepMode, COPY_BUFFER_ALIGNMENT, COPY_BYTES_PER_ROW_ALIGNMENT, MAP_ALIGNMENT,
|
||||||
QUERY_RESOLVE_BUFFER_ALIGNMENT, QUERY_SET_MAX_QUERIES, QUERY_SIZE, VERTEX_STRIDE_ALIGNMENT,
|
PUSH_CONSTANT_ALIGNMENT, QUERY_RESOLVE_BUFFER_ALIGNMENT, QUERY_SET_MAX_QUERIES, QUERY_SIZE,
|
||||||
|
VERTEX_STRIDE_ALIGNMENT,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Filter for error scopes.
|
/// Filter for error scopes.
|
||||||
@ -1770,6 +1771,31 @@ impl Adapter {
|
|||||||
format,
|
format,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Generates a timestamp using the clock used by the presentation engine.
|
||||||
|
///
|
||||||
|
/// When comparing completely opaque timestamp systems, we need a way of generating timestamps that signal
|
||||||
|
/// the exact same time. You can do this by calling your own timestamp function immediately after a call to
|
||||||
|
/// this function. This should result in timestamps that are 0.5 to 5 microseconds apart. There are locks
|
||||||
|
/// that must be taken during the call, so don't call your function before.
|
||||||
|
///
|
||||||
|
/// ```no_run
|
||||||
|
/// # let adapter: wgpu::Adapter = panic!();
|
||||||
|
/// # let some_code = || wgpu::PresentationTimestamp::INVALID_TIMESTAMP;
|
||||||
|
/// use std::time::{Duration, Instant};
|
||||||
|
/// let presentation = adapter.get_presentation_timestamp();
|
||||||
|
/// let instant = Instant::now();
|
||||||
|
///
|
||||||
|
/// // We can now turn a new presentation timestamp into an Instant.
|
||||||
|
/// let some_pres_timestamp = some_code();
|
||||||
|
/// let duration = Duration::from_nanos((some_pres_timestamp.0 - presentation.0) as u64);
|
||||||
|
/// let new_instant: Instant = instant + duration;
|
||||||
|
/// ```
|
||||||
|
//
|
||||||
|
/// [Instant]: std::time::Instant
|
||||||
|
pub fn get_presentation_timestamp(&self) -> PresentationTimestamp {
|
||||||
|
DynContext::adapter_get_presentation_timestamp(&*self.context, &self.id, self.data.as_ref())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Device {
|
impl Device {
|
||||||
|
Loading…
Reference in New Issue
Block a user