Bevy version
0.14.1
What you did
In #14721, I set a slice of seemingly correct size as a vertex buffer and got errors like Instance 555 extends beyond limit 554 imposed by the buffer in slot 3.
What went wrong
In this case, the same underlying buffer is used as vertex buffer with the same offset but different sizes (slice(item_size..) vs slice(item_size..buf_size)) from two draw functions.
It looks like TrackedRenderPass::set_vertex_buffer returns without updating the vertex buffer if buffer and offset matches, ignoring its size.
|
pub fn set_vertex_buffer(&mut self, slot_index: usize, buffer_slice: BufferSlice<'a>) { |
|
let offset = buffer_slice.offset(); |
|
if self |
|
.state |
|
.is_vertex_buffer_set(slot_index, buffer_slice.id(), offset) |
|
{ |
|
detailed_trace!( |
|
"set vertex buffer {} (already set): {:?} ({})", |
|
slot_index, |
|
buffer_slice.id(), |
|
offset |
|
); |
|
return; |
|
} |
|
pub fn is_vertex_buffer_set(&self, index: usize, buffer: BufferId, offset: u64) -> bool { |
|
if let Some(current) = self.vertex_buffers.get(index) { |
|
*current == Some((buffer, offset)) |
|
} else { |
|
false |
|
} |
|
} |
Bevy version
0.14.1
What you did
In #14721, I set a slice of seemingly correct size as a vertex buffer and got errors like
Instance 555 extends beyond limit 554 imposed by the buffer in slot 3.What went wrong
In this case, the same underlying buffer is used as vertex buffer with the same offset but different sizes (
slice(item_size..)vsslice(item_size..buf_size)) from two draw functions.It looks like
TrackedRenderPass::set_vertex_bufferreturns without updating the vertex buffer ifbufferandoffsetmatches, ignoring its size.bevy/crates/bevy_render/src/render_phase/draw_state.rs
Lines 190 to 203 in 6e2f96f
bevy/crates/bevy_render/src/render_phase/draw_state.rs
Lines 76 to 82 in 6e2f96f