diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bd13e24ce..f5a450491e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -180,6 +180,7 @@ Passing an owned value `window` to `Surface` will return a `Surface<'static>`. S - `BufferMappedRange` trait is now `WasmNotSendSync`, i.e. it is `Send`/`Sync` if not on wasm or `fragile-send-sync-non-atomic-wasm` is enabled. By @wumpf in [#4818](https://github.com/gfx-rs/wgpu/pull/4818) - Align `wgpu_types::CompositeAlphaMode` serde serialization to spec. By @littledivy in [#4940](https://github.com/gfx-rs/wgpu/pull/4940) +- `wgpu_render_pass_set_bind_group` and `wgpu_compute_pass_set_bind_group` clamp the number of dynamic offsets to fit within limits. By @bradwerth in [#4918](https://github.com/gfx-rs/wgpu/pull/4918) - Fix error message of `ConfigureSurfaceError::TooLarge`. By @Dinnerbone in [#4960](https://github.com/gfx-rs/wgpu/pull/4960) #### DX12 diff --git a/wgpu-core/src/command/compute.rs b/wgpu-core/src/command/compute.rs index 0533f29c3b..d89b4cb408 100644 --- a/wgpu-core/src/command/compute.rs +++ b/wgpu-core/src/command/compute.rs @@ -922,9 +922,17 @@ pub mod compute_ffi { return; } + // Clamp the number of dynamic offsets to the maximum value that the + // SetBindGroup structure supports. + let num_dynamic_offsets = if offset_length as u64 > std::u8::MAX.into() { + std::u8::MAX + } else { + offset_length as u8 + }; + pass.base.commands.push(ComputeCommand::SetBindGroup { index, - num_dynamic_offsets: offset_length.try_into().unwrap(), + num_dynamic_offsets, bind_group_id, }); } diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index 700a8afbd4..1ad481cfc8 100644 --- a/wgpu-core/src/command/render.rs +++ b/wgpu-core/src/command/render.rs @@ -2450,9 +2450,17 @@ pub mod render_ffi { return; } + // Clamp the number of dynamic offsets to the maximum value that the + // SetBindGroup structure supports. + let num_dynamic_offsets = if offset_length as u64 > std::u8::MAX.into() { + std::u8::MAX + } else { + offset_length as u8 + }; + pass.base.commands.push(RenderCommand::SetBindGroup { index, - num_dynamic_offsets: offset_length.try_into().unwrap(), + num_dynamic_offsets, bind_group_id, }); }