From aaef5577cdbb5f7256d177be5fc98b0965d67753 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Tue, 7 Nov 2023 10:51:40 +0100 Subject: [PATCH] UI Material: each material should have its own buffer (#10422) # Objective - When having several UI Material, nodes are not correctly placed ## Solution - have a buffer per material --- crates/bevy_ui/src/render/ui_material_pipeline.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/crates/bevy_ui/src/render/ui_material_pipeline.rs b/crates/bevy_ui/src/render/ui_material_pipeline.rs index 53d17fb6b0d00..ca1ae21bf5ab9 100644 --- a/crates/bevy_ui/src/render/ui_material_pipeline.rs +++ b/crates/bevy_ui/src/render/ui_material_pipeline.rs @@ -70,7 +70,7 @@ where .init_resource::>() .init_resource::>() .init_resource::>() - .init_resource::() + .init_resource::>() .init_resource::>>() .add_systems( ExtractSchedule, @@ -98,16 +98,18 @@ where } #[derive(Resource)] -pub struct UiMaterialMeta { +pub struct UiMaterialMeta { vertices: BufferVec, view_bind_group: Option, + marker: PhantomData, } -impl Default for UiMaterialMeta { +impl Default for UiMaterialMeta { fn default() -> Self { Self { vertices: BufferVec::new(BufferUsages::VERTEX), view_bind_group: Default::default(), + marker: PhantomData, } } } @@ -261,7 +263,7 @@ pub type DrawUiMaterial = ( pub struct SetMatUiViewBindGroup(PhantomData); impl RenderCommand

for SetMatUiViewBindGroup { - type Param = SRes; + type Param = SRes>; type ViewWorldQuery = Read; type ItemWorldQuery = (); @@ -307,7 +309,7 @@ impl RenderCommand

pub struct DrawUiMaterialNode(PhantomData); impl RenderCommand

for DrawUiMaterialNode { - type Param = SRes; + type Param = SRes>; type ViewWorldQuery = (); type ItemWorldQuery = Read>; @@ -429,7 +431,7 @@ pub fn prepare_uimaterial_nodes( mut commands: Commands, render_device: Res, render_queue: Res, - mut ui_meta: ResMut, + mut ui_meta: ResMut>, mut extracted_uinodes: ResMut>, view_uniforms: Res, ui_material_pipeline: Res>,