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.

Incorrect SPIR-V shader passthrough #1400

@197g

Description

@197g

Passing SPIR-V shaders to naga and back alters their effects.

For example see this fragment shader used to paint a 2d normal distribution.
https://github.com/HeroicKatora/stealth-paint/blob/wgpu-0.10/src/shaders/distribution_normal2d.frag

We paint over a screen-filling quad (uv = [0; 1]×[0; 1]). With parameters

let u_fragmentParams_std140: &[f32; 13] = &[
    0.0, 0.0, 0.0, 0.0, 
    100.080055, 99.83977, 0.0, 0.0, 
    99.83977, 99.6012, 0.0, 0.0, 
    0.031466257
]

Expected:
distribution_normal1d

Actual:
distribution_normal1d-bad

With parameters

let u_fragmentParams_std140: &[f32; 13] = &[
    0.0, 0.0, 0.0, 0.0, 
    5.0, 0.0, 0.0, 0.0, 
    0.0, 5.0, 0.0, 0.0, 
    1.5791368]

Expected:
distribution_normal2d

Actual:
distribution_normal2d-bad

Additional information

Reproduce: Run the test suite here.

# Enables SPIR-V passthrough, works okay.
STEALTH_PAINT_PASSTHROUGH=1 STEALTH_PAINT_BLESS=1 cargo test
# Goes through Naga, fails
STEALTH_PAINT_BLESS=1 cargo test

There is a cryptic, reappearing validation error that seems to be unrelated.

[2021-09-20T07:51:41Z ERROR wgpu_core::validation] Unexpected varying type: Array { base: [1], size: Constant([11]), stride: 4 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind: bugSomething isn't workinglang: SPIR-VBinary SPIR-V input and output

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions