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

push_constant_input test fails on GL backend #3375

Closed
Tracked by #3674
Dinnerbone opened this issue Jan 13, 2023 · 0 comments · Fixed by #4607
Closed
Tracked by #3674

push_constant_input test fails on GL backend #3375

Dinnerbone opened this issue Jan 13, 2023 · 0 comments · Fixed by #4607
Labels
api: gles Issues with GLES or WebGL type: bug Something isn't working

Comments

@Dinnerbone
Copy link
Contributor

Description
The test was implicitly skipped before as the GL backend didn't meet the max_push_constant_size limits. After #3374 increased that, the test then ran and fails with the following panic:

thread 'shader::struct_layout::push_constant_input' panicked at 'No uniform for push constant', wgpu-hal/src/gles/command.rs:674:17
stack backtrace:
   0: rust_begin_unwind
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:575:5
   1: core::panicking::panic_fmt
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/panicking.rs:65:14
   2: wgpu_hal::gles::command::<impl wgpu_hal::CommandEncoder<wgpu_hal::gles::Api> for wgpu_hal::gles::CommandEncoder>::set_push_constants
             at /home/dinnerbone/workspace/personal/wgpu/wgpu-hal/src/gles/command.rs:674:17
   3: wgpu_core::command::compute::<impl wgpu_core::hub::Global<G>>::command_encoder_run_compute_pass_impl::{{closure}}
             at /home/dinnerbone/workspace/personal/wgpu/wgpu-core/src/command/compute.rs:525:37
   4: wgpu_core::command::push_constant_clear
             at /home/dinnerbone/workspace/personal/wgpu/wgpu-core/src/command/mod.rs:458:9
   5: wgpu_core::command::compute::<impl wgpu_core::hub::Global<G>>::command_encoder_run_compute_pass_impl
             at /home/dinnerbone/workspace/personal/wgpu/wgpu-core/src/command/compute.rs:521:29
   6: wgpu_core::command::compute::<impl wgpu_core::hub::Global<G>>::command_encoder_run_compute_pass
             at /home/dinnerbone/workspace/personal/wgpu/wgpu-core/src/command/compute.rs:323:9
   7: <wgpu::backend::direct::Context as wgpu::context::Context>::command_encoder_end_compute_pass
             at ./src/backend/direct.rs:1815:29
   8: <T as wgpu::context::DynContext>::command_encoder_end_compute_pass
             at ./src/context.rs:2609:9
   9: <wgpu::ComputePass as core::ops::drop::Drop>::drop
             at ./src/lib.rs:3566:13
  10: core::ptr::drop_in_place<wgpu::ComputePass>
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/ptr/mod.rs:490:1
  11: core::mem::drop
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/mem/mod.rs:987:24
  12: wgpu_tests::shader::shader_input_output_test
             at ./tests/shader/mod.rs:337:9
  13: wgpu_tests::shader::struct_layout::push_constant_input::{{closure}}
             at ./tests/shader/struct_layout.rs:226:13
  14: wgpu_tests::common::initialize_test::{{closure}}
             at ./tests/common/mod.rs:295:53
  15: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/panic/unwind_safe.rs:271:9
  16: std::panicking::try::do_call
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:483:40
  17: __rust_try
  18: std::panicking::try
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:447:19
  19: std::panic::catch_unwind
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panic.rs:137:14
  20: wgpu_tests::common::initialize_test
             at ./tests/common/mod.rs:295:20
  21: wgpu_tests::shader::struct_layout::push_constant_input
             at ./tests/shader/struct_layout.rs:217:5
  22: wgpu_tests::shader::struct_layout::push_constant_input::{{closure}}
             at ./tests/shader/struct_layout.rs:216:1
  23: core::ops::function::FnOnce::call_once
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/ops/function.rs:251:5
  24: core::ops::function::FnOnce::call_once
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/ops/function.rs:251:5

Upon investigating it, the test creates shaders like:

struct CustomStruct { member: vec2<f32>, }
var<push_constant> input: CustomStruct;

whilst also setting the render pipeline to have a large push constant range:

let pll = ctx
        .device
        .create_pipeline_layout(&PipelineLayoutDescriptor {
            label: None,
            bind_group_layouts: &[&bgl],
            push_constant_ranges: match storage_type {
                InputStorageType::PushConstant => &[PushConstantRange {
                    stages: ShaderStages::COMPUTE,
                    range: 0..MAX_BUFFER_SIZE as u32,
                }],
                _ => &[],
            },
        });

This panics when the GL backend tries to write MAX_BUFFER_SIZE (128) bytes of data to a uniform that can only hold 8.

I'm not sure what the correct thing to do here is, why don't the other backends error too?

Repro steps

  • Enable the test for GL again in push_constant_input
  • run WGPU_BACKEND=gl nextest run -- push_constant_input

Expected vs observed behavior
Either other backends should error too, or the GL backend should silently ignore out of range inputs.

Extra materials
None

Platform
GL backend only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: gles Issues with GLES or WebGL type: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants