Skip to content

Commit 42606a2

Browse files
committed
Deploying to master from @ gfx-rs/wgpu@e2eeba7 🚀
1 parent c2b3a01 commit 42606a2

File tree

119 files changed

+230
-1016
lines changed

Some content is hidden

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

119 files changed

+230
-1016
lines changed

doc/search-index.js

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

doc/src/wgpu/backend/wgpu_core.rs.html

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3370,10 +3370,6 @@
33703370
<a href="#3369" id="3369">3369</a>
33713371
<a href="#3370" id="3370">3370</a>
33723372
<a href="#3371" id="3371">3371</a>
3373-
<a href="#3372" id="3372">3372</a>
3374-
<a href="#3373" id="3373">3373</a>
3375-
<a href="#3374" id="3374">3374</a>
3376-
<a href="#3375" id="3375">3375</a>
33773373
</pre></div><pre class="rust"><code><span class="kw">use crate</span>::{
33783374
context::downcast_ref, AdapterInfo, BindGroupDescriptor, BindGroupLayoutDescriptor,
33793375
BindingResource, BufferBinding, BufferDescriptor, CommandEncoderDescriptor, CompilationInfo,
@@ -3400,7 +3396,7 @@
34003396
sync::Arc,
34013397
};
34023398
<span class="kw">use </span>wgc::error::ContextErrorSource;
3403-
<span class="kw">use </span>wgc::{command::bundle_ffi::<span class="kw-2">*</span>, device::DeviceLostClosure, pipeline::CreateShaderModuleError};
3399+
<span class="kw">use </span>wgc::{command::bundle_ffi::<span class="kw-2">*</span>, pipeline::CreateShaderModuleError};
34043400
<span class="kw">use </span>wgt::WasmNotSendSync;
34053401

34063402
<span class="kw">pub struct </span>ContextWgpuCore(wgc::global::Global);
@@ -4728,9 +4724,8 @@
47284724
device_data: <span class="kw-2">&amp;</span><span class="self">Self</span>::DeviceData,
47294725
device_lost_callback: <span class="kw">crate</span>::context::DeviceLostCallback,
47304726
) {
4731-
<span class="kw">let </span>device_lost_closure = DeviceLostClosure::from_rust(device_lost_callback);
47324727
<span class="self">self</span>.<span class="number">0
4733-
</span>.device_set_device_lost_closure(device_data.id, device_lost_closure);
4728+
</span>.device_set_device_lost_closure(device_data.id, device_lost_callback);
47344729
}
47354730
<span class="kw">fn </span>device_destroy(<span class="kw-2">&amp;</span><span class="self">self</span>, device_data: <span class="kw-2">&amp;</span><span class="self">Self</span>::DeviceData) {
47364731
<span class="self">self</span>.<span class="number">0</span>.device_destroy(device_data.id);
@@ -4782,12 +4777,10 @@
47824777
MapMode::Read =&gt; wgc::device::HostMap::Read,
47834778
MapMode::Write =&gt; wgc::device::HostMap::Write,
47844779
},
4785-
callback: <span class="prelude-val">Some</span>(wgc::resource::BufferMapCallback::from_rust(Box::new(
4786-
|status| {
4787-
<span class="kw">let </span>res = status.map_err(|<span class="kw">_</span>| <span class="kw">crate</span>::BufferAsyncError);
4788-
callback(res);
4789-
},
4790-
))),
4780+
callback: <span class="prelude-val">Some</span>(Box::new(|status| {
4781+
<span class="kw">let </span>res = status.map_err(|<span class="kw">_</span>| <span class="kw">crate</span>::BufferAsyncError);
4782+
callback(res);
4783+
})),
47914784
};
47924785

