diff --git a/Cargo.toml b/Cargo.toml index 0abe25c..c976f6f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] edition = "2021" name = "bevy_polyline" -version = "0.13.0" +version = "0.14.0" description = "Polyline Rendering for Bevy" license = "MIT OR Apache-2.0" repository = "https://github.com/ForesightMiningSoftwareCorporation/bevy_polyline" @@ -18,19 +18,19 @@ authors = [ [dependencies] bitflags = "2.3" -bevy = { version = "0.17", default-features = false, features = [ +bevy = { version = "0.18", default-features = false, features = [ "bevy_core_pipeline", "bevy_render", "bevy_asset", ] } -bevy_post_process = "0.17" +bevy_post_process = "0.18" bytemuck = "1.16.1" [dev-dependencies] lazy_static = "1.4.0" rand = "0.8.4" ringbuffer = "0.15" -bevy = { version = "0.17", default-features = false, features = [ +bevy = { version = "0.18", default-features = false, features = [ "bevy_window", "bevy_winit", "bevy_pbr", diff --git a/src/material.rs b/src/material.rs index 77ea074..c8059ac 100644 --- a/src/material.rs +++ b/src/material.rs @@ -9,7 +9,7 @@ use bevy::{ prepass::{OpaqueNoLightmap3dBatchSetKey, OpaqueNoLightmap3dBinKey}, }, ecs::{ - component::Tick, + change_detection::Tick, query::ROQueryItem, system::{ lifetimeless::{Read, SRes}, @@ -76,8 +76,8 @@ impl Default for PolylineMaterial { } impl PolylineMaterial { - pub fn bind_group_layout(render_device: &RenderDevice) -> BindGroupLayout { - render_device.create_bind_group_layout( + pub fn bind_group_layout() -> BindGroupLayoutDescriptor { + BindGroupLayoutDescriptor::new( "polyline_material_layout", &BindGroupLayoutEntries::single( ShaderStages::VERTEX, @@ -118,12 +118,15 @@ impl RenderAsset for GpuPolylineMaterial { SRes, SRes, SRes, + SRes, ); fn prepare_asset( polyline_material: Self::SourceAsset, _: AssetId, - (device, queue, polyline_pipeline): &mut bevy::ecs::system::SystemParamItem, + (device, queue, polyline_pipeline, pipeline_cache): &mut bevy::ecs::system::SystemParamItem< + Self::Param, + >, _: Option<&Self>, ) -> Result> { let value = PolylineMaterialUniform { @@ -141,7 +144,7 @@ impl RenderAsset for GpuPolylineMaterial { let bind_group = device.create_bind_group( Some("polyline_material_bind_group"), - &polyline_pipeline.material_layout, + &pipeline_cache.get_bind_group_layout(&polyline_pipeline.material_layout), &BindGroupEntries::single(buffer_binding), ); @@ -190,13 +193,12 @@ impl Plugin for PolylineMaterialPlugin { #[derive(Resource)] pub struct PolylineMaterialPipeline { pub polyline_pipeline: PolylinePipeline, - pub material_layout: BindGroupLayout, + pub material_layout: BindGroupLayoutDescriptor, } impl FromWorld for PolylineMaterialPipeline { fn from_world(world: &mut World) -> Self { - let render_device = world.get_resource::().unwrap(); - let material_layout = PolylineMaterial::bind_group_layout(render_device); + let material_layout = PolylineMaterial::bind_group_layout(); let pipeline = world.get_resource::().unwrap(); PolylineMaterialPipeline { polyline_pipeline: pipeline.to_owned(), diff --git a/src/polyline.rs b/src/polyline.rs index 4c33bc7..fa3469f 100644 --- a/src/polyline.rs +++ b/src/polyline.rs @@ -145,15 +145,14 @@ pub fn extract_polylines( #[derive(Clone, Resource)] pub struct PolylinePipeline { - pub view_layout: BindGroupLayout, - pub polyline_layout: BindGroupLayout, + pub view_layout: BindGroupLayoutDescriptor, + pub polyline_layout: BindGroupLayoutDescriptor, pub shader: Handle, } impl FromWorld for PolylinePipeline { - fn from_world(world: &mut World) -> Self { - let render_device = world.get_resource::().unwrap(); - let view_layout = render_device.create_bind_group_layout( + fn from_world(_: &mut World) -> Self { + let view_layout = BindGroupLayoutDescriptor::new( "polyline_view_layout", &BindGroupLayoutEntries::single( ShaderStages::VERTEX, @@ -161,7 +160,7 @@ impl FromWorld for PolylinePipeline { ), ); - let polyline_layout = render_device.create_bind_group_layout( + let polyline_layout = BindGroupLayoutDescriptor::new( "polyline_layout", &BindGroupLayoutEntries::single( ShaderStages::VERTEX, @@ -326,12 +325,13 @@ pub fn prepare_polyline_bind_group( polyline_pipeline: Res, render_device: Res, polyline_uniforms: Res>, + pipeline_cache: Res, ) { if let Some(binding) = polyline_uniforms.uniforms().binding() { commands.insert_resource(PolylineBindGroup { value: render_device.create_bind_group( Some("polyline_bind_group"), - &polyline_pipeline.polyline_layout, + &pipeline_cache.get_bind_group_layout(&polyline_pipeline.polyline_layout), &BindGroupEntries::single(binding), ), }); @@ -350,11 +350,12 @@ pub fn prepare_polyline_view_bind_groups( polyline_pipeline: Res, view_uniforms: Res, views: Query>, + pipeline_cache: Res, ) { for entity in views.iter() { let view_bind_group = render_device.create_bind_group( Some("polyline_view_bind_group"), - &polyline_pipeline.view_layout, + &pipeline_cache.get_bind_group_layout(&polyline_pipeline.view_layout), &BindGroupEntries::single(&view_uniforms.uniforms), );