Bug 1930274: Update wgpu to b89a57f8c (2024-11-8) r!#webgpu-reviewers r=webgpu-reviewers,supply-chain-reviewers,ErichDonGubler

Differential Revision: https://phabricator.services.mozilla.com/D228519
This commit is contained in:
Jim Blandy 2024-11-21 20:57:25 +00:00
parent c42f692f44
commit b73b7484db
23 changed files with 137 additions and 112 deletions

View File

@ -25,9 +25,9 @@ git = "https://github.com/franziskuskiefer/cose-rust"
rev = "43c22248d136c8b38fe42ea709d08da6355cf04b"
replace-with = "vendored-sources"
[source."git+https://github.com/gfx-rs/wgpu?rev=16f012bc9327b23345b6feed754204acb6df6beb"]
[source."git+https://github.com/gfx-rs/wgpu?rev=b89a57f8ca9d8f93ef7995c8003152240fdbbe12"]
git = "https://github.com/gfx-rs/wgpu"
rev = "16f012bc9327b23345b6feed754204acb6df6beb"
rev = "b89a57f8ca9d8f93ef7995c8003152240fdbbe12"
replace-with = "vendored-sources"
[source."git+https://github.com/hsivonen/any_all_workaround?rev=7fb1b7034c9f172aade21ee1c8554e8d8a48af80"]

8
Cargo.lock generated
View File

