Texture arrays example panics in v25.0.2.1
Attempting to run the texture arrays example causes a panic here is the output:
thread '<unnamed>' panicked at src/lib.rs:417:5:
wgpu uncaptured error:
Validation Error
Caused by:
In wgpuDeviceCreateBindGroupLayout, label = 'bind group layout'
Too many bindings of type BindingArrayElements in Stage ShaderStages(FRAGMENT), limit is 0, count was 6. Check the limit `max_binding_array_elements_per_shader_stage` passed to `Adapter::request_device`
stack backtrace:
0: __rustc::rust_begin_unwind
1: core::panicking::panic_fmt
2: wgpu_native::default_uncaptured_error_handler
at /home/user/wgpu-native/src/lib.rs:417:5
3: wgpu_native::ErrorSinkRaw::handle_error
at /home/user/wgpu-native/src/lib.rs:551:25
4: wgpu_native::handle_error
at /home/user/wgpu-native/src/lib.rs:632:5
5: wgpuDeviceCreateBindGroupLayout
at /home/user/wgpu-native/src/lib.rs:1865:9
6: main
at ./main.c:535:43
7: __libc_start_call_main
8: __libc_start_main_impl
9: _start
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread '<unnamed>' panicked at library/core/src/panicking.rs:226:5:
panic in a function that cannot unwind
stack backtrace:
0: 0x1166329 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::haad32dbdee93b0c8
1: 0x1180493 - core::fmt::write::h6ad3ba0dedbcf173
2: 0x112674f - std::io::Write::write_fmt::ha3ff7d1996e99b72
3: 0x1166163 - std::sys::backtrace::BacktraceLock::print::hb6e0ad5a95b804a0
4: 0x11548ce - std::panicking::default_hook::{{closure}}::hdde2e5ae82f46e0d
5: 0x1154793 - std::panicking::default_hook::h24772f302d635910
6: 0x1154dff - std::panicking::rust_panic_with_hook::h89de30867df48bb1
7: 0x1166886 - std::panicking::begin_panic_handler::{{closure}}::h98d82b909a800684
8: 0x1166559 - std::sys::backtrace::__rust_end_short_backtrace::h0b5e9482c92da20f
9: 0x115496d - __rustc[b723cc1e8dfe1f7e]::rust_begin_unwind
10: 0x407a9d - core::panicking::panic_nounwind_fmt::h5d6ed55febaa6a52
11: 0x407b32 - core::panicking::panic_nounwind::hb707c1bf767e5855
12: 0x407cf2 - core::panicking::panic_cannot_unwind::h19ccdc9b77ce87cb
13: 0x42f6ab - wgpu_native::default_uncaptured_error_handler::h842fbc0e6c0c5ad0
at /home/user/wgpu-native/src/lib.rs:408:1
14: 0x4301fd - wgpu_native::ErrorSinkRaw::handle_error::h3c4a3c041da3a9b6
at /home/user/wgpu-native/src/lib.rs:551:25
15: 0x11bb29f - wgpu_native::handle_error::hf96917feaba998e8
at /home/user/wgpu-native/src/lib.rs:632:5
16: 0x438bb6 - wgpuDeviceCreateBindGroupLayout
at /home/user/wgpu-native/src/lib.rs:1865:9
17: 0x409849 - main
at /home/user/wgpu-native/examples/texture_arrays/main.c:535:43
18: 0x7ffff7c2a4d8 - __libc_start_call_main
19: 0x7ffff7c2a59b - __libc_start_main_impl
20: 0x40a645 - _start
21: 0x0 - <unknown>
thread caused non-unwinding panic. aborting.
make: *** [Makefile:175: run-example-texture_arrays] Aborted (core dumped)
It seems that wgpu-native does not provide any way to change max_binding_array_elements_per_shader_stage. If I downgrade to v24.0.3.1 the example runs without issue. As well running the example from the wgpu repo using v25 works as expect but there max_binding_array_elements_per_shader_stage is set explicitly.
IIUC, it does not work with our latest release, but it does work with current master. Has it been fixed? I'm not sure what you mean by max_binding_array_elements_per_shader_stage being set explicitly.
My understanding is the following. For v25 there has been a change in wgpu-core which introduces this new limit. The v25 release of wgpu-native doesn't allow users to set this limit so it's always the default value of 0. There needs to be changes to make this example (and the functionality) work again
running the example from the wgpu repo using v25 works as expect
Ah, I initially read this as the wgpu-native repo.
@Vipitis that makes sense. There's no such limit in webgpu.h yet. All limits ending in 'PerShaderStage':
uint32_t maxSampledTexturesPerShaderStage;
uint32_t maxSamplersPerShaderStage;
uint32_t maxStorageBuffersPerShaderStage;
uint32_t maxStorageTexturesPerShaderStage;
uint32_t maxUniformBuffersPerShaderStage;
Since there is no existing max_binding_array_elements_per_shader_stage limit in webgpu.h, would the idea be that we add it to the native limits header?
diff --git a/ffi/wgpu.h b/ffi/wgpu.h
index f9ab182..06a253f 100644
--- a/ffi/wgpu.h
+++ b/ffi/wgpu.h
@@ -169,6 +169,8 @@ typedef struct WGPUNativeLimits {
WGPUChainedStructOut chain;
uint32_t maxPushConstantSize;
uint32_t maxNonSamplerBindings;
+ uint32_t maxBindingArrayElementsPerShaderStage;
+ uint32_t maxBindingArraySamplerElementsPerShaderStage;
} WGPUNativeLimits;
typedef struct WGPUPushConstantRange {
diff --git a/src/conv.rs b/src/conv.rs
index f2514c2..1b8318a 100644
--- a/src/conv.rs
+++ b/src/conv.rs
@@ -492,6 +492,8 @@ pub fn write_limits_struct(wgt_limits: wgt::Limits, limits: &mut native::WGPULim
>(limits.nextInChain);
(*native_limits).maxPushConstantSize = wgt_limits.max_push_constant_size;
(*native_limits).maxNonSamplerBindings = wgt_limits.max_non_sampler_bindings;
+ (*native_limits).maxBindingArrayElementsPerShaderStage = wgt_limits.max_binding_array_elements_per_shader_stage;
+ (*native_limits).maxBindingArraySamplerElementsPerShaderStage = wgt_limits.max_binding_array_sampler_elements_per_shader_stage;
}
};
}
@@ -607,6 +609,12 @@ pub fn map_required_limits(
if limits.maxNonSamplerBindings != native::WGPU_LIMIT_U32_UNDEFINED {
wgt_limits.max_non_sampler_bindings = limits.maxNonSamplerBindings;
}
+ if limits.maxBindingArrayElementsPerShaderStage != native::WGPU_LIMIT_U32_UNDEFINED {
+ wgt_limits.max_binding_array_elements_per_shader_stage = limits.maxBindingArrayElementsPerShaderStage;
+ }
+ if limits.maxBindingArraySamplerElementsPerShaderStage != native::WGPU_LIMIT_U32_UNDEFINED {
+ wgt_limits.max_binding_array_sampler_elements_per_shader_stage = limits.maxBindingArraySamplerElementsPerShaderStage;
+ }
}
wgt_limits
}