Skip to content

Commit

Permalink
Bug 1762730: Update wgpu-core, wgpu-hal, and wgpu-types to 75e82afd. …
Browse files Browse the repository at this point in the history
…r=jgilbert

New versions of several crates are introduced to third_party/rust, by
changing the versions requested in `gfx/wgpu_bindings/Cargo.toml` and
running `mach vendor rust`:

- `wgpu-core`, `wgpu-hal`, and `wgpu-types`, as used by `wgpu_bindings`
- `naga`, `ash`, and `metal`, as used by the above

These are all exact copies of the upstream sources, at the git
revisions listed in `.cargo/config.in`.

This brings in fixes for some upstream `wgpu` bugs that were fuzzblockers:

- Compute pipelines never freed at runtime, leaking memory #2564
  gfx-rs/wgpu#2564

- Device::drop doesn't actually free the device when using backend::direct::Context #2563
  gfx-rs/wgpu#2563

The Firefox sources also needed some adjustments to catch up with
upstream changes:

- The C type `mozilla::webgpu::ffi::WGPUTextureFormat` is now a struct
  containing a tag enum and a union, not just an enum. This is needed
  for [gfx-rs/wgpu#2477](gfx-rs/wgpu#2477).

  (Note that Firefox's `WebGPU.webidl` is behind the current spec,
  so even though the newest ASTC texture formats are supported in `wgpu`,
  they're not available in Firefox yet.)

- `wgpu` got a new feature, `id32`, which cbindgen needed to be told
  about so that it would generate preprocessor-protected code like
  this:

      #if defined(WGPU_FEATURE_ID32)
      typedef uint32_t WGPUNonZeroId;
      #endif

      #if !defined(WGPU_FEATURE_ID32)
      typedef uint64_t WGPUNonZeroId;
      #endif

  instead of just spitting out two conflicting definitions of
  `WGPUNonZeroId`.

- The `wgpu_core::hub::IdentityHandlerFactory` trait's `spawn` method
  no longer takes a `min_index` argument. (Our implementations of that
  trait never used that argument anyway, so this was easy to
  accommodate.)

Differential Revision: https://phabricator.services.mozilla.com/D142779
  • Loading branch information
jimblandy committed Apr 5, 2022
1 parent 21377df commit 8075da0
Show file tree
Hide file tree
Showing 236 changed files with 20,764 additions and 17,334 deletions.
11 changes: 8 additions & 3 deletions .cargo/config.in
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,22 @@ rev = "3484d3e3ebdc8931493aa5df4d7ee9360a90e76b"
[source."https://github.com/gfx-rs/wgpu"]
git = "https://github.com/gfx-rs/wgpu"
replace-with = "vendored-sources"
rev = "6bc896f"
rev = "75e82afd"

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

[source."https://github.com/gfx-rs/metal-rs"]
git = "https://github.com/gfx-rs/metal-rs"
replace-with = "vendored-sources"
rev = "140c8f4"
rev = "1aaa903"

[source."https://github.com/gfx-rs/d3d12-rs.git"]
git = "https://github.com/gfx-rs/d3d12-rs.git"
replace-with = "vendored-sources"
rev = "ffe5e261da0a6cb85332b82ab310abd2a7e849f6"

[source."https://github.com/chris-zen/coremidi.git"]
git = "https://github.com/chris-zen/coremidi.git"
Expand Down
18 changes: 9 additions & 9 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions dom/webgpu/RenderBundleEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ ffi::WGPURenderBundleEncoder* CreateRenderBundleEncoder(
desc.label = label.get();
}

ffi::WGPUTextureFormat depthStencilFormat = ffi::WGPUTextureFormat_Sentinel;
ffi::WGPUTextureFormat depthStencilFormat = {ffi::WGPUTextureFormat_Sentinel};
if (aDesc.mDepthStencilFormat.WasPassed()) {
WebGPUChild::ConvertTextureFormatRef(aDesc.mDepthStencilFormat.Value(),
depthStencilFormat);
Expand All @@ -49,7 +49,7 @@ ffi::WGPURenderBundleEncoder* CreateRenderBundleEncoder(

std::vector<ffi::WGPUTextureFormat> colorFormats = {};
for (const auto i : IntegerRange(aDesc.mColorFormats.Length())) {
ffi::WGPUTextureFormat format = ffi::WGPUTextureFormat_Sentinel;
ffi::WGPUTextureFormat format = {ffi::WGPUTextureFormat_Sentinel};
WebGPUChild::ConvertTextureFormatRef(aDesc.mColorFormats[i], format);
colorFormats.push_back(format);
}
Expand Down
167 changes: 113 additions & 54 deletions dom/webgpu/ipc/WebGPUChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,115 +43,174 @@ static ffi::WGPUCompareFunction ConvertCompareFunction(

static ffi::WGPUTextureFormat ConvertTextureFormat(
const dom::GPUTextureFormat& aFormat) {
ffi::WGPUTextureFormat result = {ffi::WGPUTextureFormat_Sentinel};
switch (aFormat) {
case dom::GPUTextureFormat::R8unorm:
return ffi::WGPUTextureFormat_R8Unorm;
result.tag = ffi::WGPUTextureFormat_R8Unorm;
break;
case dom::GPUTextureFormat::R8snorm:
return ffi::WGPUTextureFormat_R8Snorm;
result.tag = ffi::WGPUTextureFormat_R8Snorm;
break;
case dom::GPUTextureFormat::R8uint:
return ffi::WGPUTextureFormat_R8Uint;
result.tag = ffi::WGPUTextureFormat_R8Uint;
break;
case dom::GPUTextureFormat::R8sint:
return ffi::WGPUTextureFormat_R8Sint;
result.tag = ffi::WGPUTextureFormat_R8Sint;
break;
case dom::GPUTextureFormat::R16uint:
return ffi::WGPUTextureFormat_R16Uint;
result.tag = ffi::WGPUTextureFormat_R16Uint;
break;
case dom::GPUTextureFormat::R16sint:
return ffi::WGPUTextureFormat_R16Sint;
result.tag = ffi::WGPUTextureFormat_R16Sint;
break;
case dom::GPUTextureFormat::R16float:
return ffi::WGPUTextureFormat_R16Float;
result.tag = ffi::WGPUTextureFormat_R16Float;
break;
case dom::GPUTextureFormat::Rg8unorm:
return ffi::WGPUTextureFormat_Rg8Unorm;
result.tag = ffi::WGPUTextureFormat_Rg8Unorm;
break;
case dom::GPUTextureFormat::Rg8snorm:
return ffi::WGPUTextureFormat_Rg8Snorm;
result.tag = ffi::WGPUTextureFormat_Rg8Snorm;
break;
case dom::GPUTextureFormat::Rg8uint:
return ffi::WGPUTextureFormat_Rg8Uint;
result.tag = ffi::WGPUTextureFormat_Rg8Uint;
break;
case dom::GPUTextureFormat::Rg8sint:
return ffi::WGPUTextureFormat_Rg8Sint;
result.tag = ffi::WGPUTextureFormat_Rg8Sint;
break;
case dom::GPUTextureFormat::R32uint:
return ffi::WGPUTextureFormat_R32Uint;
result.tag = ffi::WGPUTextureFormat_R32Uint;
break;
case dom::GPUTextureFormat::R32sint:
return ffi::WGPUTextureFormat_R32Sint;
result.tag = ffi::WGPUTextureFormat_R32Sint;
break;
case dom::GPUTextureFormat::R32float:
return ffi::WGPUTextureFormat_R32Float;
result.tag = ffi::WGPUTextureFormat_R32Float;
break;
case dom::GPUTextureFormat::Rg16uint:
return ffi::WGPUTextureFormat_Rg16Uint;
result.tag = ffi::WGPUTextureFormat_Rg16Uint;
break;
case dom::GPUTextureFormat::Rg16sint:
return ffi::WGPUTextureFormat_Rg16Sint;
result.tag = ffi::WGPUTextureFormat_Rg16Sint;
break;
case dom::GPUTextureFormat::Rg16float:
return ffi::WGPUTextureFormat_Rg16Float;
result.tag = ffi::WGPUTextureFormat_Rg16Float;
break;
case dom::GPUTextureFormat::Rgba8unorm:
return ffi::WGPUTextureFormat_Rgba8Unorm;
result.tag = ffi::WGPUTextureFormat_Rgba8Unorm;
break;
case dom::GPUTextureFormat::Rgba8unorm_srgb:
return ffi::WGPUTextureFormat_Rgba8UnormSrgb;
result.tag = ffi::WGPUTextureFormat_Rgba8UnormSrgb;
break;
case dom::GPUTextureFormat::Rgba8snorm:
return ffi::WGPUTextureFormat_Rgba8Snorm;
result.tag = ffi::WGPUTextureFormat_Rgba8Snorm;
break;
case dom::GPUTextureFormat::Rgba8uint:
return ffi::WGPUTextureFormat_Rgba8Uint;
result.tag = ffi::WGPUTextureFormat_Rgba8Uint;
break;
case dom::GPUTextureFormat::Rgba8sint:
return ffi::WGPUTextureFormat_Rgba8Sint;
result.tag = ffi::WGPUTextureFormat_Rgba8Sint;
break;
case dom::GPUTextureFormat::Bgra8unorm:
return ffi::WGPUTextureFormat_Bgra8Unorm;
result.tag = ffi::WGPUTextureFormat_Bgra8Unorm;
break;
case dom::GPUTextureFormat::Bgra8unorm_srgb:
return ffi::WGPUTextureFormat_Bgra8UnormSrgb;
result.tag = ffi::WGPUTextureFormat_Bgra8UnormSrgb;
break;
case dom::GPUTextureFormat::Rgb10a2unorm:
return ffi::WGPUTextureFormat_Rgb10a2Unorm;
result.tag = ffi::WGPUTextureFormat_Rgb10a2Unorm;
break;
case dom::GPUTextureFormat::Rg11b10float:
return ffi::WGPUTextureFormat_Rg11b10Float;
result.tag = ffi::WGPUTextureFormat_Rg11b10Float;
break;
case dom::GPUTextureFormat::Rg32uint:
return ffi::WGPUTextureFormat_Rg32Uint;
result.tag = ffi::WGPUTextureFormat_Rg32Uint;
break;
case dom::GPUTextureFormat::Rg32sint:
return ffi::WGPUTextureFormat_Rg32Sint;
result.tag = ffi::WGPUTextureFormat_Rg32Sint;
break;
case dom::GPUTextureFormat::Rg32float:
return ffi::WGPUTextureFormat_Rg32Float;
result.tag = ffi::WGPUTextureFormat_Rg32Float;
break;
case dom::GPUTextureFormat::Rgba16uint:
return ffi::WGPUTextureFormat_Rgba16Uint;
result.tag = ffi::WGPUTextureFormat_Rgba16Uint;
break;
case dom::GPUTextureFormat::Rgba16sint:
return ffi::WGPUTextureFormat_Rgba16Sint;
result.tag = ffi::WGPUTextureFormat_Rgba16Sint;
break;
case dom::GPUTextureFormat::Rgba16float:
return ffi::WGPUTextureFormat_Rgba16Float;
result.tag = ffi::WGPUTextureFormat_Rgba16Float;
break;
case dom::GPUTextureFormat::Rgba32uint:
return ffi::WGPUTextureFormat_Rgba32Uint;
result.tag = ffi::WGPUTextureFormat_Rgba32Uint;
break;
case dom::GPUTextureFormat::Rgba32sint:
return ffi::WGPUTextureFormat_Rgba32Sint;
result.tag = ffi::WGPUTextureFormat_Rgba32Sint;
break;
case dom::GPUTextureFormat::Rgba32float:
return ffi::WGPUTextureFormat_Rgba32Float;
result.tag = ffi::WGPUTextureFormat_Rgba32Float;
break;
case dom::GPUTextureFormat::Depth32float:
return ffi::WGPUTextureFormat_Depth32Float;
result.tag = ffi::WGPUTextureFormat_Depth32Float;
break;
case dom::GPUTextureFormat::Bc1_rgba_unorm:
return ffi::WGPUTextureFormat_Bc1RgbaUnorm;
result.tag = ffi::WGPUTextureFormat_Bc1RgbaUnorm;
break;
case dom::GPUTextureFormat::Bc1_rgba_unorm_srgb:
return ffi::WGPUTextureFormat_Bc1RgbaUnormSrgb;
result.tag = ffi::WGPUTextureFormat_Bc1RgbaUnormSrgb;
break;
case dom::GPUTextureFormat::Bc4_r_unorm:
return ffi::WGPUTextureFormat_Bc4RUnorm;
result.tag = ffi::WGPUTextureFormat_Bc4RUnorm;
break;
case dom::GPUTextureFormat::Bc4_r_snorm:
return ffi::WGPUTextureFormat_Bc4RSnorm;
result.tag = ffi::WGPUTextureFormat_Bc4RSnorm;
break;
case dom::GPUTextureFormat::Bc2_rgba_unorm:
return ffi::WGPUTextureFormat_Bc2RgbaUnorm;
result.tag = ffi::WGPUTextureFormat_Bc2RgbaUnorm;
break;
case dom::GPUTextureFormat::Bc2_rgba_unorm_srgb:
return ffi::WGPUTextureFormat_Bc2RgbaUnormSrgb;
result.tag = ffi::WGPUTextureFormat_Bc2RgbaUnormSrgb;
break;
case dom::GPUTextureFormat::Bc3_rgba_unorm:
return ffi::WGPUTextureFormat_Bc3RgbaUnorm;
result.tag = ffi::WGPUTextureFormat_Bc3RgbaUnorm;
break;
case dom::GPUTextureFormat::Bc3_rgba_unorm_srgb:
return ffi::WGPUTextureFormat_Bc3RgbaUnormSrgb;
result.tag = ffi::WGPUTextureFormat_Bc3RgbaUnormSrgb;
break;
case dom::GPUTextureFormat::Bc5_rg_unorm:
return ffi::WGPUTextureFormat_Bc5RgUnorm;
result.tag = ffi::WGPUTextureFormat_Bc5RgUnorm;
break;
case dom::GPUTextureFormat::Bc5_rg_snorm:
return ffi::WGPUTextureFormat_Bc5RgSnorm;
result.tag = ffi::WGPUTextureFormat_Bc5RgSnorm;
break;
case dom::GPUTextureFormat::Bc6h_rgb_ufloat:
return ffi::WGPUTextureFormat_Bc6hRgbUfloat;
result.tag = ffi::WGPUTextureFormat_Bc6hRgbUfloat;
break;
case dom::GPUTextureFormat::Bc6h_rgb_float:
return ffi::WGPUTextureFormat_Bc6hRgbSfloat;
result.tag = ffi::WGPUTextureFormat_Bc6hRgbSfloat;
break;
case dom::GPUTextureFormat::Bc7_rgba_unorm:
return ffi::WGPUTextureFormat_Bc7RgbaUnorm;
result.tag = ffi::WGPUTextureFormat_Bc7RgbaUnorm;
break;
case dom::GPUTextureFormat::Bc7_rgba_unorm_srgb:
return ffi::WGPUTextureFormat_Bc7RgbaUnormSrgb;
result.tag = ffi::WGPUTextureFormat_Bc7RgbaUnormSrgb;
break;
case dom::GPUTextureFormat::Depth24plus:
return ffi::WGPUTextureFormat_Depth24Plus;
result.tag = ffi::WGPUTextureFormat_Depth24Plus;
break;
case dom::GPUTextureFormat::Depth24plus_stencil8:
return ffi::WGPUTextureFormat_Depth24PlusStencil8;
result.tag = ffi::WGPUTextureFormat_Depth24PlusStencil8;
break;
case dom::GPUTextureFormat::EndGuard_:
MOZ_ASSERT_UNREACHABLE();
}
MOZ_CRASH("unexpected texture format enum");

// Clang will check for us that the switch above is exhaustive,
// but not if we add a 'default' case. So, check this here.
MOZ_ASSERT(result.tag != ffi::WGPUTextureFormat_Sentinel,
"unexpected texture format enum");

return result;
}

void WebGPUChild::ConvertTextureFormatRef(const dom::GPUTextureFormat& aInput,
Expand Down Expand Up @@ -357,7 +416,7 @@ RawId WebGPUChild::TextureCreateView(
desc.label = label.get();
}

ffi::WGPUTextureFormat format = ffi::WGPUTextureFormat_Sentinel;
ffi::WGPUTextureFormat format = {ffi::WGPUTextureFormat_Sentinel};
if (aDesc.mFormat.WasPassed()) {
format = ConvertTextureFormat(aDesc.mFormat.Value());
desc.format = &format;
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 = "6bc896f"
rev = "75e82afd"
#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 = "6bc896f"
rev = "75e82afd"

[dependencies.wgh]
package = "wgpu-hal"
git = "https://github.com/gfx-rs/wgpu"
rev = "6bc896f"
rev = "75e82afd"

[dependencies]
bincode = "1"
Expand Down
1 change: 1 addition & 0 deletions gfx/wgpu_bindings/cbindgen.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,4 @@ bitflags = true
"target_os = windows" = "XP_WIN"
"target_os = macos" = "XP_MACOSX"
"target_os = android" = "ANDROID"
"feature = id32" = "WGPU_FEATURE_ID32"
Loading

0 comments on commit 8075da0

Please sign in to comment.