Skip to content

Commit

Permalink
Bug 1769633: Update wgpu to b51fd851. r=jgilbert
Browse files Browse the repository at this point in the history
Fix Firefox for compute_pass_dispatch functions renamed upstream.

Remove set_index_buffer ffi functions; they're now in wgpu.

Differential Revision: https://phabricator.services.mozilla.com/D146509
  • Loading branch information
jimblandy committed May 17, 2022
1 parent da6683f commit 6ca282b
Show file tree
Hide file tree
Showing 59 changed files with 1,592 additions and 541 deletions.
4 changes: 2 additions & 2 deletions .cargo/config.in
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ rev = "3484d3e3ebdc8931493aa5df4d7ee9360a90e76b"
[source."https://github.com/gfx-rs/wgpu"]
git = "https://github.com/gfx-rs/wgpu"
replace-with = "vendored-sources"
rev = "0b61a191"
rev = "b51fd851"

[source."https://github.com/gfx-rs/naga"]
git = "https://github.com/gfx-rs/naga"
replace-with = "vendored-sources"
rev = "85056524"
rev = "1aa91549"

[source."https://github.com/gfx-rs/metal-rs"]
git = "https://github.com/gfx-rs/metal-rs"
Expand Down
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions dom/webgpu/ComputePassEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ void ComputePassEncoder::SetPipeline(const ComputePipeline& aPipeline) {
void ComputePassEncoder::DispatchWorkgroups(uint32_t x, uint32_t y,
uint32_t z) {
if (mValid) {
ffi::wgpu_compute_pass_dispatch(mPass, x, y, z);
ffi::wgpu_compute_pass_dispatch_workgroups(mPass, x, y, z);
}
}

void ComputePassEncoder::DispatchWorkgroupsIndirect(
const Buffer& aIndirectBuffer, uint64_t aIndirectOffset) {
if (mValid) {
ffi::wgpu_compute_pass_dispatch_indirect(mPass, aIndirectBuffer.mId,
aIndirectOffset);
ffi::wgpu_compute_pass_dispatch_workgroups_indirect(
mPass, aIndirectBuffer.mId, aIndirectOffset);
}
}

Expand Down
6 changes: 3 additions & 3 deletions gfx/wgpu_bindings/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ default = []
[dependencies.wgc]
package = "wgpu-core"
git = "https://github.com/gfx-rs/wgpu"
rev = "0b61a191"
rev = "b51fd851"
#Note: "replay" shouldn't ideally be needed,
# but it allows us to serialize everything across IPC.
features = ["replay", "trace", "serial-pass"]

[dependencies.wgt]
package = "wgpu-types"
git = "https://github.com/gfx-rs/wgpu"
rev = "0b61a191"
rev = "b51fd851"

[dependencies.wgh]
package = "wgpu-hal"
git = "https://github.com/gfx-rs/wgpu"
rev = "0b61a191"
rev = "b51fd851"

[dependencies]
bincode = "1"
Expand Down
22 changes: 0 additions & 22 deletions gfx/wgpu_bindings/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1092,28 +1092,6 @@ pub unsafe extern "C" fn wgpu_command_encoder_insert_debug_marker(
*bb = make_byte_buf(&action);
}

#[no_mangle]
pub unsafe extern "C" fn wgpu_render_pass_set_index_buffer(
pass: &mut wgc::command::RenderPass,
buffer: wgc::id::BufferId,
index_format: wgt::IndexFormat,
offset: wgt::BufferAddress,
size: Option<wgt::BufferSize>,
) {
pass.set_index_buffer(buffer, index_format, offset, size);
}

#[no_mangle]
pub unsafe extern "C" fn wgpu_render_bundle_set_index_buffer(
encoder: &mut wgc::command::RenderBundleEncoder,
buffer: wgc::id::BufferId,
index_format: wgt::IndexFormat,
offset: wgt::BufferAddress,
size: Option<wgt::BufferSize>,
) {
encoder.set_index_buffer(buffer, index_format, offset, size);
}

#[no_mangle]
pub unsafe extern "C" fn wgpu_queue_write_buffer(
dst: id::BufferId,
Expand Down
2 changes: 1 addition & 1 deletion third_party/rust/naga/.cargo-checksum.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion third_party/rust/naga/src/back/glsl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,8 @@ impl<'a, W: Write> Writer<'a, W> {
TypeInner::Pointer { .. }
| TypeInner::Struct { .. }
| TypeInner::Image { .. }
| TypeInner::Sampler { .. } => {
| TypeInner::Sampler { .. }
| TypeInner::BindingArray { .. } => {
return Err(Error::Custom(format!("Unable to write type {:?}", inner)))
}
}
Expand Down
3 changes: 3 additions & 0 deletions third_party/rust/naga/src/back/hlsl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ use crate::proc;
pub struct BindTarget {
pub space: u8,
pub register: u32,
/// If the binding is an unsized binding array, this overrides the size.
pub binding_array_size: Option<u32>,
}

// Using `BTreeMap` instead of `HashMap` so that we can hash itself.
Expand Down Expand Up @@ -214,6 +216,7 @@ impl Options {
None if self.fake_missing_bindings => Ok(BindTarget {
space: res_binding.group as u8,
register: res_binding.binding,
binding_array_size: None,
}),
None => Err(EntryPointError::MissingBinding(res_binding.clone())),
}
Expand Down
44 changes: 40 additions & 4 deletions third_party/rust/naga/src/back/hlsl/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,12 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
register
}
crate::AddressSpace::Handle => {
let register = match *inner {
let handle_ty = match *inner {
TypeInner::BindingArray { ref base, .. } => &module.types[*base].inner,
_ => inner,
};

let register = match *handle_ty {
TypeInner::Sampler { .. } => "s",
// all storage textures are UAV, unconditionally
TypeInner::Image {
Expand All @@ -624,6 +629,16 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
if let Some(ref binding) = global.binding {
// this was already resolved earlier when we started evaluating an entry point.
let bt = self.options.resolve_resource_binding(binding).unwrap();

// need to write the binding array size if the type was emitted with `write_type`
if let TypeInner::BindingArray { base, size, .. } = module.types[global.ty].inner {
if let Some(overridden_size) = bt.binding_array_size {
write!(self.out, "[{}]", overridden_size)?;
} else {
self.write_array_size(module, base, size)?;
}
}

write!(self.out, " : register({}{}", register_ty, bt.register)?;
if bt.space != 0 {
write!(self.out, ", space{}", bt.space)?;
Expand Down Expand Up @@ -732,7 +747,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
let size = module.constants[const_handle].to_array_length().unwrap();
write!(self.out, "{}", size)?;
}
crate::ArraySize::Dynamic => unreachable!(),
crate::ArraySize::Dynamic => {}
}

write!(self.out, "]")?;
Expand Down Expand Up @@ -874,7 +889,9 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
match *inner {
TypeInner::Struct { .. } => write!(self.out, "{}", self.names[&NameKey::Type(ty)])?,
// hlsl array has the size separated from the base type
TypeInner::Array { base, .. } => self.write_type(module, base)?,
TypeInner::Array { base, .. } | TypeInner::BindingArray { base, .. } => {
self.write_type(module, base)?
}
ref other => self.write_value_type(module, other)?,
}

Expand Down Expand Up @@ -933,7 +950,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
// HLSL arrays are written as `type name[size]`
// Current code is written arrays only as `[size]`
// Base `type` and `name` should be written outside
TypeInner::Array { base, size, .. } => {
TypeInner::Array { base, size, .. } | TypeInner::BindingArray { base, size } => {
self.write_array_size(module, base, size)?;
}
_ => {
Expand Down Expand Up @@ -1793,9 +1810,27 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
{
// do nothing, the chain is written on `Load`/`Store`
} else {
let base_ty_res = &func_ctx.info[base].ty;
let resolved = base_ty_res.inner_with(&module.types);

let non_uniform_qualifier = match *resolved {
TypeInner::BindingArray { .. } => {
let uniformity = &func_ctx.info[index].uniformity;

uniformity.non_uniform_result.is_some()
}
_ => false,
};

self.write_expr(module, base, func_ctx)?;
write!(self.out, "[")?;
if non_uniform_qualifier {
write!(self.out, "NonUniformResourceIndex(")?;
}
self.write_expr(module, index, func_ctx)?;
if non_uniform_qualifier {
write!(self.out, ")")?;
}
write!(self.out, "]")?;
}
}
Expand Down Expand Up @@ -1852,6 +1887,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
}
TypeInner::Matrix { .. }
| TypeInner::Array { .. }
| TypeInner::BindingArray { .. }
| TypeInner::ValuePointer { .. } => write!(self.out, "[{}]", index)?,
TypeInner::Struct { .. } => {
// This will never panic in case the type is a `Struct`, this is not true
Expand Down
11 changes: 11 additions & 0 deletions third_party/rust/naga/src/back/msl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ pub struct BindTarget {
pub buffer: Option<Slot>,
pub texture: Option<Slot>,
pub sampler: Option<BindSamplerTarget>,
/// If the binding is an unsized binding array, this overrides the size.
pub binding_array_size: Option<u32>,
pub mutable: bool,
}

Expand Down Expand Up @@ -319,6 +321,7 @@ impl Options {
buffer: Some(slot),
texture: None,
sampler: None,
binding_array_size: None,
mutable: false,
})),
None if self.fake_missing_bindings => Ok(ResolvedBinding::User {
Expand All @@ -340,6 +343,7 @@ impl Options {
buffer: Some(slot),
texture: None,
sampler: None,
binding_array_size: None,
mutable: false,
})),
None if self.fake_missing_bindings => Ok(ResolvedBinding::User {
Expand All @@ -363,6 +367,13 @@ impl ResolvedBinding {
}
}

const fn as_bind_target(&self) -> Option<&BindTarget> {
match *self {
Self::Resource(ref target) => Some(target),
_ => None,
}
}

fn try_fmt<W: Write>(&self, out: &mut W) -> Result<(), Error> {
write!(out, " [[")?;
match *self {
Expand Down
Loading

0 comments on commit 6ca282b

Please sign in to comment.