@ -4280,7 +4280,7 @@ checksum = "a2983372caf4480544083767bf2d27defafe32af49ab4df3a0b7fc90793a3664"
[[package]]
name = "naga"
version = "23.0.0"
source = "git+https://github.com/gfx-rs/wgpu?rev=16f012bc9327b23345b6feed754204acb6df6beb#16f012bc9327b23345b6feed754204acb6df6beb"
source = "git+https://github.com/gfx-rs/wgpu?rev=b89a57f8ca9d8f93ef7995c8003152240fdbbe12#b89a57f8ca9d8f93ef7995c8003152240fdbbe12"
dependencies = [
"arrayvec",
"bit-set",
@ -7113,7 +7113,7 @@ dependencies = [
[[package]]
name = "wgpu-core"
version = "23.0.0"
source = "git+https://github.com/gfx-rs/wgpu?rev=16f012bc9327b23345b6feed754204acb6df6beb#16f012bc9327b23345b6feed754204acb6df6beb"
source = "git+https://github.com/gfx-rs/wgpu?rev=b89a57f8ca9d8f93ef7995c8003152240fdbbe12#b89a57f8ca9d8f93ef7995c8003152240fdbbe12"
dependencies = [
"arrayvec",
"bit-vec",
@ -7138,7 +7138,7 @@ dependencies = [
[[package]]
name = "wgpu-hal"
version = "23.0.0"
source = "git+https://github.com/gfx-rs/wgpu?rev=16f012bc9327b23345b6feed754204acb6df6beb#16f012bc9327b23345b6feed754204acb6df6beb"
source = "git+https://github.com/gfx-rs/wgpu?rev=b89a57f8ca9d8f93ef7995c8003152240fdbbe12#b89a57f8ca9d8f93ef7995c8003152240fdbbe12"
dependencies = [
"android_system_properties",
"arrayvec",
@ -7177,7 +7177,7 @@ dependencies = [
[[package]]
name = "wgpu-types"
version = "23.0.0"
source = "git+https://github.com/gfx-rs/wgpu?rev=16f012bc9327b23345b6feed754204acb6df6beb#16f012bc9327b23345b6feed754204acb6df6beb"
source = "git+https://github.com/gfx-rs/wgpu?rev=b89a57f8ca9d8f93ef7995c8003152240fdbbe12#b89a57f8ca9d8f93ef7995c8003152240fdbbe12"
dependencies = [
"bitflags 2.6.0",
"js-sys",

View File

@ -17,7 +17,7 @@ default = []
[dependencies.wgc]
package = "wgpu-core"
git = "https://github.com/gfx-rs/wgpu"
rev = "16f012bc9327b23345b6feed754204acb6df6beb"
rev = "b89a57f8ca9d8f93ef7995c8003152240fdbbe12"
# TODO: remove the replay feature on the next update containing https://github.com/gfx-rs/wgpu/pull/5182
features = ["serde", "replay", "trace", "strict_asserts", "wgsl", "api_log_info"]
@ -26,32 +26,32 @@ features = ["serde", "replay", "trace", "strict_asserts", "wgsl", "api_log_info"
[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies.wgc]
package = "wgpu-core"
git = "https://github.com/gfx-rs/wgpu"
rev = "16f012bc9327b23345b6feed754204acb6df6beb"
rev = "b89a57f8ca9d8f93ef7995c8003152240fdbbe12"
features = ["metal"]
# We want the wgpu-core Direct3D backends on Windows.
[target.'cfg(windows)'.dependencies.wgc]
package = "wgpu-core"
git = "https://github.com/gfx-rs/wgpu"
rev = "16f012bc9327b23345b6feed754204acb6df6beb"
rev = "b89a57f8ca9d8f93ef7995c8003152240fdbbe12"
features = ["dx12"]
# We want the wgpu-core Vulkan backend on Linux and Windows.
[target.'cfg(any(windows, all(unix, not(any(target_os = "macos", target_os = "ios")))))'.dependencies.wgc]
package = "wgpu-core"
git = "https://github.com/gfx-rs/wgpu"
rev = "16f012bc9327b23345b6feed754204acb6df6beb"
rev = "b89a57f8ca9d8f93ef7995c8003152240fdbbe12"
features = ["vulkan"]
[dependencies.wgt]
package = "wgpu-types"
git = "https://github.com/gfx-rs/wgpu"
rev = "16f012bc9327b23345b6feed754204acb6df6beb"
rev = "b89a57f8ca9d8f93ef7995c8003152240fdbbe12"
[dependencies.wgh]
package = "wgpu-hal"
git = "https://github.com/gfx-rs/wgpu"
rev = "16f012bc9327b23345b6feed754204acb6df6beb"
rev = "b89a57f8ca9d8f93ef7995c8003152240fdbbe12"
features = ["oom_panic", "device_lost_panic", "internal_error_panic"]
[target.'cfg(windows)'.dependencies]

View File

@ -20,11 +20,11 @@ origin:
# Human-readable identifier for this version/release
# Generally "version NNN", "tag SSS", "bookmark SSS"
release: 16f012bc9327b23345b6feed754204acb6df6beb (2024-10-31T23:13:48Z).
release: b89a57f8ca9d8f93ef7995c8003152240fdbbe12 (2024-11-8).
# Revision to pull in
# Must be a long or short commit SHA (long preferred)
revision: 16f012bc9327b23345b6feed754204acb6df6beb
revision: b89a57f8ca9d8f93ef7995c8003152240fdbbe12
license: ['MIT', 'Apache-2.0']

View File

@ -3282,9 +3282,12 @@ criteria = "safe-to-deploy"
delta = "22.0.0 -> 23.0.0"
[[audits.naga]]
who = "Erich Gubler <erichdongubler@gmail.com>"
who = [
"Erich Gubler <erichdongubler@gmail.com>",
"Jim Blandy <jimb@red-bean.com>",
]
criteria = "safe-to-deploy"
delta = "23.0.0 -> 23.0.0@git:16f012bc9327b23345b6feed754204acb6df6beb"
delta = "23.0.0 -> 23.0.0@git:b89a57f8ca9d8f93ef7995c8003152240fdbbe12"
importable = false
[[audits.net2]]
@ -5396,9 +5399,12 @@ criteria = "safe-to-deploy"
delta = "22.0.0 -> 23.0.0"
[[audits.wgpu-core]]
who = "Erich Gubler <erichdongubler@gmail.com>"
who = [
"Erich Gubler <erichdongubler@gmail.com>",
"Jim Blandy <jimb@red-bean.com>",
]
criteria = "safe-to-deploy"
delta = "23.0.0 -> 23.0.0@git:16f012bc9327b23345b6feed754204acb6df6beb"
delta = "23.0.0 -> 23.0.0@git:b89a57f8ca9d8f93ef7995c8003152240fdbbe12"
importable = false
[[audits.wgpu-hal]]
@ -5470,9 +5476,12 @@ criteria = "safe-to-deploy"
delta = "22.0.0 -> 23.0.0"
[[audits.wgpu-hal]]
who = "Erich Gubler <erichdongubler@gmail.com>"
who = [
"Erich Gubler <erichdongubler@gmail.com>",
"Jim Blandy <jimb@red-bean.com>",
]
criteria = "safe-to-deploy"
delta = "23.0.0 -> 23.0.0@git:16f012bc9327b23345b6feed754204acb6df6beb"
delta = "23.0.0 -> 23.0.0@git:b89a57f8ca9d8f93ef7995c8003152240fdbbe12"
importable = false
[[audits.wgpu-types]]
@ -5544,9 +5553,12 @@ criteria = "safe-to-deploy"
delta = "22.0.0 -> 23.0.0"
[[audits.wgpu-types]]
who = "Erich Gubler <erichdongubler@gmail.com>"
who = [
"Erich Gubler <erichdongubler@gmail.com>",
"Jim Blandy <jimb@red-bean.com>",
]
criteria = "safe-to-deploy"
delta = "23.0.0 -> 23.0.0@git:16f012bc9327b23345b6feed754204acb6df6beb"
delta = "23.0.0 -> 23.0.0@git:b89a57f8ca9d8f93ef7995c8003152240fdbbe12"
importable = false
[[audits.whatsys]]

File diff suppressed because one or more lines are too long

View File

@ -84,7 +84,7 @@ optional = true
version = "1.1.0"
[dependencies.serde]
version = "1.0.213"
version = "1.0.214"
features = ["derive"]
optional = true
@ -96,7 +96,7 @@ optional = true
version = "1.4.1"
[dependencies.thiserror]
version = "1.0.65"
version = "1.0.67"
[dependencies.unicode-xid]
version = "0.2.6"

View File

@ -3095,7 +3095,7 @@ impl<'a, W: Write> Writer<'a, W> {
self.write_expr(image, ctx)?;
// All textureSize calls requires an lod argument
// except for multisampled samplers
if class.is_multisampled() {
if !class.is_multisampled() {
write!(self.out, ", 0")?;
}
write!(self.out, ")")?;

View File

@ -421,7 +421,10 @@ impl FunctionInfo {
let image_storage = match sampling.image {
GlobalOrArgument::Global(var) => GlobalOrArgument::Global(var),
GlobalOrArgument::Argument(i) => {
let handle = arguments[i as usize];
let Some(handle) = arguments.get(i as usize).cloned() else {
// Argument count mismatch, will be reported later by validate_call
break;
};
GlobalOrArgument::from_expression(expression_arena, handle).map_err(
|source| {
FunctionError::Expression { handle, source }
@ -434,7 +437,10 @@ impl FunctionInfo {
let sampler_storage = match sampling.sampler {
GlobalOrArgument::Global(var) => GlobalOrArgument::Global(var),
GlobalOrArgument::Argument(i) => {
let handle = arguments[i as usize];
let Some(handle) = arguments.get(i as usize).cloned() else {
// Argument count mismatch, will be reported later by validate_call
break;
};
GlobalOrArgument::from_expression(expression_arena, handle).map_err(
|source| {
FunctionError::Expression { handle, source }

File diff suppressed because one or more lines are too long

View File

@ -109,7 +109,7 @@ optional = true
version = "1"
[dependencies.thiserror]
version = "1.0.65"
version = "1.0.67"
[dependencies.wgt]
version = "23.0.0"

View File

@ -312,6 +312,17 @@ impl Global {
Ok(query_set) => query_set,
Err(e) => return make_err(e.into(), arc_desc),
};
match query_set.same_device(&cmd_buf.device) {
Ok(()) => (),
Err(e) => return make_err(e.into(), arc_desc),
}
match cmd_buf
.device
.require_features(wgt::Features::TIMESTAMP_QUERY)
{
Ok(()) => (),
Err(e) => return make_err(e.into(), arc_desc),
}
Some(ArcPassTimestampWrites {
query_set,

View File

@ -26,7 +26,7 @@ pub use timestamp_writes::PassTimestampWrites;
use self::memory_init::CommandBufferTextureMemoryActions;
use crate::device::{Device, DeviceError};
use crate::device::{Device, DeviceError, MissingFeatures};
use crate::lock::{rank, Mutex};
use crate::snatch::SnatchGuard;
@ -642,6 +642,8 @@ pub enum CommandEncoderError {
InvalidColorAttachment(#[from] ColorAttachmentError),
#[error(transparent)]
InvalidResource(#[from] InvalidResourceError),
#[error(transparent)]
MissingFeatures(#[from] MissingFeatures),
}
impl Global {

View File

@ -1358,9 +1358,11 @@ impl Global {
}) = color_attachment
{
let view = texture_views.get(*view_id).get()?;
view.same_device(device)?;
let resolve_target = if let Some(resolve_target_id) = resolve_target {
let rt_arc = texture_views.get(*resolve_target_id).get()?;
rt_arc.same_device(device)?;
Some(rt_arc)
} else {
@ -1382,6 +1384,7 @@ impl Global {
arc_desc.depth_stencil_attachment =
if let Some(depth_stencil_attachment) = desc.depth_stencil_attachment {
let view = texture_views.get(depth_stencil_attachment.view).get()?;
view.same_device(device)?;
Some(ArcRenderPassDepthStencilAttachment {
view,
@ -1394,6 +1397,9 @@ impl Global {
arc_desc.timestamp_writes = if let Some(tw) = desc.timestamp_writes {
let query_set = query_sets.get(tw.query_set).get()?;
query_set.same_device(device)?;
device.require_features(wgt::Features::TIMESTAMP_QUERY)?;
Some(ArcPassTimestampWrites {
query_set,
@ -1407,6 +1413,7 @@ impl Global {
arc_desc.occlusion_query_set =
if let Some(occlusion_query_set) = desc.occlusion_query_set {
let query_set = query_sets.get(occlusion_query_set).get()?;
query_set.same_device(device)?;
Some(query_set)
} else {

View File

@ -2147,33 +2147,27 @@ impl Global {
offset: BufferAddress,
size: Option<BufferAddress>,
op: BufferMapOperation,
) -> BufferAccessResult {
) -> Result<crate::SubmissionIndex, BufferAccessError> {
profiling::scope!("Buffer::map_async");
api_log!("Buffer::map_async {buffer_id:?} offset {offset:?} size {size:?} op: {op:?}");
let hub = &self.hub;
let op_and_err = 'error: {
let buffer = match hub.buffers.get(buffer_id).get() {
Ok(buffer) => buffer,
Err(e) => break 'error Some((op, e.into())),
};
buffer.map_async(offset, size, op).err()
let map_result = match hub.buffers.get(buffer_id).get() {
Ok(buffer) => buffer.map_async(offset, size, op),
Err(e) => Err((op, e.into())),
};
// User callbacks must not be called while holding `buffer.map_async`'s locks, so we
// defer the error callback if it needs to be called immediately (typically when running
// into errors).
if let Some((mut operation, err)) = op_and_err {
if let Some(callback) = operation.callback.take() {
callback.call(Err(err.clone()));
match map_result {
Ok(submission_index) => Ok(submission_index),
Err((mut operation, err)) => {
if let Some(callback) = operation.callback.take() {
callback.call(Err(err.clone()));
}
log::error!("Buffer::map_async error: {err}");
Err(err)
}
log::error!("Buffer::map_async error: {err}");
return Err(err);
}
Ok(())
}
pub fn buffer_get_mapped_range(

View File

@ -126,35 +126,20 @@ pub enum WaitIdleError {
/// - Each buffer's `ResourceInfo::submission_index` records the index of the
/// most recent queue submission that uses that buffer.
///
/// - Calling `Global::buffer_map_async` adds the buffer to
/// `self.mapped`, and changes `Buffer::map_state` to prevent it
/// from being used in any new submissions.
///
/// - When the device is polled, the following `LifetimeTracker` methods decide
/// what should happen next:
///
/// 1) `triage_mapped` drains `self.mapped`, checking the submission index
/// of each buffer against the queue submissions that have finished
/// execution. Buffers used by submissions still in flight go in
/// `self.active[index].mapped`, and the rest go into
/// `self.ready_to_map`.
///
/// 2) `triage_submissions` moves entries in `self.active[i]` for completed
/// 1) `triage_submissions` moves entries in `self.active[i]` for completed
/// submissions to `self.ready_to_map`. At this point, both
/// `self.active` and `self.ready_to_map` are up to date with the given
/// submission index.
///
/// 3) `handle_mapping` drains `self.ready_to_map` and actually maps the
/// 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
/// buffer. This new `Arc` is only dropped by `handle_mapping`.
pub(crate) struct LifetimeTracker {
/// Buffers for which a call to [`Buffer::map_async`] has succeeded, but
/// which haven't been examined by `triage_mapped` yet to decide when they
/// can be mapped.
mapped: Vec<Arc<Buffer>>,
/// Resources used by queue submissions still in flight. One entry per
/// submission, with older submissions appearing before younger.
///
@ -182,7 +167,6 @@ pub(crate) struct LifetimeTracker {
impl LifetimeTracker {
pub fn new() -> Self {
Self {
mapped: Vec::new(),
active: Vec::new(),
ready_to_map: Vec::new(),
work_done_closures: SmallVec::new(),
@ -211,8 +195,21 @@ impl LifetimeTracker {
});
}
pub(crate) fn map(&mut self, value: &Arc<Buffer>) {
self.mapped.push(value.clone());
pub(crate) fn map(&mut self, buffer: &Arc<Buffer>) -> Option<SubmissionIndex> {
// Determine which buffers are ready to map, and which must wait for the GPU.
let submission = self
.active
.iter_mut()
.rev()
.find(|a| a.contains_buffer(buffer));
let maybe_submission_index = submission.as_ref().map(|s| s.index);
submission
.map_or(&mut self.ready_to_map, |a| &mut a.mapped)
.push(buffer.clone());
maybe_submission_index
}
/// Returns the submission index of the most recent submission that uses the
@ -304,41 +301,24 @@ impl LifetimeTracker {
}
}
pub fn add_work_done_closure(&mut self, closure: SubmittedWorkDoneClosure) {
pub fn add_work_done_closure(
&mut self,
closure: SubmittedWorkDoneClosure,
) -> Option<SubmissionIndex> {
match self.active.last_mut() {
Some(active) => {
active.work_done_closures.push(closure);
Some(active.index)
}
// We must defer the closure until all previously occurring map_async closures
// have fired. This is required by the spec.
None => {
self.work_done_closures.push(closure);
None
}
}
}
/// Determine which buffers are ready to map, and which must wait for the
/// GPU.
///
/// See the documentation for [`LifetimeTracker`] for details.
pub(crate) fn triage_mapped(&mut self) {
if self.mapped.is_empty() {
return;
}
for buffer in self.mapped.drain(..) {
let submission = self
.active
.iter_mut()
.rev()
.find(|a| a.contains_buffer(&buffer));
submission
.map_or(&mut self.ready_to_map, |a| &mut a.mapped)
.push(buffer);
}
}
/// Map the buffers in `self.ready_to_map`.
///
/// Return a list of mapping notifications to send.

View File

@ -1256,10 +1256,13 @@ impl Queue {
unsafe { self.raw().get_timestamp_period() }
}
pub fn on_submitted_work_done(&self, closure: SubmittedWorkDoneClosure) {
pub fn on_submitted_work_done(
&self,
closure: SubmittedWorkDoneClosure,
) -> Option<SubmissionIndex> {
api_log!("Queue::on_submitted_work_done");
//TODO: flush pending writes
self.device.lock_life().add_work_done_closure(closure);
self.device.lock_life().add_work_done_closure(closure)
}
}
@ -1402,9 +1405,13 @@ impl Global {
&self,
queue_id: QueueId,
closure: SubmittedWorkDoneClosure,
) {
) -> SubmissionIndex {
api_log!("Queue::on_submitted_work_done {queue_id:?}");
//TODO: flush pending writes
let queue = self.hub.queues.get(queue_id);
queue.on_submitted_work_done(closure);
let result = queue.on_submitted_work_done(closure);
result.unwrap_or(0) // '0' means no wait is necessary
}
}

View File

@ -493,8 +493,6 @@ impl Device {
let submission_closures =
life_tracker.triage_submissions(submission_index, &self.command_allocator);
life_tracker.triage_mapped();
let mapping_closures = life_tracker.handle_mapping(self.raw(), &snatch_guard);
let queue_empty = life_tracker.queue_empty();

View File

@ -15,7 +15,7 @@ use crate::{
snatch::{SnatchGuard, Snatchable},
track::{SharedTrackerIndexAllocator, TextureSelector, TrackerIndex},
weak_vec::WeakVec,
Label, LabelHelpers,
Label, LabelHelpers, SubmissionIndex,
};
use smallvec::SmallVec;
@ -304,7 +304,7 @@ impl BufferMapCallback {
// SAFETY: the contract of the call to from_c says that this unsafe is sound.
BufferMapCallbackInner::C { inner } => unsafe {
let status = match result {
Ok(()) => BufferMapAsyncStatus::Success,
Ok(_) => BufferMapAsyncStatus::Success,
Err(BufferAccessError::Device(_)) => BufferMapAsyncStatus::ContextLost,
Err(BufferAccessError::InvalidResource(_))
| Err(BufferAccessError::DestroyedResource(_)) => BufferMapAsyncStatus::Invalid,
@ -546,7 +546,7 @@ impl Buffer {
offset: wgt::BufferAddress,
size: Option<wgt::BufferAddress>,
op: BufferMapOperation,
) -> Result<(), (BufferMapOperation, BufferAccessError)> {
) -> Result<SubmissionIndex, (BufferMapOperation, BufferAccessError)> {
let range_size = if let Some(size) = size {
size
} else if offset > self.size {
@ -633,9 +633,9 @@ impl Buffer {
.buffers
.set_single(self, internal_use);
device.lock_life().map(self);
let submit_index = device.lock_life().map(self).unwrap_or(0); // '0' means no wait is necessary
Ok(())
Ok(submit_index)
}
// Note: This must not be called while holding a lock.

File diff suppressed because one or more lines are too long

View File

@ -102,7 +102,7 @@ version = "0.6"
version = "1.1.0"
[dependencies.thiserror]
version = "1.0.65"
version = "1.0.67"
[dependencies.wgt]
version = "23.0.0"

View File

@ -777,6 +777,12 @@ pub struct Texture {
allocation: Option<suballocation::AllocationWrapper>,
}
impl Texture {
pub unsafe fn raw_resource(&self) -> &Direct3D12::ID3D12Resource {
&self.resource
}
}
impl crate::DynTexture for Texture {}
impl crate::DynSurfaceTexture for Texture {}

View File

@ -1240,13 +1240,15 @@ impl crate::CommandEncoder for super::CommandEncoder {
}
unsafe fn dispatch(&mut self, count: [u32; 3]) {
let encoder = self.state.compute.as_ref().unwrap();
let raw_count = metal::MTLSize {
width: count[0] as u64,
height: count[1] as u64,
depth: count[2] as u64,
};
encoder.dispatch_thread_groups(raw_count, self.state.raw_wg_size);
if count[0] > 0 && count[1] > 0 && count[2] > 0 {
let encoder = self.state.compute.as_ref().unwrap();
let raw_count = metal::MTLSize {
width: count[0] as u64,
height: count[1] as u64,
depth: count[2] as u64,
};
encoder.dispatch_thread_groups(raw_count, self.state.raw_wg_size);
}
}
unsafe fn dispatch_indirect(&mut self, buffer: &super::Buffer, offset: wgt::BufferAddress) {