Skip to content

Commit

Permalink
Document when types are not WebGPU types. (#3235)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
kpreid authored Dec 1, 2022
1 parent e90aace commit 98999da
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
28 changes: 26 additions & 2 deletions wgpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,9 @@ static_assertions::assert_impl_all!(Device: Send, Sync);
/// Identifier for a particular call to [`Queue::submit`]. Can be used
/// as part of an argument to [`Device::poll`] to block for a particular
/// submission to finish.
///
/// This type is unique to the Rust API of `wgpu`.
/// There is no analogue in the WebGPU specification.
#[derive(Debug, Copy, Clone)]
pub struct SubmissionIndex(<C as Context>::SubmissionIndex);
static_assertions::assert_impl_all!(SubmissionIndex: Send, Sync);
Expand Down Expand Up @@ -671,9 +674,12 @@ static_assertions::assert_impl_all!(Buffer: Send, Sync);

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

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

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

/// Surface texture that can be rendered to.
/// Result of a successful call to [`Surface::get_current_texture`].
///
/// This type is unique to the Rust API of `wgpu`. In the WebGPU specification,
/// the [`GPUCanvasContext`](https://gpuweb.github.io/gpuweb/#canvas-context) provides
/// a texture without any additional information.
#[derive(Debug)]
pub struct SurfaceTexture {
/// Accessible view of the frame.
Expand Down
5 changes: 4 additions & 1 deletion wgpu/src/util/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
//! Utility structures and functions.
//! Utility structures and functions that are built on top of the main `wgpu` API.
//!
//! Nothing in this module is a part of the WebGPU API specification;
//! they are unique to the `wgpu` library.
mod belt;
mod device;
Expand Down

0 comments on commit 98999da

Please sign in to comment.