Skip to content

Commit

Permalink
Small Fixes (#20)
Browse files Browse the repository at this point in the history
* Fix writing less than the full capacity to the staging buffer

* Add missing TrackedRenderPass::draw command
  • Loading branch information
james7132 committed Jul 7, 2021
1 parent 9a79b79 commit 811ed3e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions pipelined/bevy_render2/src/render_phase/draw_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,14 @@ impl<'a> TrackedRenderPass<'a> {
.set_index_buffer(buffer_slice.id(), offset, index_format);
}

pub fn draw(&mut self, vertices: Range<u32>, instances: Range<u32>) {
debug!(
"draw: {:?} {:?}",
vertices, instances
);
self.pass.draw(vertices, instances);
}

pub fn draw_indexed(&mut self, indices: Range<u32>, base_vertex: i32, instances: Range<u32>) {
debug!(
"draw indexed: {:?} {} {:?}",
Expand Down
3 changes: 2 additions & 1 deletion pipelined/bevy_render2/src/render_resource/buffer_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ impl<T: Pod> BufferVec<T> {

pub fn write_to_staging_buffer(&self, render_device: &RenderDevice) {
if let Some(staging_buffer) = &self.staging_buffer {
let slice = staging_buffer.slice(..);
let end = (self.values.len() * self.item_size) as u64;
let slice = staging_buffer.slice(0..end);
render_device.map_buffer(&slice, wgpu::MapMode::Write);
{
let mut data = slice.get_mapped_range_mut();
Expand Down

0 comments on commit 811ed3e

Please sign in to comment.