From 448b61fc4e02edeab5413c31171bd82f4ace7c08 Mon Sep 17 00:00:00 2001 From: Robin KAY Date: Tue, 14 Jun 2022 07:46:26 +0100 Subject: [PATCH] Change GpuViewSize from component to resource. --- src/lib.rs | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index a2df54a..55929ac 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -113,7 +113,6 @@ struct ViewSizeUniformOffset { pub offset: u32, } -#[derive(Component)] struct GpuViewSize { bind_group: BindGroup, } @@ -165,24 +164,24 @@ type DrawOutline = ( SetItemPipeline, SetMeshViewBindGroup<0>, SetMeshBindGroup<1>, - SetOutlineViewBindGroup<2>, + SetViewSizeBindGroup<2>, SetOutlineBindGroup<3>, DrawMesh, ); -struct SetOutlineViewBindGroup(); +struct SetViewSizeBindGroup(); -impl EntityRenderCommand for SetOutlineViewBindGroup { - type Param = SQuery<(Read, Read)>; +impl EntityRenderCommand for SetViewSizeBindGroup { + type Param = (SRes, SQuery>); #[inline] fn render<'w>( view: Entity, _item: Entity, - view_query: SystemParamItem<'w, '_, Self::Param>, + (gpu_view_size, offset_query): SystemParamItem<'w, '_, Self::Param>, pass: &mut TrackedRenderPass<'w>, ) -> RenderCommandResult { - let (view_size_uniform, gpu_view_size) = view_query.get_inner(view).unwrap(); - pass.set_bind_group(I, &gpu_view_size.bind_group, &[view_size_uniform.offset]); + let uniform_offset = offset_query.get_inner(view).unwrap(); + pass.set_bind_group(I, &gpu_view_size.into_inner().bind_group, &[uniform_offset.offset]); RenderCommandResult::Success } @@ -236,7 +235,6 @@ fn prepare_view_size_uniforms( let view_size_uniforms = ViewSizeUniformOffset { offset: view_size_uniforms.uniforms.push(view_size_uniform.clone()), }; - commands.entity(entity).insert(view_size_uniforms); } @@ -253,11 +251,9 @@ fn prepare_view_size_uniforms( label: Some("outline_view_size_bind_group"), layout: &outline_pipeline.view_size_bind_group_layout, }); - for (entity, _) in views.iter() { - commands.entity(entity).insert(GpuViewSize { - bind_group: bind_group.clone(), - }); - } + commands.insert_resource(GpuViewSize { + bind_group: bind_group.clone(), + }); } }