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

Make wgpu_render_pass_set_bind_group clamp the number of dynamic offsets within limits. #4918

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 @@ -922,9 +922,17 @@ pub mod compute_ffi {
return;
}

// Clamp the number of dynamic offsets to the maximum value that the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For validation we should include the original length, so that in the body of the pass we can check to make sure the original_length == clamped length, and error if they don't match.

// 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