Skip to content

[GL] Panic when a uniform block is not accessed in a shader stage. #1803

@agausmann

Description

@agausmann

Description

I have a WGSL shader that accepts a uniform buffer binding, which is used by the vertex stage (vertex transformation matrix), and is unused by the fragment stage.
On the Vullkan backend, this runs without errors. On the GL backend, the shader compiler panics.

It will panic regardless of whether the binding's visibility flags include the fragment stage.

It will not panic if the uniform buffer binding is made visible to the fragment stage AND the binding is accessed in the fragment shader code (even if the value is ultimately not used to compute any output values).

Repro steps

Extra materials

Full backtrace:

thread 'main' panicked at 'no entry found for key', /home/adam/.cargo/git/checkouts/wgpu-53e70f8674b08dd4/a222e6e/wgpu-hal/src/gles/device.rs:38:24
stack backtrace:
   0: rust_begin_unwind
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panicking.rs:515:5
   1: core::panicking::panic_fmt
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/panicking.rs:92:14
   2: core::option::expect_failed
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/option.rs:1243:5
   3: core::option::Option<T>::expect
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/option.rs:351:21
   4: <std::collections::hash::map::HashMap<K,V,S> as core::ops::index::Index<&Q>>::index
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/collections/hash/map.rs:1148:9
   5: wgpu_hal::gles::device::CompilationContext::consume_reflection
             at /home/adam/.cargo/git/checkouts/wgpu-53e70f8674b08dd4/a222e6e/wgpu-hal/src/gles/device.rs:38:24
   6: wgpu_hal::gles::device::<impl wgpu_hal::gles::Device>::create_shader
             at /home/adam/.cargo/git/checkouts/wgpu-53e70f8674b08dd4/a222e6e/wgpu-hal/src/gles/device.rs:154:9
   7: wgpu_hal::gles::device::<impl wgpu_hal::gles::Device>::create_pipeline
             at /home/adam/.cargo/git/checkouts/wgpu-53e70f8674b08dd4/a222e6e/wgpu-hal/src/gles/device.rs:190:26
   8: wgpu_hal::gles::device::<impl wgpu_hal::Device<wgpu_hal::gles::Api> for wgpu_hal::gles::Device>::create_render_pipeline
             at /home/adam/.cargo/git/checkouts/wgpu-53e70f8674b08dd4/a222e6e/wgpu-hal/src/gles/device.rs:872:21
   9: wgpu_core::device::Device<A>::create_render_pipeline
             at /home/adam/.cargo/git/checkouts/wgpu-53e70f8674b08dd4/a222e6e/wgpu-core/src/device/mod.rs:2299:22
  10: wgpu_core::device::<impl wgpu_core::hub::Global<G>>::device_create_render_pipeline
             at /home/adam/.cargo/git/checkouts/wgpu-53e70f8674b08dd4/a222e6e/wgpu-core/src/device/mod.rs:4058:34
  11: <wgpu::backend::direct::Context as wgpu::Context>::device_create_render_pipeline
             at /home/adam/.cargo/git/checkouts/wgpu-53e70f8674b08dd4/a222e6e/wgpu/src/backend/direct.rs:1229:27
  12: wgpu::Device::create_render_pipeline
             at /home/adam/.cargo/git/checkouts/wgpu-53e70f8674b08dd4/a222e6e/wgpu/src/lib.rs:1709:17
  13: wgpu_gl_unused_uniform_repro::main
             at ./src/main.rs:37:28
  14: core::ops::function::FnOnce::call_once
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/ops/function.rs:227:5

Platform

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions