Skip to content

Commit 98999da

Browse files
authored
Document when types are not WebGPU types. (#3235)
* Explain wgpu::util more precisely. * Add notes to types that are unique to wgpu (not WebGPU). I also changed the wording in BufferSlice to be more consistent with other documentation.
1 parent e90aace commit 98999da

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

wgpu/src/lib.rs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,9 @@ static_assertions::assert_impl_all!(Device: Send, Sync);
590590
/// Identifier for a particular call to [`Queue::submit`]. Can be used
591591
/// as part of an argument to [`Device::poll`] to block for a particular
592592
/// submission to finish.
593+
///
594+
/// This type is unique to the Rust API of `wgpu`.
595+
/// There is no analogue in the WebGPU specification.
593596
#[derive(Debug, Copy, Clone)]
594597
pub struct SubmissionIndex(<C as Context>::SubmissionIndex);
595598
static_assertions::assert_impl_all!(SubmissionIndex: Send, Sync);
@@ -671,9 +674,12 @@ static_assertions::assert_impl_all!(Buffer: Send, Sync);
671674

672675
/// Slice into a [`Buffer`].
673676
///
674-
/// Created by calling [`Buffer::slice`]. To use the whole buffer, call with unbounded slice:
677+
/// It can be created with [`Buffer::slice`]. To use the whole buffer, call with unbounded slice:
675678
///
676679
/// `buffer.slice(..)`
680+
///
681+
/// This type is unique to the Rust API of `wgpu`. In the WebGPU specification,
682+
/// an offset and size are specified as arguments to each call working with the [`Buffer`], instead.
677683
#[derive(Copy, Clone, Debug)]
678684
pub struct BufferSlice<'a> {
679685
buffer: &'a Buffer,
@@ -736,6 +742,10 @@ impl Drop for Sampler {
736742
///
737743
/// A `Surface` represents a platform-specific surface (e.g. a window) onto which rendered images may
738744
/// be presented. A `Surface` may be created with the unsafe function [`Instance::create_surface`].
745+
///
746+
/// This type is unique to the Rust API of `wgpu`. In the WebGPU specification,
747+
/// [`GPUCanvasContext`](https://gpuweb.github.io/gpuweb/#canvas-context)
748+
/// serves a similar role.
739749
#[derive(Debug)]
740750
pub struct Surface {
741751
context: Arc<C>,
@@ -829,6 +839,9 @@ impl Drop for ShaderModule {
829839
///
830840
/// Any necessary shader translation (e.g. from WGSL to SPIR-V or vice versa)
831841
/// will be done internally by wgpu.
842+
///
843+
/// This type is unique to the Rust API of `wgpu`. In the WebGPU specification,
844+
/// only WGSL source code strings are accepted.
832845
#[cfg_attr(feature = "naga", allow(clippy::large_enum_variant))]
833846
#[derive(Clone)]
834847
#[non_exhaustive]
@@ -876,7 +889,11 @@ pub struct ShaderModuleDescriptor<'a> {
876889
}
877890
static_assertions::assert_impl_all!(ShaderModuleDescriptor: Send, Sync);
878891

879-
/// Descriptor for a shader module given by SPIR-V binary.
892+
/// Descriptor for a shader module given by SPIR-V binary, for use with
893+
/// [`Device::create_shader_module_spirv`].
894+
///
895+
/// This type is unique to the Rust API of `wgpu`. In the WebGPU specification,
896+
/// only WGSL source code strings are accepted.
880897
pub struct ShaderModuleDescriptorSpirV<'a> {
881898
/// Debug label of the shader module. This will show up in graphics debuggers for easy identification.
882899
pub label: Label<'a>,
@@ -1213,6 +1230,9 @@ impl<V: Default> Default for LoadOp<V> {
12131230
}
12141231

12151232
/// Pair of load and store operations for an attachment aspect.
1233+
///
1234+
/// This type is unique to the Rust API of `wgpu`. In the WebGPU specification,
1235+
/// separate `loadOp` and `storeOp` fields are used instead.
12161236
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
12171237
#[cfg_attr(feature = "trace", derive(serde::Serialize))]
12181238
#[cfg_attr(feature = "replay", derive(serde::Deserialize))]
@@ -1664,6 +1684,10 @@ static_assertions::assert_impl_all!(RenderBundleEncoderDescriptor: Send, Sync);
16641684

16651685
/// Surface texture that can be rendered to.
16661686
/// Result of a successful call to [`Surface::get_current_texture`].
1687+
///
1688+
/// This type is unique to the Rust API of `wgpu`. In the WebGPU specification,
1689+
/// the [`GPUCanvasContext`](https://gpuweb.github.io/gpuweb/#canvas-context) provides
1690+
/// a texture without any additional information.
16671691
#[derive(Debug)]
16681692
pub struct SurfaceTexture {
16691693
/// Accessible view of the frame.

wgpu/src/util/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
//! Utility structures and functions.
1+
//! Utility structures and functions that are built on top of the main `wgpu` API.
2+
//!
3+
//! Nothing in this module is a part of the WebGPU API specification;
4+
//! they are unique to the `wgpu` library.
25
36
mod belt;
47
mod device;

0 commit comments

Comments
 (0)