Closed Bug 1762730 Opened 2 years ago Closed 2 years ago

Update wgpu from upstream

Categories

(Core :: Graphics: WebGPU, task, P1)

task

Tracking

()

RESOLVED FIXED
101 Branch
Tracking Status
firefox101 --- fixed

People

(Reporter: jimb, Assigned: jimb)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Upstream wgpu changeset b1900036 breaks our build: cbindgen is unhappy with some of the new public declarations.

commit b19000367c15ebc3f4aa51871e6d6b9b670126f8
Author: Alexander Guryanov <caiiiycuk@gmail.com>
Date:   Tue Jan 25 17:35:45 2022 +0700

    feature: emscripten
Severity: -- → S3
Priority: -- → P1

I believe the problem is that this change in commit b1900036 is running into cbindgen#286:

--- a/wgpu-hal/src/gles/egl.rs
+++ b/wgpu-hal/src/gles/egl.rs
@@ -26,6 +26,12 @@ type WlDisplayConnectFun =
 
 type WlDisplayDisconnectFun = unsafe extern "system" fn(display: *const raw::c_void);
 
+#[cfg(not(feature = "emscripten"))]
+type EglInstance = egl::DynamicInstance<egl::EGL1_4>;
+
+#[cfg(feature = "emscripten")]
+type EglInstance = egl::Instance<egl::Static>;
+
 type WlEglWindowCreateFun = unsafe extern "system" fn(
     surface: *const raw::c_void,
     width: raw::c_int,

This upstream PR breaks our current code:

Previously, wgpu_types::TextureFormat was a plain C-style enum, so Firefox could use code like this:

  ffi::WGPUTextureFormat depthStencilFormat = ffi::WGPUTextureFormat_Sentinel;

However, #2477 introduced a value-bearing variant to wgpu_types::TextureFormat (defined in wgpu-types/src/lib.rs):

    /// block compressed texture. 16 bytes per block.
    ///
    /// Features [`TEXTURE_COMPRESSION_ASTC_LDR`] or [`TEXTURE_COMPRESSION_ASTC_HDR`] must be enabled to use this texture format.
    Astc {
        /// compressed block dimensions
        block: AstcBlock,
        ///
        channel: AstcChannel,
    },

so cbindgen now renders TextureFormat in C as a struct:

struct WGPUTextureFormat {
  enum WGPUTextureFormat_Tag tag;
  union {
    struct WGPUTextureFormat_WGPUAstc_Body astc;
  };
};

Okay, that's fixed. There was also a change to the IdentityHandlerFactory::spawn trait method, and a new id32 feature to tell cbindgen about. I have a working FF build now, against current wgpu sources.

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:

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.

    (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.)

Assignee: nobody → jimb
Status: NEW → ASSIGNED
Pushed by jblandy@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/b67fef0360d9
Update wgpu-core, wgpu-hal, and wgpu-types to 75e82afd. r=jgilbert

Backed out for causing build bustages

Flags: needinfo?(jimb)

This backout is due to wgpu having acquired a minimum supported Rust version of 1.59 in #2557, whereas Firefox is using Rust 1.57 for builds.

Flags: needinfo?(jimb)
Depends on: 1763305
Pushed by jblandy@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/0b5d13bcf367
Update wgpu-core, wgpu-hal, and wgpu-types to 75e82afd. r=jgilbert
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 101 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: