Skip to content

Commit b45d9ae

Browse files
Deploying to master from @ gfx-rs/wgpu@03ab3a2 🚀
1 parent 06380f8 commit b45d9ae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+300
-218
lines changed

doc/search-index.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

doc/search.desc/wgpu/wgpu-desc-0-.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

doc/search.desc/wgpu/wgpu-desc-1-.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

doc/src/wgpu/api/buffer.rs.html

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,12 @@
956956
<a href="#955" id="955">955</a>
957957
<a href="#956" id="956">956</a>
958958
<a href="#957" id="957">957</a>
959-
<a href="#958" id="958">958</a></pre></div><pre class="rust"><code><span class="kw">use </span>alloc::{boxed::Box, sync::Arc, vec::Vec};
959+
<a href="#958" id="958">958</a>
960+
<a href="#959" id="959">959</a>
961+
<a href="#960" id="960">960</a>
962+
<a href="#961" id="961">961</a>
963+
<a href="#962" id="962">962</a>
964+
<a href="#963" id="963">963</a></pre></div><pre class="rust"><code><span class="kw">use </span>alloc::{boxed::Box, sync::Arc, vec::Vec};
960965
<span class="kw">use </span>core::{
961966
error, fmt,
962967
ops::{Bound, Deref, DerefMut, Range, RangeBounds},
@@ -1039,17 +1044,22 @@
10391044
/// If `buffer` was created with [`BufferUsages::MAP_WRITE`], we could fill it
10401045
/// with `f32` values like this:
10411046
///
1042-
/// ```no_run
1043-
/// # mod bytemuck {
1044-
/// # pub fn cast_slice_mut(bytes: &amp;mut [u8]) -&gt; &amp;mut [f32] { todo!() }
1045-
/// # }
1046-
/// # let device: wgpu::Device = todo!();
1047-
/// # let buffer: wgpu::Buffer = todo!();
1048-
/// let buffer = std::sync::Arc::new(buffer);
1047+
/// ```
1048+
/// # #[cfg(feature = "noop")]
1049+
/// # let (device, _queue) = wgpu::Device::noop(&amp;wgpu::DeviceDescriptor::default());
1050+
/// # #[cfg(not(feature = "noop"))]
1051+
/// # let device: wgpu::Device = { return; };
1052+
/// #
1053+
/// # let buffer = device.create_buffer(&amp;wgpu::BufferDescriptor {
1054+
/// # label: None,
1055+
/// # size: 400,
1056+
/// # usage: wgpu::BufferUsages::MAP_WRITE,
1057+
/// # mapped_at_creation: false,
1058+
/// # });
10491059
/// let capturable = buffer.clone();
1050-
/// buffer.slice(..).map_async(wgpu::MapMode::Write, move |result| {
1060+
/// buffer.map_async(wgpu::MapMode::Write, .., move |result| {
10511061
/// if result.is_ok() {
1052-
/// let mut view = capturable.slice(..).get_mapped_range_mut();
1062+
/// let mut view = capturable.get_mapped_range_mut(..);
10531063
/// let floats: &amp;mut [f32] = bytemuck::cast_slice_mut(&amp;mut view);
10541064
/// floats.fill(42.0);
10551065
/// drop(view);
@@ -1060,11 +1070,11 @@
10601070
///
10611071
/// This code takes the following steps:
10621072
///
1063-
/// - First, it moves `buffer` into an [`Arc`], and makes a clone for capture by
1073+
/// - First, it makes a cloned handle to the buffer for capture by
10641074
/// the callback passed to [`map_async`]. Since a [`map_async`] callback may be
10651075
/// invoked from another thread, interaction between the callback and the
10661076
/// thread calling [`map_async`] generally requires some sort of shared heap
1067-
/// data like this. In real code, the [`Arc`] would probably own some larger
1077+
/// data like this. In real code, there might be an [`Arc`] to some larger
10681078
/// structure that itself owns `buffer`.
10691079
///
10701080
/// - Then, it calls [`Buffer::slice`] to make a [`BufferSlice`] referring to

doc/src/wgpu/api/device.rs.html

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,41 @@
661661
<a href="#660" id="660">660</a>
662662
<a href="#661" id="661">661</a>
663663
<a href="#662" id="662">662</a>
664-
<a href="#663" id="663">663</a></pre></div><pre class="rust"><code><span class="kw">use </span>alloc::{boxed::Box, string::String, sync::Arc};
664+
<a href="#663" id="663">663</a>
665+
<a href="#664" id="664">664</a>
666+
<a href="#665" id="665">665</a>
667+
<a href="#666" id="666">666</a>
668+
<a href="#667" id="667">667</a>
669+
<a href="#668" id="668">668</a>
670+
<a href="#669" id="669">669</a>
671+
<a href="#670" id="670">670</a>
672+
<a href="#671" id="671">671</a>
673+
<a href="#672" id="672">672</a>
674+
<a href="#673" id="673">673</a>
675+
<a href="#674" id="674">674</a>
676+
<a href="#675" id="675">675</a>
677+
<a href="#676" id="676">676</a>
678+
<a href="#677" id="677">677</a>
679+
<a href="#678" id="678">678</a>
680+
<a href="#679" id="679">679</a>
681+
<a href="#680" id="680">680</a>
682+
<a href="#681" id="681">681</a>
683+
<a href="#682" id="682">682</a>
684+
<a href="#683" id="683">683</a>
685+
<a href="#684" id="684">684</a>
686+
<a href="#685" id="685">685</a>
687+
<a href="#686" id="686">686</a>
688+
<a href="#687" id="687">687</a>
689+
<a href="#688" id="688">688</a>
690+
<a href="#689" id="689">689</a>
691+
<a href="#690" id="690">690</a>
692+
<a href="#691" id="691">691</a>
693+
<a href="#692" id="692">692</a>
694+
<a href="#693" id="693">693</a>
695+
<a href="#694" id="694">694</a>
696+
<a href="#695" id="695">695</a>
697+
<a href="#696" id="696">696</a>
698+
<a href="#697" id="697">697</a></pre></div><pre class="rust"><code><span class="kw">use </span>alloc::{boxed::Box, string::String, sync::Arc};
665699
<span class="kw">use </span>core::{error, fmt, future::Future};
666700

667701
<span class="kw">use </span>parking_lot::Mutex;
@@ -705,6 +739,40 @@
705739
}
706740
}
707741

742+
<span class="doccomment">/// Constructs a stub device for testing using [`Backend::Noop`].
743+
///
744+
/// This is a convenience function which avoids the configuration, `async`, and fallibility
745+
/// aspects of constructing a device through `Instance`.
746+
</span><span class="attr">#[cfg(feature = <span class="string">"noop"</span>)]
747+
</span><span class="kw">pub fn </span>noop(desc: <span class="kw-2">&amp;</span>DeviceDescriptor&lt;<span class="lifetime">'_</span>&gt;) -&gt; (Device, Queue) {
748+
<span class="kw">use </span>core::future::Future <span class="kw">as _</span>;
749+
<span class="kw">use </span>core::pin::pin;
750+
<span class="kw">use </span>core::task;
751+
<span class="kw">let </span>ctx = <span class="kw-2">&amp;mut </span>task::Context::from_waker(task::Waker::noop());
752+
753+
<span class="kw">let </span>instance = Instance::new(<span class="kw-2">&amp;</span>InstanceDescriptor {
754+
backends: Backends::NOOP,
755+
backend_options: BackendOptions {
756+
noop: NoopBackendOptions { enable: <span class="bool-val">true </span>},
757+
..Default::default()
758+
},
759+
..Default::default()
760+
});
761+
762+
<span class="comment">// Both of these futures are trivial and should complete instantaneously,
763+
// so we do not need an executor and can just poll them once.
764+
</span><span class="kw">let </span>task::Poll::Ready(<span class="prelude-val">Ok</span>(adapter)) =
765+
<span class="macro">pin!</span>(instance.request_adapter(<span class="kw-2">&amp;</span>RequestAdapterOptions::default())).poll(ctx)
766+
<span class="kw">else </span>{
767+
<span class="macro">unreachable!</span>()
768+
};
769+
<span class="kw">let </span>task::Poll::Ready(<span class="prelude-val">Ok</span>(device_and_queue)) = <span class="macro">pin!</span>(adapter.request_device(desc)).poll(ctx)
770+
<span class="kw">else </span>{
771+
<span class="macro">unreachable!</span>()
772+
};
773+
device_and_queue
774+
}
775+
708776
<span class="doccomment">/// Check for resource cleanups and mapping callbacks. Will block if [`PollType::Wait`] is passed.
709777
///
710778
/// Return `true` if the queue is empty, or `false` if there are more queue

0 commit comments

Comments
 (0)