Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WGPU error on switching materials with normal prepass #9402

Closed
johnbchron opened this issue Aug 9, 2023 · 5 comments
Closed

WGPU error on switching materials with normal prepass #9402

johnbchron opened this issue Aug 9, 2023 · 5 comments
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior
Milestone

Comments

@johnbchron
Copy link
Contributor

johnbchron commented Aug 9, 2023

Bevy version

v0.11.0

[Optional] Relevant system information

  • Rust Version: 1.73.0-nightly (d78bbf4bd 2023-08-03)
  • OS: arch-ish
  • Adapter info: AdapterInfo { name: "Intel(R) HD Graphics 520 (SKL GT2)", vendor: 32902, device: 6422, device_type: IntegratedGpu, driver: "Intel open-source Mesa driver", driver_info: "Mesa 23.0.4", backend: Vulkan }

What you did

To reproduce, set up a 3D camera with a NormalPrepass component on it. Define a custom material that uses a WGSL fragment. Spawn a scene (I'm not sure what data is important here, but it doesn't work with just a cube; might be UVs), and then set up a system to switch out the StandardMaterial for a CustomMaterial on any entity that has a StandardMaterial. Bevy crashes.

Minimum reproducible here.

What went wrong

This error occurs:

2023-08-09T20:52:12.883651Z ERROR wgpu::backend::direct: Handling wgpu errors as fatal by default
thread 'Compute Task Pool (1)' panicked at /home/jlewis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.16.3/src/backend/direct.rs:3019:5:
wgpu error: Validation Error

Caused by:
    In Device::create_render_pipeline
      note: label = `prepass_pipeline`
    Error matching ShaderStages(FRAGMENT) shader requirements against the pipeline
    Location[2] is provided by the previous stage output but is not consumed as input by this stage.


note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Encountered a panic in system `bevy_render::render_resource::pipeline_cache::PipelineCache::process_pipeline_queue_system`!
thread 'Compute Task Pool (0)' panicked at /home/jlewis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_render-0.11.0/src/pipelined_rendering.rs:135:45:
called `Result::unwrap()` on an `Err` value: RecvError

Additional information

Honestly no clue :(

@johnbchron johnbchron added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Aug 9, 2023
@JMS55 JMS55 added A-Rendering Drawing game state to the screen and removed S-Needs-Triage This issue needs to be labelled labels Sep 10, 2023
@JMS55 JMS55 added this to the 0.12 milestone Sep 28, 2023
@idobenamram
Copy link

hey, im thinking of working on this issue. Able to reproduce the problem on my machine with your example!

@idobenamram
Copy link

hey, still working on it but it looks like it specifically doesn't work with the SceneBundle. you can also easily recreate the behavior
on the load_gltf.rs example.

@johnbchron
Copy link
Contributor Author

How interesting. Thanks for working on it!

I forgot to include this in the original comment but my workaround was to manually specify the prepass shader from the PBR implementation like so:

impl Material for CustomMaterial {
  ...

  fn prepass_fragment_shader() -> ShaderRef {
    StandardMaterial::prepass_fragment_shader()
  }
}

idobenamram added a commit to idobenamram/bevy that referenced this issue Oct 3, 2023
…ves inconsistency between vertex and fragment shader (bevyengine#9402)
@idobenamram
Copy link

cool! that makes a lot of sense, @IceSentry figured out the reason! FragmentInput in the default prepass.wgsl was missing
the VERTEX_TANGENT. Fixed it by using VertexOutput instead.

@IceSentry
Copy link
Contributor

This should now be fixed on main after the deferred PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants