Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Draw command to RenderCommand #211

Merged
merged 2 commits into from
Aug 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions crates/bevy_render/src/draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ pub enum RenderCommand {
base_vertex: i32,
instances: Range<u32>,
},
Draw {
vertices: Range<u32>,
instances: Range<u32>,
},
}

/// A component that indicates how to draw an entity.
Expand Down
14 changes: 12 additions & 2 deletions crates/bevy_render/src/render_graph/nodes/pass_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,13 @@ impl<Q: HecsQuery + Send + Sync + 'static> Node for PassNode<Q> {
log::info!("Could not draw indexed because the pipeline layout wasn't fully set for pipeline: {:?}", draw_state.pipeline);
}
}
RenderCommand::Draw { vertices, instances } => {
if draw_state.can_draw() {
render_pass.draw(vertices.clone(), instances.clone());
} else {
log::info!("Could not draw because the pipeline layout wasn't fully set for pipeline: {:?}", draw_state.pipeline);
}
}
RenderCommand::SetVertexBuffer {
buffer,
offset,
Expand Down Expand Up @@ -306,10 +313,13 @@ impl DrawState {
self.index_buffer = Some(buffer);
}

pub fn can_draw_indexed(&self) -> bool {
pub fn can_draw(&self) -> bool {
self.bind_groups.iter().all(|b| b.is_some())
&& self.vertex_buffers.iter().all(|v| v.is_some())
&& self.index_buffer.is_some()
}

pub fn can_draw_indexed(&self) -> bool {
self.can_draw() && self.index_buffer.is_some()
}

pub fn set_pipeline(
Expand Down