Replace all occurrences of Global:: in rustdocs with methods on Resources

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
sagudev authored and Andy Leiserson committed 2026-07-20 17:36:36 -07:00
1 parent 3c51fc05b5
commit 0eb5b623df
7 files changed
+27 -26

No files matched your search

+4 -4
View File
@@ -40,14 +40,14 @@ therefore immediate data must be set again.
To create a render bundle:
1) Create a [`RenderBundleEncoder`] by calling
[`Global::device_create_render_bundle_encoder`][Gdcrbe].
[`Device::create_render_bundle_encoder`][Dcrbe].
2) Record commands in the `RenderBundleEncoder` using methods on [`RenderBundleEncoder`].
3) Call [`RenderBundleEncoder::finish`], which analyzes and cleans up
the command stream and returns a [`RenderBundle`].
4) Then, any number of times, call [`render_pass_execute_bundles`][wrpeb] to
4) Then, any number of times, call [`RenderPass::execute_bundles`][rpeb] to
execute the bundle as part of some render pass.
## Implementation
@@ -70,8 +70,8 @@ called. It goes through the commands and issues them into the native command
buffer. Thanks to isolation, it doesn't track any bind group invalidations or
index format changes.
[Gdcrbe]: crate::global::Global::device_create_render_bundle_encoder
[wrpeb]: crate::global::Global::render_pass_execute_bundles
[Dcrbe]: crate::device::Device::create_render_bundle_encoder
[rpeb]: crate::command::RenderPass::execute_bundles
!*/
#![allow(clippy::reversed_empty_ranges)]
+6 -7
View File
@@ -146,15 +146,12 @@ fn make_error_state<E: Into<CommandEncoderError>>(error: E) -> CommandEncoderSta
pub(crate) enum CommandEncoderStatus {
/// Ready to record commands. An encoder's initial state.
///
/// Command building methods like [`command_encoder_clear_buffer`] and
/// [`compute_pass_end`] require the encoder to be in this
/// Command building methods like [`CommandEncoder::clear_buffer`] and
/// [`ComputePass::end`] require the encoder to be in this
/// state.
///
/// This corresponds to WebGPU's "open" state.
/// See <https://www.w3.org/TR/webgpu/#encoder-state-open>
///
/// [`command_encoder_clear_buffer`]: Global::command_encoder_clear_buffer
/// [`compute_pass_end`]: Global::compute_pass_end
Recording(CommandBufferMutable),
/// Locked by a render or compute pass.
@@ -171,14 +168,16 @@ pub(crate) enum CommandEncoderStatus {
/// Command recording is complete, and the buffer is ready for submission.
///
/// [`Global::command_encoder_finish`] transitions a
/// [`CommandEncoder::finish`] transitions a
/// `CommandBuffer` from the `Recording` state into this state.
///
/// [`Global::queue_submit`] requires that command buffers are
/// [`Queue::submit`] requires that command buffers are
/// in this state.
///
/// This corresponds to WebGPU's "ended" state.
/// See <https://www.w3.org/TR/webgpu/#encoder-state-ended>
///
/// [`Queue::submit`]: crate::device::queue::Queue::submit
Finished(CommandBufferMutable),
/// The command encoder is invalid.
@@ -126,7 +126,7 @@ pub(crate) fn transition_resources(
Ok(())
}
/// Error encountered while attempting to perform [`Global::command_encoder_transition_resources`].
/// Error encountered while attempting to perform [`CommandEncoder::transition_resources`].
#[derive(Clone, Debug, Error)]
#[non_exhaustive]
pub enum TransitionResourcesError {
+3 -3
View File
@@ -126,14 +126,14 @@ impl Global {
/// which requires [`GPUBufferDescriptor`] validation to be generated on the
/// Device timeline and leave the newly created [`GPUBuffer`] invalid.
///
/// Ideally, we would simply let [`device_create_buffer`] take care of all
/// Ideally, we would simply let [`Device::create_buffer`] take care of all
/// of this, but some errors must be detected before we can even construct a
/// [`wgpu_types::BufferDescriptor`] to give it. For example, the WebGPU API
/// allows a `GPUBufferDescriptor`'s [`usage`] property to be any WebIDL
/// `unsigned long` value, but we can't construct a
/// [`wgpu_types::BufferUsages`] value from values with unassigned bits
/// set. This means we must validate `usage` before we can call
/// `device_create_buffer`.
/// `Device::create_buffer`.
///
/// When that validation fails, we must arrange for the buffer id to be
/// considered invalid. This method provides the means to do so.
@@ -142,7 +142,7 @@ impl Global {
/// [`GPUBufferDescriptor`]: https://www.w3.org/TR/webgpu/#dictdef-gpubufferdescriptor
/// [`GPUBuffer`]: https://www.w3.org/TR/webgpu/#gpubuffer
/// [`wgpu_types::BufferDescriptor`]: wgt::BufferDescriptor
/// [`device_create_buffer`]: Global::device_create_buffer
/// [`Device::create_buffer`]: crate::device::Device::create_buffer
/// [`usage`]: https://www.w3.org/TR/webgpu/#dom-gputexturedescriptor-usage
/// [`wgpu_types::BufferUsages`]: wgt::BufferUsages
pub fn create_buffer_error(
+1 -1
View File
@@ -177,7 +177,7 @@ impl WaitIdleError {
/// 2) `handle_mapping` drains `self.ready_to_map` and actually maps the
/// buffers, collecting a list of notification closures to call.
///
/// Only calling `Global::buffer_map_async` clones a new `Arc` for the
/// Only calling [`Buffer::map_async`] clones a new `Arc` for the
/// buffer. This new `Arc` is only dropped by `handle_mapping`.
pub(crate) struct LifetimeTracker {
/// Resources used by queue submissions still in flight. One entry per
+6 -4
View File
@@ -838,9 +838,11 @@ impl Device {
/// Poll the device, returning any `UserClosures` that need to be executed.
///
/// The caller must invoke the `UserClosures` even if this function returns
/// an error. This is an internal helper, used by `Device::poll` and
/// `Global::poll_all_devices`, so that `poll_all_devices` can invoke
/// an error. This is an internal helper, used by [`Device::poll`] and
/// [`Instance::poll_all_devices`], so that `poll_all_devices` can invoke
/// closures once after all devices have been polled.
///
/// [`Instance::poll_all_devices`]: crate::instance::Instance::poll_all_devices
pub(crate) fn poll_and_return_closures(
&self,
poll_type: wgt::PollType<crate::SubmissionIndex>,
@@ -5655,7 +5657,7 @@ impl Device {
/// # Safety
/// The `data` field on `desc` must have previously been returned from
/// [`crate::global::Global::pipeline_cache_get_data`]
/// [`pipeline::PipelineCache::get_data`]
pub unsafe fn create_pipeline_cache(
self: &Arc<Self>,
desc: &pipeline::PipelineCacheDescriptor,
@@ -5685,7 +5687,7 @@ impl Device {
/// # Safety
/// The `data` field on `desc` must have previously been returned from
/// [`crate::global::Global::pipeline_cache_get_data`]
/// [`pipeline::PipelineCache::get_data`]
pub(crate) unsafe fn create_pipeline_cache_inner(
self: &Arc<Self>,
desc: &pipeline::PipelineCacheDescriptor,
+6 -6
View File
@@ -1285,18 +1285,18 @@ unsafe impl Sync for StagingBuffer {}
/// is always created mapped, and the command that uses it destroys the buffer
/// when it is done.
///
/// [`StagingBuffer`]s can be created with [`queue_create_staging_buffer`] and
/// used with [`queue_write_staging_buffer`]. They are also used internally by
/// operations like [`queue_write_texture`] that need to upload data to the GPU,
/// [`StagingBuffer`]s can be created with [`Queue::create_staging_buffer`] and
/// used with [`Queue::write_staging_buffer`]. They are also used internally by
/// operations like [`Queue::write_texture`] that need to upload data to the GPU,
/// but that don't belong to any particular wgpu command buffer.
///
/// Used `StagingBuffer`s are accumulated in [`Device::pending_writes`], to be
/// freed once their associated operation's queue submission has finished
/// execution.
///
/// [`queue_create_staging_buffer`]: crate::global::Global::queue_create_staging_buffer
/// [`queue_write_staging_buffer`]: crate::global::Global::queue_write_staging_buffer
/// [`queue_write_texture`]: crate::global::Global::queue_write_texture
/// [`Queue::create_staging_buffer`]: crate::device::queue::Queue::create_staging_buffer
/// [`Queue::write_staging_buffer`]: crate::device::queue::Queue::write_staging_buffer
/// [`Queue::write_texture`]: crate::device::queue::Queue::write_texture
/// [`Device::pending_writes`]: crate::device::Device
#[derive(Debug)]
pub struct StagingBuffer {