Skip to content

Commit

Permalink
RenderCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
Neo-Zhixing committed Mar 3, 2021
1 parent 655053d commit 105c7ab
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
14 changes: 14 additions & 0 deletions crates/bevy_render/src/draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use bevy_ecs::{Query, Res, ResMut, SystemParam};
use bevy_reflect::{Reflect, ReflectComponent};
use std::{ops::Range, sync::Arc};
use thiserror::Error;
use crate::pipeline::BindingShaderStage;

/// A queued command for the renderer
#[derive(Debug, Clone, Eq, PartialEq)]
Expand All @@ -35,6 +36,11 @@ pub enum RenderCommand {
bind_group: BindGroupId,
dynamic_uniform_indices: Option<Arc<[u32]>>,
},
SetPushConstants {
stages: BindingShaderStage,
offset: u32,
data: Arc<[u8]>
},
DrawIndexed {
indices: Range<u32>,
base_vertex: i32,
Expand Down Expand Up @@ -106,6 +112,14 @@ impl Draw {
});
}

pub fn set_push_constants(&mut self, stages: BindingShaderStage, offset: u32, data: Arc<[u8]>) {
self.render_command(RenderCommand::SetPushConstants {
stages,
offset,
data,
});
}

pub fn set_bind_group(&mut self, index: u32, bind_group: &BindGroup) {
self.render_command(RenderCommand::SetBindGroup {
index,
Expand Down
7 changes: 7 additions & 0 deletions crates/bevy_render/src/render_graph/nodes/pass_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,13 @@ where
);
draw_state.set_bind_group(*index, *bind_group);
}
RenderCommand::SetPushConstants {
stages,
offset,
data,
} => {
render_pass.set_push_constants(*stages, *offset, data);
}
}
}
}
Expand Down

0 comments on commit 105c7ab

Please sign in to comment.