Skip to content

Commit f165d20

Browse files
fix(core)!: validate set_immediate's size_bytes param.
1 parent 2a3dd23 commit f165d20

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ By @kpreid in [#9042](https://github.com/gfx-rs/wgpu/pull/9042).
226226
- Split the `TransferError::BufferOverrun` variant into new `BufferStartOffsetOverrun` and `BufferEndOffsetOverrun` variants.
227227
- `ImmediateUploadError`:
228228
- Removed the `TooLarge` variant in favor of new `StartOffsetOverrun` and `EndOffsetOverrun` variants.
229+
- Removed the `Unaligned` variant in favor of new `StartOffsetUnaligned` and `SizeUnaligned` variants.
229230
- The various "max resources per stage" limits are now capped at 100, so that their total remains below `max_bindings_per_bind_group`, as required by WebGPU. By @andyleiserson in [#9118](https://github.com/gfx-rs/wgpu/pull/9118).
230231
- The `max_uniform_buffer_binding_size` and `max_storage_buffer_binding_size` limits are now `u64` instead of `u32`, to match WebGPU. By @wingertge in [#9146](https://github.com/gfx-rs/wgpu/pull/9146).
231232
- The main 3 native backends now report their limits properly. By @teoxoy in [#9196](https://github.com/gfx-rs/wgpu/pull/9196).

wgpu-core/src/binding_model.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -866,10 +866,17 @@ pub enum ImmediateUploadError {
866866
immediate_size: u32,
867867
},
868868
#[error(
869-
"Provided immediate data offset {0} does not respect `IMMEDIATE_DATA_ALIGNMENT` ({ida})",
869+
"Provided immediate data start offset {0} does not respect \
870+
`IMMEDIATE_DATA_ALIGNMENT` ({ida})",
870871
ida = wgt::IMMEDIATE_DATA_ALIGNMENT
871872
)]
872-
Unaligned(u32),
873+
StartOffsetUnaligned(u32),
874+
#[error(
875+
"Provided immediate data byte size {0} does not respect \
876+
`IMMEDIATE_DATA_ALIGNMENT` ({ida})",
877+
ida = wgt::IMMEDIATE_DATA_ALIGNMENT
878+
)]
879+
SizeUnaligned(u32),
873880
#[error(
874881
"Provided immediate data start offset {} + size {} overruns the immediate data range \
875882
with a size of {}",
@@ -990,7 +997,11 @@ impl PipelineLayout {
990997
// and we validate that they are within the ranges.
991998

992999
if !offset.is_multiple_of(wgt::IMMEDIATE_DATA_ALIGNMENT) {
993-
return Err(ImmediateUploadError::Unaligned(offset));
1000+
return Err(ImmediateUploadError::StartOffsetUnaligned(offset));
1001+
}
1002+
1003+
if !size_bytes.is_multiple_of(wgt::IMMEDIATE_DATA_ALIGNMENT) {
1004+
return Err(ImmediateUploadError::SizeUnaligned(offset));
9941005
}
9951006

9961007
if offset > self.immediate_size {

0 commit comments

Comments
 (0)