Safari WebGPU: StandardMaterial fragment shaders fail to compile ('texture_2d<f32>' cannot be used as the type of a 'let')

Aperta
#26,378 2 commenti 4 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust, wasm

Direzione di ricerca

Read crates/bevy_pbr/src/render/pbr_fragment.wesl, pbr_prepass.wesl, and pbr_prepass_functions.wesl, looking for texture or sampler values assigned with let. The issue describes verifying the fix by compiling every shader module the app creates in Safari 26.6; done means those modules compile without the reported error.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

A-Rendering C-Bug D-Straightforward O-MacOS O-WebGPU S-Ready-For-Implementation X-Uncontroversial

Bevy version

0.20.0 (also on main as of 2026-10-30: crates/bevy_pbr/src/render/pbr_fragment.wesl).

What you did

Ran a 3D app with StandardMaterial on the webgpu backend (wasm32) in Safari 26.6 (macOS) and Safari on iOS 26.

What went wrong

Pipeline creation fails with Fragment module is invalid, the default RenderErrorHandler quits the app, and the canvas stays black. GPUShaderModule.getCompilationInfo() in Safari gives:

error 682:9 'texture_2d<f32>' cannot be used as the type of a 'let'
    >         let texture = _1bevy_pbr_render__1pbr_bindings__2base_color_texture;

Since the move to WESL the PBR shaders reach the browser with lines like these from pbr_fragment.wesl, pbr_prepass.wesl and pbr_prepass_functions.wesl:

@if(BINDLESS)
let texture = bindless_textures_2d[material_indices[slot].base_color_texture];
@else
let texture = pbr_bindings::base_color_texture;
@if(BINDLESS)
let sampler_ = bindless_samplers_filtering[material_indices[slot].base_color_sampler];
@else
let sampler_ = pbr_bindings::base_color_sampler;

WGSL doesn't allow a texture or sampler in a let (the type of a let-declaration must be constructible or a pointer). Tint (Chrome) and naga accept it; WebKit's compiler enforces the rule. Every site of this kind in those three files has the same problem (base colour, specular, specular tint, emissive, metallic-roughness, clearcoat, clearcoat roughness, specular/diffuse transmission, thickness, occlusion, normal map, clearcoat normal, anisotropy).

Fix

Name the texture and sampler directly in the textureSample* call, one statement per BINDLESS case. A patch against 0.20.0 that does this for all three files, checked by compiling every module the app creates in Safari 26.6 (all pass, none before): https://github.com/bcanfield/bevy/commit/e909449efc07d4d47d8b20e4f3c026439b058d74

Lingua principale
Rust
Stelle
49.7k
Fork
5k
Merge medio
3g 19h
PR unite (30g)
134

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di bevyengine/bevy

Tutte le issue di bevyengine/bevy

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.