Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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",
Expand Down
18 changes: 10 additions & 8 deletions src/material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use bevy::{
prepass::{OpaqueNoLightmap3dBatchSetKey, OpaqueNoLightmap3dBinKey},
},
ecs::{
component::Tick,
change_detection::Tick,
query::ROQueryItem,
system::{
lifetimeless::{Read, SRes},
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -118,12 +118,15 @@ impl RenderAsset for GpuPolylineMaterial {
SRes<RenderDevice>,
SRes<RenderQueue>,
SRes<PolylineMaterialPipeline>,
SRes<PipelineCache>,
);

fn prepare_asset(
polyline_material: Self::SourceAsset,
_: AssetId<Self::SourceAsset>,
(device, queue, polyline_pipeline): &mut bevy::ecs::system::SystemParamItem<Self::Param>,
(device, queue, polyline_pipeline, pipeline_cache): &mut bevy::ecs::system::SystemParamItem<
Self::Param,
>,
_: Option<&Self>,
) -> Result<Self, PrepareAssetError<Self::SourceAsset>> {
let value = PolylineMaterialUniform {
Expand All @@ -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),
);

Expand Down Expand Up @@ -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::<RenderDevice>().unwrap();
let material_layout = PolylineMaterial::bind_group_layout(render_device);
let material_layout = PolylineMaterial::bind_group_layout();
let pipeline = world.get_resource::<PolylinePipeline>().unwrap();
PolylineMaterialPipeline {
polyline_pipeline: pipeline.to_owned(),
Expand Down
17 changes: 9 additions & 8 deletions src/polyline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,23 +145,22 @@ 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<Shader>,
}

impl FromWorld for PolylinePipeline {
fn from_world(world: &mut World) -> Self {
let render_device = world.get_resource::<RenderDevice>().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,
uniform_buffer::<ViewUniform>(true),
),
);

let polyline_layout = render_device.create_bind_group_layout(
let polyline_layout = BindGroupLayoutDescriptor::new(
"polyline_layout",
&BindGroupLayoutEntries::single(
ShaderStages::VERTEX,
Expand Down Expand Up @@ -326,12 +325,13 @@ pub fn prepare_polyline_bind_group(
polyline_pipeline: Res<PolylinePipeline>,
render_device: Res<RenderDevice>,
polyline_uniforms: Res<ComponentUniforms<PolylineUniform>>,
pipeline_cache: Res<PipelineCache>,
) {
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),
),
});
Expand All @@ -350,11 +350,12 @@ pub fn prepare_polyline_view_bind_groups(
polyline_pipeline: Res<PolylinePipeline>,
view_uniforms: Res<ViewUniforms>,
views: Query<Entity, With<bevy::render::view::ExtractedView>>,
pipeline_cache: Res<PipelineCache>,
) {
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),
);

Expand Down
Loading