@@ -203,7 +203,7 @@ pub const IMMEDIATE_DATA_ALIGNMENT: u32 = 4;
203203#[ doc( hidden) ]
204204pub const STORAGE_BINDING_SIZE_ALIGNMENT : u32 = 4 ;
205205
206- /// Maximum queries in a [`QuerySetDescriptor`].
206+ /// Maximum number of query result slots that can be requested in a [`QuerySetDescriptor`].
207207pub const QUERY_SET_MAX_QUERIES : u32 = 4096 ;
208208
209209/// Size in bytes of a single piece of [query] data.
@@ -467,7 +467,7 @@ pub struct QuerySetDescriptor<L> {
467467 pub label : L ,
468468 /// Kind of query that this query set should contain.
469469 pub ty : QueryType ,
470- /// Total count of queries the set contains. Must not be zero.
470+ /// Total number of query result slots the set contains. Must not be zero.
471471 /// Must not be greater than [`QUERY_SET_MAX_QUERIES`].
472472 pub count : u32 ,
473473}
@@ -484,7 +484,9 @@ impl<L> QuerySetDescriptor<L> {
484484 }
485485}
486486
487- /// Type of query contained in a [`QuerySet`].
487+ /// Type of queries contained in a [`QuerySet`].
488+ ///
489+ /// Each query set may contain any number of queries, but they must all be of the same type.
488490///
489491/// Corresponds to [WebGPU `GPUQueryType`](
490492/// https://gpuweb.github.io/gpuweb/#enumdef-gpuquerytype).
@@ -493,27 +495,66 @@ impl<L> QuerySetDescriptor<L> {
493495#[ derive( Copy , Clone , Debug ) ]
494496#[ cfg_attr( feature = "serde" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
495497pub enum QueryType {
496- /// Query returns a single 64-bit number, serving as an occlusion boolean.
497- Occlusion ,
498- /// Query returns up to 5 64-bit numbers based on the given flags.
498+ /// An occlusion query reports whether any of the fragments drawn within the scope of the query
499+ /// passed all per-fragment tests (i.e. were not occluded).
499500 ///
500- /// See [`PipelineStatisticsTypes`]'s documentation for more information
501- /// on how they get resolved.
501+ /// Occlusion queries are performed by setting [`RenderPassDescriptor::occlusion_query_set`],
502+ /// then calling [`RenderPass::begin_occlusion_query()`] and
503+ /// [`RenderPass::end_occlusion_query()`].
504+ /// The query writes to a single result slot in the query set, whose value will be either 0 or 1
505+ /// as a boolean.
502506 ///
503- /// [`Features::PIPELINE_STATISTICS_QUERY`] must be enabled to use this query type.
504- PipelineStatistics ( PipelineStatisticsTypes ) ,
505- /// Query returns a 64-bit number indicating the GPU-timestamp
506- /// where all previous commands have finished executing.
507+ #[ doc = link_to_wgpu_docs ! ( [ "`RenderPassDescriptor::occlusion_query_set`" ] : "struct.RenderPassDescriptor.html#structfield.occlusion_query_set" ) ]
508+ #[ doc = link_to_wgpu_docs ! ( [ "`RenderPass::begin_occlusion_query()`" ] : "struct.RenderPass.html#structfield.begin_occlusion_query" ) ]
509+ #[ doc = link_to_wgpu_docs ! ( [ "`RenderPass::end_occlusion_query()`" ] : "struct.RenderPass.html#structfield.end_occlusion_query" ) ]
510+ Occlusion ,
511+
512+ /// A timestamp query records a GPU-timestamp value
513+ /// at which a certain command started or finished executing.
507514 ///
508- /// Must be multiplied by [`Queue::get_timestamp_period`][Qgtp] to get
509- /// the value in nanoseconds. Absolute values have no meaning,
510- /// but timestamps can be subtracted to get the time it takes
515+ /// Timestamp queries are performed by any one of:
516+ /// * Setting [`ComputePassDescriptor::timestamp_writes`]
517+ /// * Setting [`RenderPassDescriptor::timestamp_writes`]
518+ /// * Calling [`CommandEncoder::write_timestamp()`]
519+ /// * Calling [`RenderPass::write_timestamp()`]
520+ /// * Calling [`ComputePass::write_timestamp()`]
521+ ///
522+ /// Each timestamp query writes to a single result slot in the query set.
523+ /// The timestamp value must be multiplied by [`Queue::get_timestamp_period()`][Qgtp] to get
524+ /// the time in nanoseconds.
525+ /// Absolute values have no meaning, but timestamps can be subtracted to get the time it takes
511526 /// for a string of operations to complete.
527+ /// Timestamps may overflow and wrap to 0, resulting in occasional spurious negative deltas.
528+ ///
529+ /// Additionally, passes may be executed in parallel or out of the order they were submitted;
530+ /// this does not affect their results but is observable via these timestamps.
512531 ///
513532 /// [`Features::TIMESTAMP_QUERY`] must be enabled to use this query type.
514533 ///
534+ #[ doc = link_to_wgpu_docs ! ( [ "`CommandEncoder::write_timestamp()`" ] : "struct.CommandEncoder.html#method.write_timestamp" ) ]
535+ #[ doc = link_to_wgpu_docs ! ( [ "`ComputePass::write_timestamp()`" ] : "struct.ComputePass.html#method.write_timestamp" ) ]
536+ #[ doc = link_to_wgpu_docs ! ( [ "`RenderPass::write_timestamp()`" ] : "struct.RenderPass.html#method.write_timestamp" ) ]
537+ #[ doc = link_to_wgpu_docs ! ( [ "`ComputePassDescriptor::timestamp_writes`" ] : "struct.ComputePassDescriptor.html#structfield.timestamp_writes" ) ]
538+ #[ doc = link_to_wgpu_docs ! ( [ "`RenderPassDescriptor::timestamp_writes`" ] : "struct.RenderPassDescriptor.html#structfield.timestamp_writes" ) ]
515539 #[ doc = link_to_wgpu_docs ! ( [ "Qgtp" ] : "struct.Queue.html#method.get_timestamp_period" ) ]
516540 Timestamp ,
541+
542+ /// A pipeline statistics query records information about the execution of pipelines;
543+ /// see [`PipelineStatisticsTypes`]'s documentation for details.
544+ ///
545+ /// Pipeline statistics queries are performed by:
546+ ///
547+ /// * [`ComputePass::begin_pipeline_statistics_query()`]
548+ /// * [`RenderPass::begin_pipeline_statistics_query()`]
549+ ///
550+ /// A single query may occupy up to 5 result slots in the query set, based on the flags given
551+ /// here.
552+ ///
553+ /// [`Features::PIPELINE_STATISTICS_QUERY`] must be enabled to use this query type.
554+ ///
555+ #[ doc = link_to_wgpu_docs ! ( [ "`ComputePass::begin_pipeline_statistics_query()`" ] : "struct.ComputePass.html#method.begin_pipeline_statistics_query" ) ]
556+ #[ doc = link_to_wgpu_docs ! ( [ "`RenderPass::begin_pipeline_statistics_query()`" ] : "struct.RenderPass.html#method.begin_pipeline_statistics_query" ) ]
557+ PipelineStatistics ( PipelineStatisticsTypes ) ,
517558}
518559
519560bitflags:: bitflags! {
0 commit comments