Skip to content

Commit

Permalink
fix(core): return valid. err. for OOB end in set_index_buffer
Browse files Browse the repository at this point in the history
Exercised by
`webgpu:api,validation,encoding,cmds,render,setIndexBuffer:offset_and_size_oob:*`,
which was disovered to be failing in Firefox in [this `webgpu-backlog1`
run on a Windows debug build in
`try:bed05e732fb557b6173872c508612399b6bc365e`](https://treeherder.mozilla.org/jobs?repo=try&tier=1%2C2%2C3&author=egubler%40mozilla.com&selectedTaskRun=enQluY6MT36HfWG8-NnjAw.0).
  • Loading branch information
ErichDonGubler committed Jan 11, 2025
1 parent 4efc992 commit 5ea1a13
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions wgpu-core/src/command/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,17 @@ pub enum RenderPassErrorInner {
end_count_offset: u64,
count_buffer_size: u64,
},
#[error(
"Requested indirect index buffer bytes {}..{} which overruns indirect buffer of size {}",
begin_offset,
end_offset,
buffer_size
)]
IndirectIndexBufferOverrun {
begin_offset: u64,
end_offset: u64,
buffer_size: u64,
},
#[error("Cannot pop debug group, because number of pushed debug groups is zero")]
InvalidPopDebugGroup,
#[error(transparent)]
Expand Down Expand Up @@ -2178,6 +2189,21 @@ fn set_index_buffer(
Some(s) => offset + s.get(),
None => buffer.size,
};

let check_oob = |bound| {
if bound > buffer.size {
Err(RenderPassErrorInner::IndirectIndexBufferOverrun {
begin_offset: offset,
end_offset: end,
buffer_size: buffer.size,
})
} else {
Ok(())
}
};
check_oob(offset)?;
check_oob(end)?;

state.index.update_buffer(offset..end, index_format);

state
Expand Down

0 comments on commit 5ea1a13

Please sign in to comment.