Skip to content

Commit

Permalink
fix: dynamically set max_storage_buffer_binding_size based on adapter…
Browse files Browse the repository at this point in the history
… limits

Query adapter limits and set max_storage_buffer_binding_size to the maximum
supported value to prevent runtime panics due to exceeded limits.

Addresses issue #9.
  • Loading branch information
EtaCassiopeia authored Jul 1, 2024
1 parent 5dffdc8 commit 56ec62c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,15 @@ impl WGPUContext {
| wgpu::Features::TEXTURE_FORMAT_16BIT_NORM
| wgpu::Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES;

let adapter_limits = adapter.limits();

Check warning on line 95 in src/lib.rs

View workflow job for this annotation

GitHub Actions / deploy

unused variable: `adapter_limits`

let (device, queue) = adapter
.request_device(
&wgpu::DeviceDescriptor {
required_features,
#[cfg(not(target_arch = "wasm32"))]
required_limits: wgpu::Limits {
max_storage_buffer_binding_size: (1 << 30) - 1,
max_storage_buffer_binding_size: adapter_limits.max_storage_buffer_binding_size,
max_buffer_size: (1 << 30) - 1,
max_storage_buffers_per_shader_stage: 12,
max_compute_workgroup_storage_size: 1 << 15,
Expand Down

0 comments on commit 56ec62c

Please sign in to comment.