Skip to content

TrackedRenderPass::set_vertex_buffer does not update if the size of sliced buffer changed #14841

@akimakinai

Description

@akimakinai

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-RenderingDrawing game state to the screenC-BugAn unexpected or incorrect behaviorS-Needs-InvestigationThis issue requires detective work to figure out what's going wrong

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions