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/README.md b/README.md index 0964f1c..19ef3cf 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ We intend to track the `main` branch of Bevy. PRs supporting this are welcome! | bevy | bevy_polyline | | ---- | ------------- | +| 0.18 | 0.14 | | 0.17 | 0.13 | | 0.16 | 0.12 | | 0.15 | 0.11 | diff --git a/src/material.rs b/src/material.rs index 77ea074..d0bfea4 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_descriptor() -> BindGroupLayoutDescriptor { + BindGroupLayoutDescriptor::new( "polyline_material_layout", &BindGroupLayoutEntries::single( ShaderStages::VERTEX, @@ -116,6 +116,7 @@ impl RenderAsset for GpuPolylineMaterial { type SourceAsset = PolylineMaterial; type Param = ( SRes, + SRes, SRes, SRes, ); @@ -123,7 +124,9 @@ impl RenderAsset for GpuPolylineMaterial { fn prepare_asset( polyline_material: Self::SourceAsset, _: AssetId, - (device, queue, polyline_pipeline): &mut bevy::ecs::system::SystemParamItem, + (device, cache, queue, polyline_pipeline): &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, + &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_descriptor(); let pipeline = world.get_resource::().unwrap(); PolylineMaterialPipeline { polyline_pipeline: pipeline.to_owned(), diff --git a/src/polyline.rs b/src/polyline.rs index 4c33bc7..93b838f 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(_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, @@ -325,13 +324,14 @@ pub fn prepare_polyline_bind_group( mut commands: Commands, polyline_pipeline: Res, render_device: Res, + pipeline_cache: Res, polyline_uniforms: 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), ), }); @@ -347,6 +347,7 @@ pub struct PolylineViewBindGroup { pub fn prepare_polyline_view_bind_groups( mut commands: Commands, render_device: Res, + pipeline_cache: Res, polyline_pipeline: Res, view_uniforms: Res, views: Query>, @@ -354,7 +355,7 @@ pub fn prepare_polyline_view_bind_groups( 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), );