47934786
<span class="kw">match </span><span class="self">self</span>.<span class="number">0</span>.buffer_map_async(
@@ -5481,8 +5474,7 @@
54815474
queue_data: <span class="kw-2">&amp;</span><span class="self">Self</span>::QueueData,
54825475
callback: <span class="kw">crate</span>::context::SubmittedWorkDoneCallback,
54835476
) {
5484-
<span class="kw">let </span>closure = wgc::device::queue::SubmittedWorkDoneClosure::from_rust(callback);
5485-
<span class="self">self</span>.<span class="number">0</span>.queue_on_submitted_work_done(queue_data.id, closure);
5477+
<span class="self">self</span>.<span class="number">0</span>.queue_on_submitted_work_done(queue_data.id, callback);
54865478
}
54875479

54885480
<span class="kw">fn </span>device_start_capture(<span class="kw-2">&amp;</span><span class="self">self</span>, device_data: <span class="kw-2">&amp;</span><span class="self">Self</span>::DeviceData) {

doc/src/wgpu/context.rs.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3693,9 +3693,9 @@
36933693
<span class="attr">#[cfg(not(send_sync))]
36943694
</span><span class="kw">pub type </span>SubmittedWorkDoneCallback = Box&lt;<span class="kw">dyn </span>FnOnce() + <span class="lifetime">'static</span>&gt;;
36953695
<span class="attr">#[cfg(send_sync)]
3696-
</span><span class="kw">pub type </span>DeviceLostCallback = Box&lt;<span class="kw">dyn </span>Fn(DeviceLostReason, String) + Send + <span class="lifetime">'static</span>&gt;;
3696+
</span><span class="kw">pub type </span>DeviceLostCallback = Box&lt;<span class="kw">dyn </span>FnOnce(DeviceLostReason, String) + Send + <span class="lifetime">'static</span>&gt;;
36973697
<span class="attr">#[cfg(not(send_sync))]
3698-
</span><span class="kw">pub type </span>DeviceLostCallback = Box&lt;<span class="kw">dyn </span>Fn(DeviceLostReason, String) + <span class="lifetime">'static</span>&gt;;
3698+
</span><span class="kw">pub type </span>DeviceLostCallback = Box&lt;<span class="kw">dyn </span>FnOnce(DeviceLostReason, String) + <span class="lifetime">'static</span>&gt;;
36993699

37003700
<span class="doccomment">/// An object safe variant of [`Context`] implemented by all types that implement [`Context`].
37013701
</span><span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">trait </span>DynContext: Debug + WasmNotSendSync {

doc/src/wgpu_core/device/global.rs.html

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2277,18 +2277,6 @@
22772277
<a href="#2276" id="2276">2276</a>
22782278
<a href="#2277" id="2277">2277</a>
22792279
<a href="#2278" id="2278">2278</a>
2280-
<a href="#2279" id="2279">2279</a>
2281-
<a href="#2280" id="2280">2280</a>
2282-
<a href="#2281" id="2281">2281</a>
2283-
<a href="#2282" id="2282">2282</a>
2284-
<a href="#2283" id="2283">2283</a>
2285-
<a href="#2284" id="2284">2284</a>
2286-
<a href="#2285" id="2285">2285</a>
2287-
<a href="#2286" id="2286">2286</a>
2288-
<a href="#2287" id="2287">2287</a>
2289-
<a href="#2288" id="2288">2288</a>
2290-
<a href="#2289" id="2289">2289</a>
2291-
<a href="#2290" id="2290">2290</a>
22922280
</pre></div><pre class="rust"><code><span class="attr">#[cfg(feature = <span class="string">"trace"</span>)]
22932281
</span><span class="kw">use </span><span class="kw">crate</span>::device::trace;
22942282
<span class="kw">use crate</span>::{
@@ -2299,7 +2287,7 @@
22992287
},
23002288
command::{<span class="self">self</span>, CommandBuffer},
23012289
conv,
2302-
device::{bgl, life::WaitIdleError, DeviceError, DeviceLostClosure, DeviceLostReason},
2290+
device::{bgl, life::WaitIdleError, DeviceError, DeviceLostClosure},
23032291
global::Global,
23042292
hal_api::HalApi,
23052293
id::{<span class="self">self</span>, AdapterId, DeviceId, QueueId, SurfaceId},
@@ -4374,31 +4362,18 @@
43744362
<span class="self">self</span>.hub.devices.remove(device_id);
43754363
}
43764364

4377-
<span class="comment">// This closure will be called exactly once during "lose the device",
4378-
// or when it is replaced.
4365+
<span class="doccomment">/// `device_lost_closure` might never be called.
43794366
</span><span class="kw">pub fn </span>device_set_device_lost_closure(
43804367
<span class="kw-2">&amp;</span><span class="self">self</span>,
43814368
device_id: DeviceId,
43824369
device_lost_closure: DeviceLostClosure,
43834370
) {
43844371
<span class="kw">let </span>device = <span class="self">self</span>.hub.devices.get(device_id);
43854372

4386-
<span class="kw">let </span>old_device_lost_closure = device
4373+
device
43874374
.device_lost_closure
43884375
.lock()
43894376
.replace(device_lost_closure);
4390-
4391-
<span class="kw">if let </span><span class="prelude-val">Some</span>(old_device_lost_closure) = old_device_lost_closure {
4392-
old_device_lost_closure.call(DeviceLostReason::ReplacedCallback, <span class="string">""</span>.to_string());
4393-
}
4394-
}
4395-
4396-
<span class="kw">pub fn </span>device_unregister_device_lost_closure(<span class="kw-2">&amp;</span><span class="self">self</span>, device_id: DeviceId) {
4397-
<span class="kw">let </span>device = <span class="self">self</span>.hub.devices.get(device_id);
4398-
<span class="kw">let </span>closure = device.device_lost_closure.lock().take();
4399-
<span class="kw">if let </span><span class="prelude-val">Some</span>(closure) = closure {
4400-
closure.call(DeviceLostReason::ReplacedCallback, <span class="string">""</span>.to_string());
4401-
}
44024377
}
44034378

44044379
<span class="kw">pub fn </span>device_destroy(<span class="kw-2">&amp;</span><span class="self">self</span>, device_id: DeviceId) {
@@ -4448,7 +4423,8 @@
44484423
<span class="self">self</span>.hub.queues.remove(queue_id);
44494424
}
44504425

4451-
<span class="kw">pub fn </span>buffer_map_async(
4426+
<span class="doccomment">/// `op.callback` is guaranteed to be called.
4427+
</span><span class="kw">pub fn </span>buffer_map_async(
44524428
<span class="kw-2">&amp;</span><span class="self">self</span>,
44534429
buffer_id: id::BufferId,
44544430
offset: BufferAddress,
@@ -4469,7 +4445,7 @@
44694445
<span class="prelude-val">Ok</span>(submission_index) =&gt; <span class="prelude-val">Ok</span>(submission_index),
44704446
<span class="prelude-val">Err</span>((<span class="kw-2">mut </span>operation, err)) =&gt; {
44714447
<span class="kw">if let </span><span class="prelude-val">Some</span>(callback) = operation.callback.take() {
4472-
callback.call(<span class="prelude-val">Err</span>(err.clone()));
4448+
callback(<span class="prelude-val">Err</span>(err.clone()));
44734449
}
44744450
<span class="macro">log::error!</span>(<span class="string">"Buffer::map_async error: {err}"</span>);
44754451
<span class="prelude-val">Err</span>(err)

doc/src/wgpu_core/device/mod.rs.html

Lines changed: 5 additions & 205 deletions
Original file line numberDiff line numberDiff line change
@@ -458,106 +458,6 @@
458458
<a href="#457" id="457">457</a>
459459
<a href="#458" id="458">458</a>
460460
<a href="#459" id="459">459</a>
461-
<a href="#460" id="460">460</a>
462-
<a href="#461" id="461">461</a>
463-
<a href="#462" id="462">462</a>
464-
<a href="#463" id="463">463</a>
465-
<a href="#464" id="464">464</a>
466-
<a href="#465" id="465">465</a>
467-
<a href="#466" id="466">466</a>
468-
<a href="#467" id="467">467</a>
469-
<a href="#468" id="468">468</a>
470-
<a href="#469" id="469">469</a>
471-
<a href="#470" id="470">470</a>
472-
<a href="#471" id="471">471</a>
473-
<a href="#472" id="472">472</a>
474-
<a href="#473" id="473">473</a>
475-
<a href="#474" id="474">474</a>
476-
<a href="#475" id="475">475</a>
477-
<a href="#476" id="476">476</a>
478-
<a href="#477" id="477">477</a>
479-
<a href="#478" id="478">478</a>
480-
<a href="#479" id="479">479</a>
481-
<a href="#480" id="480">480</a>
482-
<a href="#481" id="481">481</a>
483-
<a href="#482" id="482">482</a>
484-
<a href="#483" id="483">483</a>
485-
<a href="#484" id="484">484</a>
486-
<a href="#485" id="485">485</a>
487-
<a href="#486" id="486">486</a>
488-
<a href="#487" id="487">487</a>
489-
<a href="#488" id="488">488</a>
490-
<a href="#489" id="489">489</a>
491-
<a href="#490" id="490">490</a>
492-
<a href="#491" id="491">491</a>
493-
<a href="#492" id="492">492</a>
494-
<a href="#493" id="493">493</a>
495-
<a href="#494" id="494">494</a>
496-
<a href="#495" id="495">495</a>
497-
<a href="#496" id="496">496</a>
498-
<a href="#497" id="497">497</a>
499-
<a href="#498" id="498">498</a>
500-
<a href="#499" id="499">499</a>
501-
<a href="#500" id="500">500</a>
502-
<a href="#501" id="501">501</a>
503-
<a href="#502" id="502">502</a>
504-
<a href="#503" id="503">503</a>
505-
<a href="#504" id="504">504</a>
506-
<a href="#505" id="505">505</a>
507-
<a href="#506" id="506">506</a>
508-
<a href="#507" id="507">507</a>
509-
<a href="#508" id="508">508</a>
510-
<a href="#509" id="509">509</a>
511-
<a href="#510" id="510">510</a>
512-
<a href="#511" id="511">511</a>
513-
<a href="#512" id="512">512</a>
514-
<a href="#513" id="513">513</a>
515-
<a href="#514" id="514">514</a>
516-
<a href="#515" id="515">515</a>
517-
<a href="#516" id="516">516</a>
518-
<a href="#517" id="517">517</a>
519-
<a href="#518" id="518">518</a>
520-
<a href="#519" id="519">519</a>
521-
<a href="#520" id="520">520</a>
522-
<a href="#521" id="521">521</a>
523-
<a href="#522" id="522">522</a>
524-
<a href="#523" id="523">523</a>
525-
<a href="#524" id="524">524</a>
526-
<a href="#525" id="525">525</a>
527-
<a href="#526" id="526">526</a>
528-
<a href="#527" id="527">527</a>
529-
<a href="#528" id="528">528</a>
530-
<a href="#529" id="529">529</a>
531-
<a href="#530" id="530">530</a>
532-
<a href="#531" id="531">531</a>
533-
<a href="#532" id="532">532</a>
534-
<a href="#533" id="533">533</a>
535-
<a href="#534" id="534">534</a>
536-
<a href="#535" id="535">535</a>
537-
<a href="#536" id="536">536</a>
538-
<a href="#537" id="537">537</a>
539-
<a href="#538" id="538">538</a>
540-
<a href="#539" id="539">539</a>
541-
<a href="#540" id="540">540</a>
542-
<a href="#541" id="541">541</a>
543-
<a href="#542" id="542">542</a>
544-
<a href="#543" id="543">543</a>
545-
<a href="#544" id="544">544</a>
546-
<a href="#545" id="545">545</a>
547-
<a href="#546" id="546">546</a>
548-
<a href="#547" id="547">547</a>
549-
<a href="#548" id="548">548</a>
550-
<a href="#549" id="549">549</a>
551-
<a href="#550" id="550">550</a>
552-
<a href="#551" id="551">551</a>
553-
<a href="#552" id="552">552</a>
554-
<a href="#553" id="553">553</a>
555-
<a href="#554" id="554">554</a>
556-
<a href="#555" id="555">555</a>
557-
<a href="#556" id="556">556</a>
558-
<a href="#557" id="557">557</a>
559-
<a href="#558" id="558">558</a>
560-
<a href="#559" id="559">559</a>
561461
</pre></div><pre class="rust"><code><span class="kw">use crate</span>::{
562462
binding_model,
563463
hub::Hub,
@@ -572,7 +472,6 @@
572472

573473
<span class="kw">use </span>arrayvec::ArrayVec;
574474
<span class="kw">use </span>smallvec::SmallVec;
575-
<span class="kw">use </span>std::os::raw::c_char;
576475
<span class="kw">use </span>thiserror::Error;
577476
<span class="kw">use </span>wgt::{BufferAddress, DeviceLostReason, TextureFormat};
578477

@@ -736,128 +635,29 @@
736635
// a on_submitted_work_done callback to be fired before the on_submitted_work_done callback.
737636
</span><span class="kw">for </span>(<span class="kw-2">mut </span>operation, status) <span class="kw">in </span><span class="self">self</span>.mappings {
738637
<span class="kw">if let </span><span class="prelude-val">Some</span>(callback) = operation.callback.take() {
739-
callback.call(status);
638+
callback(status);
740639
}
741640
}
742641
<span class="kw">for </span>closure <span class="kw">in </span><span class="self">self</span>.submissions {
743-
closure.call();
642+
closure();
744643
}
745644
<span class="kw">for </span>invocation <span class="kw">in </span><span class="self">self</span>.device_lost_invocations {
746-
invocation
747-
.closure
748-
.call(invocation.reason, invocation.message);
645+
(invocation.closure)(invocation.reason, invocation.message);
749646
}
750647
}
751648
}
752649

753650
<span class="attr">#[cfg(send_sync)]
754-
</span><span class="kw">pub type </span>DeviceLostCallback = Box&lt;<span class="kw">dyn </span>Fn(DeviceLostReason, String) + Send + <span class="lifetime">'static</span>&gt;;
651+
</span><span class="kw">pub type </span>DeviceLostClosure = Box&lt;<span class="kw">dyn </span>FnOnce(DeviceLostReason, String) + Send + <span class="lifetime">'static</span>&gt;;
755652
<span class="attr">#[cfg(not(send_sync))]
756-
</span><span class="kw">pub type </span>DeviceLostCallback = Box&lt;<span class="kw">dyn </span>Fn(DeviceLostReason, String) + <span class="lifetime">'static</span>&gt;;
757-
758-
<span class="kw">pub struct </span>DeviceLostClosureRust {
759-
<span class="kw">pub </span>callback: DeviceLostCallback,
760-
consumed: bool,
761-
}
762-
763-
<span class="kw">impl </span>Drop <span class="kw">for </span>DeviceLostClosureRust {
764-
<span class="kw">fn </span>drop(<span class="kw-2">&amp;mut </span><span class="self">self</span>) {
765-
<span class="kw">if </span>!<span class="self">self</span>.consumed {
766-
<span class="macro">panic!</span>(<span class="string">"DeviceLostClosureRust must be consumed before it is dropped."</span>);
767-
}
768-
}
769-
}
770-
771-
<span class="attr">#[repr(C)]
772-
</span><span class="kw">pub struct </span>DeviceLostClosureC {
773-
<span class="kw">pub </span>callback: <span class="kw">unsafe extern </span><span class="string">"C" </span><span class="kw">fn</span>(user_data: <span class="kw-2">*mut </span>u8, reason: u8, message: <span class="kw-2">*const </span>c_char),
774-
<span class="kw">pub </span>user_data: <span class="kw-2">*mut </span>u8,
775-
consumed: bool,
776-
}
777-
778-
<span class="attr">#[cfg(send_sync)]
779-
</span><span class="kw">unsafe impl </span>Send <span class="kw">for </span>DeviceLostClosureC {}
780-
781-
<span class="kw">impl </span>Drop <span class="kw">for </span>DeviceLostClosureC {
782-
<span class="kw">fn </span>drop(<span class="kw-2">&amp;mut </span><span class="self">self</span>) {
783-
<span class="kw">if </span>!<span class="self">self</span>.consumed {
784-
<span class="macro">panic!</span>(<span class="string">"DeviceLostClosureC must be consumed before it is dropped."</span>);
785-
}
786-
}
787-
}
788-
789-
<span class="kw">pub struct </span>DeviceLostClosure {
790-
<span class="comment">// We wrap this so creating the enum in the C variant can be unsafe,
791-
// allowing our call function to be safe.
792-
</span>inner: DeviceLostClosureInner,
793-
}
653+
</span><span class="kw">pub type </span>DeviceLostClosure = Box&lt;<span class="kw">dyn </span>FnOnce(DeviceLostReason, String) + <span class="lifetime">'static</span>&gt;;
794654

795655
<span class="kw">pub struct </span>DeviceLostInvocation {
796656
closure: DeviceLostClosure,
797657
reason: DeviceLostReason,
798658
message: String,
799659
}
800660

801-
<span class="kw">enum </span>DeviceLostClosureInner {
802-
Rust { inner: DeviceLostClosureRust },
803-
C { inner: DeviceLostClosureC },
804-
}
805-
806-
<span class="kw">impl </span>DeviceLostClosure {
807-
<span class="kw">pub fn </span>from_rust(callback: DeviceLostCallback) -&gt; <span class="self">Self </span>{
808-
<span class="kw">let </span>inner = DeviceLostClosureRust {
809-
callback,
810-
consumed: <span class="bool-val">false</span>,
811-
};
812-
<span class="self">Self </span>{
813-
inner: DeviceLostClosureInner::Rust { inner },
814-
}
815-
}
816-
817-
<span class="doccomment">/// # Safety
818-
///
819-
/// - The callback pointer must be valid to call with the provided `user_data`
820-
/// pointer.
821-
///
822-
/// - Both pointers must point to `'static` data, as the callback may happen at
823-
/// an unspecified time.
824-
</span><span class="kw">pub unsafe fn </span>from_c(<span class="kw-2">mut </span>closure: DeviceLostClosureC) -&gt; <span class="self">Self </span>{
825-
<span class="comment">// Build an inner with the values from closure, ensuring that
826-
// inner.consumed is false.
827-
</span><span class="kw">let </span>inner = DeviceLostClosureC {
828-
callback: closure.callback,
829-
user_data: closure.user_data,
830-
consumed: <span class="bool-val">false</span>,
831-
};
832-
833-
<span class="comment">// Mark the original closure as consumed, so we can safely drop it.
834-
</span>closure.consumed = <span class="bool-val">true</span>;
835-
836-
<span class="self">Self </span>{
837-
inner: DeviceLostClosureInner::C { inner },
838-
}
839-
}
840-
841-
<span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">fn </span>call(<span class="self">self</span>, reason: DeviceLostReason, message: String) {
842-
<span class="kw">match </span><span class="self">self</span>.inner {
843-
DeviceLostClosureInner::Rust { <span class="kw-2">mut </span>inner } =&gt; {
844-
inner.consumed = <span class="bool-val">true</span>;
845-
846-
(inner.callback)(reason, message)
847-
}
848-
<span class="comment">// SAFETY: the contract of the call to from_c says that this unsafe is sound.
849-
</span>DeviceLostClosureInner::C { <span class="kw-2">mut </span>inner } =&gt; <span class="kw">unsafe </span>{
850-
inner.consumed = <span class="bool-val">true</span>;
851-
852-
<span class="comment">// Ensure message is structured as a null-terminated C string. It only
853-
// needs to live as long as the callback invocation.
854-
</span><span class="kw">let </span>message = std::ffi::CString::new(message).unwrap();
855-
(inner.callback)(inner.user_data, reason <span class="kw">as </span>u8, message.as_ptr())
856-
},
857-
}
858-
}
859-
}
860-
861661
<span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">fn </span>map_buffer(
862662
buffer: <span class="kw-2">&amp;</span>Buffer,
863663
offset: BufferAddress,

0 commit comments

Comments
 (0)