Skip to content
This repository was archived by the owner on Jan 29, 2025. It is now read-only.
This repository was archived by the owner on Jan 29, 2025. It is now read-only.

pipeline that reuse the same binding group between vertex and fragment crash on Safari #1617

@mockersf

Description

@mockersf

Using Bevy pbr pipeline because I'm not really up to write my own pipelines.

Bevy is using the same shader for both fragment and vertex stages, and sharing some of the data structures between both. There are also two binding groups that are shared:

In the shader in wsgl:

[[group(0), binding(0)]]
var<uniform> view: View;

// other binding that are bound only in the fragment stage
...

[[group(2), binding(0)]]
var<uniform> mesh: Mesh;

In the vertex shader in glsl:

uniform View_block_0Vertex { View _group_0_binding_0; };
uniform Mesh_block_1Vertex { Mesh _group_2_binding_0; };

In the fragment shader in glsl:

uniform View_block_0Fragment { View _group_0_binding_0; };
uniform Mesh_block_5Fragment { Mesh _group_2_binding_0; };

This works under Firefox and Chrome, but gives an error with Safari:

"wgpu error: Validation Error

Caused by:
    In Device::create_render_pipeline
      note: label = `pbr_opaque_mesh_pipeline`
    Internal error in VERTEX | FRAGMENT | VERTEX_FRAGMENT shader: Name conflicts between uniform block field names: _group_0_binding_0


"

If I change the glsl back in naga by removing the ID and stage from:

naga/src/back/glsl/mod.rs

Lines 895 to 900 in c2328fe

let block_name = format!(
"{}_block_{}{:?}",
ty_name,
self.block_id.generate(),
self.entry_point.stage,
);

It works again with Safari, and also Firefox and Chrome.

I can submit a PR, but I'm not sure if this is the right fix, or other impacts that it may have

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: back-endOutputs of shader conversionkind: bugSomething isn't workinglang: GLSLOpenGL Shading Language

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions