Skip to content

Commit 1e76b17

Browse files
committed
Deploying to master from @ gfx-rs/wgpu@f669024 🚀
1 parent 46db65b commit 1e76b17

File tree

72 files changed

+331
-185
lines changed

Some content is hidden

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

72 files changed

+331
-185
lines changed

doc/src-files.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_core/device/resource.rs.html

Lines changed: 39 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3720,11 +3720,6 @@
37203720
<a href="#3719" id="3719">3719</a>
37213721
<a href="#3720" id="3720">3720</a>
37223722
<a href="#3721" id="3721">3721</a>
3723-
<a href="#3722" id="3722">3722</a>
3724-
<a href="#3723" id="3723">3723</a>
3725-
<a href="#3724" id="3724">3724</a>
3726-
<a href="#3725" id="3725">3725</a>
3727-
<a href="#3726" id="3726">3726</a>
37283723
</pre></div><pre class="rust"><code><span class="attr">#[cfg(feature = <span class="string">"trace"</span>)]
37293724
</span><span class="kw">use </span><span class="kw">crate</span>::device::trace;
37303725
<span class="kw">use crate</span>::{
@@ -3758,6 +3753,7 @@
37583753
UsageScopePool,
37593754
},
37603755
validation::{<span class="self">self</span>, validate_color_attachment_bytes_per_sample},
3756+
weak_vec::WeakVec,
37613757
FastHashMap, LabelHelpers, PreHashedKey, PreHashedMap,
37623758
};
37633759

@@ -3769,7 +3765,7 @@
37693765

37703766
<span class="kw">use </span>std::{
37713767
borrow::Cow,
3772-
mem::ManuallyDrop,
3768+
mem::{<span class="self">self</span>, ManuallyDrop},
37733769
num::NonZeroU32,
37743770
sync::{
37753771
atomic::{AtomicBool, AtomicU64, Ordering},
@@ -3877,8 +3873,8 @@
38773873
}
38783874

38793875
<span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">enum </span>DeferredDestroy {
3880-
TextureView(Weak&lt;TextureView&gt;),
3881-
BindGroup(Weak&lt;BindGroup&gt;),
3876+
TextureViews(WeakVec&lt;TextureView&gt;),
3877+
BindGroups(WeakVec&lt;BindGroup&gt;),
38823878
}
38833879

38843880
<span class="kw">impl </span>std::fmt::Debug <span class="kw">for </span>Device {
@@ -4111,36 +4107,42 @@
41114107
/// implementation of a reference-counted structure).
41124108
/// The snatch lock must not be held while this function is called.
41134109
</span><span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">fn </span>deferred_resource_destruction(<span class="kw-2">&amp;</span><span class="self">self</span>) {
4114-
<span class="kw">while let </span><span class="prelude-val">Some</span>(item) = <span class="self">self</span>.deferred_destroy.lock().pop() {
4110+
<span class="kw">let </span>deferred_destroy = mem::take(<span class="kw-2">&amp;mut *</span><span class="self">self</span>.deferred_destroy.lock());
4111+
<span class="kw">for </span>item <span class="kw">in </span>deferred_destroy {
41154112
<span class="kw">match </span>item {
4116-
DeferredDestroy::TextureView(view) =&gt; {
4117-
<span class="kw">let </span><span class="prelude-val">Some</span>(view) = view.upgrade() <span class="kw">else </span>{
4118-
<span class="kw">continue</span>;
4119-
};
4120-
<span class="kw">let </span><span class="prelude-val">Some</span>(raw_view) = view.raw.snatch(<span class="kw-2">&amp;mut </span><span class="self">self</span>.snatchable_lock.write()) <span class="kw">else </span>{
4121-
<span class="kw">continue</span>;
4122-
};
4123-
4124-
<span class="macro">resource_log!</span>(<span class="string">"Destroy raw {}"</span>, view.error_ident());
4125-
4126-
<span class="kw">unsafe </span>{
4127-
<span class="self">self</span>.raw().destroy_texture_view(raw_view);
4113+
DeferredDestroy::TextureViews(views) =&gt; {
4114+
<span class="kw">for </span>view <span class="kw">in </span>views {
4115+
<span class="kw">let </span><span class="prelude-val">Some</span>(view) = view.upgrade() <span class="kw">else </span>{
4116+
<span class="kw">continue</span>;
4117+
};
4118+
<span class="kw">let </span><span class="prelude-val">Some</span>(raw_view) = view.raw.snatch(<span class="kw-2">&amp;mut </span><span class="self">self</span>.snatchable_lock.write())
4119+
<span class="kw">else </span>{
4120+
<span class="kw">continue</span>;
4121+
};
4122+
4123+
<span class="macro">resource_log!</span>(<span class="string">"Destroy raw {}"</span>, view.error_ident());
4124+
4125+
<span class="kw">unsafe </span>{
4126+
<span class="self">self</span>.raw().destroy_texture_view(raw_view);
4127+
}
41284128
}
41294129
}
4130-
DeferredDestroy::BindGroup(bind_group) =&gt; {
4131-
<span class="kw">let </span><span class="prelude-val">Some</span>(bind_group) = bind_group.upgrade() <span class="kw">else </span>{
4132-
<span class="kw">continue</span>;
4133-
};
4134-
<span class="kw">let </span><span class="prelude-val">Some</span>(raw_bind_group) =
4135-
bind_group.raw.snatch(<span class="kw-2">&amp;mut </span><span class="self">self</span>.snatchable_lock.write())
4136-
<span class="kw">else </span>{
4137-
<span class="kw">continue</span>;
4138-
};
4139-
4140-
<span class="macro">resource_log!</span>(<span class="string">"Destroy raw {}"</span>, bind_group.error_ident());
4141-
4142-
<span class="kw">unsafe </span>{
4143-
<span class="self">self</span>.raw().destroy_bind_group(raw_bind_group);
4130+
DeferredDestroy::BindGroups(bind_groups) =&gt; {
4131+
<span class="kw">for </span>bind_group <span class="kw">in </span>bind_groups {
4132+
<span class="kw">let </span><span class="prelude-val">Some</span>(bind_group) = bind_group.upgrade() <span class="kw">else </span>{
4133+
<span class="kw">continue</span>;
4134+
};
4135+
<span class="kw">let </span><span class="prelude-val">Some</span>(raw_bind_group) =
4136+
bind_group.raw.snatch(<span class="kw-2">&amp;mut </span><span class="self">self</span>.snatchable_lock.write())
4137+
<span class="kw">else </span>{
4138+
<span class="kw">continue</span>;
4139+
};
4140+
4141+
<span class="macro">resource_log!</span>(<span class="string">"Destroy raw {}"</span>, bind_group.error_ident());
4142+
4143+
<span class="kw">unsafe </span>{
4144+
<span class="self">self</span>.raw().destroy_bind_group(raw_bind_group);
4145+
}
41444146
}
41454147
}
41464148
}
@@ -4365,7 +4367,7 @@
43654367
map_state: Mutex::new(rank::BUFFER_MAP_STATE, resource::BufferMapState::Idle),
43664368
label: desc.label.to_string(),
43674369
tracking_data: TrackingData::new(<span class="self">self</span>.tracker_indices.buffers.clone()),
4368-
bind_groups: Mutex::new(rank::BUFFER_BIND_GROUPS, Vec::new()),
4370+
bind_groups: Mutex::new(rank::BUFFER_BIND_GROUPS, WeakVec::new()),
43694371
<span class="attr">#[cfg(feature = <span class="string">"indirect-validation"</span>)]
43704372
</span>raw_indirect_validation_bind_group,
43714373
};
@@ -4480,7 +4482,7 @@
44804482
map_state: Mutex::new(rank::BUFFER_MAP_STATE, resource::BufferMapState::Idle),
44814483
label: desc.label.to_string(),
44824484
tracking_data: TrackingData::new(<span class="self">self</span>.tracker_indices.buffers.clone()),
4483-
bind_groups: Mutex::new(rank::BUFFER_BIND_GROUPS, Vec::new()),
4485+
bind_groups: Mutex::new(rank::BUFFER_BIND_GROUPS, WeakVec::new()),
44844486
<span class="attr">#[cfg(feature = <span class="string">"indirect-validation"</span>)]
44854487
</span>raw_indirect_validation_bind_group,
44864488
};
@@ -5113,10 +5115,6 @@
51135115

51145116
{
51155117
<span class="kw">let </span><span class="kw-2">mut </span>views = texture.views.lock();
5116-
5117-
<span class="comment">// Remove stale weak references
5118-
</span>views.retain(|view| view.strong_count() &gt; <span class="number">0</span>);
5119-
51205118
views.push(Arc::downgrade(<span class="kw-2">&amp;</span>view));
51215119
}
51225120

@@ -6106,18 +6104,10 @@
61066104
<span class="kw">let </span>weak_ref = Arc::downgrade(<span class="kw-2">&amp;</span>bind_group);
61076105
<span class="kw">for </span>range <span class="kw">in </span><span class="kw-2">&amp;</span>bind_group.used_texture_ranges {
61086106
<span class="kw">let </span><span class="kw-2">mut </span>bind_groups = range.texture.bind_groups.lock();
6109-
6110-
<span class="comment">// Remove stale weak references
6111-
</span>bind_groups.retain(|bg| bg.strong_count() &gt; <span class="number">0</span>);
6112-
61136107
bind_groups.push(weak_ref.clone());
61146108
}
61156109
<span class="kw">for </span>range <span class="kw">in </span><span class="kw-2">&amp;</span>bind_group.used_buffer_ranges {
61166110
<span class="kw">let </span><span class="kw-2">mut </span>bind_groups = range.buffer.bind_groups.lock();
6117-
6118-
<span class="comment">// Remove stale weak references
6119-
</span>bind_groups.retain(|bg| bg.strong_count() &gt; <span class="number">0</span>);
6120-
61216111
bind_groups.push(weak_ref.clone());
61226112
}
61236113

doc/src/wgpu_core/lib.rs.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@
210210
<a href="#209" id="209">209</a>
211211
<a href="#210" id="210">210</a>
212212
<a href="#211" id="211">211</a>
213+
<a href="#212" id="212">212</a>
213214
</pre></div><pre class="rust"><code><span class="doccomment">//! This library safely implements WebGPU on native platforms.
214215
//! It is designed for integration into browsers, as well as wrapping
215216
//! into other language-specific user-friendly libraries.
@@ -293,6 +294,7 @@
293294
<span class="kw">mod </span>snatch;
294295
<span class="kw">pub mod </span>storage;
295296
<span class="kw">mod </span>track;
297+
<span class="kw">mod </span>weak_vec;
296298
<span class="comment">// This is public for users who pre-compile shaders while still wanting to
297299
// preserve all run-time checks that `wgpu-core` does.
298300
// See &lt;https://github.com/gfx-rs/wgpu/issues/3103&gt;, after which this can be

0 commit comments

Comments
 (0)