Skip to content

Shader compilation error with webgpu only in debug builds #18463

@rparrett

Description

@rparrett

Bevy version

0.16.0-rc.1, most recent main

Relevant system information

macOS (m4), Chrome

What you did

Build and run Bevy's 3d_scene example for webgpu, as described in the docs.

Except, do a debug build instead of a release build.

cargo build --features webgpu --target wasm32-unknown-unknown --example 3d_scene 
wasm-bindgen --out-name wasm_example \
    --out-dir examples/wasm/target \
    --target web target/wasm32-unknown-unknown/debug/examples/3d_scene.wasm
basic-http-server examples/wasm/

What went wrong

Scene fails to render, with multiple runtime errors similar to

ERROR /Users/me/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bevy_render-0.16.0-rc.1/src/render_resource/pipeline_cache.rs:1010 failed to process shader:
error: failed to build a valid final module: Global variable [12] 'push_constants' is invalid        ┌─ /Users/me/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bevy_pbr-0.16.0-rc.1/src/render/mesh_preprocess.wgsl:120:1
    │
120 │ var<push_constant> push_constants: PushConstants;
    │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ naga::GlobalVariable [12]
    │
    = Capability Capabilities(PUSH_CONSTANT) is not supported

Additional information

Release builds "work."

cargo build --features webgpu --target wasm32-unknown-unknown --example 3d_scene --release
wasm-bindgen --out-name wasm_example \
    --out-dir examples/wasm/target \
    --target web target/wasm32-unknown-unknown/release/examples/3d_scene.wasm
basic-http-server examples/wasm/

But they show warnings like:

Compilation log for [Invalid ShaderModule (unlabeled)]:
1 error(s) generated while compiling the shader:
:33:1 error: use of variable address space 'push_constant' requires enabling extension 'chromium_experimental_push_constant'
var<push_constant> constants: Constants;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

127.0.0.1/:1 The number of storage textures (12) in the Compute stage exceeds the maximum per-stage limit (8).
 - While validating binding counts
 - While validating [BindGroupLayoutDescriptor ""downsample depth bind group layout""]
 - While calling [Device].CreateBindGroupLayout([BindGroupLayoutDescriptor ""downsample depth bind group layout""]).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-RenderingDrawing game state to the screenC-BugAn unexpected or incorrect behaviorO-WebSpecific to web (WASM) builds

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions