Commit 8c4605cf authored by Jim Blandy's avatar Jim Blandy
Browse files

Bug 1762730: Update wgpu-core, wgpu-hal, and wgpu-types to 75e82afd. 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
  https://github.com/gfx-rs/wgpu/issues/2564

- Device::drop doesn't actually free the device when using backend::direct::Context #2563
  https://github.com/gfx-rs/wgpu/issues/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](https://github.com/gfx-rs/wgpu/pull/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
parent 9d544b19
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -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"
+9 −9
Original line number Diff line number Diff line
@@ -124,9 +124,9 @@ dependencies = [

[[package]]
name = "ash"
version = "0.35.0+1.2.203"
version = "0.37.0+1.3.209"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a7638ce84f8c84d6fd6faa63aa267574d345181ba591c0eeb5550d4c30cd600"
checksum = "006ca68e0f2b03f22d6fa9f2860f85aed430d257fec20f8879b2145e7c7ae1a6"
dependencies = [
 "libloading 0.7.2",
]
@@ -1185,8 +1185,7 @@ dependencies = [
[[package]]
name = "d3d12"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2daefd788d1e96e0a9d66dee4b828b883509bc3ea9ce30665f04c3246372690c"
source = "git+https://github.com/gfx-rs/d3d12-rs.git?rev=ffe5e261da0a6cb85332b82ab310abd2a7e849f6#ffe5e261da0a6cb85332b82ab310abd2a7e849f6"
dependencies = [
 "bitflags",
 "libloading 0.7.2",
@@ -2727,6 +2726,7 @@ checksum = "8c2352bd1d0bceb871cb9d40f24360c8133c11d7486b68b5381c1dd1a32015e3"
dependencies = [
 "libc",
 "libloading 0.7.2",
 "pkg-config",
]

[[package]]
@@ -3099,7 +3099,7 @@ dependencies = [
[[package]]
name = "metal"
version = "0.23.1"
source = "git+https://github.com/gfx-rs/metal-rs?rev=140c8f4#140c8f4e39001ae154f153ffc767da6c0c9d7f06"
source = "git+https://github.com/gfx-rs/metal-rs?rev=1aaa903#1aaa9033a22b2af7ff8cae2ed412a4733799c3d3"
dependencies = [
 "bitflags",
 "block",
@@ -3429,7 +3429,7 @@ checksum = "a2983372caf4480544083767bf2d27defafe32af49ab4df3a0b7fc90793a3664"
[[package]]
name = "naga"
version = "0.8.0"
source = "git+https://github.com/gfx-rs/naga?rev=c0b7ac7#c0b7ac7f542cc42ccac6f2ec3fc1fb01309cf4d7"
source = "git+https://github.com/gfx-rs/naga?rev=f90e563#f90e563c281cfc71c794e0426ebcced9e3999202"
dependencies = [
 "bit-set",
 "bitflags",
@@ -5908,7 +5908,7 @@ dependencies = [
[[package]]
name = "wgpu-core"
version = "0.12.0"
source = "git+https://github.com/gfx-rs/wgpu?rev=6bc896f#6bc896fe8cc6d74e09934afc7f257c0c60aac59f"
source = "git+https://github.com/gfx-rs/wgpu?rev=75e82afd#75e82afd355ba56b2f3d6f6384fb40c1cb46f1a4"
dependencies = [
 "arrayvec 0.7.2",
 "bitflags",
@@ -5931,7 +5931,7 @@ dependencies = [
[[package]]
name = "wgpu-hal"
version = "0.12.0"
source = "git+https://github.com/gfx-rs/wgpu?rev=6bc896f#6bc896fe8cc6d74e09934afc7f257c0c60aac59f"
source = "git+https://github.com/gfx-rs/wgpu?rev=75e82afd#75e82afd355ba56b2f3d6f6384fb40c1cb46f1a4"
dependencies = [
 "arrayvec 0.7.2",
 "ash",
@@ -5968,7 +5968,7 @@ dependencies = [
[[package]]
name = "wgpu-types"
version = "0.12.0"
source = "git+https://github.com/gfx-rs/wgpu?rev=6bc896f#6bc896fe8cc6d74e09934afc7f257c0c60aac59f"
source = "git+https://github.com/gfx-rs/wgpu?rev=75e82afd#75e82afd355ba56b2f3d6f6384fb40c1cb46f1a4"
dependencies = [
 "bitflags",
 "bitflags_serde_shim",
+2 −2
Original line number Diff line number Diff line
@@ -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);
@@ -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);
  }
+113 −54
Original line number Diff line number Diff line
@@ -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,
@@ -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;
+3 −3
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ 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"]
@@ -25,12 +25,12 @@ 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"
Loading