Skip to content

Commit

Permalink
Refactor UI renderer to pass node information via a uniform buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
oceantume authored and tygyh committed Feb 10, 2024
1 parent ed435aa commit f93938d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions crates/bevy_ui/src/render/render_pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ pub type DrawUi = (
SetItemPipeline,
SetUiViewBindGroup<0>,
SetUiTextureBindGroup<1>,
SetUiUniformBindGroup<2>,
DrawUiNode,
);

Expand Down Expand Up @@ -171,6 +172,26 @@ impl<P: PhaseItem, const I: usize> RenderCommand<P> for SetUiTextureBindGroup<I>
RenderCommandResult::Success
}
}
pub struct SetUiUniformBindGroup<const I: usize>;
impl<const I: usize> EntityRenderCommand for SetUiUniformBindGroup<I> {
type Param = (SRes<UiMeta>, SQuery<Read<UiBatch>>);

fn render<'w>(
_view: Entity,
item: Entity,
(ui_meta, query_batch): SystemParamItem<'w, '_, Self::Param>,
pass: &mut TrackedRenderPass<'w>,
) -> RenderCommandResult {
let batch = query_batch.get(item).unwrap();

pass.set_bind_group(
I,
ui_meta.into_inner().ui_uniform_bind_group.as_ref().unwrap(),
&[batch.ui_uniform_offset],
);
RenderCommandResult::Success
}
}
pub struct DrawUiNode;
impl<P: PhaseItem> RenderCommand<P> for DrawUiNode {
type Param = SRes<UiMeta>;
Expand Down

0 comments on commit f93938d

Please sign in to comment.