Skip to content

Commit

Permalink
Make wgpu_render_pass_set_bind_group clamp the number of dynamic offs…
Browse files Browse the repository at this point in the history
…ets within limits.
  • Loading branch information
bradwerth committed Dec 21, 2023
1 parent 85b91c0 commit 810edbd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ Passing an owned value `window` to `Surface` will return a `Surface<'static>`. S
#### General

- `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)
- `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)

#### Vulkan

Expand Down
10 changes: 9 additions & 1 deletion wgpu-core/src/command/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -919,9 +919,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,
});
}
Expand Down
10 changes: 9 additions & 1 deletion wgpu-core/src/command/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
}
Expand Down

0 comments on commit 810edbd

Please sign in to comment.